Section 02: Import-Sigs Traversal — Cross-Module Imported Generic Top-Level Mono (BUG-04-119)
Status: In Progress (§02.N close-out pending — /tpr-review + /impl-hygiene-review items unchecked per frontmatter; plan_corpus check + BUG-04-119 tracker annotated + plan annotations swept flipped [x] 2026-05-16; test-all.sh gated by parallel-session baseline-red)
Goal: Close the cross-module gap. ori build’s mono-collection pipeline registers imported generic top-level functions reachable from host-module callers, so LLVM module verification succeeds before realize.
Success Criteria: see frontmatter — all items contribute to mission criterion 1 (top-level imported generics).
Context: Per §01.4 BUG-04-119 entry (also documented in §01.1 F2), compile_common.rs:217-246 constructs import_sigs for imported functions (line 217) and consumes them via collect_mono_functions (line 246). The function’s three-input lookup chain (function_sigs, impl_sigs, none) silently skips instances whose fn_name is from another module, yielding E5001 unresolved function 'assert_eq' in apply/invoke — missing mono instance at LLVM verification. This is the architectural skeleton — §03/§04/§05 reuse the lookup-chain extension pattern this section establishes.
Scope boundary (per Decision 02): §02 owns TOP-LEVEL imported generic functions only. Imported generic METHODS are routed to §03 (section-03-inherent-method-mono.md) which owns the inherent-method-on-generic-type dispatch surface and gains AOT export-surface work for multi.rs::public_methods.
Linkage mechanism (per Decision 01): Imported mono instances use the body-import path (Option B) — compile_common.rs constructs imported_mono_fns: Vec<ImportedMonoFn> from per-module CanonResult retention; arc_lowering specializes each imported mono locally against the SOURCE module’s CanonResult via lower_to_arc(mono_fn.mangled_name, &mono_fn.sig, mono_fn.original_name, source_canon, ...). The host module emits the body via the existing declare_mono_functions path. No declare_imported_mono function is created.
Reference implementations (graph-first per intelligence.md):
- Rust
rustc_monomorphize::collectorenumerates imported items viatcx.upstream_monomorphizations— same shape: imported sig table consulted alongside local sigs. Verify withscripts/intel-query.sh similar "collect_mono_functions" --repo rust --limit 5. - Swift SILGen treats imported generic specializations as first-class call-site targets, registered uniformly with local generics.
Depends on: §01 (cite-back: §01.1 API surface inventory + §01.4 BUG-04-119 classification).
Cross-cutting concern (per blind-spots): JIT/AOT path duplication is RESOLVED by §02 — both paths use the body-import carrier shape. JIT’s imported_mono_fns (oric/src/test/runner/imported_mono.rs:22) carrier is promoted to AOT production scope at compile_common.rs per Decision 01 Option B. Single mechanism, not parallel.
Intelligence Reconnaissance
Queries planned (run AT section-open-for-work per compose-intel-summary.md):
scripts/intel-query.sh callers "collect_mono_functions" --repo ori— confirmevaluator/compile.rs:230,codegen_pipeline/mod.rs:138,arc_lowering.rs:272remain the three call sites (re-verify post-§01).scripts/intel-query.sh callers "run_borrow_inference" --repo ori— confirmcodegen_pipeline/mod.rs:319remains the sole production call site; identify any test-only consumers.scripts/intel-query.sh callers "lower_and_infer_borrows" --repo ori— full call-site set for the test runner.scripts/intel-query.sh file-symbols "compiler/oric/src/commands/compile_common" --repo ori— inventoryimport_sigsconstruction surface AND identify per-module CanonResult retention points.scripts/intel-query.sh file-symbols "compiler/oric/src/test/runner/imported_mono" --repo ori— inventoryImportedMonoFncarrier +build_imported_mono_functionsfor AOT promotion.scripts/intel-query.sh similar "collect_used_items" --repo rust --limit 3— Rust’s imported-mono enumeration prior art.
Results summary (≤500 chars, recorded 2026-05-15; line refs refreshed 2026-05-16 to current HEAD) [ori]: callers of collect_mono_functions confirmed at evaluator/compile.rs:230, codegen_pipeline/mod.rs:143, arc_lowering.rs:272 — three production sites; run_borrow_inference sole production caller is run_codegen_pipeline at codegen_pipeline/mod.rs:372; import_sigs construction surface confirmed at compile_common.rs:206-223 (single-module entry; multi-module retention via CompiledModuleInfo at multi.rs:201-219 + consumer at multi.rs::build_imported_mono_state at multi.rs:722); ImportedMonoFn carrier at imported_mono.rs:22, build_imported_mono_functions at codegen_pipeline/imported_mono.rs.
02.1 collect_mono_functions signature + traversal extension
File: compiler_repo/compiler/ori_llvm/src/monomorphize/mod.rs:71
- Add
import_sigs: &[(Name, FunctionSig)]as a new parameter tocollect_mono_functions. Position: afterimpl_sigs, beforeinterner(parameter order matches existing convention atmod.rs:71). - Build a third lookup map alongside
fn_sig_by_nameandimpl_sig_by_name(current construction nearmod.rs:75):let import_sig_by_name: FxHashMap<Name, &FunctionSig> = import_sigs.iter().map(|(n, s)| (*n, s)).collect(); - Extend the lookup chain in the loop body (currently
mod.rs:88-92): wheninstance.receiver_type.is_none()ANDfunction_sigs.get(&instance.fn_name).is_none(), tryimport_sig_by_name.get(&instance.fn_name)BEFORE falling through to the silent-skip branch (thetracing::debug!log — preserve as-is to support MONO-REG invariant verification). - DO NOT extend the
instance.receiver_type.is_some()path to consultimport_sig_by_name— methods are owned by §03 per Decision 02 (decisions/02-imported-method-scope-routing.md). Receiver-bearing instances continue to use onlyimpl_sig_by_name; §03 will extend that lookup chain in its own commit when it addsmulti.rs::public_methodsexport surface. - Mark imported-mono
MonoFunctionrecords via a newMonoFunction.is_imported: boolfield set totruefor instances resolved viaimport_sig_by_name. Codegen consumers (declare_mono_functionsatdefine_phase.rs:30) MAY observe this flag for diagnostics; the body-import path (Decision 01 Option B) does NOT branch on it — both local and imported mono functions flow through identicaldeclare_mono_functions+prepare_mono_cachedplumbing. - DELETE the §02.1 line 81 instruction referencing
declare_imported_mono(ghost function — does not exist in codebase). Decision 01 selects body-import via the existingdeclare_mono_functionspath. (Already removed during Step-5 editor pass; ghost reference absent from current §02.1 body.) - Update
compiler_repo/compiler/ori_llvm/src/monomorphize/tests.rsunit tests to constructimport_sigsfixtures; cover the new lookup path (positive: instance resolves via import_sigs after function_sigs+impl_sigs miss; negative: instance withreceiver_type.is_some()does NOT consult import_sigs even when name matches). - Subsection close-out (02.1) — MANDATORY before starting §02.2:
- All tasks above
[x];cargo build --release -p ori_llvmsucceeds. -
cargo test --release -p ori_llvm --test aot genericsreports same pass count as pre-§02.1 baseline (no regression — host-module mono path unchanged). - Run
compiler_repo/diagnostics/repo-hygiene.sh --check. - Stabilization-discipline note (per blind-spots architectural risk): Workspace
cargo checkwill be RED at end of §02.1 becauseoricconsumers haven’t been updated yet —collect_mono_functionssignature change breaks the three callers (evaluator/compile.rs:230,codegen_pipeline/mod.rs:138,arc_lowering.rs:272). This is the canonical multi-commit-sequencing case perimpl-hygiene.md §Stabilization Disciplinerule “Multi-commit sequences ordered by dependency, not chronology”. §02.2 MUST land in the same plan execution session immediately after §02.1; commit boundary between §02.1 and §02.2 is acceptable per multi-commit dependency-order rule. No--no-verifybypass; no dev-loop break.
- All tasks above
02.2 Driver wiring — compile_common + codegen_pipeline + arc_lowering test runner + JIT path
Files:
-
compiler_repo/compiler/oric/src/commands/compile_common.rs:217-246(import_sigs construction at :217; consumed viacollect_mono_functionsat :246) -
compiler_repo/compiler/oric/src/commands/codegen_pipeline/mod.rs:79(run_borrow_inferencesignature) +:143(collect_mono_functions call) +:372(run_borrow_inference call from caller) -
compiler_repo/compiler/oric/src/test/runner/arc_lowering.rs:39(lower_and_infer_borrowssignature) +:272(collect_mono_functions call) -
compiler_repo/compiler/ori_llvm/src/evaluator/compile.rs:230(JIT collect_mono_functions call) -
run_borrow_inferencesignature extension (codegen_pipeline/mod.rs:79): addimport_sigs: &[(Name, FunctionSig)]parameter (position afterimpl_sigs, beforecanon). Forward to internalcollect_mono_functionscall atmod.rs:143. -
run_borrow_inferencecaller update (codegen_pipeline/mod.rs:372): passimport_sigsfrom the enclosingrun_codegen_pipelineorchestrator (codegen_pipeline/mod.rs:314). Theimport_sigs: &[(Name, FunctionSig)]parameter is already present onrun_codegen_pipeline(verified atmod.rs:314); thread it through to therun_borrow_inferencecall. -
compile_common.rsdriver wiring (compile_common.rs:206-223): the existingimport_sigs: Vec<(Name, FunctionSig)>construction at line 206 already exists per BUG-04-119 evidence. The call torun_codegen_pipelineatcompile_common.rs:235ALREADY passes&import_sigs(verified). No edit tocompile_common.rsrequired — wiring is in place; downstream propagation throughrun_codegen_pipeline → run_borrow_inference → collect_mono_functionsis the work scope. -
lower_and_infer_borrowstest-runner sync (arc_lowering.rs:39): addimport_sigs: &[(Name, FunctionSig)]parameter symmetric to production. Forward to internalcollect_mono_functionscall atarc_lowering.rs:272. Update every caller incompiler_repo/compiler/oric/src/test/runner/to pass&[]if no imported sigs are in test scope, OR construct test fixtures with imported sigs for the new matrix tests at §02.4. -
JIT path passthrough (
evaluator/compile.rs:230): pass&[]forimport_sigs. JIT compiles only the host module; cross-module imports are AOT-only by design. Document with a public-safe// JIT: single-module scope; cross-module imports are an AOT concern.line at the call site (NO bug IDs, NO wrapper plan paths in compiler source perimpl-hygiene.md §STRUCTURE:public-leak). -
Verification:
cargo build --releaseandcargo buildboth succeed (workspacecargo checkreturns to GREEN at end of §02.2). -
Subsection close-out (02.2) — MANDATORY before starting §02.3:
-
cargo build --release && cargo buildboth succeed; workspace clean. -
cargo test --release -p ori_llvm --test aot genericsreports same pass count as pre-§02 baseline (modulo the still-failingtest_poly_lambda_with_imported_assert_eq_*tests — those green at §02.4). - Run
compiler_repo/diagnostics/repo-hygiene.sh --check.
-
02.3 Per-module CanonResult retention + imported_mono_fns construction (Decision 01 Option B AOT promotion)
Files:
compiler_repo/compiler/oric/src/commands/build/multi.rs:201-219— per-module CanonResult retention viaCompiledModuleInfo(type_result+canon_result+poolfields under#[allow(dead_code)]guards).compiler_repo/compiler/oric/src/commands/build/multi.rs:722—compile_single_moduleinvokesbuild_imported_mono_state, which constructsImportedMonoState { canons, imported_mono_fns }against the merged pool.compiler_repo/compiler/oric/src/commands/compile_common.rs:134—compile_to_llvm_with_imported_monos(single-module entry); threadsimported_mono_fns+re_interned_canonsthrough torun_codegen_pipeline.compiler_repo/compiler/oric/src/commands/compile_common.rs:194—compile_to_llvm_with_imports(multi-module entry); same threading.compiler_repo/compiler/oric/src/commands/mod.rs:25— re-export sitepub(crate) use codegen_pipeline::imported_mono::ImportedMonoFn;bridging the privatemod codegen_pipeline;boundary.compiler_repo/compiler/oric/src/commands/codegen_pipeline/imported_mono.rs— productionbuild_imported_mono_functionsAOT entry point.compiler_repo/compiler/oric/src/test/runner/imported_mono.rs— thin wrapper forwarding to the production builder (post-promotion).
This subsection promotes the JIT carrier shape (oric/src/test/runner/imported_mono.rs::build_imported_mono_functions) into AOT production scope per Decision 01 Option B. Without this work, §02.1 + §02.2 wire the sig-table but arc_lowering.rs cannot specialize the imported generic body — it has no source CanonResult to feed lower_to_arc.
- Promote
ImportedMonoFncarrier type to a shared production location: moved thepub(crate) type ImportedMonoFn = (ori_llvm::monomorphize::MonoFunction, usize, ori_ir::Name);definition intocompiler_repo/compiler/oric/src/commands/codegen_pipeline/imported_mono.rs(NEW file) as apub(crate)item. Re-export wired atcommands/mod.rs:29-31aspub(crate) use codegen_pipeline::imported_mono::{build_imported_mono_functions as build_imported_mono_functions_for_test_runner, ImportedMonoFn};(narrow approach —mod codegen_pipeline;stays private; re-export bridges the boundary). Test-runner site atoric/src/test/runner/imported_mono.rsnow consumes the production type viapub(super) use crate::commands::ImportedMonoFn;re-export. - Promote
build_imported_mono_functionsto AOT-callable in the newcodegen_pipeline/imported_mono.rs. JIT signature mirrored verbatim peroric/src/test/runner/imported_mono.rs:28-39. Implementation copies the JIT body (no behavioral divergence) and shares thebuild_body_type_map+build_concrete_sighelpers. Test-runner version is now a thin wrapper that forwards tocrate::commands::build_imported_mono_functions_for_test_runnerperimpl-hygiene.md §Algorithmic DRY(eliminates the second copy). -
multi.rs::CompiledModuleInfoper-module CanonResult retention: extendedCompiledModuleInfo(compiler_repo/compiler/oric/src/commands/build/multi.rs:201-237) with three new fields —type_result: TypeCheckResult,canon_result: SharedCanonResult,pool: Arc<Pool>— guarded with#[allow(dead_code, reason = "consumer arrives at §02.4 merged-pool re-interning")].compile_single_modulepopulates them after the codegen call. The actual merged-pool re-interning consumer arrives at §02.4 matrix-test wiring. -
compile_common.rsimported_mono_fns construction: extendedcompile_to_llvm_with_imports(compile_common.rs:184) withimported_mono_fns: &[ImportedMonoFn]parameter.multi.rs::compile_single_module(multi.rs:309) currently builds an emptyVec<ImportedMonoFn>and threads through; populated construction (callingbuild_imported_mono_functionswithimported_generic_sigsderived from retained per-moduleTypeCheckResultvia merged-pool re-interning) arrives at §02.4 alongside the matrix-test wiring. -
run_borrow_inferencesecond signature extension (codegen_pipeline/mod.rs:79): addedimported_mono_fns: &[crate::commands::ImportedMonoFn]parameter (position afterimport_sigs). Forwarded fromrun_codegen_pipeline(codegen_pipeline/mod.rs:314). Internal threading: arc_lowering specialization loop added at lines:188-210(mirrors the test-runner shape atarc_lowering.rs:108-117). Returnsmono_functionsmerged with imported monos so codegen’sdeclare_mono_functionssees both. -
lower_and_infer_borrowssecond signature extension (arc_lowering.rs:39): NO CHANGE NEEDED — test-runner already accepts this parameter atarc_lowering.rs:50(JIT). Production signature now matches test-runner shape; both consume the sameImportedMonoFncarrier. - arc_lowering body specialization: promoted the test-runner specialization loop body into the production
run_borrow_inferencepath atcodegen_pipeline/mod.rs:188-210. EachImportedMonoFntriple feedslower_to_arc(mono_fn.mangled_name, &mono_fn.sig, *source_body_name, canon, ...)against the host’s CanonResult (current — merged-pool re-interning arrives at §02.4 for full multi-module support). - JIT path passthrough (
evaluator/compile.rs:230): no change needed — JIT already passes&[]forimport_sigsand the new pipeline signature parameter is added incompile_common.rs/run_codegen_pipelineonly. The JIT site usescollect_mono_functionsdirectly with its own pre-builtimported_mono_functionsand bypassesrun_codegen_pipeline. - Verification:
cargo build --release && cargo buildboth succeed; existing JIT tests continue to pass (5 new unit tests cover the production carrier shape + builder behavior). - Subsection close-out (02.3) — MANDATORY before starting §02.4:
- All tasks above
[x]; both build profiles green. -
cargo test --release -p ori_llvm --test aot generics(94 passed, 11 failed, 4 ignored — same pass count as pre-§02 baseline per §02.2 close-out at line 143; 11 failures are pre-existing parallel-session baseline) andcargo test --release -p oric --lib(625 passed, 0 failed — green) both report same pass count as pre-§02 baseline. AIMS snapshot test (aims_snapshots_across_all_passes_match_baselines) is failing due to parallel-session ori_arc/aims-burden-tracking work — unrelated to §02.3 (my changes are no-ops with emptyimported_mono_fnsslice; cannot affectrealize_rc_reusesnapshot). - Verify Decision 01 acceptance gate items (decision file
decisions/01-imported-mono-linkage-mechanism.md); confirm decisionstatus: establishedmatches the implementation (frontmatter already atestablishedsince decision-authoring time). - Run
compiler_repo/diagnostics/repo-hygiene.sh --check— clean.
- All tasks above
02.4 Matrix tests — imported generic top-level functions
File: compiler_repo/compiler/ori_llvm/tests/aot/poly_lambda_mono.rs
Matrix dimensions per tests.md §Matrix Testing Rule:
| Receiver shape | Element type | Test name | Status |
|---|---|---|---|
| top-level fn | int | test_poly_lambda_with_imported_assert_eq_int | currently failing — greens at §02.4 |
| top-level fn | str | test_poly_lambda_with_imported_assert_eq_str | currently failing — greens at §02.4 |
| top-level fn | [int] | test_imported_generic_fn_list_int | new |
| top-level fn | struct | test_imported_generic_fn_struct | new |
Method matrix (Option<int>.unwrap() / Result<int,str>.ok() / [int].first()) is owned by §03 per Decision 02 — not authored here.
- Author the two new tests
test_imported_generic_fn_list_intandtest_imported_generic_fn_structundercompiler_repo/compiler/ori_llvm/tests/aot/poly_lambda_mono.rs. Each test imports a generic top-level function from a sibling test fixture (compiler_repo/compiler/ori_llvm/tests/aot/fixtures/imported_generics/) and exercises mono dispatch in a host-module caller. - Each test pins both Ok behavior (correct result) AND a semantic pin (would fail if §02.1’s
import_sig_by_namelookup branch is reverted — assertion catchesE5001 unresolved function). - Negative pin:
test_unimported_generic_still_fails_cleanly— generic from a module NOT inimport_sigsproduces a clear E5001 (not a silent crash). Asserts the failure mode is diagnostic, not corruption. PASSES — confirms boundary semantics. - Remove
#[ignore]annotations fromtest_poly_lambda_with_imported_assert_eq_int+_str— annotations removed so the tests now run alongside the new matrix tests. - Wire merged-pool re-interning consumer in
multi.rs::compile_single_module:- New
ImportedMonoStatestruct +build_imported_mono_statehelper (multi.rs) — clones host pool, Salsa-queries eachresolved_imports.modules[i]for type-check + canon (covers stdlib AND relative imports uniformly), re-interns each module’s canon arena + generic sigs into the merged pool with shared per-module cache + var_remap, buildsimported_mono_fns: Vec<ImportedMonoFn>via the SSOTbuild_imported_mono_functions_for_test_runnerentry point promoted in §02.3. - Thread
re_interned_canons: &[CanonResult]throughcompile_to_llvm_with_imports→run_codegen_pipeline→run_borrow_inference(compile_common.rs + codegen_pipeline/mod.rs signatures); single-file path passes&[]. -
run_borrow_inference’s imported_mono lowering loop consumesre_interned_canons[*source_module_idx](withunwrap_or(canon)fallback for legacy callers passing&[]) soarc_lowering::lower_to_arcspecializes the generic body against the SOURCE module’s canon in merged-pool coordinates.
- New
- Subsection close-out (02.4):
- All 4 matrix tests + 1 negative pin pass — 5/5 pass at commit
3bb8aa725(cargo test --release -p ori_llvm --test aot poly_lambda_monoreturns5 passed; 0 failed; 0 ignored). Architectural blocker resolved per 2026-05-15 HISTORY entry “§02.4 architectural blocker resolved” below. timeout 150 ./test-all.shgreen — full regression check per CLAUDE.md§Commands. (deferred-with-anchor: §02.N completion checklist line “timeout 150 compiler_repo/test-all.shgreen — full regression check per CLAUDE.md§Commands(success criterion 13)”) — scoped verification at §02.4-commit-time covered §02’s actual scope (cargo test --release -p ori_llvm --test aot poly_lambda_mono5/5;cargo test --release -p ori_llvm --test aot generics94/11/4 matching §02.3 baseline); broad-suite re-run lives at §02 close-out per the §02.N anchor above, gated on parallel-session work (plans/aims-burden-tracking+plans/typeck-inference-completeness) clearing the test baseline they currently own.-
timeout 150 compiler_repo/diagnostics/dual-exec-verify.sh tests/aot/poly_lambda_mono.rs— N/A by design. The §02.4 matrix tests are Rust-harness#[test]functions exercising the AOT path; the JIT path documented inevaluator/compile.rs:230passes&[]forimport_sigsper success-criterion line 14 (cross-module imports are AOT-scope-only; single-module JIT does not see imported generics).dual-exec-verify.shreturns exit-3 zero-verifications by design vs by tooling defect. Verified via inspection 2026-05-15 commit3bb8aa725. - Run
compiler_repo/diagnostics/repo-hygiene.sh --check— clean. - Cross-reference §06 test matrix totals: imported-generic matrix lives in §02.4 (4 positive + 1 negative consolidated here), not §06 (per TPR-02-R5-003 deferral anchor). Verified:
section-06-test-matrix.md:101enumeration credits “§02.4 (4 + 1 negative)” and:79lists§02 ∩ §05cross-facet test consistent with this attribution; no §06 edit required.
- All 4 matrix tests + 1 negative pin pass — 5/5 pass at commit
02.R — Third Party Review Findings
Populated by /tpr-review invocations. Findings land here as - [ ] items with Resolved: lines on closure.
- [TPR-02-R5-001-codex][High] GAP — Imported-signature lookup chain at §02.1 may be incomplete: the
import_sig_by_namekeying uses canonicalNamebut JIT-sideimported_mono_fnsuses local-vs-aliased names; verify §02.1 implementation handles the dual-name case OR explicitly route through canonical mangling. Resolved: §02.1 — both paths useori_ir::Name(interned ID) via sharedStringInterner:monomorphize/mod.rs:94-97keysimport_sig_by_namewith*namefrom the input slice, andcompile_common.rs:209constructsimport_sigs: Vec<(Name, FunctionSig)>using the same interner that produces JIT-sideimported_mono_fns: Vec<(MonoFunction, usize, Name)>atoric/src/test/runner/imported_mono.rs:22. Dual-name divergence ruled out per opencode-r3 code verification + 13/13 unit-test pass. - [TPR-02-R5-002-codex][Medium] DRIFT —
run_borrow_inferencemono-lowering loop placement: codex notes mod.rs:319 caller and mod.rs:138-160 production loop; verify §02.2 placesimported_mono_fnsspecialization INSIDErun_borrow_inference(not at caller) AND mod.rs:319 forwards parameters only. Resolved: §02.2 —collect_mono_functionscall lives insiderun_borrow_inferenceatcodegen_pipeline/mod.rs:143; themod.rs:319caller (run_codegen_pipeline) only forwardsimport_sigsper success_criterion line 11. Line 170 plan-prose updated in /tpr-review round 1 to clarify caller-vs-internal direction. - [TPR-02-R5-003-codex][Medium] DRIFT — §06 test matrix totals may need refresh once §02.4 lands (4 positive + 1 negative consolidated under §02.4 vs distributed across §06). Cross-reference update at §06 implementation. Resolved: §06 cross-reference verified accurate at commit
3bb8aa725—section-06-test-matrix.md:101enumeration credits §02.4 (4 + 1 negative); §06 needed no edit.
Round 5 cap-exit findings (this invocation; filed 2026-05-15, cap_reached_max_rounds)
Filed per /tpr-review §7 cap-exit accept-with-findings; resolution owned by §02.3/§02.4 implementation work. Cap-exit reason recorded in third_party_review.notes.
- [TPR-02-R5-004-codex][High] GAP — §02.3 names
compile_common.rsas the per-module CanonResult retention site, but actual cross-module retention orchestration lives atcompiler_repo/compiler/oric/src/commands/build/multi.rs::CompiledModuleInfo(multi.rs:201-219). multi.rs:262-263 callscheck_sourceper-module and dropscanon_resultlocally; compile_common.rs:184-240 is single-module entry only. Resolved: §02.3 implementation (2026-05-15 HISTORY entry) extendedCompiledModuleInfowithtype_result + canon_result + poolretention fields; multi.rs::compile_single_module loop threads per-module canons throughre_interned_canons: &[CanonResult]parameter oncompile_to_llvm_with_imports→run_codegen_pipeline→run_borrow_inference; imported_mono lowering loop inrun_borrow_inferenceconsumesre_interned_canons[*source_module_idx]soarc_lowering::lower_to_arcspecializes the generic body against the SOURCE module’s canon in merged-pool coordinates. Cured by commits in §02.3 + §02.4 work-arc (terminal commit3bb8aa725). - [TPR-02-R5-005-codex][Medium] GAP — §02.3 plan to move
ImportedMonoFnfromoric/src/test/runner/imported_mono.rs:22tocommands/codegen_pipeline/imported_mono.rsrequires visibility specification:commands/mod.rs:25declaresmod codegen_pipeline;(private). Test runner atcrate::test::runner::imported_monocannot import unless visibility raised. Resolved: §02.3 + §02.4 work-arc promotedImportedMonoFn+build_imported_mono_functionsintocompiler/oric/src/commands/codegen_pipeline/imported_mono.rs(production);compiler/oric/src/commands/build/mod.rscarriespub(crate) use multi::build_imported_mono_state;re-export (the §02.4 cure path widened visibility for single-file + multi-file consumers). Test-runner site atoric/src/test/runner/imported_mono.rsreduced to thin wrapper per §02.3 HISTORY entry. Cured by commit3bb8aa725re-export block. - [TPR-02-R5-006-opencode][High] PLAN_COHERENCE_DRIFT — §02.1/§02.2 sections marked
status: completewhile their owning cap-exit findings (TPR-02-R5-001/002) were- [ ]until this invocation’s cure. Resolved: TPR-02-R5-001/002 flipped[x]above with code-verified Resolved annotations citing monomorphize/mod.rs:94-97 (shared StringInterner) + codegen_pipeline/mod.rs:143 (inside run_borrow_inference). - [TPR-02-R5-007-opencode][Medium] PLAN_COHERENCE_DRIFT — TPR-02-R5-003 deferral lacked concrete anchor per CLAUDE.md
§ALL Deferrals Must Have Implementation Anchors. Resolved: added- [ ]cross-reference anchor under §02.4 close-out checklist; TPR-02-R5-003 Resolved field updated to cite that anchor.
Round 6 cap-exit findings (this invocation; filed 2026-05-16, cap_reached_max_rounds)
Filed per /tpr-review §7 cap-exit accept-with-findings; cap-exit reason recorded in third_party_review.notes. Per-round summary (5 rounds, parallel-session line-ref drift surfacing across rounds):
-
Round 1: 2 verified findings cured inline (stale
mod.rs:59line refs at success_criterion line 11 + 13-site§02.X/TPR-02-R5-005source-comment sweep acrosspoly_lambda_mono.rs/multi.rs/codegen_pipeline/imported_mono/tests.rs/codegen_pipeline/mod.rs). -
Round 2: 4 meta findings cured inline (mod.rs:77/138/319 → :79/143/372 line refs + retired
:stale-plan-annotation→:non-spec-pointercategory + subsection enumeration 02.R addition +reviewer_setfrontmatter field). -
Round 3: 2 findings cured inline + 7 adjacent litter-pickup (codex-Critical
LEAK:scattered-knowledgemethodology vocab strip atcodegen_pipeline/imported_mono.rs:41+ Major plan-ref strip attest/runner/imported_mono.rs:6; litter-pickup swept 7 more refs acrosspoly_lambda_mono.rs:36/compile_common.rs:186/codegen_pipeline/mod.rs:174 + :276/multi.rs:222 + :372 + :417 + :640 + :843). -
Round 4: 2 findings cured inline (mod.rs line refs again —
:143-165→:188-210for imported-mono loop; success_criterion line 12 prose rewrite to attribute imported_mono_fns construction tomulti.rs::build_imported_mono_statevs compile_common.rs). -
Round 5: 3 verified findings filed below + 1 dropped (consistency with round-1 disposition); 2 gemini plan-checkbox-bypass attempts dropped across rounds 2+4.
-
[TPR-02-2026-05-16-001-codex][Minor] PLAN_COHERENCE_DRIFT — §02.3 Files block at section.md:152-153 carries pre-implementation prose that no longer matches HEAD: line 152 “currently drops canon_result at multi.rs:330-336” is stale (canon_result is retained via
CompiledModuleInfoat multi.rs:203-238 with#[allow(dead_code)]guards); line 153 describes compile_common.rs as constructing imported_mono_fns when actual construction lives inmulti.rs::build_imported_mono_state(multi.rs:722) per round-4 cure to success_criterion line 12. Cosmetic prose drift; resolution: refresh §02.3 Files block to match HEAD coordinates + delete obsolete pre-implementation claims. Resolved (Round 1 2026-05-16): §02.3 Files block rewritten at section-02-import-sigs-traversal.md:151-157 to reflect HEAD shape —multi.rs:201-219retains canon_result viaCompiledModuleInfo;multi.rs:722invokesbuild_imported_mono_state(constructsImportedMonoState);compile_common.rs:134(compile_to_llvm_with_imported_monos) +compile_common.rs:194(compile_to_llvm_with_imports) threadimported_mono_fns+re_interned_canonstorun_codegen_pipeline. Pre-implementation prose deleted. -
[TPR-02-2026-05-16-002-gemini][Minor] PLAN_COHERENCE_DRIFT:citation-drift — §02.2 body line refs at section.md:132-138 carry stale mod.rs numbers (mod.rs:77 should be :79; mod.rs:138 should be :143; mod.rs:319 should be :372; mod.rs:263 should be :314) while success_criterion line 11 already carries the cured refs per round-4 fix. Body/criterion divergence. Resolution: refresh §02.2 Files block + task body line refs to current HEAD coordinates matching success_criterion line 11; consider adding a “verified at recon-time HEAD” annotation or migrating to symbol anchors (per round-1 codex broader cure note) to prevent future drift recurrence. Resolved (Round 1 2026-05-16): §02.2 Files block at section-02-import-sigs-traversal.md:132 + §02.2 task body at lines 136-137 + §02.3 task bodies at lines 164 + 166 refreshed to HEAD coordinates
:79/:143/:372/:314/:188-210matching success_criterion line 11. -
[TPR-02-2026-05-16-003-opencode][Medium] PLAN_COHERENCE_DRIFT — 00-overview.md mission criterion at line 25
- [ ] cargo test --release -p ori_llvm --test aot poly_lambda_mono ... passes both test_poly_lambda_with_imported_assert_eq_int and test_poly_lambda_with_imported_assert_eq_str (delivered by §02.4 matrix tests subsection). <!-- delivered-by: §02.4 -->is unchecked but the deliverable is verifiably complete: §02.4 status: complete per frontmatter; close-out reports 5/5 pass at commit3bb8aa725viacargo test --release -p ori_llvm --test aot poly_lambda_monoreturning5 passed; 0 failed; 0 ignored;<!-- delivered-by: §02.4 -->annotation present. Plan-checkbox-bypass does NOT apply (cargo test command, not slash-command). Resolution: flip[ ]→[x]on 00-overview.md:25 at §02.N close-out via mechanical auto-fix. Resolved (Round 1 2026-05-16): 00-overview.md:25 flipped[ ]→[x]perfeedback_auto_fix_cleanup.mdmechanical auto-fix; HTML comment extended to citeverified 5/5 pass at commit 3bb8aa725.
Round 7 cap-exit findings (this invocation; filed 2026-05-16, cap_reached_max_rounds)
Filed per /tpr-review §7 cap-exit accept-with-findings; cap-exit reason recorded in third_party_review.notes. Per-round summary (5 rounds, survivor-mode 2-of-3 on round 5 — codex transport-failed Tier 4.5):
-
Round 1: 3 findings cured inline (§02.2 + §02.3 Files-block + line-refs refresh to HEAD coords; 00-overview.md:25 mission criterion flipped
[x]). -
Round 2: 3 findings cured inline (compiler-source plan-section refs stripped from
monomorphize/tests.rs:202+240+poly_lambda_mono.rs:72closed-BUG-04-042 ref + litter-pickup attests.rs:271). -
Round 3: 4 actionable findings cured inline (closed BUG-01-002 §C.2/§C.4 refs stripped from
monomorphize/tests.rs:275-282; recon-block coords at section.md:101 refreshed; BUG-04-119 annotated inbug-tracker/section-04-codegen-llvm.md:120with<!-- delivered-by: -->; section.md:252plan_corpus checkcheckbox flipped[x]; §02.N “BUG-04-119 tracker entry annotated” flipped[x]; generics::* success-criterion wording softened to cite parallel-session baseline carve-out) + 2 false-positives dropped (semantic-pin preserved vocab; section-not-complete circular) + 2 meta accepted. -
Round 4: 2 actionable findings cured inline (
compile_common.rs:179“Section 12.14” stripped;monomorphize/tests.rs:315“§C.4.1” stripped) + 2 meta improvements applied (test-all.sh blocked-by annotation + plan-annotations-sweep grep command; sweep verified clean across §02-owned code surfaces, §02.N checkbox flipped[x]). -
Round 5: 2 actionable findings cured inline (line-ref drift at section.md:205 + status-summary prose at section.md:70) + 1 meta dropped (circular
/tpr-reviewcheckbox flip recommendation) + codex transport-failed Tier 4.5 (survivor mode). -
[TPR-02-2026-05-16-004-gemini][Minor] PLAN_COHERENCE_DRIFT:citation-drift — §02.4 close-out prose at section.md:205 cites “success-criterion line 18-19” for the JIT
&[]passthrough explanation, but the correct ref is line 14 (lines 18-19 are the no-regression + matrix criteria, not the JIT passthrough criterion). Cosmetic citation drift; resolution: update inline citation to line 14. Resolved (Round 5 2026-05-16): section.md:205 citation updated from “line 18-19” → “line 14” matching the JIT passthrough success-criterion at frontmatter line 14. -
[TPR-02-2026-05-16-005-opencode][Minor] PLAN_COHERENCE_DRIFT — §02 body status prose at section.md:70 lists
plan_corpus checkas a pending §02.N item, but §02.N line 252 marks it[x]verified clean 2026-05-16 (Round 3 cure). Status-summary string stale relative to §02.N close-out checklist. Resolution: dropplan_corpus checkfrom the prose enumeration; refresh to reflect 2 remaining gates only (/tpr-review+/impl-hygiene-review). Resolved (Round 5 2026-05-16): section.md:70 rewritten to enumerate the 2 remaining unchecked gates + cite the 3 flipped items (plan_corpus check+BUG-04-119 tracker annotated+plan annotations swept) with the test-all.sh gating noted.
02.N Completion Checklist
- All 02.1, 02.2, 02.3, 02.4, 02.R subsections
status: complete. - Decision 01 (
decisions/01-imported-mono-linkage-mechanism.md) flipped tostatus: established; acceptance gate items verified. - Decision 02 (
decisions/02-imported-method-scope-routing.md) flipped tostatus: established; §03 amendment co-landed (§03 frontmatter + §03.4 + §03.5 subsections authored — this is §03’s own commit, NOT §02’s, but §02 close-out verifies the cross-section commitment landed). -
/tpr-reviewon §02 diff returns clean across active reviewer set (codex + gemini + opencode when all present; documented survivor-mode subset per.claude/skills/tpr-pipeline/failure-matrix.md§Survivor-mode matrix +.claude/skills/tpr-pipeline/reviewer-set-composition.mdruntime detection when one drops). -
/impl-hygiene-reviewon §02 diff returns clean after TPR. -
python -m scripts.plan_corpus check plans/aot-mono-completeness/section-02-import-sigs-traversal.mdreturns exit 0. . -
timeout 150 compiler_repo/test-all.shgreen — full regression check per CLAUDE.md§Commands(success criterion 13). - BUG-04-119 tracker entry annotated
<!-- delivered-by: plans/aot-mono-completeness/section-02-import-sigs-traversal.md -->(full retirement happens at §07). - §02 plan annotations swept — no stale
TPR-,CROSS-,Phase A,BUG-04-119references remain in code touched by §02 perimpl-hygiene.md COMMENT_HYGIENE_DRIFT:non-spec-pointer. Verify clean via:rg -n '§0[2-9]|Decision 0[1-9]|TPR-0[2-9]-|CROSS-0[2-9]-|Phase [A-Z]|BUG-04-119' compiler_repo/compiler/ori_llvm/src/monomorphize compiler_repo/compiler/ori_llvm/tests/aot/poly_lambda_mono.rs compiler_repo/compiler/oric/src/commands/build/multi.rs compiler_repo/compiler/oric/src/commands/codegen_pipeline compiler_repo/compiler/oric/src/commands/compile_common.rs compiler_repo/compiler/oric/src/test/runner/imported_mono.rs compiler_repo/compiler/oric/src/test/runner/arc_lowering.rsreturns zero matches. - Section frontmatter flipped:
status: complete,reviewed: trueviaflip_from_in_review_clean()perstate-discipline.md §4.
HISTORY
-
2026-05-15 — §02.3 implementation complete: promoted
ImportedMonoFncarrier +build_imported_mono_functionsfrom JIT test-runner into production atcompiler_repo/compiler/oric/src/commands/codegen_pipeline/imported_mono.rs; extendedCompiledModuleInfowithtype_result+canon_result+poolretention (consumer arrives at §02.4 merged-pool re-interning); threadedimported_mono_fns: &[ImportedMonoFn]throughcompile_to_llvm_with_imports→run_codegen_pipeline→run_borrow_inference; added arc_lowering specialization loop inrun_borrow_inferencemirroring test-runner shape atarc_lowering.rs:108-117; test-runner site atoric/src/test/runner/imported_mono.rsreduced to thin wrapper. 5 new unit tests pass; both build profiles green;genericsAOT pass count matches pre-§02 baseline (94 passed / 11 failed / 4 ignored — pre-existing parallel-session baseline failures). AIMS snapshot test failure independent of §02.3 (no-op changes whenimported_mono_fnsis empty). -
2026-05-15 — §02.4 architectural blocker resolved (commit
3bb8aa725): two distinct failure modes from the prior §02.4 entry were cured bycompiler/oric/src/commands/build/multi.rs::extract_public_function_typesaddingif func_sig.is_generic() { continue; }filter (generics reach codegen via imported-mono dispatch path; rawimport_sigsMUST NOT carry source-poolBoundVarleaves) AND single-file build wiringcompile_to_llvm_with_imported_monos(new entry-point incompile_common.rs) souse std.testing { assert_eq }/use std.<generic>imports get monomorphized viabuild_imported_mono_stateagainst the merged pool. Mirrors the JIT path’s filter atoric/src/test/runner/llvm_backend.rs:213— production AOT now consistent with the JIT reference. Files modified:compiler/oric/src/commands/build/multi.rs(generic-skip filter;ImportedMonoStatevisibility widened topub(crate);_compiled_modulesparameter removed);compiler/oric/src/commands/build/mod.rs(pub(crate) use multi::build_imported_mono_state;re-export);compiler/oric/src/commands/compile_common.rs(compile_to_llvm_with_imported_monosreplacing deadcompile_to_llvm);compiler/oric/src/commands/build/single.rs(call-site rewiring);compiler/oric/src/commands/run/mod.rs(call-site rewiring). Verification:cargo test --release -p ori_llvm --test aot poly_lambda_mono→ 5/5 pass;cargo test --release -p ori_llvm --test aot generics→ 94 passed / 11 failed / 4 ignored (matches §02.3 baseline — failures are pre-existing parallel-session AIMS-burden-tracking entries, not §02 regressions). Observation surfaced + not filed: pre-fixTag::BoundVarleak was layout-sensitive (6-line fixture-header difference shifted pool-index allocation enough to mask the bug for some shapes); cure (filter generics fromimport_sigs) eliminates the layout dependency. -
2026-05-15 — §02.4 partial implementation + architectural blocker surfaced:
- Implementation landed: 4 matrix tests + 1 negative pin authored in
compiler_repo/compiler/ori_llvm/tests/aot/poly_lambda_mono.rs; fixtures atcompiler_repo/compiler/ori_llvm/tests/aot/fixtures/imported_generics/{generics,host_list_int,host_struct}.ori;#[ignore]removed fromtest_poly_lambda_with_imported_assert_eq_int+_str. Merged-pool re-interning consumer wired inmulti.rs::compile_single_modulevia newImportedMonoState+build_imported_mono_statehelper (usesoric::query::type_check_module+canonicalize_cached_by_pathSalsa queries — covers stdlib AND relative imports uniformly without depending oncompiled_modules).re_interned_canonsplumbed throughcompile_to_llvm_with_imports→run_codegen_pipeline→run_borrow_inference; imported_mono lowering loop inrun_borrow_inferencenow specializes againstre_interned_canons[source_module_idx](withunwrap_or(canon)fallback). Build green; negative pin (test_unimported_generic_still_fails_cleanly) passes — confirms boundary semantics. - Architectural blocker: 4 positive tests still fail with two distinct failure modes:
assert_eq(stdlib):unresolved function 'assert_eq' in apply/invoke — missing mono instance?—mono_dispatch_by_id[host_mono_instance_id]lookup returns None ormono_dispatch[Name("assert_eq")]fallback fails arg-type matching despiteimported_mono_fnscarrying the correct(MonoFunction, source_module_idx, original_name)triple with populatedinstance_ids. The merged path produces 3 ImportedMonoFn entries (identity,assert_eq,first) forhost_list_int.ori;imported_generic_sigsmap correctly keyed by local name;build_imported_mono_functionssucceeds;run_borrow_inferencemerges imported monos intoall_mono_functions. Suggestsdeclare_mono_functions↔lookup_mono_dispatchchain has a gap for imported-mono entries.identity/pair(relative-path helper):Tag::BoundVar reached codegen — upstream substitution missed a leafatIdx(224|225)fromcompiler_repo/compiler/ori_llvm/src/codegen/type_info/store.rs:388. Thebody_type_map(built bybuild_mono_body_type_mapiterating merged_pool entries withHAS_VAR | HAS_BOUND_VAR) appears to miss one leaf in the re-interned imported-generic body. Likely root:re_intern_type_with_var_remapre-interns body BoundVar leaves with fresh merged-pool var_ids via sharedper_module_var_remaps[i], but those var_ids may not flow intovar_substconsistently ifextend_var_subst_with_roots(called inbuild_body_type_map) doesn’t traverse union-find roots correctly across pool boundaries.
- Resolution path — requires architectural amendment beyond §02.4 scope:
- Audit
declare_mono_functionsflow for imported-mono entries: verifymono_dispatch_by_id[instance_id]is populated for everymono_fn.instance_idsentry fromimported_mono_fns, AND verify the host’sCanonResult.mono_dispatch_map_cancarries entries that map host’s per-call-siteExprId→MonoInstanceIdfor imported call sites (vs only host-local generic calls). - Audit
build_mono_body_type_map↔ re-intern interaction: verify that afterper_module_var_remapspopulates fresh merged-pool var_ids,extend_var_subst_with_rootscorrectly threads union-find roots so EVERYTag::BoundVar(merged_var_id)leaf in the re-interned body has a correspondingvar_subst[merged_var_id] → concrete_idxentry. - Cross-validate against the JIT test runner:
oric/src/test/runner/llvm_backend.rsconsumes the SAMEimported_mono_fnsshape and works for the corresponding spec test attests/spec/expressions/poly_lambda_with_imported_generic.ori. Diff the JIT path’s data flow vs the AOT path’s to identify what the JIT does that the AOT doesn’t.
- Audit
- Files modified (§02.4):
compiler_repo/compiler/ori_llvm/tests/aot/poly_lambda_mono.rs,compiler_repo/compiler/ori_llvm/tests/aot/fixtures/imported_generics/{generics,host_list_int,host_struct}.ori(NEW),compiler_repo/compiler/oric/src/commands/build/multi.rs(addedImportedMonoState+build_imported_mono_state+ threading),compiler_repo/compiler/oric/src/commands/compile_common.rs(addedre_interned_canonsparameter oncompile_to_llvm_with_imports),compiler_repo/compiler/oric/src/commands/codegen_pipeline/mod.rs(run_codegen_pipeline+run_borrow_inferenceacceptre_interned_canons; imported_mono lowering loop usesre_interned_canons[source_module_idx]). Build green; §02.3 dead-code allows onCompiledModuleInfo.{type_result,canon_result,pool}retained for future cleanup once the §02.4 consumer pattern matures.
- Implementation landed: 4 matrix tests + 1 negative pin authored in
-
2026-05-15 — /commit-push halt skipped (autopilot continuation): halt_reason=
test_all_fail; failing_repo=compiler_repo(step 5 pre-commit./test-all.sh); scope=cross-scope (Phase A bundle carried parallel-session work — aims-burden-tracking §03.4 cycle 50bburden_dec-before-settagemission tests + lower, ori_typesclosure_unify, ori_llvmarc_emitterdispatch refactor, ori_reprrange/transfertouch — none owned by aot-mono-completeness §02). Autopilot continues perskill-control-contract.md §Autopilot Modeunified hook-failure clause; orchestrator re-invoked with--bypass-gate dirty_tree; parallel sessions retain ownership of clearing their working-tree state via user-typed/commit-push --bypass.