Skip to main content

Crate brink_db

Crate brink_db 

Source
Expand description

Incremental project database for inkle’s ink narrative scripting language.

ProjectDb is the query-shaped project model (scripting-substrate spec §3): file texts are salsa inputs, and every pipeline stage — parse, HIR, include graph, symbol index, resolution, signatures, analysis, LIR, StoryData — is a memoized tracked query with dependency tracking and early cutoff. This crate is the only one that knows salsa exists; stage crates (brink-syntax, brink-ir, brink-analyzer, brink-codegen-inkb) export plain functions the queries call. The compiler (one-shot), LSP, and IDE all use ProjectDb as their project model.

Structs§

BodyTypes
The full inferred picture of one def’s body: params, every local (params ∪ temps) by name, and the return type. A superset of InferredSigsignatures is the firewall-facing projection, bodies is what a hover/diagnostic consumer (TM-5) wants.
CompileProduct
Outcome of the full pipeline: compiled StoryData or the diagnostics that prevented it. Batch compile = pull this one query (spec §5).
EffectAtoms
The raw per-definition atoms harvested from one body walk — the inputs the solve_scc_effects fixpoint closes over. reads/writes/calls are the direct atoms this body emits; direct_calls are the inferable (knot/stitch) callees whose rows must be joined in transitively; creates_fn_values are the targets this body creates fn values for (Fork A, issue #1726 — structural, fed into the call graph alongside direct_calls); opaque records that the body performed a call through a function value whose reaching values were not all created in-project (or another effects-opaque construct), forcing the pessimal floor.
EffectRow
A static summary of the atomic effects a definition (and everything it transitively calls) may perform — the spec §2 “row”. Unordered sets over a finite per-project lattice, so join is a monotone least-upper-bound and the per-SCC fixpoint terminates without widening.
FileDiagnostics
Per-file inputs to partition_diagnostics.
FileId
Opaque identifier for a source file within a multi-file project.
InMemory
Map-backed SourceTree: the test and web seam.
InferenceResult
The whole-project inference result (mirrors AnalysisResult’s shape: one pure function over already-computed inputs, callable directly or wrapped as a salsa query).
InferredSig
A def’s inferred signature: positional param types (declaration order) plus a return type. The generalized, per-def result of a body’s fixpoint solve — what a caller reads (never the caller reading the callee’s body directly; that’s the firewall).
LirProduct
Outcome of the pipeline through LIR lowering, mirroring brink-compiler’s compile_lir stage sequence exactly.
ProjectDb
Stateful incremental project database.
ResolvedProject
Index + resolutions, aggregated across every file’s [resolve_query] (issue #632 / FG-3) — deliberately without diagnostics, so this struct’s PartialEq never touches a diagnostic’s range. Neither [symbol_index_query] nor any file’s [resolve_query] reads project.analysis_options, so an AnalysisOptions edit that only changes diagnostics (e.g. raising semantic_type_check to Error) never even triggers salsa to re-run this query’s closure — not just a backdate, a full skip (pinned by fg3_dependency_edges.rs).
Sig
Per-declaration signature summary (phase-0 stub).

Enums§

Ty
A type in the checker’s universe (typed-mode-spec §2).

Traits§

SourceTree
A source of .brink files: enumerate what exists under a root (held by the implementation since construction — see the module docs), and read any key, whether or not enumeration returned it.

Functions§

compute_relative_path
Compute the relative INCLUDE target to reach to_file from from_file’s directory — the inverse of resolve_include_path: normalize(resolve_include_path(from_file, compute_relative_path(from_file, to_file))) == to_file for both forward and ..-traversing layouts. Used when a file is renamed/moved to rewrite every INCLUDE that points at it (and the moved file’s own includes).
has_recognized_source_extension
Whether path names a file with a recognized ink (.ink) or native (.brink) source extension, compared case-insensitively — used by [project_is_all_native]’s nativity vote, and now (issue #2368) also the shared, public seam brink-lsp’s own file-watcher/workspace-scan classification (is_source_path in crates/brink-lsp/src/backend.rs) routes through, rather than carrying its own ad-hoc, case-sensitive ext == "ink" || ext == "brink" copy — the same “shared seam, not N copies” fix #2329/PR #2357 applied inside this crate’s own query surfaces.
is_native_source_path
Whether path names a native (.brink) source file, compared case-insensitively — [file_language] narrowed to a boolean, and public for the same reason has_recognized_source_extension is (issue #2368): brink-lsp carried two of its own ad-hoc, case-sensitive ext == "brink" copies (crates/brink-lsp/src/backend.rs’s is_native_path and crates/brink-lsp/src/backend/projects.rs’s function of the same name) for a classification this crate already performs correctly — a real .BRINK file on a case-insensitive filesystem must classify identically to .brink, not silently fall through to “not native” the way ext == "brink" alone would.
partition_diagnostics
Collect all diagnostics (lowering + analysis), apply suppressions, and partition into (errors, warnings).
resolve_include_path
Resolve an INCLUDE path relative to the including file’s directory.