Skip to content

Commit 7a11cc0

Browse files
committed
docs: refine phase4-hir-burndown-spec §5 metrics per pythia python#187
Splits the §5 checkpoint metric from single "net LOC delta" into three independent trajectories (C added, C++ removed, shell-pending) per pythia python#187 + supervisor 2026-04-27T08:58:19Z authorization. Net-LOC alone false-positive-aborts during 4.A-D because algorithm bodies port to C while the C++ Pass-class shell stays until bridge dissolution in Phase 4.E. BLME batch 2 +140 net LOC is the in-flight precedent: .cpp 184→21 (-163 algorithm), _c.c +295 (C add), +9 verifier; net positive by design, healthy by per-trajectory metric. Adds §5.0 three-trajectory framework + per-file accounting template, restructures §5.A/§5.B/§5.E pass criteria around the three trajectories, adds new §5.F Phase 4.E close gate where net-LOC becomes valid (post-shell-deletion).
1 parent 681333c commit 7a11cc0

1 file changed

Lines changed: 112 additions & 34 deletions

File tree

docs/phase4-hir-burndown-spec.md

Lines changed: 112 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -230,68 +230,146 @@ land):
230230

231231
## 5. Intermediate checkpoint gates (per pythia #186 2026-04-27)
232232

233-
The Phase-4-close LOC-delete falsifier (§7 falsifier #1, ≥80% LOC
233+
The Phase-4-close LOC-delete falsifier (§8 falsifier #1, ≥80% LOC
234234
delete) is a single trigger at the END of Phase 4. Pythia #186 flagged
235235
that this leaves no mid-flight signal: BLME alone (the easiest pilot)
236236
won't validate Phase 4.C class-state path or the ≥80% target.
237237

238-
**Mid-Phase-4 checkpoint gates** (added per pythia #186):
238+
### 5.0 — Three-trajectory metric (per pythia #187 2026-04-27)
239+
240+
Net-LOC alone is NOT a valid Phase-4 metric. Algorithm bodies port to
241+
C while the C++ shell (Pass class wrapper, virtual interface) STAYS
242+
until bridge dissolution in Phase 4.E. Single net-LOC delta will
243+
false-positive abort during 4.A-D as C accumulates and shells linger.
244+
245+
Each checkpoint MUST evaluate **three trajectories independently**
246+
against projection:
247+
248+
1. **C added (cumulative across landed files):** new `_c.c` body LOC.
249+
Expected POSITIVE during 4.A-D; reflects algorithm migration.
250+
Healthy range: roughly equal to or modestly exceeding original
251+
.cpp algorithm LOC (BLME precedent: 184 LOC .cpp → 295 LOC .c due
252+
to comments + container helpers).
253+
254+
2. **C++ removed (cumulative across landed files):** algorithm bodies
255+
deleted from `.cpp` files. Expected NEGATIVE during 4.A-D as
256+
algorithm bodies migrate; **excludes shell residue** (remaining
257+
`.cpp` shells are not "removed" yet, they're "shell-pending").
258+
Healthy: each landed file's .cpp shrinks to ≤25 LOC shell
259+
(Pass class + Run() forwarding to C entry).
260+
261+
3. **Shell-pending (file count + cumulative LOC):** `.cpp` shells
262+
awaiting deletion in Phase 4.E. These MUST contain only Pass class
263+
wrapper + Run() forwarding; algorithm bodies in C. Tracked per
264+
file. Phase 4.E deletion gates on whether the shell's C++ Pass
265+
class is still consumed externally (compiler.cpp pass chain) —
266+
most shells delete when compiler.cpp's pass-chain rewires to C
267+
entries.
268+
269+
**Net-LOC delta** is reported as derived (C added − C++ removed) but
270+
NEVER as primary pass/fail criterion. Strongly negative net-LOC only
271+
becomes the metric in Phase 4.E (bridge dissolution + shell deletion).
272+
273+
**Per-file accounting template** (record at each file's commit):
274+
```
275+
File: <name>.cpp
276+
Pre-port C++ LOC: <N>
277+
Post-port C++ LOC: <M> (shell)
278+
C++ removed: N − M
279+
C added (_c.c): <K>
280+
Net delta: K − (N − M)
281+
Shell-pending: yes (forwarding Pass class)
282+
```
239283

240284
### 5.A — Phase 4.A close gate
241-
**Trigger:** when 3 of 4 Phase 4.A files have landed (3,786 - 957/377/184
242-
= 2,602 LOC C++ deleted target before printer.cpp/hir.cpp).
243-
**Pass criteria:**
244-
- Cumulative C++ delete ≥ 2,200 LOC (85% of 2,602 target)
245-
- Per-commit ABBA: same-session geo-mean ≥ -5% across the 3 files
246-
- Zero functional regressions on the 7-test Phoenix JIT suite
247-
- ARM64 dual-arch tree-match clean for every commit
285+
**Trigger:** when 3 of 4 Phase 4.A files have landed (printer.cpp /
286+
hir_instr_c_verify.cpp / blme / hir.cpp; trigger when the 3rd lands,
287+
hold-out re-spec on 4th if needed).
288+
**Per-trajectory pass criteria:**
289+
- **C++ removed (algorithm bodies):** ≥85% of landed files' original
290+
.cpp algorithm LOC migrated to C. Per-file shell residue ≤25 LOC
291+
acceptable. (Reference: BLME landed at 21 LOC shell from 184 LOC
292+
pre-port; ratio = 0.114, well within budget.)
293+
- **C added:** within 30%-150% of algorithm-LOC-migrated band (C
294+
port may add comments + container helpers; ≥150% indicates
295+
over-engineering, ≤30% indicates incomplete port).
296+
- **Shell-pending:** every landed file has its .cpp shell tracked
297+
for Phase 4.E deletion eligibility (grep shows only Pass class +
298+
Run() forwarding).
299+
- **Per-commit ABBA:** same-session geo-mean ≥ -5% across the 3
300+
files (Phase 3D protocol).
301+
- **Functional:** zero regressions on the 7-test Phoenix JIT suite.
302+
- **ARM64 dual-arch tree-match** clean for every commit.
248303
**Fail action:** PAUSE Phase 4.B start; theologian re-spec the §4.A
249-
remaining file (likely hir.cpp 1,268 LOC if it's the holdout).
304+
remaining file (likely hir.cpp 1,268 LOC if it's the holdout) OR the
305+
C-added-band that triggered the failure.
250306

251307
### 5.B — Phase 4.B close gate
252308
**Trigger:** preload.cpp + inliner.cpp both landed.
253-
**Pass criteria:**
254-
- Cumulative Phase 4.A+B C++ delete ≥ 3,400 LOC (84% of 4,060 target)
255-
- Inliner.cpp post-Pilot-3 verification: temps_ usage in inlineHIR
256-
goes through PhxTempAllocator with zero _cpp bridge calls
257-
- Same per-commit ABBA + ARM64 + functional gates
309+
**Per-trajectory pass criteria:**
310+
- **C++ removed (algorithm bodies):** ≥85% of preload.cpp +
311+
inliner.cpp algorithm LOC migrated; per-file shell ≤25 LOC.
312+
- **C added:** within 30%-150% band as §5.A.
313+
- **Shell-pending:** preload.cpp + inliner.cpp shells tracked.
314+
- **Inliner.cpp Pilot-3 dependency check:** temps_ usage in inlineHIR
315+
goes through PhxTempAllocator with zero _cpp bridge calls.
316+
- Same per-commit ABBA + ARM64 + functional gates.
258317
**Fail action:** PAUSE Phase 4.C scope expansion; theologian re-spec
259-
the inliner-temps_ interaction.
318+
the inliner-temps_ interaction or C-added band.
260319

261-
### 5.C — Phase 4.C Pilot 3 entry gate (per §7 falsifier #1)
320+
### 5.C — Phase 4.C Pilot 3 entry gate (per §8 falsifier #1)
262321
**Trigger:** before Pilot 3 (temps_ migration) commits begin.
263322
**Pass criteria:**
264323
- PhxTempAllocator design doc landed (analogous to PhxExceptionTable
265-
spec) — theologian-authored, supervisor-approved
324+
spec) — theologian-authored, supervisor-approved.
266325
- Reference benchmark: same-session ABBA on TempAllocator-heavy
267326
workload (e.g. simplify_c benchmark suite, or fibonacci/nqueens
268-
which exercise register allocation)
269-
- Pre-Pilot-3 baseline geo-mean recorded
270-
**Fail action:** STAND DOWN Pilot 3; investigate whether PhxRegisterArray
271-
realloc pattern matches std::vector growth.
327+
which exercise register allocation).
328+
- Pre-Pilot-3 baseline geo-mean recorded.
329+
**Fail action:** STAND DOWN Pilot 3; investigate whether
330+
PhxRegisterArray realloc pattern matches std::vector growth.
272331

273332
### 5.D — Phase 4.C Pilot 5 (Class A delete) per-field gate
274333
**Trigger:** before each of the 5 Class A field deletions.
275334
**Pass criteria:**
276335
- Pre-deletion grep: zero remaining C++ direct accesses to the field
277-
outside of `state_.<field>` reads
278-
- Mutator-site enumeration matches inventory in §2
336+
outside of `state_.<field>` reads.
337+
- Mutator-site enumeration matches inventory in §2.
279338
- JIT_DCHECK on equality of `state_.<field>` vs C++ mirror passes
280-
during full test suite
281-
**Fail action:** keep the C++ mirror until grep returns clean; do not
282-
delete on incomplete migration.
339+
during full test suite.
340+
**Fail action:** keep the C++ mirror until grep returns clean; do
341+
not delete on incomplete migration.
283342

284343
### 5.E — Phase 4.D dispatch loop entry gate
285344
**Trigger:** before translate() conversion commits begin.
286-
**Pass criteria:**
345+
**Per-trajectory pass criteria:**
287346
- Phase 4.A-C all landed (no C++ HirBuilder state remains except
288-
TranslationContext + dispatch)
289-
- Cumulative C++ delete ≥ 8,500 LOC (75% of pre-Phase-4.D target of
290-
11,319 LOC excluding bridge)
347+
TranslationContext + dispatch).
348+
- **C++ removed (algorithm bodies, cumulative 4.A+B+C):** ≥85% of
349+
the original 4,060 LOC + Pilot 3/4 container LOC migrated. Shells
350+
for hir/printer/inliner/preload/blme/verify all ≤25 LOC.
351+
- **Shell-pending count:** 6 (the 4.A+B file shells); compiler.cpp
352+
pass-chain rewire to C entries scheduled in 4.E.
353+
- **C added cumulative** within 30%-150% band of algorithm migration.
291354
- Golden-output capture of representative HIR for 5+ functions BEFORE
292-
conversion (per §6 decision #5 acceptance criteria)
293-
**Fail action:** if cumulative <8,500 LOC, the bottom-up sequencing
294-
assumption is failing; theologian re-spec.
355+
conversion (per §6 decision #5 acceptance criteria).
356+
**Fail action:** if any trajectory fails, the bottom-up sequencing
357+
assumption is failing on that dimension; theologian re-spec only the
358+
failing dimension (do not re-spec what's working).
359+
360+
### 5.F — Phase 4.E close gate (NEW per pythia #187 — net-LOC validity)
361+
**Trigger:** after Phase 4.E bridge dissolution + shell deletion
362+
commits land.
363+
**Pass criteria — net-LOC IS the metric here:**
364+
- Net LOC delta strongly negative: ≥10,000 LOC C++ removed (algorithm
365+
+ shell + bridge dissolution) − C added (cumulative across 4.A-D).
366+
- Phase 4 acceptance criteria §6 #5 ALL met:
367+
PhxHirBuilderState 100% of state, builder.cpp ≤200 LOC, hir_c_api.cpp
368+
HIR-internal-only bridges deleted (~600-1,000 LOC), all Phase 4.A+B
369+
files at ≤25 LOC shell or zero.
370+
- Per-commit ABBA, functional, ARM64 gates clean throughout.
371+
**Fail action:** Phase 4 EXIT BLOCKED; theologian + supervisor
372+
post-mortem to identify which dimension under-performed.
295373

296374
---
297375

0 commit comments

Comments
 (0)