100%

intel_repo Producer Re-Calibration

Goal

Make the precomputed hygiene flags trustworthy for Ori at the SOURCE: today phase_order_violation fires on ~70% of Ori symbols and is_layering_violation is all-false — both unusable raw. Re-derive both against the canon.md pipeline crate-rank so they carry real signal, threshold-markered in intel_repo/CLAUDE.md per the _load_* SSOT pattern.

Implementation Sketch

In intel_repo/neo4j/gds_enrich.py / metrics_thresholds.py, recompute is_layering_violation as a CALLS back-edge against the canon.md crate rank — a call whose caller crate ranks strictly LOWER than the callee crate (a lower layer depending on a higher one), EXCLUDING calls into rank-0 foundations (ori_ir/ori_diagnostic/ori_registry, universally depended upon and never a layering violation). Two preconditions make the recomputed flag carry real signal:

  1. Artifact-filter the CALLS substrate before computing back-edges. The raw cross-crate CALLS substrate is artifact-polluted: Environment::collect alone absorbs 674 edges, and the .collect/.pop/.take/.cmp/.keys/.values method sinks resolve to std/iterator combinators rather than real inter-crate dependencies. Excise this combinator-sink set from the edge population first; without the filter the recalibrated flag manufactures false layering violations into ori_eval/ori_patterns.
  2. The crate-rank map MUST be total over all 19 compiler crates, not the 8 pipeline crates alone. Pipeline rank: ori_lexer_core < ori_lexer < ori_parse < ori_types < ori_canon < ori_arc < ori_repr < ori_llvm. ori_eval/ori_patterns are llvm-peer backends (same rank tier as ori_llvm). ori_ir/ori_diagnostic/ori_registry are rank-0 FOUNDATIONS (not pipeline phases — the rank-model error this session proved load-bearing). Off-pipeline crates ori_rt/ori_fmt/oric/ori_test_harness/ori_stack/ori_compiler carry explicit ranks so no firing crate is left undefined. The back-edge test is undefined for any crate absent from the map.

Recompute phase_order_violation symmetrically over the SAME artifact-filtered substrate + crate-rank map: a symbol fires only when one of its OWN outbound CALLS crosses the pipeline rank FORWARD — a callee whose crate ranks strictly HIGHER than the caller’s (an earlier-phase crate such as ori_lexer reaching into a later phase such as ori_llvm), so the legal directions never fire: calls into rank-0 foundations (ori_ir/ori_diagnostic/ori_registry, callee rank 0 is never strictly higher) and later-phase-to-earlier-phase calls (callee rank lower) both pass, replacing the per-symbol crate-cycle-membership stamp (_propagate_crate_phase_order) that currently fires on every symbol in any cycle-member crate (the ~70% over-fire). Add a **layering_crate_rank = ...** bold marker in intel_repo/CLAUDE.md read by a _load_* helper that lands in metrics_thresholds.py (mirrors the proven _load_hub_threshold SSOT loader there), with tests in intel_repo/tests/.

Spec References

intel_repo/CLAUDE.md GDS metrics-layer thresholds (_load_* SSOT; hardcoded float = DRIFT:hardcoded-threshold); canon.md §1 pipeline crate order; impl-hygiene.md LEAK:phase-bleeding.

Work Items

  • Add the canonical crate-rank SSOT as a marker in intel_repo/CLAUDE.md + a _load_* helper in metrics_thresholds.py; the rank map MUST be total over all 19 compiler crates (pipeline ori_lexer_core<ori_lexer<ori_parse<ori_types<ori_canon<ori_arc<ori_repr<ori_llvm, ori_eval/ori_patterns as llvm-peer backends, ir/diagnostic/registry as rank-0 foundations, off-pipeline ori_rt/ori_fmt/oric/ori_test_harness/ori_stack/ori_compiler carrying explicit ranks) so the back-edge test is defined for every firing crate
  • Recompute is_layering_violation as a pipeline back-edge (caller crate rank strictly LOWER than callee crate rank — a lower layer depending on a higher one — EXCLUDING edges into rank-0 foundations, which are universally depended upon) over the artifact-filtered CALLS substrate (excise the .collect/.pop/.take/.cmp/.keys/.values combinator-sink set + Environment::collect, which otherwise inject ~674 spurious edges into ori_eval/ori_patterns); confirm population is precise (fires on a small, real set, not all-false, with zero combinator-artifact false positives)
  • Recalibrate phase_order_violation as a per-symbol forward-edge test over the artifact-filtered substrate + crate-rank map (a symbol fires only when its own outbound CALL targets a strictly-HIGHER-rank crate — an earlier phase reaching forward into a later phase; calls into rank-0 foundations and later-to-earlier calls never fire), replacing the crate-cycle-membership stamp so it no longer fires on the majority of Ori symbols
  • intel_repo pytest covering both recalibrated flags + the threshold-marker loader, INCLUDING a live-precision test (intel_repo/tests/test_calibration_precision.py) that asserts against the real enriched graph (not a mocked fixture): phase_order_violation fires on <5% of Ori symbols, is_layering_violation fires on 1<=count<=50 symbols (not all-false), and zero combinator-artifact false positives survive the filter — the section success_criterion probe runs THIS test, so a mocked-shape unit test alone does NOT satisfy the gate