Expand description
Bynk’s semantic-analysis layer — the crate between bynk-syntax and the
emitter.
Holds name resolution (resolver), type checking (checker), the registries
the checker dispatches and the LSP reads (kernel_methods, builtin_names),
the first-party embedded sources (firstparty), actor analysis (actors),
and the captured analysis tables written during resolution/checking:
the binding index, inlay hints, expr_types, and locals. These tables
are produced here and queried by the IDE layer (bynk-ide, a later slice):
captured tables live in bynk-check, queries live above it (ADR 0102, and
the crate-decomposition track’s check↔IDE seam).
Extracted from bynkc as slice 3 of the crate-decomposition track. Behaviour
is unchanged; bynkc depends on this crate and re-exports its modules so its
public API and the emitter/project layers above are untouched.
P4.1 (#1115) added this crate’s first project-level orchestration:
project_model (discovery→parse→group→resolve, shared with bynk-emit’s
run_checks), check_pipeline (the per-file resolve+check core, also
shared), and analysis (ProjectAnalysis and the new
analyse_project entry point bynk-ide will call once P4.2 repoints it).
context_checks — the per-file context/capability/provider/service/agent
validation, previously bynk-emit’s validate.rs — moved here in the
same slice, for the same reason: project_model’s and check_pipeline’s
shared pipeline needs it, and duplicating it into a second copy is exactly
what this crate’s extraction discipline exists to avoid.
Modules§
- actors
- v0.45 actor contracts (the actors-foundations slice).
- agent_
state - #2195: the agent state model — each agent’s state machine, derived from its
handlers (agent-state-views track, slice 1; retired-track
summary in
design/archive/retired-tracks.md, §3.1, §3.3, §3.7). - analysis
- The project-level analysis entry point (P4.1, #1115): discovery
(
bynk-project) → parse → resolve → check, returning thebynk-ide-facing analogue ofbynk-emit’sProjectAnalysis— without ever emitting. - assets
- #1883 (static assets): the checker-side rules for
asset name = "path"declarations — the path rules, the name rule, the composition of a unit’s visible assets throughuses([DECISION G]) — and (slice 1b) the build side’s shared definitions: the existence check, the served URL path, and the files each Worker ships. - ast_
text - Short source-text renderings of AST fragments, shared by the agent state
model (
crate::agent_state) andbynk-ide’s sequence diagram and effect summary: a branch’s outcome, a match arm’s pattern, and a parenthesis peel. #2220 moved them here frombynk-ide’ssequence.rswith the state model. - builtin_
names - Centralised string literals for the language’s built-in vocabulary (refactor track item 8, v0.29.11). Built-in type/method names were compared as bare string literals scattered across the checker, emitter, and project modules; a typo was a silent never-match. One edit point per name now.
- check_
pipeline - The shared per-unit/per-file resolve-check core, used by both
bynk-emit’scheck_unit_files(Mode::BuildandMode::Analyse) and this crate’s owncrate::analysis::analyse_project. - checker
- Type checker and refinement validator (spec §§5–6, v0.1 §4.2, v0.2 §4.2).
- context_
checks - contract
- v0.177 (#643): the canonical normal form of a cross-context contract, and its hash.
- embeds
- #2387 (embedded text): the checker-side rules for
embed name = "path"declarations — the path rules, the name rule, the composition of a unit’s visible embeds throughuses— mirroringcrate::assetsfor the part an embed shares with an asset. - exports
- The shareable-unit set (packaging slice 1, #2207; track D1): a package’s
[package] exportslists the units it shares, and each must be a commons or an adapter the project declares. A context is never shareable — it is a deployment unit, whose Worker, secrets and deploy state belong to the project that deploys it. - expr_
types - v0.30.2 (ADR 0063): the expression-type sink.
- firstparty
- First-party standard adapters embedded in the toolchain (v0.17 §4.2).
- hints
- v0.27 (ADR 0056): the inlay-hint sink.
- icu
- message-bundles slice 3 (#878): the ICU MessageFormat placeholder
mini-parser, plus the plain-
{name}template scanner (split_template) it dispatches from. Self-contained andbynk-syntax-free by design (Decision B) — the whole ICU sub-grammar ({name, plural, one {…} other {…}},{name, select, …},{name, number[, style]},{name, date[, style]}) lives entirely inside amessagestemplate’sStringcontent, parsed here as plain&strand consumed by both the checker (bynk-emit/src/project/validate.rs) and the emitter (emit_message_entry_renderer). Nobynk-syntaxgrammar/lexer/AST change backs this — a template stays one opaqueStringall the way through parsing. - index
- v0.25: the project-wide binding index (ADR 0053).
- kernel_
methods - v0.30.2 (ADR 0063): the enumerable kernel-method registry.
- locals
- v0.31 (ADR 0064): the local-binding sink.
- narrowing
- Which
istests an expression proves. #1654 (runtime-semantics track S5, Decision A): the one structural rule the resolver, the checker and the emitter all read, so their views of anisbinding’s scope cannot drift. - packages
- Packaging slice 2a (#2223): loading a project’s path dependencies into one compile.
- project_
model - Project-wide orchestration: discovery → parse → group → resolve, shared
between
bynk-emit’srun_checks(bothMode::BuildandMode::Analyse) and this crate’s owncrate::analysis::analyse_project. - recovery
- #1663: diagnosing a file the strict parser rejects, for the CLI’s
single-file check. The editor’s
bynk_ide::diagnosefollows the same rules (Decisions A and B) on its own recovering parse. - requirements
- v0.99 (ADR — agent capability provenance): the capability-requirement ledger.
- resolver
- Name resolution (spec §5.1, v0.1 §4.1, v0.2 §4.1).
- schema_
registry - Events track, slice 3c (#980): the cross-build schema registry’s
reconciliation logic — verifying a project’s live event shapes against a
committed
bynk.schema.lock, keyed by qualified event name, storing each event’s field shape (name, type, whether the field has a default) and its current schema version. Every build reconciles the live shape against the stored one and either leaves the version alone, bumps it (a purely additive change), or fails the build (a change that isn’t safely additive). - secrets
bynk.Secretsread-name checking (v0.173, ADR 0196 D1).- shadow_
uses - #1824: where a unit’s own code meets an imported declaration’s position that names a type the unit shadows.
- stability
- Experimental standard-library items and the project’s opt-in to them (standard-library S3, #1963; track D2).
- store_
ops - #611: the enumerable storage-operation registry.
- store_
write - #2194/#2195: recognising a write to an agent’s own state, shared by the sequence diagram (state-write notes) and the agent state model.
- symbols
- test_
env - #2134: a suite’s configuration,
env { NAME = "value" … }. - test_
suites - Test/integration-suite checking (P5.4,
design/tracks/semantics-in-the-checker.md§6) — closes category 7 ofbynk-check/src/analysis.rs’s own residual-gap accounting, the last of the seven.bynk-emit/src/project/tests_emit.rsheldprocess_tests/process_integration_tests, real production code (not fixture noise, despite the filename) checking + emittingsuite/test integrationbodies — but it ran only insidebynk-emit::run_checks(Mode::Analyseincluded), never insidebynk_check::analysis::analyse_project, the entry point the LSP now uses. That gap meant no diagnostics and noRefSinkbindings (go-to-definition/find-references) for anything inside a test file, in the editor — seeanalysis.rs’s own module doc for the full accounting this closes. - unit_
signature - P8.1 (#1512):
UnitIdandUnitSignature— the load-bearing types this whole phase’s firewall (R3.14) is stated in terms of.UnitSignatureprojects aUnitTableinto design notes §15’s four required-annotation categories — cross-context types, fn signatures (free functions and methods), handler signatures plus storage, capability sets — with every body/body-adjacent field excluded ([DECISION B],design/tracks/incrementality.md§3.4/Q4) rather than merely ignored by the comparison:body/requires/ensuresnever reachFnSignature,bodynever reachesHandlerSignature,init/annotationsnever reachStoreFieldSignature— the type system, not a comparison function’s own discipline, makes “no body reachable fromUnitSignature” a fact. - websocket
- v0.104 (real-time track slice 3b): shared analysis of a
from websocketon openhandler for the Workers wire path. - wire
- #855: the wire-contract IR — the shape a Bynk type takes crossing a context boundary, derived once from the AST + type table so both the emitter’s codec generation and the editor’s “wire contract” peek render the same derivation instead of two hand-synchronised ones.
- wire_
default - wire_
format - #1969: the cross-context wire format, version 1, as a published surface.
- worker_
bindings - A Worker’s binding names must be unique (
bynk.context.duplicate_binding).
Enums§
- Platform
- The deploy platform — a selection axis distinct from the
--target {bundle,workers}emit mode (§6.2). It chooses whichbynk-<platform>.tsbinding is linked for thebynksurface. v0.17 shippedcloudflare; v0.18 addsnode, making the axis observable (and giving v0.19’s platform-lock enforcement a second platform to fire against).