refactor(#1796): ADR-1769 Path A — finish STATE.md preservation consolidation (#1799)

Extract readModifyWriteStateMd's post-sync preservation block into a pure,
field-classification-table-driven applyStatePreservation in the STATE.md
Transition Module. progress / status / stopped_at now join current_phase_name
as table-governed (getFieldClassification), so a preservation-policy change is
a one-row table edit instead of a per-call-site patch.

This realizes the consolidation ADR-1769 / CONTEXT.md already claimed shipped
('Absorbs readModifyWriteStateMd post-sync preservation block') and routes the
#1264 preservation policy through the single field-classification table — the
bug class is now structurally guarded by the table, not just the call-site
shouldResync flag.

Behavior is byte-identical to the pre-amendment inline block (Hyrum-safe — the
15 readModifyWriteStateMd callers' observable preservation is unchanged):
- state/frontmatter/transition + bug regression suite: 847 pass
- phase/milestone/verify (other RMW consumers): 582 pass
- codex (gpt-5.5/high) adversarial review: CLEAN (58,564-case equiv sweep)

ADR-1769 amendment appended documenting #1796.

Closes #1796
This commit is contained in:
Tom Boucher
2026-06-27 22:49:52 -04:00
committed by GitHub
parent a194f3f9a7
commit 21f0b4316f
5 changed files with 322 additions and 68 deletions

View File

@@ -215,3 +215,38 @@ alongside, leave callbacks — parallel worlds don't converge (ADR-857's failure
| 5 | `milestoneComplete` + `milestone.cts:352` | #1789 | — |
| 6 | `patch` | #1791 | #1743, #1695 |
| 7 | `sync`, `prune`, `update` | #1793 | #1760, #1761 |
## Amendments
### #1796 — Finish the preservation consolidation (Path A)
**Date:** 2026-06-28 · **Status:** Accepted
Surfaced by an `/adr-phase-coverage` audit of this ADR (issue #1796): the
Consequences claim that the module *"Absorbs … `readModifyWriteStateMd`'s
post-sync preservation block"* was **not** realized by Phases 0–7. The block
stayed inline in `readModifyWriteStateMd` (`state.cts`); only
`current_phase_name`'s preservation was table-driven. `#1264` was fixed by a
call-site `shouldResync` guard rather than the field-classification table, so the
bug *class* was not "killed structurally" as the Consequences (line 161) claimed.
**Resolution — Path A ("finish the consolidation"):** the post-sync preservation
block is now the pure, field-classification-table-driven `applyStatePreservation`
in `src/state-transition.cts`, consulted via `getFieldClassification` for **all
four** preserved fields — `progress`, `status`, `stopped_at`, `current_phase_name`
(previously only the last was table-driven). `readModifyWriteStateMd` calls it.
This makes the CONTEXT.md "Absorbs … post-sync preservation block" claim accurate
and routes the `#1264` preservation policy through the single field-classification
table (one policy source, not three drifting encodings).
Behavior is byte-identical to the pre-amendment inline block (Hyrum-safe — 15
callers' observable preservation is unchanged); the full state / frontmatter /
transition regression suite (847 tests, including the `#1264`, `#1743`, `#1695`,
`#1760`, `#1761`, `#3242`, `#1230` characterization blocks) passes unmodified.
A codex (gpt-5.5 / high) adversarial review returned CLEAN — no behavior drift
across a 58,564-case equivalence sweep, no security surface introduced.
The `shouldResync` call-site guard remains — it is the transition's declaration
of "am I re-deriving from disk?" What changed is that the *preservation policy*
it feeds is now centralized and table-driven rather than re-encoded per writer,
which is the consolidation this ADR originally specified.