Skip to main content

Module ast

Module ast 

Source
Expand description

Abstract syntax tree types for Bynk v0 (spec §9.2).

Structs§

ActorDecl
An actor declaration (v0.45 §3.7). An actor is a nominal contract type describing an external party at a boundary — not a runnable entity. A handler consumes an actor on its by clause; the boundary verifies the declared auth scheme and mints a sealed identity (name.identity).
ActorRefinement
The reserved refinement form actor Admin = User where <predicate> (Q3). Parsed in Foundations so the grammar is fixed; admission is a later slice.
AdapterDecl
An adapter qualified.name { … } declaration (v0.17 §3.1). An adapter co-locates a capability contract with a non-Bynk binding: it may declare capabilities, the boundary types they reference, inline pure helper type/fn (and uses), external (bodiless) providers, exports capability, and exactly one binding clause. It may not declare services, agents, or bodied providers. Like commons/contexts it may be split across files in a directory.
AgentDecl
An agent declaration (v0.5 §3.6). Agents are state-bearing entities with their own handlers.
Annotation
A storage annotation on a store field (v0.85, storage track; ADR 0111): @<name>(<args>). The name is matched against the closed registry (@indexed/@ttl/@retain/@bounded) by the checker; the grammar accepts any identifier so an unknown name is a checker diagnostic, not a parse error. Arguments are compile-time metadata, restricted to literals (and the by: field-name labels of @indexed) by the checker per ADR 0111 D4.
AnnotationArg
A single annotation argument (v0.85; ADR 0111): an optional label: followed by a value expression — by: orderId (labelled) or 5.minutes (positional). The value is parsed as an ordinary Expr so the duration-literal form (5.minutes, landing with the Duration slice) needs no special grammar; the checker restricts it to a literal where the annotation is functional.
AssignStmt
name := expr — a Cell store write (v0.81, storage track). target is the Cell field being written (a bare name for now; the checker resolves it to a store field). value is the new value.
BindingDecl
A binding "<module>" requires { "pkg": "range", … } clause inside an adapter (v0.17 §3.5). module is the TypeScript module supplying the adapter’s external provider symbols, resolved relative to the adapter’s source file. requires declares npm dependencies folded into the generated package.json.
Block
A brace-delimited block of statements ending in a tail expression whose value is the block’s value (spec v0.1 §3.1).
ByClause
The by (<binder>:)? <Actor> clause on a handler (v0.45; binder optional in v0.50). Names the actor contract the handler consumes; when a binder is given, the verified identity binds to it and is read as binder.identity. Omitting the binder (by <Actor>) declares-and-verifies the contract without capturing the identity — for anonymous or verify-and-discard handlers. Sits after the protocol config and before the parameters.
CapRef
A capability reference in a given clause (v0.15 §3.2). A bare name is a local capability (given Cap); a dotted name refers to a capability a consumed context provides (given B.Cap / given Alias.Cap).
CapabilityDecl
A capability declaration (v0.5 §3.3). Capabilities are interface-like contracts for external dependencies, used inside contexts. They may only appear inside a context declaration.
CapabilityOp
One operation in a capability (signature only; no body).
Case
A case "name" [as <tier>] { [provides …] body } block inside a suite (v0.7 §3.3; v0.118 adds the tier clause and case-scoped provides).
Commons
A whole parsed commons source file.
ConsumesDecl
A consumes other.context declaration (v0.4 §3.2). May optionally carry an alias introduced by consumes other.context as Alias (v0.6 §3.1).
Context
A whole parsed context source file (v0.4 §3.1).
Contract
A function contract clause (v0.115 §, testing track slice 3). A named predicate on a fn signature — a requires (precondition) or ensures (postcondition). A contract is the invariant predicate attached to a function (ADR 0144 — one predicate surface): the predicate is a pure Bool expression over the parameters (requires) or the parameters plus result (ensures), with implies/is and pure methods, mirroring Invariant. The name rides the failure report and the redundant-test dedup.
ExpectStmt
ExportsDecl
An exports visibility { names } clause (v0.4 §3.3) or, v0.15, an exports capability { names } clause.
Expr
FieldInit
One field-initialiser inside a record construction expression: either name: expr or the shorthand name (which requires a binding of the same name in scope and uses its value).
FloatBound
A float refinement bound (v0.21): the parsed value plus the signed source lexeme (for byte-stable emission). v0.40 (ADR 0073): also the source span, for the InRange-swap quick-fix.
FnDecl
ForAll
The for all x: T, … [where <pred>] { … } binder inside a PropertyDecl.
ForAllBinding
One for all binding: name: T, where the runner generates inhabitants of T from its refinements.
Handler
A handler block — on call(args) -> T given C1, C2 { body }. Used by both services and agents.
HttpVariant
One variant of the built-in HttpResult[T] sum (v0.9 §3.3).
Ident
An identifier with its source span.
IntBound
An integer refinement bound (v0.40, ADR 0073): the parsed value plus the bound’s source span (covering a leading -). Value-only beyond the span — ints have one canonical printed form, so the formatter stays idempotent without a stored lexeme. The span backs the InRange-swap quick-fix.
Invariant
An agent invariant (v0.80 §14). A named predicate over the agent’s state fields that must hold of every committed state; a commit that would violate it faults (InvariantViolation) before the state is persisted. The predicate references state fields by bare name, mirroring the design-notes worked examples (status == Paid implies paymentRef.isSome()).
LambdaExpr
A lambda expression (v0.20a): (params) => expr or (params) => { … }. => is the value arrow (shared with match); param annotations are optional where an expected function type supplies them.
LambdaParam
A lambda parameter. A separate type from Param because its annotation is optional — Param.type_ref stays mandatory at every signature site.
LetStmt
MatchArm
One arm of a match expression: pattern => body.
ObservationExpr
An observation of a capability operation’s recorded calls (v0.117, testing track slice 5). cap/op name the seam (Logger.log); matcher is the claim about the recorded calls.
Param
PatternBinding
A single binding inside a variant pattern. Two surface forms: name (positional — bind the i-th payload field) and fieldName: bindName (named — bind the named payload field). Both forms also accept _ as the bind name to discard.
PropertyDecl
A property "name" { for all <bindings> [where <pred>] { body } } block inside a suite (v0.114, testing track slice 2, ADR 0149). The generative sibling of Case: the runner draws inhabitants of each binding’s type from its refinement domain and evaluates the body’s expects over them.
ProviderDecl
A provider declaration (v0.5 §3.4). Supplies an implementation for a capability.
ProviderOp
One operation in a provider (signature plus body).
ProvidesClause
v0.118: a per-seam provider override provides Cap.method(<args>) returns <v> | fails (testing track slice 6, ADR 0154). Substitutes one capability method’s provision under test; the right-hand side is a value or a fault, never a computed body.
QualifiedName
A dotted name like fitness.units.
QueueVariant
One variant of the built-in QueueResult sum (v0.44).
RecordBody
Body of a record-type declaration (v0.2 §3.1).
RecordField
One field of a record type declaration. Each field may carry inline refinement, which is enforced at construction time on the field’s value.
Refinement
RefinementPred
RequiresDep
One "pkg": "range" entry in a binding’s requires { … } map.
SchemeArg
One key = value argument in a scheme config (Scheme(key = value, …)).
SendStmt
ServiceDecl
A service declaration (v0.5 §3.5). Services are the boundary interface of a context.
StoreField
A store field (v0.81, storage track). Each is an access-pattern slot of a declared storage kind: store <name>: <Kind>[…] [@annotations] [= <init>]. The kind and its element type are carried as an ordinary TypeRef (Cell[Int], Map[K, V]); the checker restricts which heads are storage kinds. Access-pattern annotations (@indexed, …) parse into annotations (v0.85, ADR 0111); the checker validates them against the closed registry.
StoreKind
A storage kind applied to its element type(s) (v0.81): Cell[Int], Map[ReservationId, Reservation]. The head is the kind name (Cell, Map, Set, Log, Queue, Cache); the checker validates it against the closed catalogue. Element types are ordinary TypeRefs. Refined element types (Cell[Int where NonNegative]) ride a later slice (parse_type_ref does not yet accept an inline refinement in type-argument position).
SuiteDecl
A test <qualified-name> { ... } declaration (v0.7 §3.1).
SumBody
Body of a sum-type declaration (v0.2 §3.2).
Transition
An agent step invariant (v0.116 §, testing track slice 4). A named predicate over the pair of committed states — the pre-commit old and the proposed new, each the agent’s state record — that must hold of every state move; a commit that would violate it faults (InvariantViolation) before the state is persisted, exactly as a snapshot Invariant does. Widens the invariant subject from a snapshot to a step (ADR 0144 — one predicate surface); the predicate reuses the invariant surface (implies/is/pure methods) with old/new bound contextually (old.status is Paid implies new.status is Paid).
Trivia
Comment trivia attached to a declaration or statement (v1.1 LSP spec §3.5). The parser collects line comments from the token stream and attaches them to nearby AST nodes so the formatter can re-emit them.
TypeDecl
TypeParam
A function type parameter (v0.20a, fn name[A, B](…)). A struct rather than a bare Ident so the ADR-0028 “bound-capable” promise is a later field addition, not a representation change.
UsesDecl
A uses other.commons declaration (v0.3 §3.3).
Variant
One variant of a sum type. Variants may have payload fields; a payload-less variant is a simple tag.
VariantField
One payload field of a sum variant. Variant payload fields use named declarations like record fields, but do not carry refinement in v0.2.

Enums§

ArgPattern
v0.118: one argument pattern in a provides call pattern. Patterns for the same method are tried top-to-bottom, first match wins.
BaseType
BinOp
CommonsForm
The two surface forms in which a commons body may be parsed (v0.3 §3.1).
CommonsItem
DurationUnit
A Duration literal unit (v0.86, ADR 0112) — the closed set of suffixes in a <int>.<unit> literal. Each maps to a fixed millisecond factor (Duration erases to Int milliseconds).
ExportKind
What an exports clause exposes: types (with a visibility) or, v0.15, capabilities offered for cross-context consumption.
ExprKind
FnName
A function-declaration name: either a free function f or a method T.method (v0.2 §3.6).
HandlerKind
HttpMethod
HTTP methods supported by on http handlers (v0.9).
HttpVariantPayload
Payload shape of an HttpResult[T] variant (v0.9 §3.3).
InterpPart
One part of an interpolated string (v0.43, ADR 0075). An ExprKind::InterpStr holds an alternating run of these.
MatchBody
The right-hand side of a match arm — either a single expression or a block.
ObservationMatcher
The claim an ObservationExpr makes about a seam’s recorded calls (v0.117).
Pattern
A pattern (v0.2 §3.8). Patterns appear in match arms and as the right-hand side of the is operator.
PatternBindingKind
PredKind
ProvidesRhs
v0.118: the right-hand side of a provides clause.
QueueVariantPayload
Payload shape of a QueueResult variant (v0.44). Non-generic — a verdict carries no value; Retry carries a String reason for the log path.
SchemeArgValue
A scheme config arg value — a string literal or an integer.
SeqOutcome
v0.118: one outcome in a sequenced (returns each) provides.
ServiceProtocol
The protocol a service conforms to — declared on the header via from <protocol> (v0.44). Call is the default (no from clause): a contract-mediated internal-RPC surface, not a wire protocol. Multi-endpoint protocols (Http, Cron) carry no binding — the endpoint lives on each handler; single-binding Queue carries its queue name.
SourceUnit
Either a commons or a context — the two declaration kinds at the file level (v0.4 §3.1). v0.7 adds the test declaration kind; v0.17 the adapter.
Statement
Block-level statement.
TestTier
v0.118: the tier a case runs at (testing track slice 6, ADR 0153). One body promoted across the testing pyramid; unit is the default and elided.
TypeBody
The right-hand side of a type declaration. In v0/v0.1 only the Refined variant existed; v0.2 adds records and sums; v0.3 adds opaque.
TypeRef
UnaryOp
Visibility
Visibility level for an exports clause (v0.4 §3.3).

Constants§

HTTP_VARIANTS
All HttpResult[T] variants, in declaration order (ascending status). The vocabulary tracks the common, modern HTTP status codes (RFC 9110): success and created/accepted (Value), redirects carrying a Location URL, and the client/server failures that handlers routinely return (Message when an explanation helps the caller, None for self-describing statuses).
QUEUE_VARIANTS
All QueueResult variants, in declaration order. Ack confirms the message; Retry redelivers it, carrying a reason for observability.

Functions§

http_variant
Find an HttpResult[T] variant by name. Returns the variant info or None if the name doesn’t match.
queue_variant
Find a QueueResult variant by name.