Expand description
#2469: capability paths — the answer to “why does this need Logger?”.
The requirement ledger records every capability use
and whether the enclosing declaration’s given covers it. This module adds
the second half of the explanation: how a declaration reaches a use that
lives in another body. The only such edge in the language is an agent-handler
call (Agent(key).m()): a service or agent handler’s deps are widened to
cover the agent handlers it calls (#527), and a provider must list them in
its given (bynk.provider.agent_call_undeclared_capability).
The checker owns the answer. CapabilityGraph::build runs in the same
pass as that provider check, over the same Callee::Agent classification,
and records two things per file:
- one witness — the shortest chain — for each
(given entry, capability)pair, so a hover is a lookup; and - the compact call/use facts the witnesses were drawn from, so the full set
of chains is computed on demand (
CapabilityGraph::all_paths) rather than stored for every pair.
Nothing here re-reads source text: the editor surfaces ask this module, they never re-derive a path.
Structs§
- Capability
Graph - One file’s capability call/use facts and the witnesses drawn from them.
- Capability
Path - A chain from a declaration to a use of a capability: zero or more
PathStep::Calls then exactly onePathStep::Use. A direct use is the one-step chain. - Capability
Witness - The shortest chain recorded for one
givenentry.
Enums§
- Path
Step - One hop of a capability path.
Constants§
- MAX_
PATHS - The most chains
CapabilityGraph::all_pathsreturns for one entry. A densely connected project can have exponentially many simple paths; the action lists the shortestMAX_PATHSand says it stopped.
Type Aliases§
- File
Capability Paths - Project-relative source path → that file’s capability graph.