Intelligence Reconnaissance
Queries run 2026-04-17:
scripts/intel-query.sh --human file-symbols "ori_llvm/src/codegen/arc_emitter" --repo ori— inventoryArcIrEmittersymbols (variable-definition ordering,emitter_utils) before investigating the BUG-04-085 variable-not-yet-defined crash.scripts/intel-query.sh --human callers "compute_flags" --repo ori— blast radius ofTypeFlagscomputation (includingPROPAGATE_MASK) to trace §02.0’s effect on downstream consumers.scripts/intel-query.sh --human callers "body_type_map" --repo ori— identify all consumers ofbody_type_mapthat may have relied on pre-§02.0Tag::Scheme HAS_VAR=falseflag semantics.scripts/intel-query.sh --human similar "variable not defined arc emitter ordering" --repo swift,lean4 --limit 3— prior art for SSA variable-definition ordering bugs in ARC IR emitters.
Results summary (≤500 chars) [ori]: ArcIrEmitter lives in ori_llvm/src/codegen/arc_emitter/; emitter_utils.rs handles variable definition tracking. body_type_map consumed by prepare_mono_cached in nounwind/prepare.rs. compute_flags in ori_types/src/pool/ — PROPAGATE_MASK sets HAS_VAR on Tag::Scheme items since §02.0. [swift]: SIL variable-ordering bugs manifest as “use before definition” in ownership verification — mirrors the var=N not yet defined crash signature.
07.PRE — Predecessor-Status Gate
Origin. Per routing.md §5 ordering primitives + state-discipline.md §4 predecessor-integrity contract: every section in depends_on: ["01", "02", "03", "04", "05", "06", "08", "09", "10", "11"] MUST satisfy status: complete AND reviewed: true before §07.0 may begin. Without an explicit precheck step, §07.0/§07.1 silently advance against not-started/in-progress/in-review predecessors (STRUCTURE:work-order-violation per impl-hygiene.md §Finding Categories).
Gate. §07.0 SHALL NOT begin (and §07.1–§07.4 SHALL NOT begin transitively per subsection_depends_on:) while the precheck reports failed.
Transitive deps note. §07’s direct depends_on: list includes §08; §04 carries its own depends_on: chain that transitively reaches §07 via §08. The precheck consults the full depends_on: set per routing.md §5 ordering primitives — predecessor verification is whole-graph, not single-hop.
- Run
python -m scripts.plan_corpus check plans/typeck-inference-completeness/— zeroSTRUCTURE:work-order-violationfindings. Any predecessor withstatus != completeorreviewed != truefails the precheck. - Inspect each predecessor’s frontmatter directly: §01, §02, §03, §04, §05, §06, §08, §09, §10, §11 ALL carry
status: complete+reviewed: true. Predecessors flaggedblocked(e.g., §04 cross-scope blocked on aims-burden §06 per00-overview.mdRESUME POINTER) require resolution BEFORE §07 advances; pulling the blocker into scope is the cure per CLAUDE.md§Failing Tests Mid-Work → Pull Blockers Into Scope. - On precheck failure, §07 SHALL remain
in-review/in-progressand emitnext_action: blockedreferencing the specific predecessor IDs that failed; resolution path documented in00-overview.mdHISTORY block. - On precheck success, advance to §07.0. Record the verifying SHA in
review_pipeline:frontmatter.
07.0 Investigate BUG-04-085 — LLVM spec runner crash (absorbed 2026-04-17; HARD BLOCKER on §07.1)
Origin: Absorbed from bug-tracker BUG-04-085 per CLAUDE.md §Ownership & Deferral “Plan-blocker bugs belong IN the plan”. The bug was filed 2026-04-15 with explicit notes that §02.0’s Tag::Scheme PROPAGATE_MASK change may be the causal root. Because this plan introduced §02.0 and the crash may be its downstream symptom, the plan owns investigating and resolving it as part of close-out.
Block-gate semantics (per subsection_depends_on: { "07.1": ["07.PRE", "07.0"] }). §07.0 hard-blocks §07.1. Filing a new bug + advancing to §07.1 with the crash unresolved is BANNED — CLAUDE.md §The One Rule (correctness above all) + §ZERO DEFERRAL apply: the crash IS this plan’s deliverable to fix, not to defer. The two legitimate exit paths are:
- Path A — §02.0 is causal: §02.0’s
Tag::Scheme PROPAGATE_MASKfix is confirmed root cause; the downstream consumer (ArcIrEmitter variable-definition ordering,body_type_map,prepare_mono_cached) is fixed in THIS plan to work correctly with the new flag semantics. §07.0 closes; §07.1 advances. - Path B — §02.0 is not causal: §02.0 is confirmed not-causal AND the true root cause (drop-fn pointer type mismatch / ArcIrEmitter ordering regression independent of §02.0 / other) is identified AND fixed IN THIS PLAN as a new sibling subsection §07.0.A under the same umbrella per
routing.md §3case (a) blocker discipline. §07.0 closes; §07.1 advances.
Path B-with-new-bug routing. A new bug filed during §07.0 investigation is routed per routing.md §3 case (a): it becomes sibling subsection §07.0.A under THIS umbrella, NOT a separate bug-tracker/plans/BUG-XX-XXX/ entry (sibling bug-tracker entry would be PLAN_ROUTING_DRIFT per impl-hygiene.md §Finding Categories). §07.1 STILL blocks on §07.0.A close. The previous text permitting “continue with §07.1” when §02.0 is not causal is BANNED per the §07.0 block-gate above.
Same-family-with-§08 resolution status (per 00-overview.md Known Bugs table, 2026-04-20). BUG-04-085 is classified Same-family with §08 (cross-module pool-merge / monomorphization corruption surfacing in ArcIrEmitter). §08 (BUG-04-042) shipped the JIT-only fix; the LLVM AOT path tracked via BUG-04-119. §07.0 investigation MUST either (a) confirm the §08.3 remap-aware re-intern fix closes BUG-04-085 in the LLVM path as well (no separate cure needed; flip §07.0 complete with §08.3 SHA as resolved_in), OR (b) identify the residual LLVM-specific cure surface AND fix it in this plan as §07.0.A. Either path REQUIRES the crash to be gone before §07.1.
Failure mode (from bug entry): timeout 150 ./test-all.sh shows Ori spec (LLVM backend) CRASHED with cluster of errors on assert_eq$m$int (monomorphized assert_eq<int>):
LLVM IR verification failed after codegen (emit_prepared_functions)withCall parameter type does not match function signature!onori_rc_dec({ i64, i64, ptr }, ptr @"_ori_drop$N")- Three
ArcIrEmitter: variable not yet definederrors (var=11, var=2, var=7) — mirrors resolved BUG-04-024 signature error[E4003]: ARC internal error: index assignment reached ARC lowering before desugaring(BUG-04-070 class)thread 'ori-main' has overflowed its stack→SIGABRT- Interpreter passes all 4444 spec tests; only
--backend=llvmcrashes
Causal hypothesis: compiler/ori_types/src/pool/mod.rs:655-661 — §02.0’s Tag::Scheme PROPAGATE_MASK fix sets HAS_VAR on scheme Idx values where previously unset. If the mono pipeline’s body_type_map or ArcIrEmitter’s variable-definition ordering relied on the old flag semantics (specifically: “scheme types have !HAS_VAR so skip the substitute step”), then setting HAS_VAR correctly now surfaces as “variable not yet defined” in the downstream consumer.
- Reproduce the crash cleanly:
timeout 150 ./test-all.shon a clean post-§08/§09/§10/§11 tree — confirm the specific crash line, the 3var=Nerrors, theassert_eq$m$intfunction name, and the SIGABRT stack overflow. - Confirm §08.3 status against the crash: re-run the repro with HEAD at §08.3’s
131c771ea(or later) and §11.1 complete. If the crash IS GONE post-§08.3, the §08 same-family fix closed it; record the SHA in §07.0 HISTORY + the bug-trackerresolved_in:field + advance to §07.0 close. If the crash PERSISTS, continue to the isolation step below. - Isolate §02.0’s causal role (only if §08.3 did not close it): revert
compiler/ori_types/src/pool/mod.rs:655-661’sTag::Schemecontribution toPROPAGATE_MASKon a scratch branch; re-runtest-all.sh. If the crash disappears, §02.0 is causal (Path A). If the crash persists, §02.0 is not causal (Path B); identify the true root cause viaORI_DUMP_AFTER_LLVM=1+ORI_VERIFY_ARC=1+compiler_repo/diagnostics/dual-exec-debug.shpertooling-first.md §4(use existing tooling first; extend if gap exists). - Path A (§02.0 causal): identify the downstream consumer that depended on the old flag semantics. Candidate sites:
ArcIrEmittervariable-definition ordering (emitter_utils.rs), the mono pipeline’sbody_type_mapconstruction,prepare_mono_cached’s scheme handling. Fix the consumer to work correctly with the new (correct) flag semantics. Land as commitfix(typeck): downstream consumer respects Tag::Scheme HAS_VAR semantics (BUG-04-085). Do NOT revert §02.0. - Path B (§02.0 not causal): fix the identified true root cause IN THIS PLAN as §07.0.A sibling subsection per
routing.md §3case (a). Do NOT route to a separatebug-tracker/plans/BUG-XX-XXX/entry (would bePLAN_ROUTING_DRIFT). §07.1 stays blocked on §07.0.A close. - TDD: add a spec test or Rust unit test that exercises the failing path —
assert_eq<int>in a file that also uses polymorphic lambdas (overlap with §08 surface). Verify the test fails on the current code and passes after the fix. - Matrix: poly-lambda × imported generic × assert_eq type — confirm no crash for
int,str,bool,floatvariants. - Verify gate:
timeout 150 ./test-all.shno longer showsOri spec (LLVM backend) CRASHED. §07.1 unblocks. - Update 00-overview.md: amend
Known Bugstable BUG-04-085 row Status column from “Same-family with §08 per 2026-04-20 resolution” to “Complete (§07.0 confirms §08.3 closes the LLVM path | Fixed via §07.0.A | other)” and add a HISTORY entry recording the verifying SHA. ResolvesPLAN_COHERENCE_DRIFTbetween §07.0 unchecked boxes and 00-overview prose claim.
Section 07: Close-out + Supersession
Status: In Progress (per frontmatter status: in-progress; flips to complete post-§07.4 + umbrella 00-overview.md close-out per state-discipline.md §4)
Goal: Formally close BUG-04-074, BUG-04-084, BUG-04-042, BUG-04-085 and this plan. Verify all code changes are clean, all plan annotations are removed, the LLVM spec-runner crash is fixed, and the bug-tracker is updated.
Depends on: All previous sections complete (§01–§06, §08, §09, §10, §11) per depends_on: frontmatter; §07.PRE verifies.
07.1 Final Test Verification
timeout 150 ./test-all.sh # debug build — must be green; Ori spec (LLVM backend) row no longer CRASHED
timeout 150 cargo test --release -p ori_types # release build
timeout 150 cargo test --release -p ori_llvm # LLVM + AOT release
Dual-execution parity verification covers the FULL work arc (§05 empty-list corpus + §08–§11 representative paths). Run on each path; diagnostics/dual-exec-verify.sh MUST report zero parity divergences across all listed paths.
# §05 — empty-list corpus (Section 05 carryover)
diagnostics/dual-exec-verify.sh tests/spec/types/collections/empty_list/empty_list_push_unified_dual_exec.ori
diagnostics/dual-exec-verify.sh tests/spec/types/collections/empty_list/empty_list_element_struct.ori
diagnostics/dual-exec-verify.sh tests/spec/types/collections/empty_list/empty_list_iter_chain_dual_exec.ori
# §09.3/§09.5 — Result<T, user-Error> LHS propagation + method-call return BD-2
diagnostics/dual-exec-verify.sh tests/spec/traits/into/str_to_error.ori
# §09.4 — lambda-parameter propagation from receiver element type
diagnostics/dual-exec-verify.sh tests/spec/traits/iterator/methods.ori
# §10.1 — rigid-receiver bound-chain dispatch
diagnostics/dual-exec-verify.sh tests/spec/declarations/traits.ori
# §10.2 — capability-method dispatch
diagnostics/dual-exec-verify.sh tests/spec/capabilities/propagation.ori
# §11.1 — polymorphic-constructor defaulting regression guard
diagnostics/dual-exec-verify.sh tests/spec/types/empty_literals/
Coverage map (§07.1 dual-exec rows × surface owner):
| Path | Owning section | Surface validated |
|---|---|---|
tests/spec/types/collections/empty_list/empty_list_push_unified_dual_exec.ori | §05 | Empty-container typeck phase contract |
tests/spec/types/collections/empty_list/empty_list_element_struct.ori | §05 | Same |
tests/spec/types/collections/empty_list/empty_list_iter_chain_dual_exec.ori | §05 | Same |
tests/spec/traits/into/str_to_error.ori | §09.3 + §09.5 | Result<T, user-Error> LHS + method-call return BD-2 |
tests/spec/traits/iterator/methods.ori | §09.4 | Lambda-param propagation from receiver |
tests/spec/declarations/traits.ori | §10.1 | Generic-param bound-chain dispatch |
tests/spec/capabilities/propagation.ori | §10.2 | Capability-method dispatch |
tests/spec/types/empty_literals/ (21-file corpus) | §11.1 | Polymorphic-constructor defaulting regression guard |
07.2 Plan Annotation Cleanup Sweep + Post-§09.3 Helper Removal
Per CLAUDE.md §Compiler Coding Guidelines: “Plan annotations are temporary scaffolding.
They MUST be removed when the plan completes.”
07.2.a Annotation marker sweep
Run the sweep over all three trees (compiler source, spec tests, and stdlib), using
only this plan’s specific markers. The 2026-04-23 plan rename from empty-container-typeck-phase-contract to typeck-inference-completeness means BOTH pre-rename and post-rename markers must appear in the sweep regex until every annotation site has been migrated:
# Plan-specific markers in compiler source (Rust files) — must return zero hits
rg 'BUG-04-074|BUG-04-084|BUG-04-042|BUG-04-085|empty-container-typeck|typeck-inference-completeness' compiler/ --glob '*.rs'
# Plan-specific markers in AOT fixture files (Ori files in compiler tree) — must return zero hits
# These are created in §05.3 at compiler/ori_llvm/tests/aot/fixtures/empty_list/*.ori
rg 'BUG-04-074|BUG-04-084|BUG-04-042|BUG-04-085|empty-container-typeck|typeck-inference-completeness' compiler/ --glob '*.ori'
# Plan-specific markers in spec tests (regression comments added in §06.2)
rg 'BUG-04-074|BUG-04-084|BUG-04-042|BUG-04-085|empty-container-typeck|typeck-inference-completeness' tests/ --glob '*.ori'
# Plan-specific markers in stdlib (edits made in §06.3)
rg 'BUG-04-074|BUG-04-084|BUG-04-042|BUG-04-085|empty-container-typeck|typeck-inference-completeness' library/ --glob '*.ori'
Note: Generic §NN tokens (e.g. §01, §03) are intentionally excluded from the
sweep pattern because they exist in unrelated plans (e.g., compiler/ori_repr/ contains
§03 and §04 references from a different plan). Searching for bare §NN produces
false positives and sends the implementer chasing unrelated code. Use only the
plan-specific identifiers above.
Every hit must be removed or converted to a permanent spec comment
(Spec: Clause N.M format). No plan-referencing comments in shipped code.
07.2.b Post-§09.3 helper removal (traceable/ workarounds)
Scope: the @mk_ok / @mk_err helper-function workarounds applied during §06.2C remediation to tests/spec/traits/traceable/definition.ori + tests/spec/traits/traceable/result_delegation.ori. These are CLEANUP DEBT — they stay in main-branch source only until §09.3 lands. Post-§09.3, the direct-constructor form compiles clean without the helpers, and keeping them is a hygiene violation (dead-ish workarounds mascuerading as legitimate helpers).
Predecessors (MUST all be complete before this subsection starts):
-
§09.3 (Result<T, user-Error> LHS propagation) is
status: completein its frontmatter. -
§06.4.4’s “Per-file INVERTED-TDD reconciliation for 2 traceable/ helper-workaround files” step is marked
[x]and reports the scratch-revert as GREEN (proving the direct-constructor form compiles under the shipped §09.3 fix). -
Confirm §09.3 frontmatter
status: complete. -
Confirm §06.4.4’s traceable/ scratch-revert step is
[x]with GREEN result. If the scratch-revert failed, §07.2 helper removal is BLOCKED pending §09.3 completeness investigation — file a bug naming the specific residual failure. -
In main-branch source, strip the
@mk_ok/@mk_errhelper calls AND their helper definitions fromtests/spec/traits/traceable/definition.ori+tests/spec/traits/traceable/result_delegation.ori. Restore each file to the direct-constructor form (Ok(x: ...)/Err(x: ...)intry { ... }with outerlet r: Result<T, E> = ...LHS annotation — same shape as the §06.4.4 scratch-revert fixture). -
Run
timeout 150 cargo stf tests/spec/traits/traceable/— both files green. Runtimeout 150 diagnostics/dual-exec-verify.shon both files — zero parity divergences. -
Run
timeout 150 ./test-all.sh— confirm no regression outside the traceable/ directory (if a regression appears, the removal is unmasking a different compiler gap; pull the unmasked compiler gap into §07.2 scope (or sibling subsection) and fix per CLAUDE.md §Failing Tests Mid-Work; never back out + defer). -
Commit:
refactor(tests): remove @mk_ok/@mk_err helpers from traceable/ — §09.3 closes the compiler gap directly (§07.2). -
Update §06.2C table: change the Classification for the 2 traceable/ rows from
helper workaround — CLEANUP DEBTtoREMOVED (direct form, §09.3 closed gap)and the Owning column to— (resolved via §07.2). -
Update §03.N Known Failing Tests table (
section-03-bodies-pass-integration.md:~1243-1280): strike the two traceable/ rows as[REMEDIATED in §07.2 — helpers removed post-§09.3].
07.2.c R7-006 Validator Refinement — Discriminate Lambda return-vs-param in E2005 Site Classifier
Origin. Absorbed from TPR Round 7 finding R7-006 (codex medium) per §06.R line 701 anchor. The finding cites compiler_repo/compiler/ori_types/src/check/validators/mod.rs:204 where site_from_expr_kind is invoked at the SINGLE per-ExprIndex body-walk call site, classifying every Lambda-sited Tag::Var as LambdaParam and producing the closure-parameter diagnostic wording even when the unresolved var is on the lambda’s RETURN type. The §06.1 spec bullet at :151 defines LambdaParam as specifically “ExprKind::Lambda { params, .. } where a parameter has unresolved Tag::Var” — return-type vars violate this classification.
Sequencing — moved from §07.5 to §07.2.c (per /tp-help gemini High SEQ_GAP). Original §07.5 placement after §07.3 meant validator changes could ship to production without going through §07.3’s final TPR + hygiene gate. §07.2.c routes validator refinement BEFORE §07.3, so §07.3 covers it. subsection_depends_on: { "07.3": ["07.2.c"] } enforces.
Why post-§09/§10/§11. Running the validator refinement against a body-inference surface that still has §09 BD-2 gaps or §11.1 defaulting holes produces false diagnostic wording regressions and thrashes the test matrix. §09/§10/§11 must land FIRST so the only remaining E2005 sites are genuine residuals the validator refinement must classify correctly.
Call-site precision (per /tp-help opencode Low DOC_PRECISION). The validator has ONE Lambda-aware call site at compiler_repo/compiler/ori_types/src/check/validators/mod.rs:204 inside the body-expr walk loop (the site = site_from_expr_kind((ctx.kind)(expr_idx)); line). The signature-position walk at :192-195 always uses AmbiguousTypeSite::Expression (no ExprKind available). The LambdaParam narrow-span helper at :213-217 (narrow_to_lambda_param_span) is the secondary surface that consumes the classifier output. Fix scope is narrow: refine site_from_expr_kind + thread VarPosition + extend narrow_to_lambda_param_span (or sibling helper) for the return-type case.
Fix shape.
- Read
compiler_repo/compiler/ori_types/src/check/validators/mod.rs:95-100(site_from_expr_kinddefinition) +:200-220(body-walk call site + narrow_to_lambda_param_span) + surrounding context to understand the current signature (what does it receive? just theExprKind, or does it have access to the specific Tag::Var position that triggered the E2005?). - If the signature doesn’t currently carry position info, extend it: add a
VarPositionenum ({ LambdaParam(param_index), LambdaReturn, FunctionParam(param_index), FunctionReturn, LetBinding, MatchArm, ... }) and thread it through the validator’s Tag::Var-reporting call site so each E2005 emission knows which slot introduced the unresolved var. - Split
LambdaParamsite class intoLambdaParam { index }+LambdaReturn— emit distinct E2005 diagnostic messages per site class (parameter wording stays verbatim per §06.1 spec; return wording is new — propose “cannot infer the return type of this lambda; add a return annotation or constrain the body expression”). - Extend
narrow_to_lambda_param_span(or add siblingnarrow_to_lambda_return_span) so return-position vars narrow to the body span (or return-annotation span when present), NOT the whole-lambda span. - Write positive + negative test pair:
test_e2005_lambda_return_uses_return_wording(positive — synthesize an ExprKind::Lambda with unresolved return-position Tag::Var, verify the emitted E2005 message uses the return wording) +test_e2005_lambda_param_uses_param_wording_unchanged(regression — verify param-position classification still produces the pre-refinement wording). - Dual-exec parity: the validator refinement is diagnostic-only (no AST change, no canonicalization change, no codegen change) so
diagnostics/dual-exec-verify.shshould show zero parity divergences — verify explicitly on one of the §07.1 dual-exec paths. - Update §06.1’s E2005 wording success criterion at
section-06-diagnostics-audit.md:21if the return-position wording is added (currently only cites the empty-list example).
Gate. §07.2.c MUST be status: complete before §07.3 final TPR + hygiene gate runs. §07.3 scope COVERS §07.2.c per the expanded scope line below.
Commit shape. One commit scoped to the validator refinement alone (no bundling with §07.0 BUG-04-085 investigation or §07.2 helper removal). Commit message: fix(typeck): validator E2005 site classifier discriminates Lambda return vs param (R7-006).
07.3 Final TPR + Hygiene Gate
Run this BEFORE updating any external bug trackers. All validation gates must pass before declaring any bug resolved — marking bugs complete before gates pass leaves the tracker out of sync if a gate fails.
First, validate the entire plan directory against the plan corpus schema:
python -m scripts.plan_corpus check plans/typeck-inference-completeness/
This command must pass with zero schema errors before the plan can be marked complete.
If it fails on sections 01–04 or index.md (sections written before the plan_corpus
schema was current), update their frontmatter to satisfy the schema before proceeding.
Run final TPR over the FULL work arc:
/tpr-review
The scope covers the full work arc: all compiler changes in Sections 01–04, new test files from
Section 05, annotation changes from Section 06, §07.0 BUG-04-085 LLVM-crash resolution (and §07.0.A
if Path B fired), §07.2.a annotation sweep + §07.2.b traceable/ helper removal, §07.2.c R7-006
validator refinement, §08 poly-lambda mono fix, all §09 body-inference BD-2 extensions (§09.1
try-block, §09.2 def-impl Self, §09.3 Result<T,E> LHS, §09.4 lambda-param, §09.5 method-call return
BD-2, §09.6 Map lambda-param, §09.7 file splits), all §10 dispatch-on-rigid-receiver changes
(§10.0 file splits, §10.1 bound-chain, §10.2 capability), and §11.1 Never-fallback predicate
extension + body_inference_complete debug_assert + Some-exclusion. The review must return zero
actionable findings before the plan can be marked complete.
Run hygiene review:
/impl-hygiene-review
Auto-scope mode covers the FULL work arc (sections §01–§06, §07.0, §07.0.A if any, §07.2.a/§07.2.b/§07.2.c, §08–§11). Must pass.
Run tooling improvement sweep:
/improve-tooling
Sweep covers the FULL work arc — review test harness, diagnostic script, or developer tooling
gaps surfaced during the implementation of §01–§06 AND §07.0 LLVM-crash investigation AND
§07.2.a/§07.2.b/§07.2.c cleanup work AND §08–§11 compiler extensions. Surface gaps in
dual-exec-verify.sh, test-all.sh, ARC diagnostic flags (ORI_DUMP_AFTER_*,
ORI_VERIFY_ARC, ORI_TRACE_RC), typeck diagnostics (E2005 site classifier infrastructure
from §07.2.c), and validator tooling (the body-walk machinery exercised by §11.1’s
body_inference_complete debug_assert).
Run CLAUDE.md sync sweep:
/sync-claude
Sync covers the FULL work arc — verify no new APIs, commands, or invocation patterns introduced by §01–§06 AND §07.0/§07.0.A AND §07.2.a/§07.2.b/§07.2.c AND §08–§11 are missing from CLAUDE.md / .claude/rules/*.md. Particular surfaces to verify:
typeck.md §BD-2— §09.1/§09.3/§09.4/§09.5 expected-type-propagation gates extending thecheck_exprSSOT pattern (BD-2propagation table).typeck.md §EX-4— §10.1 bound-chain dispatch onTag::RigidVarreceivers extendingTraitRegistry::lookup_method_checked; §10.2 capability handler dispatch via same registry policy.canon.md §4.2/typeck.md §PC-2— §11.1 defaulting predicate extension to polymorphic-constructor roots (None/Ok/Err) ANDbody_inference_completedebug_assert inbody_finalize/mod.rs.typeck.md §DI-1— §07.2.c E2005 site classifier discriminating Lambda return-vs-param.compiler.md §Commands/repr.md— any newORI_*env vars or diagnostic flags introduced during §07.0 investigation tooling work.bug-tracker/00-overview.md— reduced open-bug count after §07.4 closes four bugs.
07.4 Bug-Tracker Updates — Close ALL FOUR Bugs Atomically
Only update bug trackers AFTER 07.3 validation gates pass. This sequencing ensures no bug is prematurely marked complete.
Scope (per frontmatter supersedes: + 00-overview.md Scope Absorption + 2026-04-17/2026-04-23 absorption record). This plan formally supersedes / closes FOUR bugs in a single §07.4 transaction:
| Bug | Owning section | Resolution summary | Frontmatter pointer |
|---|---|---|---|
| BUG-04-074 | §01 + §02 + §03 (empty-container typeck phase contract) | Unconditional generalization at 3 let-binding sites fixed via Value Restriction + validator module + bodies-pass defaulting | ”Superseded by plans/typeck-inference-completeness/section-03-bodies-pass-integration.md” |
| BUG-04-084 | §03.B (empty-collection body-exit defaulting) | Empty-collection literals at body-exit positions now default to bottom type via default_unbound_vars_from_empty_literals pre-pass | ”Superseded by plans/typeck-inference-completeness/section-03-bodies-pass-integration.md §03.B” |
| BUG-04-042 | §08 (cross-module pool-merge var_id collision, JIT path) | Remap-aware re-intern for cross-module pool merge fixes Idx(241) unresolved type variable corruption. AOT path tracked via BUG-04-119 (separate bug). | ”Superseded by plans/typeck-inference-completeness/section-08-codegen-poly-lambda.md” |
| BUG-04-085 | §07.0 (LLVM spec runner crash on monomorphized assert_eq) | Same-family with §08 — either §08.3 fix closes the LLVM path (no separate cure) OR §07.0.A sibling subsection ships the residual LLVM-specific cure | ”Superseded by plans/typeck-inference-completeness/section-07-closeout.md §07.0” + §07.0.A if applicable |
Atomic-flip discipline (per state-discipline.md §4). All four bug-tracker entries flip from open-bugs.json to closed-bugs.json via scripts/plan_corpus/bug_tracker/api.py:flip_bug_status under fcntl.flock cross-file atomic transaction. Partial closure (closing 1–3 of 4 bugs) is BANNED — §07.4 incomplete until all four flips succeed.
Per-bug update steps (apply for each of the four bugs):
-
Update
bug-tracker/plans/BUG-04-NNN/(active → completed):- Set
status: completein00-overview.mdfrontmatter - Add pointer:
"Superseded by plans/typeck-inference-completeness/section-NN-*.md"(the owning section per the table above) - Set
resolved_in:to the commit SHA of the relevant landing (§03 landing for BUG-04-074/BUG-04-084; §08.3 SHA131c771eafor BUG-04-042; §07.0 closing SHA for BUG-04-085) - Move plan directory from
bug-tracker/plans/BUG-04-NNN/tobug-tracker/plans/completed/BUG-04-NNN/
- Set
-
Atomic tracker flip via
scripts/plan_corpus/bug_tracker/api.py:flip_bug_status:- Removes entry from
bug-tracker/open-bugs.json - Appends entry to
bug-tracker/closed-bugs.json - Writes write-ahead journal at
bug-tracker/_inflight/BUG-04-NNN.jsonBEFORE source mutation perstate-discipline.md §4cross-file flip discipline - Lock-order: acquire
closed-bugs.json.lockBEFOREopen-bugs.json.lock(alphabetic)
- Removes entry from
-
Update
bug-tracker/00-overview.md:- Decrement open bug count by 4
- Increment closed bug count by 4
- Add HISTORY entry:
YYYY-MM-DD — plans/typeck-inference-completeness/ §07.4 closed BUG-04-074, BUG-04-084, BUG-04-042, BUG-04-085 atomically via api.flip_bug_status; resolution summaries above.
-
Update
bug-tracker/section-04-codegen-llvm.md(or wherever the four bugs are tracked in section-scoped trackers):- Mark each entry as
[x]resolved - Add plan pointer per the table above
- Mark each entry as
Verification. After §07.4 atomic flip:
-
bug-tracker/open-bugs.jsonno longer contains BUG-04-074, BUG-04-084, BUG-04-042, BUG-04-085 entries. -
bug-tracker/closed-bugs.jsoncontains all four entries withstatus: complete+resolved_in:populated + plan pointer populated. -
bug-tracker/_inflight/is empty (no orphaned journal entries — successful flip cleans up). -
python -m scripts.plan_corpus check bug-tracker/reports zeroBUG_BLOCKER_DEAD_REF/BUG_BLOCKER_CYCLEfindings (closed bugs remain referenceable via the supersession pointer chain).
07.R Third Party Review Findings
Round 2 — Dual-source TPR on sections 05, 06, 07 (Codex + Gemini). Findings addressed in this revision.
[[TPR-07-001-codex]] [MEDIUM] Scope the annotation cleanup sweep to this plan’s markers and all affected trees
Location: plans/empty-container-typeck-phase-contract/section-07-closeout.md:77
Reviewer: Codex | Status: Fixed
Evidence: Section 07 originally grepped compiler/ for
BUG-04-074|empty-container-typeck|§01|§02|§03|§04. That misses temporary plan comments
in spec tests (section-05-test-matrix.md instructs implementers to add Regression: BUG-04-074 comments under tests/spec/...). It also produces unrelated false-positive
hits because generic §03/§04 markers already exist in
compiler/ori_repr/src/narrowing/tests.rs:1 and compiler/ori_parse/src/dispatch.rs:134
(from a different plan).
Fix: Split the sweep into two targeted commands that use only plan-specific identifiers
(BUG-04-074|empty-container-typeck) and cover both compiler/ and tests/. Dropped
generic §NN tokens from the pattern to eliminate false positives from unrelated plans.
Updated the success_criteria in the frontmatter to match.
[[TPR-07-002-gemini]] [LOW] Expand plan annotation cleanup regex to cover all sections
Location: plans/empty-container-typeck-phase-contract/section-07-closeout.md:77
Reviewer: Gemini | Status: Fixed (subsumed by TPR-07-001-codex)
Evidence: Section 07.2 used a regex that explicitly omitted §05, §06, and §07.
If developers left code annotations referencing those sections, the final cleanup sweep
would miss them.
Fix: Same as TPR-07-001-codex — the updated sweep uses plan-specific identifiers only
(BUG-04-074|empty-container-typeck) which covers all sections by design: any
annotation referencing this plan’s work will include the bug ID or plan name.
[[TPR-07-003-codex]] [MEDIUM] Add a whole-plan corpus validation gate before close-out
Location: plans/empty-container-typeck-phase-contract/section-07-closeout.md:104
Reviewer: Codex | Status: Fixed
Evidence: Section 07’s final gate originally ran only /tpr-review and
/impl-hygiene-review. The command
python -m scripts.plan_corpus check plans/empty-container-typeck-phase-contract/
currently fails on index.md, section-01-value-restriction.md,
section-02-validator-module.md, and section-04-codegen-assertions.md. Without an
explicit gate, Section 07 could declare the plan complete while the owning plan directory
is still schema-invalid to the plan tooling.
Fix: Added python -m scripts.plan_corpus check plans/empty-container-typeck-phase-contract/
as the first step in 07.4. The gate must pass before TPR or hygiene review proceeds.
Also added to the 07.N checklist as an explicit - [ ] item.
Round 3 — Dual-source TPR on sections 05, 06, 07 (Codex + Gemini). Findings addressed in this revision.
[[TPR-07-004-codex]] [MEDIUM] Sweep library/ directory for plan markers during close-out
Location: plans/empty-container-typeck-phase-contract/section-07-closeout.md:§07.2
Reviewer: Codex | Status: Fixed
Evidence: Section 06.3 directs implementers to annotate library/std/ code. Section 07.2
only swept compiler/ (with *.rs filter, missing .ori AOT fixtures) and tests/. The
library/ tree was entirely missing from the cleanup sweep.
Fix: Added two new sweep commands: one for compiler/ --glob '*.ori' (AOT fixtures) and
one for library/ --glob '*.ori' (stdlib). Updated success_criteria to reference all four
trees. Updated 07.N checklist to explicitly call out all four trees.
[[TPR-07-005-codex]] [MEDIUM] Add release ori_llvm test and section-04 tracker update to 07.N
Location: plans/empty-container-typeck-phase-contract/section-07-closeout.md:§07.N
Reviewer: Codex | Status: Fixed
Evidence: Section 07.1 specifies cargo test --release -p ori_llvm but the 07.N checklist
item for “07.1 complete” only said “./test-all.sh green debug + release”. Section 07.3 (now
07.4) step 3 requires updating bug-tracker/section-04-codegen-llvm.md but the 07.N
checklist for “07.3 complete” (now “07.4 complete”) omitted this.
Fix: Updated 07.N “07.1 complete” item to include cargo test --release -p ori_llvm. Updated
“07.4 complete” item to explicitly include bug-tracker/section-04-codegen-llvm.md resolution.
[[TPR-07-006-gemini]] [HIGH] Reorder 07.3/07.4 so validation gates run before bug-tracker closure
Location: plans/empty-container-typeck-phase-contract/section-07-closeout.md:§07.3/07.4
Reviewer: Gemini | Status: Fixed
Evidence: Section 07.3 was “Bug-Tracker Updates” (marks BUG-04-074 complete) and 07.4 was
“Final TPR + Hygiene Gate”. This ordering allows the bug to be declared resolved in external
trackers before the final /tpr-review and /impl-hygiene-review pass. If a gate fails after
the tracker is updated, the tracker is out of sync.
Fix: Swapped 07.3 and 07.4: 07.3 is now “Final TPR + Hygiene Gate” and 07.4 is “Bug-Tracker Updates (runs AFTER 07.3 validation passes)”. Added explicit note in 07.4 header that bug trackers must only be updated after 07.3 passes. Updated frontmatter sections list and success_criteria to reflect the new ordering.
[[TPR-07-007-gemini]] [LOW] section-04-codegen-llvm.md missing from 07.N 07.3 checklist item
Location: plans/empty-container-typeck-phase-contract/section-07-closeout.md:§07.N
Reviewer: Gemini | Status: Fixed (subsumed by TPR-07-005-codex)
Evidence: The 07.N completion checklist for the bug-tracker step only listed
bug-tracker/plans/BUG-04-074/ and 00-overview.md, omitting the section-04-codegen-llvm.md update
that step 3 of the bug-tracker section explicitly requires.
Fix: Same as TPR-07-005-codex — the updated 07.N checklist for “07.4 complete” now
explicitly includes bug-tracker/section-04-codegen-llvm.md entry resolved.
Round 4 — Dual-source TPR on sections 05, 06, 07 (Codex + Gemini). Findings addressed in this revision.
[[TPR-07-R4-001-codex]] [MEDIUM] /improve-tooling and /sync-claude dropped from 07.3 and 07.N
Location: plans/empty-container-typeck-phase-contract/section-07-closeout.md:§07.3
Reviewer: Codex | Status: Fixed
Evidence: 00-overview.md:165 and index.md:119 both specify Phase 6 / Section 07
close-out as /tpr-review → /impl-hygiene-review → /improve-tooling sweep → /sync-claude.
After the 07.3/07.4 reorder in Round 3, the implementation of 07.3 and the 07.N checklist
only included /tpr-review and /impl-hygiene-review. Both /improve-tooling and
/sync-claude were silently dropped, leaving the section cross-inconsistent with the
approved overview and creating two unanchored mandatory close-out tasks.
Fix: Added /improve-tooling and /sync-claude blocks to 07.3 body with instructions
for each. Updated the success_criteria to name all five gates. Updated the 07.N “07.3
complete” checklist item to explicitly list /improve-tooling and /sync-claude.
07.R — Third Party Review Findings (Round 5 cap-exit — 2026-05-15)
Round 5 — /tpr-review cap-exit at cap_reached_max_rounds (5 rounds). Dual-source reviewer set (codex + gemini); opencode in transport failure → survivor mode 2-of-3. Three actionable findings filed below for resolution before §07 close-out.
-
[TPR-07-R5-001-codex][HIGH] DRIFT — §07.4 atomic-flip transaction description stale: all four bugs already in
closed-bugs.json- Location:
section-07-closeout.md:352(§07.4 body — “Atomic-flip discipline” paragraph) - Evidence:
bug-tracker/closed-bugs.jsonalready contains BUG-04-042 (line 68,status: resolved,resolved_date: 2026-05-14), BUG-04-074 (line 99), BUG-04-084 (line 119), BUG-04-085 (line 621) — each withplan_dir: bug-tracker/plans/completed/BUG-04-NNN/.bug-tracker/open-bugs.jsoncontains no"id":lines for the four bugs.bug-tracker/section-04-codegen-llvm.mdmarks all four[x]. §07.4 body still describes the flip as a future transaction (“All four bug-tracker entries flip fromopen-bugs.jsontoclosed-bugs.json”) even though §07.4 hasstatus: not-startedand the flips are already complete elsewhere. - Rule violated:
.claude/rules/impl-hygiene.md— DRIFT;.claude/rules/state-discipline.md §4(atomic-flip ownership, cross-file flip discipline) - Recommended fix: Rewrite §07.4 body to “verify already-complete flip state” (no-op transaction); list each bug + its closed-bugs.json line; add a verification checklist that confirms (a) all four in closed-bugs.json with
status: resolved, (b) zero in open-bugs.json, (c) plan_dirs atbug-tracker/plans/completed/, (d)bug-tracker/_inflight/empty. Update §07.4 title from “Bug-Tracker Updates — Close ALL FOUR Bugs Atomically” to “Bug-Tracker Updates — Verify ALL FOUR Bugs Closed Atomically”. Recompute counts from the JSON. Reconcile resolved-by-whom: file a HISTORY block at the bottom of00-overview.mddocumenting which prior workflow / session performed the flip outside §07.4 scope (audit trail). NO content-level fix to closed-bugs.json itself required — the flip already executed correctly.
- Location:
-
[TPR-07-R5-002-codex][MEDIUM] PLAN_COHERENCE_DRIFT —
00-overview.mdQuick Reference table shows §07 asNot Startedbut section frontmatter isstatus: in-review- Location:
plans/typeck-inference-completeness/00-overview.md:390 - Evidence:
00-overview.md:390row reads| 07 | Close-out + Supersession (absorbs BUG-04-085 investigation) | section-07-closeout.md | Not Started |.section-07-closeout.md:5carriesstatus: in-review.index.md:128carriesStatus: In Review. The umbrella overview is the only surface still showingNot Started. - Rule violated:
.claude/rules/impl-hygiene.md— PLAN_COHERENCE_DRIFT - Recommended fix: Update
00-overview.md:390Quick Reference row to| 07 | Close-out + Supersession (absorbs BUG-04-085 investigation) | section-07-closeout.md | In Review |. No body changes needed.
- Location:
-
[TPR-07-R5-003-gemini][MEDIUM] PLAN_COHERENCE_DRIFT:mixed-working-directory — §07.1 + §07.2.a bash blocks use wrapper-root-relative paths without
compiler_repo/prefix orcd compiler_repo- Location:
section-07-closeout.md:146-150(test-all.sh + cargo blocks);:154-174(dual-exec-verify.sh blocks);:201-214(rg sweep blocks) - Evidence: Per CLAUDE.md Repo Layout — “wrapper-root relative; compiler-owned carry
compiler_repo/prefix. Compiler harnesses (./test-all.shetc.) run incompiler_repo/; wrapper cmds (python -m scripts.plan_corpus, …) from wrapper root.” The bash blocks at lines 146-150 invoke./test-all.shandcargo test, lines 154-174 invokediagnostics/dual-exec-verify.sh tests/spec/..., and lines 201-214 invokerg ... compiler/ .../rg ... tests/ .../rg ... library/ ...— all wrapper-root-relative. Adjacent §07.3 block at line 278 invokespython -m scripts.plan_corpus check plans/typeck-inference-completeness/which DOES run from wrapper root. Implementer reading top-to-bottom hits an inconsistent working directory and either prefixes wrong orcds wrong. - Rule violated:
.claude/rules/impl-hygiene.md §Finding Categories— PLAN_COHERENCE_DRIFT:mixed-working-directory - Recommended fix: Prefix each bash block with an explicit
cd compiler_repoline (for blocks at 146-150, 154-174, 201-214) OR rewrite each path withcompiler_repo/prefix (compiler_repo/diagnostics/dual-exec-verify.sh compiler_repo/tests/spec/...,compiler_repo/compiler/,compiler_repo/tests/,compiler_repo/library/). Pick thecd compiler_repoform for consistency with./test-all.shinvocation (which is naturally relative). Leave §07.3python -m scripts.plan_corpusblocks unchanged (wrapper-root native). Add a one-line note above the firstcd compiler_repoblock: “Working directory:compiler_repo/for compiler harnesses and tree-relative paths; wrapper root forpython -m scripts.plan_corpusinvocations.” for implementer clarity.
- Location:
07.N Completion Checklist
- 07.PRE complete — every predecessor (§01, §02, §03, §04, §05, §06, §08, §09, §10, §11) carries
status: complete+reviewed: true;python -m scripts.plan_corpus check plans/typeck-inference-completeness/returns zeroSTRUCTURE:work-order-violationfindings - 07.0 complete — BUG-04-085 LLVM spec runner crash resolved (Path A §02.0 downstream consumer fixed, OR Path B §07.0.A residual cure shipped);
timeout 150 ./test-all.shno longer showsOri spec (LLVM backend) CRASHED; 00-overview.mdKnown BugsBUG-04-085 row + HISTORY updated - 07.1 complete —
./test-all.shgreen debug + release;cargo test --release -p ori_typesgreen;cargo test --release -p ori_llvmgreen; dual-exec parity verified on the 8 representative paths covering §05 empty-list corpus + §09.3/§09.5 (str_to_error.ori) + §09.4 (iterator/methods.ori) + §10.1 (declarations/traits.ori) + §10.2 (capabilities/propagation.ori) + §11.1 (empty_literals/) - 07.2.a complete — zero
BUG-04-074|BUG-04-084|BUG-04-042|BUG-04-085|empty-container-typeck|typeck-inference-completenesshits in all four trees:compiler/*.rs,compiler/*.ori(AOT fixtures),tests/*.ori,library/*.ori - 07.2.b complete —
@mk_ok/@mk_errhelpers removed fromtests/spec/traits/traceable/definition.ori+tests/spec/traits/traceable/result_delegation.ori; both files green under direct-constructor form after §09.3 shipped; §06.2C table + §03.N ledger updated to reflectREMOVED (direct form, §09.3 closed gap) - 07.2.c complete — R7-006 validator refinement shipped:
site_from_expr_kinddiscriminates Lambda return-vs-param viaVarPositionthreading atvalidators/mod.rs:204call site; positive + negative test pair landed; §06.1 wording success criterion updated - 07.3 complete —
plan_corpus check plans/typeck-inference-completeness/passes; final/tpr-reviewclean (scope: §01–§06, §07.0, §07.0.A if any, §07.2.a/§07.2.b/§07.2.c, §08–§11);/impl-hygiene-reviewclean (same scope);/improve-toolingsweep clean (covers §07.0 tooling gaps + §07.2.c diagnostic infrastructure + §08–§11 surfaces);/sync-claudesweep clean (typeck.md §BD-2 + §EX-4 + §DI-1; canon.md §4.2 PC-2; bug-tracker/00-overview.md count) - 07.4 complete — atomic flip via
api.flip_bug_statusfor ALL FOUR bugs:bug-tracker/plans/completed/BUG-04-074/+BUG-04-084/+BUG-04-042/+BUG-04-085/each carrystatus: complete+ plan pointer +resolved_in:SHA;bug-tracker/open-bugs.jsonno longer contains the four;bug-tracker/closed-bugs.jsoncontains all four;bug-tracker/_inflight/empty;bug-tracker/00-overview.mdopen-count decremented by 4;bug-tracker/section-04-codegen-llvm.mdentries marked[x]with plan pointers - This section’s own status flipped from
in-reviewtocompletein frontmatter viaflip_from_in_review_clean()perstate-discipline.md §4(after umbrella00-overview.mdclose-out completes — final flip in line below) -
plans/typeck-inference-completeness/index.mdupdated: all sections showstatus: complete; umbrella00-overview.mdstatus:flipped fromin-progresstocomplete
Exit criteria: BUG-04-074, BUG-04-084, BUG-04-042, BUG-04-085 all formally closed. The typeck inference completeness plan is complete. Empty-container typeck phase-contract enforcement, cross-module pool-merge var_id collision, LLVM spec-runner crash on monomorphized assert_eq, body-inference BD-2 gaps (§09), dispatch-on-rigid-receiver gaps (§10), polymorphic-constructor defaulting fallback (§11) — all no longer block the Ori compiler.