Expand description
#855: the wire-contract peek — the model behind “hover a service handler”
and “Show Wire Contract”. Renders bynk_check::wire::WireModel (the
same IR bynk-emit’s codec generation consumes) narrowed to one
handler, plus the facts the IR does not carry: the request envelope
shape, the cross-context contract form + hash (on call only), and the
HTTP response set a route can actually answer with.
Handler resolution mirrors bynk-lsp/src/sequence_request.rs’s
sequence_model_at: re-parse the committed snapshot with
parse_unit_with_recovery, find the Handler whose span contains the
cursor. The re-parsed Handler supplies spans/body; the retained
ContextBoundaryInfo supplies the type table — a single-file re-parse
cannot see a uses target’s types, which is the whole reason that table
is retained project-wide (Phase 3).
Provenance. bynk_check::wire::Provenance distinguishes a type this
module owns from one reached through another unit. ContextBoundaryInfo‘s
types table is contract_types_for(unit, …) — this unit’s own type
namespace: own declarations, its uses targets’, and (#2073) the types of
the contexts it consumes, which its own signatures may name — the exact
table own_contract_hashes (bynk-driver/src/project.rs) hashes a
service’s contract through. Every name resolvable through it is this
unit’s own view of its boundary, so the peek reports
Provenance::Owned throughout, a borrowed consumed type included. A
caller’s view of another unit’s boundary is out of scope for a peek that
answers “what does this handler send and receive”.
Scope. Service handlers only. An agent’s on call handler crosses a
Durable-Object RPC boundary too, but the issue’s worked examples (an HTTP
route, a cross-context on call) are both service handlers, and
ContextBoundaryInfo does not retain agents’ own handler bodies in a form
this module needs. Left for a later slice if an agent peek is wanted.
Structs§
- Contract
Form - The canonical form + hash of an
on callhandler’s contract — the same projectionbynk-driver/src/project.rs’sown_contract_hashesbuilds, so the hash this peek shows is provably the hash the emittedX-Bynk-Contractconstant stamps. - Http
Response - One reachable HTTP outcome.
- Wire
Contract Model - The wire contract of one handler: its request envelope, its reachable
response set (HTTP handlers only), its cross-context contract form + hash
(
on callonly), and the boundary type shapes both reference.
Enums§
- Boundary
Kind - Which protocol hosts the hovered handler: the system model’s own
bynk_model::IrHandlerKind, read throughbynk_model::lower_handler_kind_ir. - Envelope
- The request shape a handler’s caller sends. Three cases, not two —
bynk-emit/src/emitter/workers_entry.rs’sh.params.len() == 1branch is the only bare-value case; everything else, including zero params, takes the object branch. Rendering onlyBare/Keyedwould misstate a zero-arg service as accepting an (empty) object body it never inspects, when what actually happens is the body is not read at all. - IrHttp
Method BoundaryKind::Http’s method: the model’sbynk_model::IrHttpMethod.IrHandlerKind::Http’s own method field — a field-for-field mirror ofbynk_syntax::ast::HttpMethod, same reasoning asIrHandlerKinditself.- NoCross
Context Reason - Why there is no cross-context contract to show for this handler. Rendered on the panel only — hover stays quiet about an absence (Part 4).
- Response
Body - What a response’s body is (#3632): the classification
bynk openapi’sresponses_ofmakes perHttpVariantPayload, as data a client can read. - Response
Origin - Why a response was reachable — so a renderer can tell an author-declared outcome from one the boundary injects on their behalf without their having written a line for it.
Constants§
- REDIRECT_
HEADER - The header a
ResponseBody::Redirectcarries its target in.
Functions§
- http_
result_ inner Effect[HttpResult[T]]/HttpResult[T]→T;Nonewhen the declared return is not anHttpResult. The one place the payload type is read, shared withbynk openapiso the two cannot drift.- real_
context_ count - How many real contexts/adapters a project has — the input
wire_contract_at/wire_contract_for_service’scontext_countwants, decidingNoCrossContextReason::SingleContext. - response_
body - The body of one response, or
Nonewhen it has none to describe: a no-payload variant, a()value payload, or a boundary-implicit response (the boundary shapes those bodies, not the handler). - response_
payload - The wire shape of the body one response carries (#3609), given the model’s
WireContractModel::success:Tfor a value variant,Nonefor everything else. A message variant’s body is{ "error": String }and a redirect’s location travels in a header with no body (asbynk openapidescribes them); neither is a ref intotypes, so they are leftNonehere and described byresponse_bodyinstead (#3632). Boundary-implicit responses areNonetoo — the boundary shapes their bodies, not the handler. - wire_
contract_ at - Locate the
Handlerenclosingoffsetintextand build its wire contract. Mirrorssequence_request::sequence_model_at’s re-parse convention.infois the owning unit’s retained boundary table (Phase 3);expr_typesis that same file’s checked expression types (empty for a file with errors — theOk-overload disambiguation then falls back to the declared return type, seeResponseWalk::is_http_result_exprbelow). - wire_
contract_ for_ service - Build the wire contract for one already-located handler. The pure half of
wire_contract_at— the part that never touches the offset/re-parse machinery — split out the same waysequence_model_atdelegates tosequence::sequence_model.