Skip to main content

Module analysis

Module analysis 

Source
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

PassModuleDescription
EscapeescapeDetects zone-local values escaping their scope
OwnershipownershipLinear type enforcement (use-after-move)
Discoverydiscover_with_importsMulti-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:

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 gram is 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 /_relay itself.
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§

AssembledProgram
One assembled compilation unit: the combined source plus the metadata later passes need for qualified-name resolution, collision diagnostics, and cross-file error attribution.
CallInstance
One call of a generic function, as the checker solved it.
CapabilityDef
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.
DimensionChecker
DimensionError
A dimension coherence error. trail names 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.
DiscoveryPass
Discovery pass that scans tokens before main parsing to build a TypeRegistry.
DiscoveryResult
Result of running the discovery pass
EscapeChecker
EscapeError
Error type for escape violations
FieldDef
Field definition within a struct
FnSig
Function signature for tracked functions.
ImportLint
One import-hygiene finding.
IndexedTypeError
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.
LocatedTypeError
A type error and the top-level function it was found in — None for a ## Main statement. A checked program has no source spans left (lowering writes functions of its own), so the function is the location a report can give.
OwnershipChecker
Ownership checker - tracks variable states through control flow
OwnershipError
Error type for ownership violations
OwnershipFinding
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, for Parser::nested_stmt_spans(): trail is the erring statement and each one around it, innermost first, and cause is the statement that gave the value away.
PolicyRegistry
Registry for security policies defined in ## Policy blocks.
PredicateDef
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.
RustNames
Centralized name resolution for Rust identifier output.
ScopeInfo
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 its start corresponds to.
SourceMap
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.
TypeRegistry
VariantDef
Phase 33: Variant definition for sum types

Enums§

DefKind
The kind of a top-level definition, for collision messages.
EscapeErrorKind
FieldType
Type reference for struct fields (avoids circular deps with ast::TypeExpr)
ImportLintKind
What kind of import-hygiene problem was found.
LintSeverity
The severity of an import lint. Warnings never block a build; errors do.
LogosType
Structured type representation for LOGOS values.
MaybeGivenIn
Where a value may have been given away: the construct whose paths disagree about it.
OwnershipErrorKind
PolicyCondition
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_path into 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 bare Import <Dep>. resolves against a path/git-local package outside the project root. dep_roots empty is byte-for-byte identical to assemble_project, so a single-project build is unchanged.
check_program
Check a LOGOS program and return a typed TypeEnv for 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_calls for the mixed-document seam: exports is the callable surface of a bundled proven module (see proven_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 an Import must stand to import anything.
infer_instantiations
Check stmts as 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 Err only if the entry can’t be read.
lint_imports_with_deps
lint_imports, resolving imports with the declared dependency roots so a path/git-local import is lint-checked too. dep_roots empty is identical to lint_imports.
misplaced_imports
Every Import sentence below a file’s first ## header, each with its byte span. That is where scan_dependencies does 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 fn name. The Forge emits proven functions, check_* predicates, and non-nullary enum constructors all as pub fns (a nullary constructor is a pub 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 TypeEnv is not: its variables are one flat map, so a function’s own x and the program’s x share an entry there.
scan_dependencies
Scans the first paragraph (Abstract) of a LOGOS file for [Alias](URI) links.