Skip to main content

Module sequence

Module sequence 

Source
Expand description

#846: the sequence-diagram query.

Classifies a handler body’s calls into runtime-participant lifelines — consumed capabilities, calls into consumed contexts, and agents (including same-context agents) — for the “Show Sequence Diagram” VS Code feature. Everything else (commons fns, context-local fns, methods, constructors) folds into the entry participant’s own activation: no message is emitted for the call, and — because this repo’s resolver does not inline call bodies either — a lifeline call written inside a commons fn’s own body is invisible to this walk. That is a stated Tier-1 limitation, not a bug: see design/pending/sequence-diagram-846.md.

A pure, read-only IDE query: it never touches the checker’s hot path (bynk_check::checker::check_handler_body) and is built on the exhaustive expr_children/statement_exprs walkers only insofar as this module’s own statement dispatch mirrors their coverage of Statement — a new Statement variant is a compile error here, in Builder::walk_block’s match, not a silent gap.

#2194: in an agent’s own handler, a write to the agent’s state — a := or a mutating store operation on one of its store fields — is not a lifeline either, but it is not folded away: it is a MessageKind::StateWrite from the entry to itself, rendered as a note.

Cross-context/agent calls are boundary-stop (Decision C): one Call + one Return message: the callee’s own body is never walked, even where reachable (an agent’s handlers are visible via ContextSequenceInfo::agents). Model-diagrams slice 3 names the callee instead (Message::callee), so a client can open the callee’s own diagram (a UML ref).

Model-diagrams slice 3 (ADR 0858): the model is complete. Nesting is walked to MAX_BLOCK_DEPTH, a safety cap far beyond real code, and each block carries its AltBlock::depth; how much to show is the client’s call. A ? at the top of a statement’s value is an early return, modelled as an AltKind::Break block, and the model names its Trigger.

Structs§

AltBlock
Branch
Callee
The handler a boundary-stop call reaches, named rather than walked (Decision C). The LSP layer resolves it to a location.
Message
Participant
SequenceModel
Trigger
What starts a handler (model-diagrams slice 3).

Enums§

AltKind
HandlerOwner
Which declaration owns the handler being diagrammed.
MessageKind
ParticipantKind
TriggerKind

Constants§

EARLY_RETURN
The reply a break block (a ?) gives: the handler returns early with the operand’s None or Err (a 404 under HttpResult, the error otherwise).
MAX_BLOCK_DEPTH
A safety cap on if/match nesting, not a presentation choice (ADR 0858, model-diagrams slice 3): the model is complete to this depth and the client decides how much to show. It bounds the work and the payload for a pathological handler; real code never comes near it. Beyond it the walk emits a single AltKind::Collapsed marker instead of recursing further. (It was 2, a presentation cut, until slice 3.)
MIXED_KEYS
An agent participant’s key when the handler’s calls key it differently.

Functions§

sequence_model
default_given is the owning service’s service-level given default (v0.155, ServiceDecl.default_given) — a handler that declares no given of its own inherits it. This classifier walks a freshly-parsed AST that has not been through bynk-emit’s inject_service_defaults normalization pass (which is what mutates handler.given in the compile pipeline), so the fallback has to be applied here or a handler relying on the service default would drop every capability lifeline. Pass &[] when there is no default (always the case for HandlerOwner::Agent — agents have no service-level given). default_by is the owning service’s service-level by default (v0.155, ServiceDecl.default_by) — a handler that declares no by of its own inherits it, exactly as it does the given default. Pass None for an agent (agents have no principal).