Expand description
Bynk’s TypeScript emission, plus the per-unit build sequencing that drives
it — the layer above bynk-project (discovery, the dependency graph),
bynk-check (all semantic checking, R3.5), and (since the P7.12 crate
carve) bynk-ir/bynk-lower (the typed IR and its &CheckedProgram → Ir
lowering pass).
project owns compile_project/run_checks: the two-pass sequence over
a project’s units — discover and parse (bynk-project), then resolve,
type-check (bynk-check) and emit each unit with full visibility of what
it uses/consumes. emitter lowers a checked program to TypeScript.
Input: a project tree (or an in-memory overlay). Output: TypeScript files
plus diagnostics — this crate originates none of its own (P5.5,
design/tracks/semantics-in-the-checker.md §3.5, R10.1).
testgen generates the test harness: each suite’s test module, the test entry and the
discovery manifest, with the test-runtime fragments they embed. The driver calls it, and
keeps orchestration, file I/O and process spawning (1B.2a, #4028).
Extracted from bynkc as slice 4 of the crate-decomposition track over
bynk-syntax + bynk-check. Behaviour is unchanged; bynk depends on this
crate and re-exports its modules so its public API (compile_project,
ProjectOutput, …) and the binary are untouched.
Re-exports§
pub use emitter::wrangler::COMPATIBILITY_DATE;pub use emitter::wrangler::DEFAULT_COMPATIBILITY_FLAGS;pub use emitter::wrangler::WRANGLER_MIN;pub use emitter::wrangler::compatibility_flags;
Modules§
- emit_
model - The model the code generator shares with the orchestration layer: the
output documents (
Artefacts,Document,ProjectOutput), the import extension, the per-unit emission context (EmitProjectCtx) and the provider-instantiation expressions the emitter splices into generated code. - emitter
- TypeScript emission (spec §7, v0.1 §6, v0.2 §6).
- testgen
- Test-harness generation:
suite/test integrationprocessing, the test entry (tests/main.ts), the discovery manifest and the embedded test-runtime fragments. The fragments are authored as modules underbynk-emit/runtime/src/testing/and reach the harness only throughruntime_splice(1B.3a, #4047). - wire_
format - State-migrations S4 (#2259): the call signature and the sweep route’s
names, for
bynk migrate sweep, which signs as the runtime verifies. #1969: the cross-context wire format, version 1, as a published surface.
Structs§
- Compiled
- A single-file compile that also returns the non-failing warnings produced on
success — what a CLI prints (v0.89, ADR 0117).
compileis the warning-discarding convenience over this.
Constants§
- AGENTS_
MANIFEST - #3562 (G5): the file every Worker that hosts an agent stages beside its entry, naming each
context and the agent classes it owns, which
bynk deployreads to guard a move. - CONTAINERS_
UNAVAILABLE_ VAR - #3477 (slice C3): the
wrangler dev --varthat tells a generated container class its containers are off (bynk devwithout Docker), so a call faults naming Docker. The runtime’s own copy isCONTAINERS_UNAVAILABLE_VAR(container.ts);xtask/tests/env_protocol.rskeeps the two equal (#4003). Thewrangler dev --varthat tells a generated container class its containers are off (bynk devwithout Docker). - EDGE_
FROM_ PREFIX - I2 (#1971): the edge keys’ names, for the driver (
bynk dev,bynk deploy), which sees the compiler only through this crate. The prefix of the secret a callee holds for the edge from one caller, followed by the caller’s edge suffix. - EDGE_
TO_ PREFIX - I2 (#1971): the edge keys’ names, for the driver (
bynk dev,bynk deploy), which sees the compiler only through this crate. The prefix of the secret a caller holds for the edge to one callee, followed by the callee’s edge suffix. - INSPECT_
CALLER - #3581 (the dev agent-inspection track): the caller name
bynk dev inspectsigns its requests as, and the variable under whichbynk devgives every served Worker the local key for it (BYNK_CALL_FROM_plus the caller’s edge suffix). The runtime’sINSPECT_CALLERis the same name. - INSPECT_
CALLER_ KEY_ VAR - The edge key from
bynk dev inspect’s caller,bynk.dev: theCALL_FROM_PREFIXfamily’s one fixed member. - INSPECT_
MEMBERS_ FILE - #3562 (G6): the file a
bynk devgroup build stages beside its entry, naming each member that hosts an agent and its classes, sobynk dev inspectcan sign a request for the member that answers it. - LOCAL_
CALL_ KEY - I2 (#1971): the value of every edge key off the deployed path.
bynk devpasses it for each edge a Worker is on (BYNK_CALL_TO_<callee>,BYNK_CALL_FROM_<caller>, named bybynk_check::wire_format), and the generated test harnesses put it in every participant’senv. Fixed rather than random so twobynk dev --contextsessions run side by side still admit each other’s calls. It guards nothing, so it must never reach a deployed Worker:bynk deploymints one key per edge, and none is ever written into a generatedwrangler.toml. - NODE_
FLOOR - The Node floor as
(major, minor): whatbynk doctorcompares against. - NODE_
MAJOR_ FLOOR - Minimum supported Node.js major version for the
nodeplatform binding and for running Bynk’s emitted TypeScript. - NODE_
MINOR_ FLOOR - The minor version within
NODE_MAJOR_FLOORthe floor sits at: 22.13, the first 22.x whose built-innode:sqliteloads without--experimental-sqlite(standard-library P4a, #2602: theD1test double runs on it). CI’s floor job installs exactly this version. - STORAGE_
LAYOUT - The storage layout this emitter writes an agent’s state in (#3189, the
retired per-entry-storage track in
design/archive/retired-tracks.md): 1 is the wholesale layout, with every collection inline in the one"state"record, and 2 is the per-entry layout, with eachMap/Set/Cache/Logentry and index posting under its own key.bynk deployrecords it in each version’s facts so thatbynk deploy revertcan refuse a rollback to a build that writes an older layout over stored data. The slice that changes the layout raises this together with the emitter’s writer. - TYPESCRIPT_
MAJOR_ TESTED - The TypeScript major the emitted output is verified against, and the only
one Bynk supports (#3420): the one users get from
npm install -g typescript. Every CI leg installs it and type-checks every positive fixture under it, thenpxfallbacks provision it, andbynk doctorwarns on atscbelow it and reports one newer than it as untested. (There was a lower floor, 5, until #3420: tsc 5 cost about 4x tsc 7 perbynk test, and the shape of the generated code is meant to be independent of the tooling.)
Functions§
- check_
with_ warnings - Check a single-file commons without building it: the same diagnostics as
compile_with_warnings, minus the build-only ones, and no emission. Returns the non-failing warnings on success. The single-file half ofbynk check(bynk_driver::run_check); a directory goes through the project pipeline inMode::Checkinstead. - compile
- Compile a single Bynk source string to a TypeScript string.
- compile_
with_ warnings - The warning-preserving single-file compile behind
compile. SeeCompiled. - edge_
key_ from - I2 (#1971): the edge keys’ names, for the driver (
bynk dev,bynk deploy), which sees the compiler only through this crate. I2 (#1971): the secret the callee holds for calls fromcaller(BYNK_CALL_FROM_SHOP__ORDERS). The callee picks it by the request’sCALLER_HEADER, so an undeclared caller finds no key and is refused. - edge_
key_ to - I2 (#1971): the edge keys’ names, for the driver (
bynk dev,bynk deploy), which sees the compiler only through this crate. I2 (#1971): the secret the caller holds for calls tocallee(BYNK_CALL_TO_SHOP__PAYMENT). Same value as the callee’sedge_key_fromfor the same edge.