Skip to main content

Module shape

Module shape 

Source
Expand description

Per-fn shape recognition — typed facts over resolved HIR.

Stage 1 of issue #232 (0.23 “Shape”). This module is the recognition-only layer: walks ResolvedFnDef bodies, builds Facts per fn, emits multi-label archetype classifications, computes call-graph SCCs. No ModuleShape vector / Kind / Layer / renderer here — those live one tier up in aver::diagnostics::shape (presentation) or aver::codegen::proof_lower (meaning), and the future Stage 6 patterns / relations (WrapperOverRecursion, ResultPipeline, …) land here next to the primitives they’re built from.

Structs§

Facts
FnRecognition
Per-fn recognition output: precedence-picked primary archetype + the full multi-label set the classifier fired on.
ProgramShape
Whole-program shape facts produced by analyze_program.

Enums§

Archetype
Per-fn archetype label. Multi-label per fn — classify returns a Vec<Archetype>; primary_label picks one by the precedence declared in Archetype::all. Stringified only at presentation boundaries (renderer, JSON, LSP hover).
ModulePattern
A ModulePattern is a recognized structural fact about a whole module’s surface — the level above per-fn archetypes — carrying the typed payload downstream consumers need to act on it.

Functions§

analyze_program
Build a ProgramShape over the post-resolver fn snapshot in one pass. Caller picks which fns participate (typically every ResolvedTopLevel::FnDef of the entry module, sometimes plus dep-module fns when a cross-module analysis needs the broader view).
analyze_program_with_modules
Same as analyze_program but also detects module-level patterns (ModulePattern::RefinementSmartConstructor, …) by walking the source items and dep modules. Callers that have both the resolved-fn snapshot and the source items should prefer this.
classify
collect_inductable_sum_types
Walk entry items + dep modules and collect the names of sum types that pass the proof-export induction eligibility check: directly self-referential in at least one variant, and not indirectly recursive through nested generics that the per-variant emit would have to give up on. Mirrors the inline scan that proof_lower::detect_induction_target used to perform so the detector can read from ProgramShape.inductable_sum_types and avoid re-walking the AST.
compute_sccs
detect_module_patterns
Walk entry items + dep modules and emit every typed ModulePattern we can recognize. Used by analyze_program_with_modules to populate ProgramShape.patterns.
extract_facts
primary_label
type_is_result