100%

Provenance edge set (structure + mono + resolution)

Goal

Assemble the FULL provenance edge set for one root Idx in ori_types: structure edges + monomorphization edges (body_type_map) + resolution edges (Pool.resolutions), plus a generic-leaf divergence detector that flags the #217-vs-#231 shape. This is the SSOT edge collection the whole diagnostic reads.

Implementation Sketch

The provenance edges for the bug class ALREADY EXIST in the compiler — only assembly + rendering were missing. Consume MonoInstance.body_type_map (output/mono.rs) and build_mono_body_type_map (pool/substitute/body_type_map.rs) for (source_idx -> substituted_idx); Pool.resolutions for Named/Applied -> concrete. All reads, no mutation.

Spec / Rule References

compiler/ori_types/src/output/mono.rs (MonoInstance, MonoInstanceId, mono_dispatch_map); compiler/ori_types/src/pool/substitute/body_type_map.rs; .claude/rules/types.md TY-2 (resolutions); .claude/rules/tests.md §Matrix Testing Rule.

Test Strategy

TDD fail-first matrix: nesting {struct-in-struct, enum-in-enum, struct-in-enum, enum-in-struct} x {clean-monomorphic, generic-leaf-divergent}; assert per-cell edge sets + divergence flag; self-verifying count assertion that every cell is visited.

Work Items

  • Formalize STRUCTURE edges as a typed StructureEdge { parent_idx, field_name, child_idx } over struct_fields/enum_variants (lift the skeleton walk into the SSOT edge collector).
  • MONOMORPHIZATION edges: consume MonoInstance/MonoFunction.body_type_map (compiler/ori_types/src/output/mono.rs, compiler/ori_types/src/pool/substitute/body_type_map.rs) as MonoEdge { source_idx, substituted_idx }; key into the DAG by root + nested Idx.
  • RESOLUTION edges: Named/Applied -> concrete from Pool.resolutions as ResolutionEdge { applied_idx, concrete_idx } (read via the pool resolution accessor; NEVER mutate).
  • GENERIC-LEAF divergence detector: flag a node whose resolve_fully body carries a generic-param leaf (Tag::Named/BoundVar/RigidVar) while a sibling/parallel instantiation of the same surface type resolves to a concrete body — the #217-vs-#231 shape (Wrap#217{inner: T#141} vs concrete #231{inner: int#0}).
  • Matrix tests (TDD, fail-first): nesting {struct-in-struct, enum-in-enum, struct-in-enum, enum-in-struct} x {clean-monomorphic, generic-leaf-divergent}; assert edge sets + the divergence flag per cell; count-assert all cells visited.

Fresh intel (regenerated)

{ “schema_version”: 1, “target”: { “kind”: “plan-section”, “ref”: “idx-provenance-diagnostic/s-95bb9dfd” }, “generated_at”: “2026-06-28T02:30:42.946094+00:00”, “graph_state”: { “head_sha”: “8340d7a0”, “last_code_import_at”: “2026-06-28T02:25:32.559Z”, “embedding_stale”: false, “insights_stale”: false, “cpg_stale”: false }, “surfaces”: {}, “summary”: “intel-package[plan-section:idx-provenance-diagnostic/s-95bb9dfd] agent-authored dossier”, “degraded”: false, “dossier”: { “objective_symbols”: [], “tiers”: {}, “agent_authored”: true, “constrained_symbols”: [ “substitute_in_pool”, “resolve_fully”, “resolve_fully_guarded”, “set_resolution” ], “difficulty”: { “class”: “routine”, “research_online”: false, “research_mode”: “auto”, “signals”: [], “plan_dir”: “/home/eric/projects/ori_lang/plans/idx-provenance-diagnostic” } } }

(full dossier: provenance-edges—s-95bb9dfd.intel.json)