Expand description
Re-export of analysis utilities from the compile crate.
Useful for tooling that needs to analyze LOGOS source without performing a full build. Compile-time analysis passes for the LOGOS compilation pipeline.
This module provides static analysis that runs after parsing but before code generation. These passes detect errors that would otherwise manifest as confusing Rust borrow checker errors.
§Analysis Passes
| Pass | Module | Description |
|---|---|---|
| Escape | escape | Detects zone-local values escaping their scope |
| Ownership | ownership | Linear type enforcement (use-after-move) |
| Discovery | discover_with_imports | Multi-file type discovery |
§Pass Ordering
Parser Output (AST)
│
▼
┌──────────────┐
│ Escape Check │ ← Catches zone violations (fast, simple)
└──────────────┘
│
▼
┌─────────────────┐
│ Ownership Check │ ← Catches use-after-move (control-flow aware)
└─────────────────┘
│
▼
Code Generation§Re-exports
This module re-exports types from logicaffeine_language::analysis for
convenience, including:
TypeRegistry,TypeDef,FieldDef- Type definitionsPolicyRegistry,PredicateDef,CapabilityDef- Security policiesDiscoveryPass- Token-level type discovery
Modules§
- assemble
- Source-level assembly of a multi-file / multi-directory LOGOS project.
- callgraph
- check
- Bidirectional type checker for the LOGOS compilation pipeline.
- defined_
real - Which functions may define a real number:
the real number whose digits in base 3 are f,the real number approximated by f. - dependencies
- dimension_
check - Dimension-aware static analysis — rejects dimension-incoherent quantity arithmetic at COMPILE
time, before any code is generated.
2 meters + 1 gramis a type error, not a runtime panic: a length and a mass have no common dimension, so adding them cannot mean anything. - escape
- Escape analysis for zone safety.
- import_
hygiene - Import-hygiene lints — the pit-of-success guardrails that keep a project’s import blocks honest. An UNRESOLVABLE import is already a hard error at assembly (with a “did you mean” suggestion from the loader); this pass finds the problems that ASSEMBLE FINE but are still mistakes: an import that is never used, the same module imported twice, and a module importing itself.
- known_
calls - Definition-time resolution of CALLED NAMES — a call to a name that exists NOWHERE in the program is a check error, not a native-build E0425 or a runtime surprise.
- liveness
- ownership
- Native ownership analysis for use-after-move detection.
- pipes
- Which function parameters carry a pipe.
- policy
- readonly
- registry
- relay
- Whether a program’s pages talk to the relay — and so whether the backend serving them answers
/_relayitself. - tower
- Which values of a program the exact extension reaches: the bindings, function results and parameters that can hold an infinitesimal, a hyperreal, an infinite integer, an algebraic number, a computable real, an ordinal, a residue-dependent value or a provisional answer.
- types
- Type inference pass for the LOGOS compilation pipeline.
- unify
- Unification engine for the bidirectional type checker.
Structs§
- Assembled
Program - One assembled compilation unit: the combined source plus the metadata later passes need for qualified-name resolution, collision diagnostics, and cross-file error attribution.
- Call
Instance - One call of a generic function, as the checker solved it.
- Capability
Def - A capability definition:
A User can publish the Document if... - DefSite
- A single definition site: which module (canonical path) declared a bare name, and the normalized content of the definition (its identity — two defs with the same normalized body are THE SAME definition).
- Dependency
- A dependency declaration found in the document’s abstract.
- Dimension
Checker - Dimension
Error - A dimension coherence error.
trailnames the statements it propagated out through, innermost first — the statement that holds the incoherent arithmetic, then each block statement around it — so a diagnostic can point at the sentence at fault. - Discovery
Pass - Discovery pass that scans tokens before main parsing to build a TypeRegistry.
- Discovery
Result - Result of running the discovery pass
- Escape
Checker - Escape
Error - Error type for escape violations
- Field
Def - Field definition within a struct
- FnSig
- Function signature for tracked functions.
- Import
Lint - One import-hygiene finding.
- Indexed
Type Error - One typechecker finding with the top-level statement it belongs to.
- Instantiations
- What the checker solved at every generic site of a program — the input to monomorphization.
- Located
- A combined-source offset resolved back to its origin.
- Located
Type Error - A type error and the top-level function it was found in —
Nonefor a## Mainstatement. A checked program has no source spans left (lowering writes functions of its own), so the function is the location a report can give. - Ownership
Checker - Ownership checker - tracks variable states through control flow
- Ownership
Error - Error type for ownership violations
- Ownership
Finding - One ownership finding with its statement coordinates: the top-level
statement that ERRED, and (when known) the one that CAUSED it by moving
the variable — both map 1:1 onto
Parser::stmt_spans()— plus the exact statements, nested ones included, forParser::nested_stmt_spans():trailis the erring statement and each one around it, innermost first, andcauseis the statement that gave the value away. - Policy
Registry - Registry for security policies defined in
## Policyblocks. - Predicate
Def - A predicate definition:
A User is admin if the user's role equals "admin". - Provenance
- Bare-name → the modules that define it. A bare name owned by more than one distinct module is ambiguous: a bare reference to it is a hard error, and the qualified form disambiguates.
- Rust
Names - Centralized name resolution for Rust identifier output.
- Scope
Info - Per-file lexical scope for the whole project: what each file is allowed to reference. A file sees its own definitions and the exports of the modules it directly imports — never anything reached only transitively.
- Segment
- One contributed segment of the combined source: its
[start, end)byte range in the combined string, the ORIGINAL file it came from, and — for a byte-intact segment — the offset in that file itsstartcorresponds to. - Source
Map - File-level attribution: for each contributed segment of the combined source, its byte range, originating file, and (for byte-intact segments) the offset-within-file mapping — so a diagnostic on the combined blob is attributed to the user’s own file and line.
- TypeEnv
- Type environment built by a forward pass over the AST.
- Type
Registry - Variant
Def - Phase 33: Variant definition for sum types
Enums§
- DefKind
- The kind of a top-level definition, for collision messages.
- Escape
Error Kind - Field
Type - Type reference for struct fields (avoids circular deps with ast::TypeExpr)
- Import
Lint Kind - What kind of import-hygiene problem was found.
- Lint
Severity - The severity of an import lint. Warnings never block a build; errors do.
- Logos
Type - Structured type representation for LOGOS values.
- Maybe
Given In - Where a value may have been given away: the construct whose paths disagree about it.
- Ownership
Error Kind - Policy
Condition - Condition in a policy definition. Represents the predicate logic for security rules.
- Site
- A node of the checked program, by address. The checker and a later pass over the SAME statements agree on it without the AST carrying ids.
- TypeDef
- VarState
- Ownership state for a variable
Functions§
- assemble_
project - Assemble the whole project reachable from
entry_pathinto one compilation unit. Returns an error only for unreadable/unresolvable imports; the combined source is then parsed by the normal pipeline. - assemble_
project_ with_ deps assemble_project, additionally linking the declared dependency roots so a bareImport <Dep>.resolves against apath/git-local package outside the project root.dep_rootsempty is byte-for-byte identical toassemble_project, so a single-project build is unchanged.- check_
program - Check a LOGOS program and return a typed
TypeEnvfor codegen. - check_
program_ collect - Collect EVERY failing top-level statement instead of bailing at the first.
- check_
program_ located check_program, reporting which top-level function a failure is in.- check_
scopes - Enforce per-file scoping over the assembled program: a reference to a name that is another user module’s export, from a file that neither defines nor imports it, is a hard error (no transitive leakage). Builtins, stdlib, and a file’s own/imported names are always fine, so a valid program never trips.
- check_
unknown_ calls - Reject the first call (in source order) to a name that exists nowhere in the post-prelude program. See the module docs for the KNOWN-name rule.
- check_
unknown_ calls_ with_ exports check_unknown_callsfor the mixed-document seam:exportsis the callable surface of a bundled proven module (seeproven_module_exports), whose names the imperative half calls by design (use proven::*;).- discover_
with_ imports - Recursive discovery with module imports.
- first_
section_ header - A file’s first
##section header outside a ``` fence, as its 1-based line and its text: the line above which anImportmust stand to import anything. - infer_
instantiations - Check
stmtsas far as each statement goes — a failing statement does not stop the rest — and answer what every generic site was solved at. The input to monomorphization; a backend with no generics of its own reads which instance each call and construction needs from here. - lint_
imports - Lint the entry file’s imports for unused / duplicate / self-import problems.
Unresolvable imports are NOT reported here — the assembler already rejects
those with a suggestion. Returns
Erronly if the entry can’t be read. - lint_
imports_ with_ deps lint_imports, resolving imports with the declared dependency roots so apath/git-local import is lint-checked too.dep_rootsempty is identical tolint_imports.- misplaced_
imports - Every
Importsentence below a file’s first##header, each with its byte span. That is wherescan_dependenciesdoes not read, so such a sentence imports nothing: the module is never spliced and the program runs on without it. A caller refuses each at its own line. A line inside a - proven_
module_ exports - The callable surface of a bundled proven module: every
pub fnname. The Forge emits proven functions,check_*predicates, and non-nullary enum constructors all aspub fns (a nullary constructor is apub const, which is an identifier reference, not a call — outside this pass’s domain). - refuse_
retired_ calls - The first call, in source order, to a builtin the language no longer has
(
crate::semantics::builtins::retired_builtin), refused in that builtin’s own sentence. A name the program defines or binds is its own and is called. Every tier’s front end runs this before the program runs, so each refuses the call in the same words, whether or not the call is ever reached. - root_
binding_ types - The type of every binding the program’s ROOT declares, as the checker settled it once the whole
program was read. Exact where
TypeEnvis not: its variables are one flat map, so a function’s ownxand the program’sxshare an entry there. - scan_
dependencies - Scans the first paragraph (Abstract) of a LOGOS file for
[Alias](URI)links.