bynk_driver/project.rs
1//! Multi-file project compilation (v0.3 §3.2 and §3.3, v0.4 §3.5).
2//!
3//! A "project" is a directory tree of `.bynk` source files. The dotted name
4//! of a commons or context (e.g., `bynk.time`, `commerce.orders`) maps to a
5//! path under the project root — either a single file (`bynk/time.bynk`) or
6//! a directory of files all sharing the same header (`bynk/time/*.bynk`).
7//!
8//! v0.4: each file is one of two kinds — commons or context. Both kinds share
9//! the same multi-file directory machinery; they differ in body content
10//! (contexts have `consumes`/`exports`, types are nominally per-context), in
11//! visibility (contexts export only the types listed), and in TypeScript
12//! emission (contexts re-brand types from used commons).
13//!
14//! Compilation proceeds in two passes:
15//! 1. **Discover and parse** every `.bynk` file. Group by qualified name
16//! and kind. Build a global symbol table where each unit contributes
17//! its declarations.
18//! 2. **Resolve, type-check, and emit** each unit with full visibility of
19//! the units it transitively `uses` or `consumes`. Two passes keep
20//! `uses` cycles trivial — there is no order-of-evaluation, only
21//! declarative mixin.
22//!
23//! This file is the facade; the children hold the stages of one build:
24//! `options` (what a build is asked for), `entry` (the on-disk entry points),
25//! `in_memory` (the editor, wasm and test entry points), `pipeline` (what is
26//! checked, in what order: `run_checks`), `unit` (how one unit is checked and
27//! emitted), `output` (the files a successful build stages) and `agent_deps`
28//! (a Durable Object's rebuilt `given` deps). `diagnostics`, `remote_tests`,
29//! `schema_registry` and `worker_bindings` are older children.
30
31// P4.0 (#1113): discovery, the unit graph, path resolution, and cross-unit
32// consistency checks moved to `bynk-project` — this crate is now a
33// dependent, not an owner, of that code (`design/tracks/project-model.md`
34// §6 row P4.0). P4.1 (#1115): `symbols` and the per-file `context_checks`
35// subset of `validate` moved to `bynk-check` for the same reason — this
36// crate reaches them as `bynk_check::symbols`/`bynk_check::context_checks`
37// now. P5.0-P5.3 (`design/tracks/semantics-in-the-checker.md` §6) emptied
38// `validate` out the same way, project-wide check by project-wide check,
39// including the reconciliation half of `schema_registry` (now
40// `bynk_check::schema_registry`). P5.4 moved `tests_emit`'s checking half
41// (target/participant resolution, `stub` resolution, case/property body
42// type-checking) to `bynk_check::test_suites` the same way — `tests_emit`
43// stays here as a caller of it, holding only TypeScript emission plus the
44// two functions' unchanged public shape. P5.5 (§5, §6): `validate` reached
45// empty (its last occupant, `check_platform_lock`, left at P5.3) and its
46// remaining diagnostic-emitting sites — the `bynk.secrets.computed_name`
47// warning and the `bynk.project.schema_registry_corrupt` construction, both
48// outside the seven-category accounting — relocated too (§3.2's "eighth
49// site" and §9's open risk respectively); `validate.rs` and its module
50// declaration are deleted, this track's own completion criterion (§5).
51// Pipeline-driving types (`diagnostics`'s `Mode`/`ErrorSink`/
52// `ProjectAnalysis`/`ProjectFailure`) stay here too.
53mod agent_deps;
54mod diagnostics;
55mod entry;
56#[cfg(test)]
57mod entry_scope_tests;
58mod in_memory;
59mod options;
60mod output;
61mod pipeline;
62mod remote_tests;
63mod schema_registry;
64#[cfg(test)]
65mod tests;
66mod unit;
67mod worker_bindings;
68
69pub use agent_deps::AgentDepsPlan;
70pub use bynk_emit::emit_model::{
71 Artefacts, DiscoveredCase, DiscoveredSuite, Document, ImportExt, ProjectOutput, RemoteSkip,
72 RemoteTests, TestLocation, WORKER_ASSETS_DIR, is_worker_asset_path, is_worker_migration_path,
73 node_wasm_shim, sibling_path, wasm_shim_path, worker_assets_dir,
74};
75pub use entry::{D1SqlRef, EmailForward, ProjectCheck, check_project, compile_project};
76pub use in_memory::{
77 InMemoryAnalysis, InMemoryProjectAnalysis, analyse_in_memory, analyse_in_memory_project,
78 analyse_in_memory_with_types, compile_files_in_memory, compile_files_in_memory_locked,
79 compile_files_in_memory_remote, compile_in_memory, slash_key,
80};
81pub use options::{CompileOptions, ProgressEvent, ProgressSink};
82
83// External facade: items referenced as `crate::project::X` from outside this
84// module (emitter, main, lib) must stay reachable at that path.
85pub use bynk_check::project_model::BuildTarget;
86pub use bynk_check::schema_registry::{AgentVersions, MigrationStep};
87pub use bynk_check::symbols::{FileDeclIndex, UnitTable};
88// 1B.2a (#4028): the suffix is defined beside the test-harness generation that reads it.
89pub use bynk_emit::testgen::SMOKE_SUITE_SUFFIX;
90// #1883, slice 1b: the `assets/` folder helpers, for the driver and testkit.
91pub use bynk_project::assets;
92pub use bynk_project::{
93 AttributedError, LabelFile, ProjectPaths, ProjectPathsError, Roots, SchemaLock, TestTarget,
94 UnitKind, WorkersConfig, Workspace, check_manifest, check_manifest_str, dependency_trees,
95 discover_project_files, is_workspace_root, load_workspace, try_read_mutate_exclude,
96 try_read_project_paths, try_read_project_paths_with, try_read_test_targets,
97 try_read_workers_config, try_read_workers_config_with, worker_dir_name,
98 worker_handlers_output_path, worker_handlers_source_path,
99};
100pub use diagnostics::{ContextBoundaryInfo, ContextSequenceInfo, ProjectAnalysis, ProjectFailure};