Skip to main content

real_context_count

Function real_context_count 

Source
pub fn real_context_count(
    boundary_info: &HashMap<String, ContextBoundaryInfo>,
    unit_sources: &HashMap<String, Vec<PathBuf>>,
) -> usize
Expand description

How many real contexts/adapters a project has — the input wire_contract_at/wire_contract_for_service’s context_count wants, deciding NoCrossContextReason::SingleContext.

Must be computed this way, not as a bare boundary_info.len(): boundary_info (mirroring sequence_info, #846) retains an entry for every UnitKind::Context | UnitKind::Adapter, which includes the synthetic toolchain-injected bynk capability-surface unit — so a project with nothing but consumes bynk { Clock } would count two “contexts” and SingleContext would almost never fire. unit_sources (ADR 0095) already excludes synthetic units for exactly this reason (document links, consumed-context navigation); intersecting against it reuses that existing filter rather than a bespoke name == "bynk" check.

A free function (not buried in a caller’s own helper) precisely so bynk-lsp’s bynk/wireContract handler calls this — the one place the filter is encoded — instead of re-deriving boundary_info.len() from the plan’s literal parameter name and reintroducing the bug.