diff --git a/docs/audit/r3-debt-sweep-2026-05-06.md b/docs/audit/r3-debt-sweep-2026-05-06.md index 41a834c29e8..9131dc38426 100644 --- a/docs/audit/r3-debt-sweep-2026-05-06.md +++ b/docs/audit/r3-debt-sweep-2026-05-06.md @@ -1,6 +1,6 @@ -# R3 Debt Sweep — 2026-05-06 +# R3 Debt Sweep — 2026-05-06 (Phase 1 organize 2026-05-09) -**Status:** **Framework draft** — Phase 1 of 3-phase sweep per Director dispatch at [gunbc#828 #issuecomment-4383739792](https://github.com/gunb-ai/gunbc/issues/828#issuecomment-4383739792). PM-authored §1 schema + §3 eligibility rubric + §4 anticipation discipline; awaiting Director ratification before Phase 2 (parallel Mgr canvas dispatch). +**Status:** **Framework draft + initial Class A-G + new Class P populated 2026-05-09** — Phase 1 organize cycle completed by Debt-Paydown Mgr (gentle-newt-665) per PM dispatch at gunb-ai/gunbc#846 (Brian operator directive 2026-05-09 ~20:30Z; lane scope expanded to all v3 debt + active posture). Class A-G rows seeded from `docs/audit/v3-comprehensive-debt-audit-2026-05-09.md` 10-source inventory + ROADMAP `## Tracked debts` rows + §10.3 §1.8 ledger cross-references + 4 stranded bug-fix briefs (PR #2373) + 6 gpt-5-5-pro novel findings (PR #2358 §8). Class P NEW per Brian directive — past-R3 / R4+ ambition parking lot. Mgr re-organize cycle continues; row population is initial pass, not exhaustive. **Authority:** Brian-ratified scope at gunbc#828 (Director-relayed): 1. **v2 retirement folded into R3** (was separate Pure-Bootstrap-Zero / T-PB-A + T-PB-B program) @@ -38,43 +38,156 @@ Column rules (load-bearing): Bridges that exist because a substrate carrier or grammar surface isn't yet modeled. Wait for parser/grammar surface, function-valued data, file-ingestion, workflow/scheduling, reflection-closure. -[Mgr canvas populates rows] +Initial population 2026-05-09 per Brian-directive lane scope expansion (PM dispatch at gunbc#846 → gentle-newt-665 organize cycle): + +| Bridge | Class | File / location | Dissolution trigger | R3-close eligibility | Source PR | Owner Mgr | +|---|---|---|---|---|---|---| +| `parse_parser_body.txt` 1350-LOC recursive-descent algorithm | A | `src/v3/compiler/parse_parser_body.txt` | SG-2b proper `parse.dag` ownership lands | YELLOW | #589 | Substrate | +| `Bool` inhabits `BooleanAlgebra` not wired (Class 5 Gap 1) | A | `dsl/std/bool.dag` + lower.rs | 1e-2b lane Path A landing | YELLOW | pre-R3 | Substrate | +| `data` body shape boundary (Class 5 Gap 3 — ValueBody extension) | A | `lower.rs:3514-3604` + emit.rs ValueBody::Structural | ValueBody substrate extension lane | YELLOW | pre-R3 | Substrate | +| Function-valued data not first-class (Class 2 Gap) | A | `dsl/std/algebra.dag:168-181` Semiring deferred witness | T-E-P-Producer-Broadening Phase 1 / S10 | DECLARED §1.8 #61 | pre-R3 | Substrate | +| File-ingestion substrate gap (`.dag` consumes external files w/o include_str) | A | T-Workflow-As-Data lane | §1.8 #62 substrate_gap_file_ingestion_closed | DECLARED | pre-R3 | Substrate | +| Workflow/scheduling substrate gap (CI workflow as `.dag` data) | A | T-Workflow-As-Data + T-Lens-Self-Application | §1.8 #63 substrate_gap_workflow_scheduling_closed | DECLARED | pre-R3 | Substrate | +| Reflection-closure substrate gap (`lens_apply.rs` reflection via PB-Runtime) | A | T-LensProducer-Retirement | §1.8 #64 substrate_gap_reflection_closure_closed | DECLARED | pre-R3 | PB | +| Parser/grammar substrate gap (typed numerics + algebra-machine-constraint) | A | `src/v3/spec/rust.dag` + numeric carriers | §1.8 #60 substrate_gap_parser_grammar_closed (Int<64>/Real<64>/Nat<8> evidence) | DECLARED | pre-R3 | Substrate | +| `IntLit` host-narrowed at tokenizer boundary; `i64::MIN` unrepresentable | A | `src/v3/std/tokenize.dag:30` IntLit(Int) | unbounded-magnitude IntLit at concept layer; reconciliation-narrows | YELLOW | pre-R3 | Substrate | +| Domain refinements regressed pending Q-Regex-Primitive | A | `dsl/std/types.dag` CommitSha/Sha256/Email/Url/SemVer/Timestamp/MimeType | regex/content predicate grounding | YELLOW | pre-R3 | Substrate | +| `KNOWN_PREDICATES` Rust-side semantic authority (string carrier names) | A | `lower.rs` KNOWN_PREDICATES | substrate-reflection / `.dag` predicate declarations | YELLOW | abf5f24d | Substrate | +| Constructor ambient prefix scan in lower.rs | A | `lower.rs` payload-lookup | `TransformTarget::Callable` outer-type metadata | YELLOW | pre-R3 | Substrate | +| PathCall resolution source-order fragile | A | PathCall lowering tests | order-independent ValueBody population OR explicit declaration-order semantics | YELLOW | pre-R3 | Substrate | +| `MethodContract.size_effect` substrate-shape | A | `dsl/std/method_contract.dag` | typed size-effect carrier | YELLOW | pre-R3 | Substrate | +| `MethodContract.cost_shape` substrate-shape | A | `dsl/std/method_contract.dag` | typed cost-shape carrier (post-T-CostLens) | YELLOW | pre-R3 | Substrate | +| `MethodContract.callback_element_position` substrate-shape | A | `dsl/std/method_contract.dag` | typed callback-position carrier | YELLOW | pre-R3 | Substrate | +| Character-level under-consumption in tokenize + syntax | A | tokenize.dag + syntax authorities | character-class substrate refinement | YELLOW | #693 | Substrate | +| Unit-mismatch enforcement for phantom Unit/Currency typed wrappers | A | typed value wrappers | phantom-parameter unit-discipline carrier | YELLOW | pre-R3 | Substrate | +| `Secret` nominal-wrapper graduation | A | nominal-opacity carriers | Secret PR A continuation per #900 | YELLOW | #900 | Substrate | ### Class B — Pattern-A NYI predicates (~7 expected) Test predicates declared but `NotYetImplemented`-shaped runtime: TC1, TC2, TC3, free-consequences, RustDagIsomorphism, BridgeLedgerZero, SymbolicCostExprEquals. -[Mgr canvas populates rows; some entries pre-named per Director framework] +| Bridge | Class | File / location | Dissolution trigger | R3-close eligibility | Source PR | Owner Mgr | +|---|---|---|---|---|---|---| +| TC1 η-equivalence executable (#11) | B | `r3-program-plan.md:212` §1.8 #11 | Evaluator E3.c #1970 merge → DECLARED→PASSING | DECLARED (HOLD branch B) | #2184 | Verification | +| TC2 Church-Rosser executable (#12) | B | §1.8 #12 | second strategy/input order + strategy-keyed report | DECLARED | pre-R3 | Verification | +| TC3 Pattern-A second-mover executable (#13) | B | §1.8 #13 | Descent execution proof (E5) + eval-step producer | DECLARED | pre-R3 | Verification | +| RustDagIsomorphism executable (#14) | B | §1.8 #14 | shape-report producers | DECLARED | pre-R3 | Verification | +| BridgeLedgerZero ratchet ledger-count (#36) | B | §1.8 #36 | unified ledger reports 0 | DECLARED | pre-R3 | Debt-Paydown | +| SymbolicCostExprEquals executable (#40) | B | §1.8 #40 + test_runner.rs | cost-lens consumer per ε path | DECLARED | pre-R3 | Verification | +| Free-Consequences demonstrations (#43-#52, 10 gates) | B | §1.8 #43-#52 | bind-independence/dependence parallelism + auto-memoization demos | DECLARED | pre-R3 | Verification | +| `resolve_producer_opt` typed return (P3 fail-closed violation) | B | brief: `r3-bug-resolve-producer-opt-typed-return-worker.md` | dispatch worker; typed Result | YELLOW | #2373 brief | Verification | ### Class C — Pattern-C typed-carrier + Rust-mirror (~6+ expected) Rust mirrors of `.dag` typed carriers that should dissolve when v3 evaluator authoritatively executes the .dag side: EmissionDiagnostic, Value, EvalStrategy, BridgeLedgerRef, target-primitive routing. -[Mgr canvas populates rows] +| Bridge | Class | File / location | Dissolution trigger | R3-close eligibility | Source PR | Owner Mgr | +|---|---|---|---|---|---|---| +| u128 grounding-pilot Rust mirror drift | C | `src/v3/grounding_pilot/src/lib.rs:6-8,256-265` ↔ `dsl/extdeps/languages/rust/primitives.dag:274-277` | dispatch worker brief; ratchet test or structural consumption | YELLOW | brief #2373 | Substrate | +| FieldProject dual-authority (`field_label` ↔ `field_child` disagreement) | C | `dag.rs:1890-1892` + `infer.rs:4198-4208` | UnresolvedFieldProject/ResolvedFieldProject lifecycle split | YELLOW | brief #2373 | Substrate | +| CallGraph forward-only authority (illegal-state-representable in product) | C | brief: `r3-bug-callgraph-forward-only-authority-worker.md` | dispatch worker | YELLOW | brief #2373 | Substrate | +| `MissingEmissionPath` stringifies typed axes (connective/behavior/target as String) | C | gpt-5-5-pro Finding 1 | typed-carrier diagnostic boundary | YELLOW | PR #2358 | Substrate | +| `ComposedEffect { idempotent, breaking_operation }` illegal product | C | gpt-5-5-pro Finding 5 | sum-typed effect-composition carrier | YELLOW | PR #2358 | Substrate | +| `derive_op_effect(method_str, path_str)` string parser at structural boundary | C | gpt-5-5-pro Finding 6 | typed dispatch over Method × Path carriers | YELLOW | PR #2358 | Substrate | +| `EmitModelVariants` manually-enumerated cache (label-string mirror) | C | `dag.rs` EmitModelVariants | generate from `emit_model.dag` OR exhaustiveness ratchet | YELLOW | pre-R3 | Substrate | +| `EmissionDiagnostic` Rust mirror | C | `src/v3/compiler/src/diagnostics.rs` | v3 evaluator authoritative on diagnostic emission | YELLOW | pre-R3 | Substrate | +| `Value` Rust mirror | C | `src/v3/compiler/src/value.rs` | v3 evaluator value-domain authority | YELLOW | pre-R3 | Substrate | +| `EvalStrategy` Rust mirror | C | `src/v3/compiler/src/eval/` | strategy-keyed `.dag` authority | YELLOW | pre-R3 | Substrate | +| Reflected witness carriers forgeable (ParamRef/TransformRef/ElementRef/BoolPortRef) | C | `src/v3/std/substrate.dag:337-374` + `effects.dag:447-530` | substrate-level proof-carrying handles or constructor parity | YELLOW | b09e0c8 | Substrate | +| `ValueBody` Rust↔.dag mirror drift (no isomorphism gate; partially CLOSED via #2288) | C | gate #96 substrate_value_body_mirror_isomorphism | further Tier-3 retirement | CONSUMER_LANDED §1.8 #96 | #2288 | Substrate | +| `FieldMap` duplicate-free invariant lost in `.dag` mirror | C | NOVEL row 2026-04-30 | duplicate-free typed carrier | YELLOW | pre-R3 | Substrate | +| Operator inference `(T,T)→T` arrow fabrication on algebra-walk failure | C | gpt-5-5-pro NOVEL 2026-04-30 | fail-closed structural diagnostic | YELLOW | pre-R3 | Substrate | +| Duplicate record-literal fields silently accepted | C | NOVEL highest-value 2026-04-30 | typed second-write fail-closed | YELLOW | pre-R3 | Substrate | ### Class D — Generated bridges with freshness gates (~3-5 expected) Generated artifacts that would be debt without freshness ratchets but are bounded scaffolds with explicit regeneration gates: `render_repeat_string_bootstrap.dag`, `generated_method_template_projection.rs`. **Not debt by intent**; freshness gate prevents drift. May still be GREEN at R3 close if R3-close includes v2 retirement (which it now does per Brian-ratified fold-in). -[Mgr canvas populates rows] +| Bridge | Class | File / location | Dissolution trigger | R3-close eligibility | Source PR | Owner Mgr | +|---|---|---|---|---|---|---| +| `render_repeat_string_bootstrap.dag` generated scaffold | D | `dsl/std/render_repeat_string_bootstrap.dag` | v2 retirement closes | GREEN | pre-R3 | Substrate | +| `generated_method_template_projection.rs` | D | grounded mirror | v2 retirement closes | GREEN | pre-R3 | Grounding | +| `slow-test-exemptions.txt` 41-row meta-ratchet | D | `scripts/slow-test-exemptions.txt` | per-exempt budget Phase 2 ratchet (#2322) | YELLOW | pre-R3 | Debt-Paydown | +| Peano materialization cap `256` literal in 3 authorities | D | `dsl/std/termination.dag:238-243` + `src/v3/std/termination.dag:138-140` + `dag.rs:1022-1027` | generate Rust cap from `.dag` OR ratchet test | YELLOW | b09e0c8 | Substrate | ### Class E — v2 ↔ v3 transition bridges (~10+ expected; **now in R3 scope per fold-in**) Bridges that exist solely because v3 isn't yet authoritative for some surface that v2 still owns: `emit_model.dag` facade, method-template legacy adapters, v2 transport infrastructure. Per Brian's R3-fold-in ratification, these are R3-close eligible (GREEN if v2 retirement closes; previously would have been "post-R3 / Pure Bootstrap"). -[Mgr canvas populates rows] +| Bridge | Class | File / location | Dissolution trigger | R3-close eligibility | Source PR | Owner Mgr | +|---|---|---|---|---|---|---| +| `emit_model.dag` facade duplicate authority | E | `dsl/v3/std/emit_model.dag` | T-V2-Retirement | YELLOW §1.8 #41/#42 | pre-R3 | PB | +| Method-template legacy adapters | E | emit_model + lower bridge | T-V2-Retirement | YELLOW | pre-R3 | PB | +| v2 transport infrastructure | E | `src/v2/transport/` | §1.8 #42 v2_directory_deleted | DECLARED | pre-R3 | PB | +| v2 oracle test consumers | E | tests consuming `src/v2/` | §1.8 #41 v2_oracle_no_remaining_test_consumers | DECLARED | pre-R3 | PB | +| `emit/rust_target.rs` v2-shape Class E (per PR #1804 §1.2) | E | grounded carrier | post-EmissionPathProjection / Anthropic post-projection-metadata | YELLOW | #1804 | Grounding | +| `emit/python_target.rs` v2-shape Class E | E | grounded carrier | as above | YELLOW | #1804 | Grounding | +| `collection_ops_method_contract.rs` v2-shape Class E | E | grounded carrier | as above | YELLOW | #1804 | Grounding | +| Pipeline dual-authoring drift (post-#1171 source-text bridge retirement) | E | pipeline.dag + pipeline-rust mirror | full pipeline-as-data migration | YELLOW | post-#1171 | PB | +| Method-template consumer migration over row population priority | E | method_template adapters | T-Tier3-Dissolution lane | YELLOW | pre-R3 | PB | +| Tier3 termination mirror (gate #1) | E | §1.8 #1 | T-Tier3-Dissolution | DECLARED | pre-R3 | PB | +| Tier3 computation mirror (gate #2) | E | §1.8 #2 | T-Tier3-Dissolution | DECLARED | pre-R3 | PB | +| Tier3 induction mirror (gate #3) | E | §1.8 #3 | T-Tier3-Dissolution | DECLARED | pre-R3 | PB | +| Tier3 effect-carrier mirror (gate #4) | E | §1.8 #4 | T-Tier3-Dissolution | DECLARED | pre-R3 | PB | +| `lens_apply.rs` retired (gate #5) | E | §1.8 #5 | T-LensProducer-Retirement (PB-Runtime interpreter-as-data) | DECLARED | pre-R3 | PB | +| `lens_testgen.rs` retired (gate #6) | E | §1.8 #6 | T-LensProducer-Retirement | DECLARED | pre-R3 | PB | +| `regen_lens.rs` retired (gate #7) | E | §1.8 #7 | PB-1 bin-shim emit pattern | DECLARED | pre-R3 | PB | +| SG-0 non-test zero (gate #8) | E | §1.8 #8 | EXPECTED_HAND_AUTHORED_NON_TEST count = 0 | DECLARED | pre-R3 | PB | ### Class F — Operator/algebra ontology duplication (~3 surfaces expected) Duplicate representations of operator/algebra concepts: OperatorSpec / OperatorKind / BinaryOpRow. Should consolidate to single ontology. -[Mgr canvas populates rows] +| Bridge | Class | File / location | Dissolution trigger | R3-close eligibility | Source PR | Owner Mgr | +|---|---|---|---|---|---|---| +| OperatorSpec / OperatorKind / BinaryOpRow triplicate | F | parse_tables.dag + lower + emitter operator surfaces | SG-2c proper `parse_tables.dag` decision; single ontology | YELLOW | pre-R3 | Substrate | +| `algebra.dag` declaration-vs-template surface asymmetry | F | `dsl/std/algebra.dag` | rescoped per Lane G #654 investigation | YELLOW | #654 | Substrate | +| `ShapeATarget = Rust \| Python \| Go` closed enum vs `LanguageSpec` data extensibility | F | gpt-5-5-pro Finding 2 | LanguageSpec consumption replacing closed enum | YELLOW | PR #2358 | Grounding | +| `Map` as set across graph/syntax/node files (`set_has` ignores stored bool) | F | gpt-5-5-pro Finding 3 | use declared `Set` from std | YELLOW | PR #2358 | Substrate | +| `StructuralEffectShape.combine_effects` bespoke local lattice merge | F | `src/v3/lenses/effect_enumeration.dag:50-54,175-207` | `BoundedLattice` instance | YELLOW | b09e0c8 | Substrate | +| Hand-rolled lattice instances (NEW class instance) | F | tracked at ROADMAP `:384` | typed `Lattice` instances | YELLOW | pre-R3 | Substrate | +| Anthropic schema mirror multiplication risk (provider/API class) | F | Anthropic schema + OpenAI ratchets + GitHub | typed-end-to-end serde alignment §1.8 #29/#30 | DECLARED | pre-R3 | Grounding | +| `container_template_algebra_rows` string-table duplicate authority | F | `dsl/std/types.dag:133-146` + aliases `:211-213` | `.dag` alias reflection lands | YELLOW | #651 | Substrate | ### Class G — Local/small bridges (~5-10 expected) Smaller scope bridges: F10 install_hint, ad-hoc fold sentinels, etc. -[Mgr canvas populates rows] +| Bridge | Class | File / location | Dissolution trigger | R3-close eligibility | Source PR | Owner Mgr | +|---|---|---|---|---|---|---| +| `cross_target_coverage.dag` doc/code drift (RETIRED) | G | `src/v3/std/cross_target_coverage.dag` + sg0_census_test.rs comments | RETIRED via PR #2333 (2026-05-09) | RETIRED | #2333 | Substrate | +| `Strict Forward Progress` subdoc ↔ heading drift | G | `docs/invariants/strict-forward-progress.md` | naming-design call + rename or split | YELLOW | pre-R3 | PM | +| `IntegrationRsScan` raw/byte-string panic-loud mode | G | `src/v3/compiler/tests/integration/common/mod.rs` | widen scan for raw/byte strings or replace with structural reader | YELLOW | #1856 | PB | +| Stale-receipt sweep in `docs/briefs/` (PARTIAL T-Receipts W1) | G | `docs/briefs/` broad sweep | post-W1-wave staleness sweep | YELLOW | T-Receipts W1 | Debt-Paydown | +| `__EMIT_BUG_{0}__` target emit-spec sentinels (rescoped) | G | `src/v2/05_emit.dag:996,1046` | refactor to Diagnostic + halt; sentinels become unreachable | YELLOW | #657 | PB | +| `extdeps/browser.dag` typed-carrier service-boundary collapse | G | `dsl/extdeps/browser.dag` | typed service-boundary carriers | YELLOW | pre-R3 | Substrate | +| Filename / sentinel bridges in `test_runner.rs` | G | `test_runner.rs` (parallel test-predicate authority) | freeze new bespoke arms; convert ratchet to count-decreasing | YELLOW | pre-R3 | Evaluator+PB | +| Lossy user-lens reflection vs full substrate (PARTIAL) | G | lens reflection paths | full-substrate reflection landing | YELLOW | pre-R3 | Substrate | +| Duplicated declaration walkers + `SubstStack` between `lower.rs`/`infer.rs` | G | `lower.rs` + `infer.rs` | shared walker abstraction or substrate-driven dispatch | YELLOW | NOVEL | Substrate | +| Closed-vocabulary consumer proof — C1 stop ratchet | G | meta-review follow-up | NOVEL row | YELLOW | pre-R3 | Substrate | +| `go_method_template_contracts` live diagnostic mismatch | G | go_method_template_contracts | diagnostic alignment | YELLOW | pre-R3 | Grounding | +| "diagnostics empty" acceptance gate missing for new bootstrap fixtures | G | bootstrap fixtures | gate addition | YELLOW | pre-R3 | Verification | +| Lens fold execution: undeclared fallback structure + file-path semantics | G | `src/v3/compiler/src/lens_apply.rs:105-148,22-39,372-383` | structural R1-certified fold shape carrier | YELLOW | NOVEL 2026-04-25 | Substrate | +| `PartitionResult` bypassed by anonymous return type | G | gpt-5-5-pro Finding 4 | typed return restoration | YELLOW | PR #2358 | Substrate | +| 4 TODO/FIXME markers in `src/v3/` non-test | G | `grep -rn 'TODO\|FIXME\|XXX' src/v3/` | per-marker dissolution | YELLOW | pre-R3 | Substrate | +| SG-0 census untagged entries (no dissolution-trigger comments) | G | `sg0_census_test.rs`; live counts in `docs/audit/sg0-census-classification-2026-05-09.md` §Summary | per-entry §1.8 gate-id linkage + Class A-G ratification (script: `scripts/classify-sg0-census.py`) | YELLOW | PR #2358 §1 | Debt-Paydown | +| Hand-Rust acceptance growing faster than `.dag` TestClaim migration | G | per-test SG-0 ratchet | net-zero/net-shrink discipline; per-PR pairing | YELLOW | pre-R3 | PB+Debt-Paydown | +| Reflection completeness over-trusted (not closed mechanical theorem) | G | reflection-completeness claim | mechanical theorem or ratchet | YELLOW | pre-R3 | Substrate | + +### Class P — Past-R3 debt (R4+ ambition; lane scope per Brian directive 2026-05-09) + +NEW class introduced 2026-05-09 per Brian operator directive: substrate-capability gaps that don't block R3 close but do block R4+ ambition. Inventory parking lot for forward debt-track without R3-blocking framing. Eligibility column = "P" (past-R3). + +| Bridge | Class | File / location | Dissolution trigger | R3-close eligibility | Source PR | Owner Mgr | +|---|---|---|---|---|---|---| +| C1 Parallelism lens (R4-carve) | P | `docs/r4-carve-out-routing.md` C1 | Stage 2e walker port substrate; R4 lane | P (R4) | r4-carve-out | Substrate | +| C2 Effect-enumeration lens (R4-carve) | P | `r4-carve-out-routing.md` C2 | 4c carrier P1 substrate-fact-introduction | P (R4) | r4-carve-out | Substrate | +| C3 Register zero-proxy/zero-stub broader (R4-carve) | P | `r4-carve-out-routing.md` C3 | post-Q-LBP narrowing; complexity+cost in R3 only | P (R4) | r4-carve-out | Verification | +| C4/C5/C6 substrate-axis defers | P | `r4-carve-out-routing.md` C4-C6 | substrate-axis lane R4 prep | P (R4) | r4-carve-out | Substrate | +| TC1 #11 canvas-deferred (post-R3 substrate) | P | TC1 generic G1.b / X1.b path B | post-R3 generic + eta relation | P (R4) | pre-R3 | Verification | +| ProgramShape richer-shape variants | P | design §8.2 | post-R3 design call | P (R4) | pre-R3 | Substrate | +| Tier 4 ("out of scope, declared") inclusion | P | `r3-program-plan.md` §10.3 Q-Tier4-Inclusion | Brian directive (HOLD pending) | P (R4) | ctrl#1608 §6d | PM | +| Q-Class-6-Substrate-Extension-Lens (3 ctrl-side proposals) | P | §10.3 Q-Class-6 | Research PM sharper framing + Director ratification | P (R4-pending) | ctrl#370/#404/#405/#407/#408 | Research PM | --- diff --git a/docs/audit/sg0-census-classification-2026-05-09.md b/docs/audit/sg0-census-classification-2026-05-09.md new file mode 100644 index 00000000000..790742aea20 --- /dev/null +++ b/docs/audit/sg0-census-classification-2026-05-09.md @@ -0,0 +1,208 @@ +# SG-0 Census Per-Entry Classification — 2026-05-09 + +> **Single source for SG-0 untagged-count**: this document's §Summary is the canonical live count (regenerated by `scripts/classify-sg0-census.py` from `src/v3/compiler/tests/integration/sg0_census_test.rs`). Sweep doc + audit prose link here rather than repeat numbers — fixes codex BLOCKING on PR #2437 sha `03a88309`. + +**Authority**: PM dispatch at gunb-ai/gunbc#846 c#4413701937; Brian operator directive 2026-05-09 active posture; Debt-Paydown Mgr Phase 2 (3) standing authority. + +**Methodology**: heuristic regex classification on preceding-comment-block + path; Mgr review converts heuristic → ratified classification + dissolution-trigger comment in `sg0_census_test.rs`. + +**Heuristic rules** (in priority order): see `scripts/classify-sg0-census.py` `CLASS_RULES`. + +--- + +## EXPECTED_HAND_AUTHORED_NON_TEST (53 entries) + +| # | Path | Class | Heuristic basis | Comment present? | +|---|---|---|---|---| +| 1 | `src/v3/compiler/benches/tier3_mirror_perf.rs` | E | Tier3 mirror dissolution | ✓ | +| 2 | `src/v3/compiler/build.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | +| 3 | `src/v3/compiler/src/bin/emit_method_template_projection.rs` | E | v2-retirement | ✓ | +| 4 | `src/v3/compiler/src/bin/r1c_e_emit_gates.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | +| 5 | `src/v3/compiler/src/bin/regen_bootstrap.rs` | D | Generated bridge with freshness gate | — UNTAGGED | +| 6 | `src/v3/compiler/src/bin/regen_lens.rs` | E | T-LensProducer-Retirement | — UNTAGGED | +| 7 | `src/v3/compiler/src/bin/regen_parse.rs` | D | Generated bridge — bootstrap/regen binary (path) [UNTAGGED] | — UNTAGGED | +| 8 | `src/v3/compiler/src/bin/regen_parse_tables.rs` | D | Generated bridge — bootstrap/regen binary (path) [UNTAGGED] | — UNTAGGED | +| 9 | `src/v3/compiler/src/bin/regen_tokenize.rs` | D | Generated bridge — bootstrap/regen binary (path) [UNTAGGED] | — UNTAGGED | +| 10 | `src/v3/compiler/src/bin/regen_v3.rs` | D | Generated bridge — bootstrap/regen binary (path) [UNTAGGED] | — UNTAGGED | +| 11 | `src/v3/compiler/src/bin/self_host_fixed_point.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | +| 12 | `src/v3/compiler/src/bootstrap.rs` | D | Generated bridge with freshness gate | — UNTAGGED | +| 13 | `src/v3/compiler/src/bootstrap_regen_fresh.rs` | D | Generated bridge with freshness gate | — UNTAGGED | +| 14 | `src/v3/compiler/src/complexity_lattice.rs` | C | Compiler Rust mirror — algebra/typed-carrier (path) [UNTAGGED] | — UNTAGGED | +| 15 | `src/v3/compiler/src/cost_basis_declaration.rs` | C | Compiler Rust mirror — algebra/typed-carrier (path) [UNTAGGED] | — UNTAGGED | +| 16 | `src/v3/compiler/src/dag.rs` | C | Compiler Rust mirror of .dag substrate (path) [UNTAGGED] | — UNTAGGED | +| 17 | `src/v3/compiler/src/dag/builder.rs` | C | Compiler Rust mirror of .dag substrate (path) [UNTAGGED] | — UNTAGGED | +| 18 | `src/v3/compiler/src/dag/cardinality_payload.rs` | C | Compiler Rust mirror of .dag substrate (path) | ✓ | +| 19 | `src/v3/compiler/src/dag/effects.rs` | C | Compiler Rust mirror of .dag substrate (path) [UNTAGGED] | — UNTAGGED | +| 20 | `src/v3/compiler/src/dag/ports.rs` | C | Compiler Rust mirror of .dag substrate (path) [UNTAGGED] | — UNTAGGED | +| 21 | `src/v3/compiler/src/diagnostics.rs` | C | Compiler Rust mirror of .dag substrate (path) [UNTAGGED] | — UNTAGGED | +| 22 | `src/v3/compiler/src/dimension.rs` | C | Compiler Rust mirror — algebra/typed-carrier (path) [UNTAGGED] | — UNTAGGED | +| 23 | `src/v3/compiler/src/emit.rs` | C | Compiler Rust mirror of .dag substrate (path) [UNTAGGED] | — UNTAGGED | +| 24 | `src/v3/compiler/src/emit/collection_ops_method_contract.rs` | C | Compiler Rust mirror of .dag substrate (path) | ✓ | +| 25 | `src/v3/compiler/src/emit/python_target.rs` | C | Compiler Rust mirror of .dag substrate (path) [UNTAGGED] | — UNTAGGED | +| 26 | `src/v3/compiler/src/emit/rust_target.rs` | C | Compiler Rust mirror of .dag substrate (path) [UNTAGGED] | — UNTAGGED | +| 27 | `src/v3/compiler/src/emit_rust.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | +| 28 | `src/v3/compiler/src/emit_rust_bin_shim.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | +| 29 | `src/v3/compiler/src/emit_rust_roundtrip_fixtures.rs` | G | Local/small bridge (default) | ✓ | +| 30 | `src/v3/compiler/src/enforced_lens_application.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | +| 31 | `src/v3/compiler/src/infer.rs` | C | Compiler Rust mirror of .dag substrate (path) [UNTAGGED] | — UNTAGGED | +| 32 | `src/v3/compiler/src/int_literal_ranges.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | +| 33 | `src/v3/compiler/src/lens_apply.rs` | E | T-LensProducer-Retirement | — UNTAGGED | +| 34 | `src/v3/compiler/src/lens_t_las_carrier.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | +| 35 | `src/v3/compiler/src/lens_testgen.rs` | E | T-LensProducer-Retirement | ✓ | +| 36 | `src/v3/compiler/src/lib.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | +| 37 | `src/v3/compiler/src/lower.rs` | C | Compiler Rust mirror of .dag substrate (path) [UNTAGGED] | — UNTAGGED | +| 38 | `src/v3/compiler/src/memory_peak_cost.rs` | G | Local/small bridge (default) | ✓ | +| 39 | `src/v3/compiler/src/omni_shape_b_openapi.rs` | G | Local/small bridge (default) | ✓ | +| 40 | `src/v3/compiler/src/pb_method_template_projection.rs` | E | v2-retirement | ✓ | +| 41 | `…/v3/compiler/src/pb_method_template_projection_dag_emit.rs` | G | Local/small bridge (default) | ✓ | +| 42 | `src/v3/compiler/src/pipeline_authority.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | +| 43 | `src/v3/compiler/src/post_emit_verifier.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | +| 44 | `src/v3/compiler/src/process_exit.rs` | G | Local/small bridge (default) | ✓ | +| 45 | `src/v3/compiler/src/r1c_e_gates.rs` | G | Local/small bridge (default) | ✓ | +| 46 | `src/v3/compiler/src/regen_bootstrap_emit.rs` | D | Generated bridge with freshness gate | — UNTAGGED | +| 47 | `src/v3/compiler/src/regen_parse_emit.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | +| 48 | `src/v3/compiler/src/regen_parse_tables_emit.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | +| 49 | `src/v3/compiler/src/regen_tokenize.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | +| 50 | `src/v3/compiler/src/self_host_receipt_p0.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | +| 51 | `src/v3/compiler/src/test_runner.rs` | A | Substrate-gap (parser/grammar/predicate) — path [UNTAGGED] | — UNTAGGED | +| 52 | `src/v3/compiler/src/workflow_idempotency.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | +| 53 | `src/v3/compiler/src/workflow_parallelism.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | + +## EXPECTED_HAND_AUTHORED_TEST (105 entries) + +| # | Path | Class | Heuristic basis | Comment present? | +|---|---|---|---|---| +| 1 | `src/v3/compiler/tests/boundary/m1_3_emit_go_test.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | +| 2 | `src/v3/compiler/tests/boundary/m1_3_emit_rust_test.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | +| 3 | `src/v3/compiler/tests/boundary/m1_4_emit_python_test.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | +| 4 | `src/v3/compiler/tests/boundary/m1_5_emit_omni_demo_test.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | +| 5 | `…/tests/boundary/m2_emit_multi_field_struct_variant_test.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | +| 6 | `src/v3/compiler/tests/determinism_test.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | +| 7 | `src/v3/compiler/tests/integration.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | +| 8 | `…iler/tests/integration/anthropic_messages_callable_test.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | +| 9 | `…v3/compiler/tests/integration/anthropic_operations_test.rs` | G | Local/small bridge (default) | ✓ | +| 10 | `…mpiler/tests/integration/anthropic_schema_lockstep_test.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | +| 11 | `…3/compiler/tests/integration/bridge_ledger_carrier_test.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | +| 12 | `…tegration/bridge_lower_helpers_patch_zero_residual_test.rs` | G | Local/small bridge (default) | ✓ | +| 13 | `…er/tests/integration/canonical_lens_bridge_ratchet_test.rs` | E | T-LensProducer-Retirement | ✓ | +| 14 | `…gration/cementing/cementing_lens_registry_dispatch_test.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | +| 15 | `…gration/cementing/complexity_lens_behavioral_completion.rs` | G | Local/small bridge (default) | ✓ | +| 16 | `…tests/integration/cementing/memory_peak_cost_basis_demo.rs` | G | Local/small bridge (default) | ✓ | +| 17 | `src/v3/compiler/tests/integration/common/budgeted.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | +| 18 | `src/v3/compiler/tests/integration/common/cached_compile.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | +| 19 | `…/compiler/tests/integration/common/determinism_fixtures.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | +| 20 | `…/v3/compiler/tests/integration/common/list_variant_tags.rs` | G | Local/small bridge (default) | ✓ | +| 21 | `src/v3/compiler/tests/integration/common/mod.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | +| 22 | `src/v3/compiler/tests/integration/common/r1_gates_bridge.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | +| 23 | `…v3/compiler/tests/integration/common/substrate_receipts.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | +| 24 | `…iler/tests/integration/cost_lens_symbolic_consumer_test.rs` | G | Local/small bridge (default) | ✓ | +| 25 | `…er/tests/integration/cross_target_coverage_carrier_test.rs` | STRUCTURAL | Measurement infrastructure (§3.A grandfathered) | ✓ | +| 26 | `…piler/tests/integration/e6_g1a_option3_static_lens_test.rs` | G | Local/small bridge (default) | ✓ | +| 27 | `…ler/tests/integration/e_i_lane_induction_preflight_test.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | +| 28 | `…ompiler/tests/integration/emission_provenance_lens_test.rs` | G | Local/small bridge (default) | ✓ | +| 29 | `…r/tests/integration/extdeps_rust_primitives_loader_test.rs` | G | Local/small bridge (default) | ✓ | +| 30 | `…compiler/tests/integration/four_fixture_regression_test.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | +| 31 | `…ests/integration/idempotency_lens_instance_blocker_test.rs` | G | Local/small bridge (default) | ✓ | +| 32 | `…compiler/tests/integration/int_literal_cardinality_test.rs` | G | Local/small bridge (default) | ✓ | +| 33 | `src/v3/compiler/tests/integration/l1_5_fixed_point_test.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | +| 34 | `…compiler/tests/integration/lane2_stage_2a_effects_smoke.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | +| 35 | `…/v3/compiler/tests/integration/lane2_stage_2b_db18_test.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | +| 36 | `…/v3/compiler/tests/integration/lane2_stage_2c_db15_test.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | +| 37 | `…ler/tests/integration/lane2_stage_2d_symbolic_cost_test.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | +| 38 | `…piler/tests/integration/lane2_stage_2e_parallelism_test.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | +| 39 | `src/v3/compiler/tests/integration/lane3_stage_3b_db1_test.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | +| 40 | `…ler/tests/integration/lens_cost_target_realization_test.rs` | D | Generated bridge with freshness gate | ✓ | +| 41 | `…ler/tests/integration/lens_register_correspondence_test.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | +| 42 | `…/compiler/tests/integration/lens_substrate_carrier_test.rs` | D | Generated bridge with freshness gate | ✓ | +| 43 | `src/v3/compiler/tests/integration/m0_acceptance.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | +| 44 | `src/v3/compiler/tests/integration/m1_3_lens_cost_test.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | +| 45 | `…iler/tests/integration/m1_3_lens_unused_parameters_test.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | +| 46 | `…mpiler/tests/integration/m1_5_omni_shape_b_openapi_test.rs` | G | Local/small bridge (default) | ✓ | +| 47 | `src/v3/compiler/tests/integration/m1_5_testgen_test.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | +| 48 | `…ler/tests/integration/m1_5_user_authored_lens_gate_test.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | +| 49 | `src/v3/compiler/tests/integration/m1_5_verification_test.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | +| 50 | `…sts/integration/m1_fn_external_body_reconciliation_test.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | +| 51 | `…er/tests/integration/m1_lens_structural_resolution_test.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | +| 52 | `src/v3/compiler/tests/integration/m1_substrate_test.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | +| 53 | `src/v3/compiler/tests/integration/m2_feature_parity_test.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | +| 54 | `…compiler/tests/integration/m2_field_access_binding_test.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | +| 55 | `…/compiler/tests/integration/m2_lens_cost_migration_test.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | +| 56 | `…ompiler/tests/integration/m2_lens_idempotency_emit_test.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | +| 57 | `…er/tests/integration/m2_lens_idempotency_migration_test.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | +| 58 | `…ler/tests/integration/m2_lens_provenance_migration_test.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | +| 59 | `…ntegration/m2_lens_structural_resolution_migration_test.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | +| 60 | `…ts/integration/m2_lens_unused_parameters_migration_test.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | +| 61 | `…ests/integration/m2_lens_variant_payload_migration_test.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | +| 62 | `…ompiler/tests/integration/m2_substrate_inhabitance_test.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | +| 63 | `src/v3/compiler/tests/integration/method_registry_test.rs` | D | Generated bridge with freshness gate | ✓ | +| 64 | `…ompiler/tests/integration/method_template_contract_test.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | +| 65 | `…ion/method_template_projection_emit_shim_coherence_test.rs` | G | Local/small bridge (default) | ✓ | +| 66 | `…iler/tests/integration/p0_std_render_repeat_string_test.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | +| 67 | `…iler/tests/integration/pb1_bootstrap_full_snapshot_test.rs` | D | Generated bridge with freshness gate | — UNTAGGED | +| 68 | `…integration/pb_method_template_projection_dag_emit_test.rs` | G | Local/small bridge (default) | ✓ | +| 69 | `…er/tests/integration/pb_method_template_projection_test.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | +| 70 | `src/v3/compiler/tests/integration/pipe_desugar.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | +| 71 | `…/integration/prereq_x_call_on_field_access_ratchet_test.rs` | G | Local/small bridge (default) | ✓ | +| 72 | `…3/compiler/tests/integration/r1_release_acceptance_test.rs` | E | T-LensProducer-Retirement | ✓ | +| 73 | `…3/compiler/tests/integration/r1c_d_pb_census_gates_test.rs` | B | Pattern-A NYI | ✓ | +| 74 | `…v3/compiler/tests/integration/r1c_e_emit_gates_dag_test.rs` | G | Local/small bridge (default) | ✓ | +| 75 | `…mpiler/tests/integration/r1c_e_emit_gates_omni_dag_test.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | +| 76 | `…/tests/integration/r2_b5_loop_construction_closure_test.rs` | G | Local/small bridge (default) | ✓ | +| 77 | `…tests/integration/r3_free_consequences_first_batch_test.rs` | G | Local/small bridge (default) | ✓ | +| 78 | `…ests/integration/r3_free_consequences_second_batch_test.rs` | G | Local/small bridge (default) | ✓ | +| 79 | `…ts/integration/r3_pb_runtime_evaluator_corpus_seed_test.rs` | E | T-LensProducer-Retirement | ✓ | +| 80 | `…ests/integration/r3_verification_l4_l7_l5_skeleton_test.rs` | B | Pattern-A NYI | ✓ | +| 81 | `…/compiler/tests/integration/services_carrier_shape_test.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | +| 82 | `src/v3/compiler/tests/integration/sg0_census_test.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | +| 83 | `…/compiler/tests/integration/sg1_tokenize_authority_test.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | +| 84 | `…/v3/compiler/tests/integration/sg2_parse_authority_test.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | +| 85 | `…ler/tests/integration/sg2c1_parse_tables_authority_test.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | +| 86 | `…ompiler/tests/integration/sg2c5_soft_keyword_ident_test.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | +| 87 | `…er/tests/integration/sg3_lower_parse_surface_stack_test.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | +| 88 | `…/tests/integration/sg3_surface_reflection_consumer_test.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | +| 89 | `…ompiler/tests/integration/sg6_hand_authored_census_test.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | +| 90 | `…sts/integration/sg7_prep_variant_payload_freshness_test.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | +| 91 | `…egration/shape_a_target_source_filtering_authority_test.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | +| 92 | `…/integration/t_impossiblebugs_unenumerated_effects_test.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | +| 93 | `…ntegration/t_las_complexity_contract_compile_error_test.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | +| 94 | `…piler/tests/integration/t_las_crdt_cost_basis_demo_test.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | +| 95 | `…/v3/compiler/tests/integration/t_pb_b_1_dag_runner_test.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | +| 96 | `…ler/tests/integration/t_pb_b_brief_d_fixture_smoke_test.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | +| 97 | `…ration/tc1_substrate_lens_eta_equivalence_deferred_test.rs` | B | Pattern-A NYI | ✓ | +| 98 | `…ion/tc1_substrate_lens_eta_equivalence_strict_fire_test.rs` | B | Pattern-A NYI | ✓ | +| 99 | `…ests/integration/tc3_strong_normalization_deferred_test.rs` | B | Pattern-A NYI | — UNTAGGED | +| 100 | `src/v3/compiler/tests/integration/test_runner_test.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | +| 101 | `src/v3/compiler/tests/integration/thesis_parallelism_test.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | +| 102 | `src/v3/compiler/tests/integration/thesis_validation_test.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | +| 103 | `…er/tests/integration/timing_lens_substrate_carrier_test.rs` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | +| 104 | `…ntegration/value_body_substrate_mirror_isomorphism_test.rs` | C | typed-carrier+Rust-mirror | ✓ | +| 105 | `src/v3/compiler/tests/integration/workflow_root_port_test.rs` | G | Local/small bridge (default) | ✓ | + +## EXPECTED_HAND_AUTHORED_FRAGMENTS (1 entries) + +| # | Path | Class | Heuristic basis | Comment present? | +|---|---|---|---|---| +| 1 | `src/v3/compiler/parse_parser_body.txt` | G | (no comment — untagged; Mgr review needed) | — UNTAGGED | + +--- + +## Summary + +- **Class A**: 1 (0.6%) +- **Class B**: 5 (3.1%) +- **Class C**: 16 (10.1%) +- **Class D**: 12 (7.5%) +- **Class E**: 9 (5.7%) +- **Class F**: 0 (0.0%) +- **Class G**: 115 (72.3%) +- **Class STRUCTURAL**: 1 (0.6%) +- **Total entries**: 159 +- **Untagged (no preceding comment)**: 115 (72.3%) + +## Mgr next-action + +1. Review heuristic classifications (especially Class G default + STRUCTURAL grandfathering). +2. For each Class A-F entry: confirm dissolution-trigger comment matches lane gate; surface drift to lane-Mgr if mismatch. +3. For each untagged entry: add explicit dissolution-trigger comment per option-(c) discipline OR escalate as "no clear path" to Director. +4. Classifications fold back into `docs/audit/r3-debt-sweep-2026-05-06.md` §1 Class A-G rows as per-entry sub-rows or row-aggregation. + diff --git a/docs/briefs/r3-novel-f1-missingemissionpath-typed-axes-worker.md b/docs/briefs/r3-novel-f1-missingemissionpath-typed-axes-worker.md new file mode 100644 index 00000000000..73a7fa7ec45 --- /dev/null +++ b/docs/briefs/r3-novel-f1-missingemissionpath-typed-axes-worker.md @@ -0,0 +1,78 @@ +# R3 Novel-Finding Worker Brief — F1 `MissingEmissionPath` typed-axes substrate + +**Owner**: Substrate Mgr (warm-wolf-698 / gunbc#2068) lane scope; worker dispatch via Substrate Mgr standing authority OR Debt-Paydown Mgr (gentle-newt-665 / gunbc#2062) standing authority per Brian directive 2026-05-09. +**Authority parent**: gpt-5-5-pro reflective analysis on `main@b09e0c8` Finding 1; PM dispatch at gunbc#846 c#4413701937 (operator authorized 2026-05-09; standing-authority confirmed). +**Priority**: HIGH — typed-carrier regression at diagnostic boundary; Rust mirror is MORE typed than substrate (inverted drift). + +--- + +## §0. Problem statement + +Substrate stringifies typed axes that the Rust mirror types correctly: + +`src/v3/std/diagnostics.dag:219-223`: +``` +| MissingEmissionPath { + connective: String, + behavior: String, + target: String + } +``` + +Rust mirror `src/v3/grounding_cross_target_meta/src/diagnostic.rs:26-30`: +```rust +MissingEmissionPath { + connective: FormAxis, + behavior: BehaviorAxis, + target: ShapeATarget, +} +``` + +Substrate comments at `:215-218` admit: *"Each axis carries a string label (substrate-anchored discriminant; resolved against `TypeConnective` per #1229 anchor + `Behavior` per L1 model + Shape A targets per `r2-grounding-manager.md` portability set)."* + +P1 Modeling Faithfulness violation: substrate authority weaker-typed than its consumer. Reverse-direction drift — the typed names exist (`TypeConnective`, `Behavior`, `ShapeATarget`); substrate just bypasses them via String labels. + +## §1. Required outcome + +Substrate axes typed against existing carriers; Rust mirror trivially aligns. + +## §2. Fix options + +**Option A (preferred)**: Type substrate fields directly: +``` +| MissingEmissionPath { + connective: TypeConnective, + behavior: Behavior, + target: ShapeATarget + } +``` + +Update consumers (lower / emit / test_runner) to pass typed values. Rust mirror matches without conversion. + +**Option B (pragmatic)**: Keep String axes; add typed-discriminant-roundtrip assertion in Rust constructor (`from_cell` at `:34-41`); document the substrate-weak-type as deliberate boundary. + +PM-recommended: Option A — eliminates the drift class entirely. Option B preserves it as ratified-bridge. + +## §3. Files + +**Option A**: +- `src/v3/std/diagnostics.dag` (type fields) +- `src/v3/grounding_cross_target_meta/src/diagnostic.rs` (no change to Rust — already typed) +- consumers of `MissingEmissionPath` constructor in `.dag` (typecheck) +- new `.dag` `TestClaim` cementing typed roundtrip + +## §4. Cross-cutting constraints + +- No new hand-Rust tests; `.dag` `TestClaim` form. +- STOP-and-PING via Mgr inbox if `TypeConnective`/`Behavior`/`ShapeATarget` need substrate-shape changes. +- Cross-references Class C row 4 in `docs/audit/r3-debt-sweep-2026-05-06.md`. + +## §5. Receipt + +- Substrate-side fields typed; Rust mirror trivially aligns. +- Cementing `TestClaim` pinning typed roundtrip. +- ROADMAP / sweep-doc Class C row 4 updated to RETIRED. + +--- + +**End of brief.** diff --git a/docs/briefs/r3-novel-f2-shapeatarget-vs-languagespec-worker.md b/docs/briefs/r3-novel-f2-shapeatarget-vs-languagespec-worker.md new file mode 100644 index 00000000000..05f07776d7e --- /dev/null +++ b/docs/briefs/r3-novel-f2-shapeatarget-vs-languagespec-worker.md @@ -0,0 +1,52 @@ +# R3 Novel-Finding Worker Brief — F2 `ShapeATarget` closed enum vs `LanguageSpec` extensibility + +**Owner**: Grounding Mgr (sunny-koi-893 / gunbc#2063) lane scope; coordinate with Substrate Mgr (warm-wolf-698 / gunbc#2068) on carrier consumption shape. +**Authority parent**: gpt-5-5-pro reflective analysis Finding 2; PM dispatch at gunbc#846 c#4413701937 (operator authorized 2026-05-09). +**Priority**: HIGH — Class F ontology duplication; closed enum constrains thesis extensibility claim. + +--- + +## §0. Problem statement + +`ShapeATarget = Rust | Python | Go` is a closed sum type used at `src/v3/grounding_cross_target_meta/src/cells.rs` and consumed across grounding-related crates. In parallel, `LanguageSpec` data declarations at `src/v3/spec/{rust,python,go}.dag` are extensible — adding a fourth language is "add `.dag` data + retypecheck." + +But `ShapeATarget` is closed at the Rust enum boundary. Adding a fourth target requires editing the enum, the discriminant, and every match-arm — Rust-side change instead of `.dag`-data change. + +P1 Modeling Faithfulness: thesis says target extensibility is data-driven; the enum says it's closed. The `LanguageSpec` carrier IS the source of truth; `ShapeATarget` is a parallel-authority shadow. + +## §1. Required outcome + +`ShapeATarget` consumes from `LanguageSpec` data declarations; closed enum dissolves to a typed-id reference. + +## §2. Fix options + +**Option A (proper dissolution)**: Replace `ShapeATarget = Rust | Python | Go` with `ShapeATarget = LanguageSpecRef { spec_id: DeclarationId }` carrying a typed reference to the `LanguageSpec` data declaration. Consumers dispatch via reflected spec lookup; adding a target = `.dag` data only. + +**Option B (pragmatic ratchet)**: Keep closed enum + add cementing test that asserts `ShapeATarget` variants partition the registered `LanguageSpec` declarations (any new `LanguageSpec` without a matching enum variant fails closed). Test fails if the enum drifts behind data. + +PM-recommended: Option A — extensibility is the thesis claim; the enum negates it. Option B ratchets the drift but doesn't dissolve the boundary. + +## §3. Files + +**Option A**: +- `src/v3/grounding_cross_target_meta/src/cells.rs` (replace closed enum with typed ref) +- `src/v3/grounding_cross_target_meta/src/diagnostic.rs:29` (consumer) +- `src/v3/compiler/tests/integration/cross_target_coverage_carrier_test.rs` (substrate read) +- All Rust match-arm consumers across grounding crates + +## §4. Cross-cutting constraints + +- Substrate-grep before authoring (Mgr-cited discipline): consumer-side breadth audit before changing the Rust enum. +- STOP-and-PING if substrate-side reflection plumbing isn't ready (`LanguageSpec` declaration-id lookup via `declaration_by_name` α). +- Cross-references Class F row 3 in sweep doc. + +## §5. Receipt + +- `ShapeATarget` consumes typed `LanguageSpec` reference (Option A); OR cementing test pins enum ⊇ registered specs (Option B). +- All consumers updated. +- Cementing `.dag` `TestClaim` for the partition-or-typed-ref invariant. +- Sweep-doc Class F row 3 updated. + +--- + +**End of brief.** diff --git a/docs/briefs/r3-novel-f3-map-string-bool-as-set-worker.md b/docs/briefs/r3-novel-f3-map-string-bool-as-set-worker.md new file mode 100644 index 00000000000..3aae02700fb --- /dev/null +++ b/docs/briefs/r3-novel-f3-map-string-bool-as-set-worker.md @@ -0,0 +1,50 @@ +# R3 Novel-Finding Worker Brief — F3 `Map` used as set across graph/syntax/node files + +**Owner**: Substrate Mgr (warm-wolf-698 / gunbc#2068) lane scope. +**Authority parent**: gpt-5-5-pro reflective analysis Finding 3; PM dispatch at gunbc#846 c#4413701937 (operator authorized 2026-05-09). +**Priority**: MEDIUM — Class F missed algebraic structure; `Set` already declared in std but bypassed. + +--- + +## §0. Problem statement + +`Map` appears repeatedly as a presence-set across graph/syntax/node files — e.g., `src/v2/04_infer.dag:400` `fn set_has(m: Map, key: String) -> Bool`. The stored `Bool` value is ignored; `set_has` exists solely because the substrate doesn't reach for `Set` declared elsewhere in `dsl/std/`. + +P1 Modeling Faithfulness: a present algebraic structure (`Set`) is bypassed in favor of a structurally-weaker `Map` shape. Field labels lie about what's stored. + +## §1. Required outcome + +`Map` presence-set consumers migrate to `Set`; `set_has` deletes (or routes to `Set::contains`). + +## §2. Fix options + +**Option A**: Find all `Map` declarations + uses; verify each is a presence-set (Bool-value-ignored); migrate to `Set`. Delete `set_has` helper after migration. Cementing test scans for any new `Map` with `Bool`-ignored consumer. + +**Option B**: Add ratchet test that flags new `Map` declarations matching the bypassed-Set shape (regex over `.dag` files); allow existing instances to ratchet down via per-PR migration. + +PM-recommended: Option A for the migration cycle; Option B as a closing ratchet if some instances can't migrate (cross-cutting constraint emerges). + +## §3. Files + +**Option A**: +- `src/v2/04_infer.dag` + similar across graph/syntax/node files (audit then migrate) +- `dsl/std/set.dag` (verify `Set::contains` shape; add if missing) +- consumers (typecheck migration) +- new `.dag` `TestClaim` for ratchet + +## §4. Cross-cutting constraints + +- Audit pass before migration: enumerate `Map<.*Bool>` instances; classify presence-set vs genuine bool-value. +- v2-side migrations (e.g., `src/v2/04_infer.dag`) are Class E v2-retirement-eligible; coordinate with PB Mgr (warm-dove-618 / gunbc#2074) on whether to migrate-then-retire or skip. +- Cross-references Class F row 4 in sweep doc. + +## §5. Receipt + +- All `Map` presence-set consumers migrated to `Set`. +- `set_has` helper deleted or aliased to `Set::contains`. +- Ratchet `TestClaim` blocks regressions. +- Sweep-doc Class F row 4 updated. + +--- + +**End of brief.** diff --git a/docs/briefs/r3-novel-f4-partitionresult-anonymous-bypass-worker.md b/docs/briefs/r3-novel-f4-partitionresult-anonymous-bypass-worker.md new file mode 100644 index 00000000000..53fd8f74ac1 --- /dev/null +++ b/docs/briefs/r3-novel-f4-partitionresult-anonymous-bypass-worker.md @@ -0,0 +1,52 @@ +# R3 Novel-Finding Worker Brief — F4 `PartitionResult` bypassed by anonymous return type + +**Owner**: Substrate Mgr (warm-wolf-698 / gunbc#2068) lane scope. +**Authority parent**: gpt-5-5-pro reflective analysis Finding 4; PM dispatch at gunbc#846 c#4413701937. +**Priority**: LOW-MEDIUM — Class G small-scope cleanup; thesis-faithfulness doc/consumer drift. + +--- + +## §0. Problem statement + +`dsl/std/filesystem.dag:51` declares: +``` +type PartitionResult { ... } +``` + +But the consumer at `:83` uses an anonymous return record: +``` +fn partition_entries(entries: List) -> { readable: List, skipped: List } { ... } +``` + +The named type `PartitionResult` exists but is bypassed — the anonymous return shape duplicates the declared type's structural shape without naming it. Class G small duplicate-authority cleanup. + +## §1. Required outcome + +`partition_entries` returns `PartitionResult` directly; anonymous duplication eliminated. + +## §2. Fix options + +**Option A**: Update `partition_entries` signature to `-> PartitionResult`; verify consumers don't break; delete anonymous shape duplication. + +(Single option; trivial scope.) + +## §3. Files + +- `dsl/std/filesystem.dag` (signature change) +- consumers of `partition_entries` (typecheck) + +## §4. Cross-cutting constraints + +- Verify shape exact-match between `PartitionResult` declaration and current anonymous return before substituting. +- Cross-references Class G row 14 in sweep doc. + +## §5. Receipt + +- `partition_entries` returns `PartitionResult` named type. +- Anonymous return type deleted. +- Consumers verified or updated. +- Sweep-doc Class G row 14 updated. + +--- + +**End of brief.** diff --git a/docs/briefs/r3-novel-f5-composedeffect-illegal-product-worker.md b/docs/briefs/r3-novel-f5-composedeffect-illegal-product-worker.md new file mode 100644 index 00000000000..fe08bbcd6ef --- /dev/null +++ b/docs/briefs/r3-novel-f5-composedeffect-illegal-product-worker.md @@ -0,0 +1,64 @@ +# R3 Novel-Finding Worker Brief — F5 `ComposedEffect { idempotent, breaking_operation }` illegal product + +**Owner**: Substrate Mgr (warm-wolf-698 / gunbc#2068) lane scope. +**Authority parent**: gpt-5-5-pro reflective analysis Finding 5; PM dispatch at gunbc#846 c#4413701937. +**Priority**: HIGH — Class C illegal-state-representable; soundness adjacent. + +--- + +## §0. Problem statement + +`dsl/std/effects.dag:135` declares: +``` +type ComposedEffect { ... } +``` + +with fields including `idempotent: Bool` and `breaking_operation: ...`. These two fields can both be set in inconsistent ways — e.g., a "breaking operation" claimed `idempotent: true` is contradictory; the type permits the illegal state. + +P1 Modeling Faithfulness: typed carriers should not admit semantically-illegal field combinations. Class C illegal-product instance. + +## §1. Required outcome + +`ComposedEffect` shape redesigned so contradictory field combinations are unrepresentable. + +## §2. Fix options + +**Option A (sum split)**: Replace product with sum: +``` +type ComposedEffect = + | IdempotentEffect { ... } + | BreakingEffect { breaking_operation: OperationEffect, ... } + | NeutralEffect { ... } +``` + +The sum forecloses contradictory field combinations. + +**Option B (refinement)**: Keep product; add `where` refinement constraining valid (idempotent, breaking_operation) pairs. Requires DB-11 alias-RHS `where` parsing already landed (#703). + +PM-recommended: Option A — eliminates the illegal state shape entirely (per `feedback_load_bearing_ratchet_preservation` / structural-illegal preference). Option B retains the product shape with downstream refinement load. + +## §3. Files + +**Option A**: +- `dsl/std/effects.dag:135` (replace product with sum) +- `src/v2/effect_derivation.dag` consumers +- `src/v2/stage0/src/v2_compiler_effect_derivation.rs` (consumer; v2-Class-E) +- consumers across .dag effect_derivation paths +- new `.dag` `TestClaim` cementing legal-state-only construction + +## §4. Cross-cutting constraints + +- v2-side consumer (`src/v2/...`) migration; coordinate with PB Mgr on v2-retirement timeline interaction. +- Cross-references Class C row 5 in sweep doc. +- STOP-and-PING via Mgr inbox if `OperationEffect` shape needs co-evolution. + +## §5. Receipt + +- `ComposedEffect` redesigned (Option A or B); illegal field combinations no longer representable. +- Consumers updated. +- Cementing `TestClaim` for legal-construction-only. +- Sweep-doc Class C row 5 updated. + +--- + +**End of brief.** diff --git a/docs/briefs/r3-novel-f6-derive-op-effect-string-parser-worker.md b/docs/briefs/r3-novel-f6-derive-op-effect-string-parser-worker.md new file mode 100644 index 00000000000..f50fbe2fba6 --- /dev/null +++ b/docs/briefs/r3-novel-f6-derive-op-effect-string-parser-worker.md @@ -0,0 +1,50 @@ +# R3 Novel-Finding Worker Brief — F6 `derive_op_effect(method_str, path_str)` string parser at structural boundary + +**Owner**: Substrate Mgr (warm-wolf-698 / gunbc#2068) lane scope. +**Authority parent**: gpt-5-5-pro reflective analysis Finding 6; PM dispatch at gunbc#846 c#4413701937. +**Priority**: HIGH — Class C string-keyed dispatch over typed carriers; structural-boundary violation. + +--- + +## §0. Problem statement + +`src/v2/effect_derivation.dag:20-41` exposes `derive_op_effect(method_str: String, path_str: String) -> OperationEffect`. The function parses unstructured strings (HTTP method as String, path as String) at what should be a structural boundary — typed carriers `HttpMethod` (sum-type-shaped) and `Path` (`http_path.dag`) exist but are bypassed. + +P2 Boundary Discipline: structural facts encoded as strings at internal boundaries. Reverse-direction problem from F1 — here the consumer is well-typed but the producer-input boundary stringifies. + +## §1. Required outcome + +`derive_op_effect` consumes typed `HttpMethod` + `Path` carriers; string parsing dissolves to surface-only (parse once at HTTP boundary, structural everywhere downstream). + +## §2. Fix options + +**Option A (proper dissolution)**: Change signature to `derive_op_effect(method: HttpMethod, path: Path) -> OperationEffect`. Parsing happens once at the HTTP-surface boundary; `derive_op_effect` operates structurally. Cementing test pins typed-input invariant. + +**Option B (hybrid)**: Keep string signature for v2 compat; add typed wrapper `derive_op_effect_typed(method: HttpMethod, path: Path)` that string-converts internally; migrate callers; delete string variant after migration. + +PM-recommended: Option A if v2-retirement timeline allows direct migration. Option B if Class E v2-bridge constraint forces gradual migration. + +## §3. Files + +**Option A**: +- `src/v2/effect_derivation.dag` (signature change + remove string parsing) +- `src/v2/stage0/src/v2_compiler_effect_derivation.rs` (Rust consumer; v2-Class-E) +- callers (typecheck migration) +- new `.dag` `TestClaim` for typed-input invariant + +## §4. Cross-cutting constraints + +- v2-side surface; coordinate with PB Mgr on v2-retirement timing (Class E). +- Cross-references Class C row 6 in sweep doc. +- STOP-and-PING via Mgr inbox if `HttpMethod` typed-carrier doesn't yet exist (substrate prereq). + +## §5. Receipt + +- `derive_op_effect` consumes typed carriers; string parsing dissolves. +- Callers migrated. +- Cementing `TestClaim` pins typed-input invariant. +- Sweep-doc Class C row 6 updated. + +--- + +**End of brief.** diff --git a/scripts/classify-sg0-census.py b/scripts/classify-sg0-census.py new file mode 100755 index 00000000000..9f57aaedd79 --- /dev/null +++ b/scripts/classify-sg0-census.py @@ -0,0 +1,158 @@ +#!/usr/bin/env python3 +"""Extract SG-0 census entries from sg0_census_test.rs and produce per-entry +Class A-G/P classification proposals. + +Authority: PM dispatch at gunb-ai/gunbc#846 c#4413701937 (Brian operator +directive 2026-05-09; Debt-Paydown Mgr standing authority Phase 2 (3)). + +Output: docs/audit/sg0-census-classification-2026-05-09.md — per-entry table: + | Path | Comment-block | Class candidate | Dissolution trigger | Notes | + +Heuristic classification: + - Comment cites "T-Tier3-Dissolution" / "tier3_*_dissolved" → Class E + - Comment cites "v2-retirement" / "v2 retire" → Class E + - Comment cites "T-LensProducer" / "PB-Runtime" → Class E (gates #5/#6/#7) + - Comment cites "substrate-gap" / "substrate-capability" → Class A + - Comment cites "Pattern-A" / "NotYetImplemented" → Class B + - Comment cites "Rust mirror" / "typed-carrier" / "EmissionDiagnostic" → Class C + - Comment cites "freshness gate" / "regenerated" / "bootstrap" → Class D + - Comment cites "operator/algebra ontology" / "duplicate authority" → Class F + - No comment OR generic dissolution → Class G (Mgr review) + - Bench / measurement infrastructure → STRUCTURAL (out-of-class per §3.A) + +Entries WITHOUT preceding comment-blocks are flagged as "untagged" — these are +the 113 of 159 entries the audit specifically calls out. +""" +import re +import sys +from pathlib import Path + +CENSUS_FILE = Path("src/v3/compiler/tests/integration/sg0_census_test.rs") +OUTPUT = Path("docs/audit/sg0-census-classification-2026-05-09.md") + +ARRAY_RE = re.compile( + r'const\s+(EXPECTED_HAND_AUTHORED_NON_TEST|EXPECTED_HAND_AUTHORED_TEST|EXPECTED_HAND_AUTHORED_FRAGMENTS)' + r':\s*&\[&str\]\s*=\s*&\[(.*?)\];', + re.DOTALL, +) + +ENTRY_RE = re.compile(r'((?:[ \t]*//[^\n]*\n)*)\s*"([^"]+)"', re.MULTILINE) + +CLASS_RULES = [ + (re.compile(r'tier3|Tier3|tier3_.*_dissolved|T-Tier3-Dissolution', re.I), 'E', 'Tier3 mirror dissolution'), + (re.compile(r'v2[- ]retire|v2-retirement|src/v2/|v2 fully', re.I), 'E', 'v2-retirement'), + (re.compile(r'T-LensProducer|PB-Runtime|lens_apply\.rs|lens_testgen|regen_lens|bin-shim', re.I), 'E', 'T-LensProducer-Retirement'), + (re.compile(r'substrate[- ]gap|substrate-capability|Class\s*[2-6]\s*Gap', re.I), 'A', 'Substrate-gap-blocked'), + (re.compile(r'Pattern-A|NotYetImplemented|TC1|TC2|TC3|RustDagIsomorphism|BridgeLedgerZero|SymbolicCostExprEquals', re.I), 'B', 'Pattern-A NYI'), + (re.compile(r'Rust mirror|typed[- ]carrier|EmissionDiagnostic|EvalStrategy|target-primitive', re.I), 'C', 'typed-carrier+Rust-mirror'), + (re.compile(r'freshness gate|regenerat|bootstrap|generated.*ratchet', re.I), 'D', 'Generated bridge with freshness gate'), + (re.compile(r'operator.*ontology|OperatorSpec|OperatorKind|BinaryOpRow|duplicate authority', re.I), 'F', 'Operator/algebra ontology duplication'), + (re.compile(r'bench|measurement|perf.*budget|Criterion harness|measur', re.I), 'STRUCTURAL', 'Measurement infrastructure (§3.A grandfathered)'), +] + +# Path-based fallback rules — fire only when comment-based rules miss + path matches. +# Stronger signals than default-G; refines untagged entries via canonical compiler-Rust-mirror locations. +PATH_RULES = [ + (re.compile(r'src/v3/compiler/benches/|/bench[^/]*\.rs$', re.I), 'STRUCTURAL', 'Measurement infrastructure (path: bench)'), + (re.compile(r'src/v3/compiler/src/bin/regen_|src/v3/compiler/src/bootstrap', re.I), 'D', 'Generated bridge — bootstrap/regen binary (path)'), + (re.compile(r'src/v3/compiler/src/(dag|lower|infer|emit|value|diagnostics|eval)\.rs|src/v3/compiler/src/(emit|dag|eval)/', re.I), 'C', 'Compiler Rust mirror of .dag substrate (path)'), + (re.compile(r'src/v3/compiler/src/(parse|tokenize|test_runner)', re.I), 'A', 'Substrate-gap (parser/grammar/predicate) — path'), + (re.compile(r'src/v3/compiler/src/(complexity|cost|dimension|cardinality)', re.I), 'C', 'Compiler Rust mirror — algebra/typed-carrier (path)'), + (re.compile(r'src/v3/grounding_pilot/|src/v3/grounding_cross_target', re.I), 'C', 'Grounding-pilot / cross-target Rust mirror (path)'), + (re.compile(r'src/v3/lenses/', re.I), 'E', 'Lens producer (Class E v2↔v3 transition / T-LensProducer)'), + (re.compile(r'src/v3/spec/', re.I), 'C', 'Target spec Rust mirror (path)'), + (re.compile(r'src/v3/std/', re.I), 'C', 'std/ Rust mirror (path)'), +] + +def classify(comment_block: str, path: str) -> tuple[str, str]: + # First pass: comment-based rules (highest signal) + for pattern, cls, label in CLASS_RULES: + if comment_block.strip() and pattern.search(comment_block): + return (cls, label) + if pattern.search(path): + return (cls, label) + # Second pass: path-based fallback rules + for pattern, cls, label in PATH_RULES: + if pattern.search(path): + tag = '' if comment_block.strip() else ' [UNTAGGED]' + return (cls, label + tag) + # Default + if not comment_block.strip(): + return ('G', '(no comment — untagged; Mgr review needed)') + return ('G', 'Local/small bridge (default)') + +def parse_entries(text: str) -> dict[str, list[tuple[str, str]]]: + out = {} + for m in ARRAY_RE.finditer(text): + name = m.group(1) + body = m.group(2) + entries = [] + for em in ENTRY_RE.finditer(body): + comment = em.group(1).strip() + path = em.group(2) + entries.append((path, comment)) + out[name] = entries + return out + +def main(): + text = CENSUS_FILE.read_text() + arrays = parse_entries(text) + + counts = {'A': 0, 'B': 0, 'C': 0, 'D': 0, 'E': 0, 'F': 0, 'G': 0, 'STRUCTURAL': 0} + untagged = 0 + + lines = [ + '# SG-0 Census Per-Entry Classification — 2026-05-09', + '', + '> **Single source for SG-0 untagged-count**: this document\'s §Summary is the canonical live count (regenerated by `scripts/classify-sg0-census.py` from `src/v3/compiler/tests/integration/sg0_census_test.rs`). Sweep doc + audit prose link here rather than repeat numbers — fixes codex BLOCKING on PR #2437 sha `03a88309`.', + '', + '**Authority**: PM dispatch at gunb-ai/gunbc#846 c#4413701937; Brian operator directive 2026-05-09 active posture; Debt-Paydown Mgr Phase 2 (3) standing authority.', + '', + '**Methodology**: heuristic regex classification on preceding-comment-block + path; Mgr review converts heuristic → ratified classification + dissolution-trigger comment in `sg0_census_test.rs`.', + '', + '**Heuristic rules** (in priority order): see `scripts/classify-sg0-census.py` `CLASS_RULES`.', + '', + '---', + '', + ] + + for name, entries in arrays.items(): + lines.append(f'## {name} ({len(entries)} entries)') + lines.append('') + lines.append('| # | Path | Class | Heuristic basis | Comment present? |') + lines.append('|---|---|---|---|---|') + for i, (path, comment) in enumerate(entries, 1): + cls, basis = classify(comment, path) + counts[cls] += 1 + has_comment = '✓' if comment.strip() else '— UNTAGGED' + if not comment.strip(): + untagged += 1 + short_path = path if len(path) <= 60 else '…' + path[-58:] + lines.append(f'| {i} | `{short_path}` | {cls} | {basis} | {has_comment} |') + lines.append('') + + lines.append('---') + lines.append('') + lines.append('## Summary') + lines.append('') + total = sum(counts.values()) + for cls in ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'STRUCTURAL']: + pct = (counts[cls] / total * 100) if total else 0 + lines.append(f'- **Class {cls}**: {counts[cls]} ({pct:.1f}%)') + lines.append(f'- **Total entries**: {total}') + lines.append(f'- **Untagged (no preceding comment)**: {untagged} ({untagged/total*100:.1f}%)') + lines.append('') + lines.append('## Mgr next-action') + lines.append('') + lines.append('1. Review heuristic classifications (especially Class G default + STRUCTURAL grandfathering).') + lines.append('2. For each Class A-F entry: confirm dissolution-trigger comment matches lane gate; surface drift to lane-Mgr if mismatch.') + lines.append('3. For each untagged entry: add explicit dissolution-trigger comment per option-(c) discipline OR escalate as "no clear path" to Director.') + lines.append('4. Classifications fold back into `docs/audit/r3-debt-sweep-2026-05-06.md` §1 Class A-G rows as per-entry sub-rows or row-aggregation.') + lines.append('') + + OUTPUT.write_text('\n'.join(lines) + '\n') + print(f'wrote {OUTPUT} ({total} entries; {untagged} untagged)', file=sys.stderr) + print(f'class breakdown: {counts}', file=sys.stderr) + +if __name__ == '__main__': + main()