Expand description
Multi-file project compilation (v0.3 §3.2 and §3.3, v0.4 §3.5).
A “project” is a directory tree of .bynk source files. The dotted name
of a commons or context (e.g., bynk.time, commerce.orders) maps to a
path under the project root — either a single file (bynk/time.bynk) or
a directory of files all sharing the same header (bynk/time/*.bynk).
v0.4: each file is one of two kinds — commons or context. Both kinds share
the same multi-file directory machinery; they differ in body content
(contexts have consumes/exports, types are nominally per-context), in
visibility (contexts export only the types listed), and in TypeScript
emission (contexts re-brand types from used commons).
Compilation proceeds in two passes:
- Discover and parse every
.bynkfile. Group by qualified name and kind. Build a global symbol table where each unit contributes its declarations. - Resolve, type-check, and emit each unit with full visibility of
the units it transitively
usesorconsumes. Two passes keepusescycles trivial — there is no order-of-evaluation, only declarative mixin.
Structs§
- Agent
Deps Plan - #527: the DO-side deps plan for one workers context. Capability providers
cannot cross the DO wire (
{ args, deps }is JSON — a provider’s methods die in serialisation), so the generated Durable Object reconstructs its agents’givendeps inside the DO from the same wiring compose uses. - Attributed
Error - v0.24 (ADR 0052): a compile error attributed — where possible — to the
project-relative source file it belongs to, tagged at the collection
point (the phase that produced it knows which file it was processing).
Noneis the project-level bucket: validations spanning files (group/cycle/directory consistency) with no single owning file. - Compile
Options - Options for
compile_project. Construct withCompileOptions::singleorCompileOptions::split, then chain.target(…)/.platform(…)/.import_ext(…)to override the bundle/default-platform/.jsdefaults. - Compiled
File - One generated TypeScript file.
- Context
Boundary Info - #855: the per-unit slice of resolution the wire-contract peek needs —
see
ProjectAnalysis::boundary_info. A sibling ofContextSequenceInfo, not a field on it: that struct is named and documented for #846, and this is a separate retained table serving a separate query (hover/panel over a single handler’s boundary, not the sequence-diagram classifier). Moved verbatim (Decision C, #1115). - Context
Sequence Info - #846: the per-unit slice of resolution the sequence-diagram classifier
needs — see
ProjectAnalysis::sequence_info. Moved verbatim (Decision C, #1115) frombynk-emit/src/project/diagnostics.rs. - Discovered
Case - One discovered
test "<name>"case.locationpoints at the case-name literal (a run failure instead points at the failingassert), giving the editor click-through to the declaration before any run. - Discovered
Suite - v0.67: a discovered test suite — one
test <target>group (unit) ortest integration "<suite>"(integration).name+kindmirror exactly what the NDJSON runner emits atsuite-begin(kind"unit"carries the joined target name;"integration"carries the bare suite name), so the editor reconciles discovery and run documents to the same tree items. - File
Decl Index - For each name declared in the unit (type, fn, method), record which source file declared it. Used by the emitter to render relative imports.
- InMemory
Analysis - The outcome of
analyse_in_memory_with_types: diagnostics plus the analysed file’s(span, type)entries (span-sorted — seeExprTypeSink::take_files), for a position→type query (#397, the playground’s hover), and its local bindings (#808, the playground’s completion —bynk_check::locals::locals_atoverlocalsanswers “what’s in scope at this offset”). - Project
Analysis - v0.24: the analyse-mode result — every discovered file’s analysed text
snapshot (positions must convert against the text that was analysed, not
a newer buffer) plus the attributed diagnostics. Moved verbatim (Decision
C, #1115) from
bynk-emit/src/project/diagnostics.rs;bynk-emitre-exports this type at its old path (bynk_emit::project::ProjectAnalysis) sobynk-ide’s existing destructuring needs no field-by-field rewrite. - Project
Check - Result of
check_project: every diagnostic from a non-bailing project analysis — errors and warnings together (ADR 0117), unconditionally, unlikeProjectOutput/ProjectFailurewhereerrors/warningsis picked by which variant the caller got.bynk check’s exit code is decided bySelf::has_errors, not by whether this was reached at all. - Project
Failure - v0.24: a failed build with its attribution and snapshots intact — what
the CLI renders rich (ariadne source context per file); the plain
compile_project*wrappers flatten it to the pre-v0.24 error list. - Project
Output - Result of compiling a project.
- Project
Paths - v0.113 (DECISION S): the project’s source tree, read from
bynk.toml’s[paths]section. Test-ness is a property of thesuitedeclaration, not of a directory, so the layout is a flatincludelist of trees to compile and anexcludelist of subtrees to skip — not the role-namedsrc/testssplit. Eachincludeentry is a root walked for.bynkfiles; a file’s identity path is relative to theincluderoot that contains it. - Test
Location - A project-root-relative
path:line:colsource location, structured. Line and col are 1-indexed (thebynk_syntax::span::line_colconvention). - Unit
Table - Combined symbol tables for a single logical commons or context.
Enums§
- Build
Target - The build target. Determines how cross-context calls and per-context modules are emitted (v0.8). Bundle mode is the default — all contexts emit into one TypeScript bundle and cross-context calls are direct function invocations. Workers mode produces per-context Cloudflare Worker bundles that communicate via Service Bindings.
- Import
Ext - The extension emitted import specifiers use (
import … from "./x.<ext>"). - Project
Paths Error - A problem in
bynk.tomlthattry_read_project_pathssurfaces instead of silently falling back to the conventional layout. - Roots
- Where a project’s
.bynkfiles live. - Schema
Lock bynk-emit’sCompileOptions::schema_registryvalue — whether a build reconcilesbynk.schema.lock, and if so, its current content.- Unit
Kind - Distinguishes a commons from a context (and from a test) in the project graph. Tests are a third kind in v0.7.
Functions§
- analyse_
in_ memory - Analyse a single in-memory Bynk source and return all diagnostics —
non-bailing, no emission (in-browser track, slice 5d). The editor calls this
on every (debounced) keystroke for live diagnostics: unlike
compile_in_memory(build mode, which bails at the first failing phase), this runs inAnalysemode, so parse / resolve / check diagnostics are recovered and reported together — and it works for acontext(the playground’s typical program), not only a commons. Same fs-free seam ascompile_in_memory. - analyse_
in_ memory_ with_ types - Like
analyse_in_memory, but also exposes the expression-type map the checker captured (ADR 0063’sexpr_typessink) — the same oneanalyse_project_withdrains — instead of discarding it. Per ADR 0094, this is a best-effort partial map inAnalysemode: a function that type-checked cleanly contributes its types even if a different function in the same file has an error, soexpr_typesis empty only when the expression at hand never typed at all (e.g. it sits in an unresolved region, ADR 0094’s “out of scope — the resolve gate”), not merely because the file has some error somewhere. - analyse_
project - v0.24: analyse a project without building — non-bailing, overlay-aware,
file-attributed (ADR 0052).
overlaymaps canonicalised absolute paths to buffer text layered over disk reads (unsaved editor buffers). - analyse_
project_ with - Slice A: analyse a project whose roots are resolved from its manifest — the
same
Rootscompile_projectconsumes, resolved the same way, so the LSP discovers exactly the filesbynkccompiles. - check_
project - Check a project without building (finding #64) — never bails after
discovery (
Mode::Analyse, the same modeanalyse_project_withalready uses for the editor), so a diagnostic anywhere in the project does not suppress diagnostics elsewhere.compile_project’sMode::Buildbails at the first structural error and returns only what it collected up to that point — correct forbuild/test, which must not emit past a real error, but wrong forcheck, whose only job is to report everything.bynk check’s directory path calls this instead ofcompile_project. - compile_
in_ memory - Compile a single in-memory Bynk source through the full project pipeline —
no filesystem access (in-browser track, slice 3). The source is the in-process
Bundlesubset thatconsumes bynk; first-party injection and the per-platform binding emission run exactly as for an on-disk build, so the returnedProjectOutputis the complete module graph (the user unit +runtime.ts+ thebynk-<platform>.tsbinding +compose.ts). The wasm entry point pairs this withbynk-stripto produce JavaScript for the playground. - compile_
project - Compile a Bynk project, keeping error attribution + snapshots on failure
(so the CLI can render project errors with source context, ADR 0052). Use
.map_err(ProjectFailure::flatten)for the flattenedVec<CompileError>shape. - discover_
project_ files - Slice A: the
.bynkfiles these roots contain — the same walkcompile_projectperforms, honouringexcludeand the tool’s ownout/node_modulescaches. - try_
read_ project_ paths - Read
bynk.toml’s[paths]section, surfacing a malformed manifest — a parse failure or an unrecognised[paths]key — as an error instead of silently falling back to the conventional layout (the previousread_project_pathstotal form’s behaviour, R3.8 — deleted in favour of this at all 18 of its callers, #1113). - try_
read_ project_ paths_ with - Like
try_read_project_paths, but honoursoverlayforbynk.tomlitself, the same waydiscovery::read_sourcedoes for every other file. - worker_
dir_ name - v0.8: directory name of a Worker for a given context, with dots replaced
by dashes (
commerce.payment→commerce-payment). - worker_
handlers_ output_ path - v0.8: project-relative output path of the workers-mode handlers file.
- worker_
handlers_ source_ path - v0.8: project-relative synthetic source path of the workers-mode handlers file for a given context. Used so the emitter’s relative-import machinery resolves correctly against the workers layout.