* chore: rebuild ADR index as a generated artifact and enforce lifecycle invariants
The ADR index in docs/adr/README.md was hand-maintained with nothing checking
it, and had drifted to 40 of 65 ADRs. The absent rows included the entire
capability family (857/894/959/1016/1143/1213/1244) and ADR-1239 (EoS) itself,
so the decisions a reader most needed were the ones they could not find.
Make the index a derived artifact, matching the repo's existing generated-file
idiom (lint:generated-sync), and enforce the corpus' lifecycle invariants:
- scripts/gen-adr-index.cjs generates the index between markers and validates
the status vocabulary (Accepted/Proposed/Superseded/Legacy/Retired),
successor links, id/filename agreement, and supersession symmetry.
- Wire --check into lint:generated-sync so drift fails CI.
Correct the lifecycle metadata the gate surfaced, without flipping any status:
- ADR-1239 (EoS) declared it subsumed ADR-1016/58/3660/894; none recorded it.
Add reciprocal "Subsumed by" pointers + dated amendments. Subsumption keeps
the target Accepted -- these are live adapters, not dead decisions.
- ADR-857/894 carry dated status caveats: they read Proposed while the
capability system shipped and epic #857 is closed. Ratification is a
maintainer act and is deliberately left open.
- Link ADR-0005/0007/0012/3524 -> ADR-0174 and ADR-0010 -> ADR-0009; record
the reciprocal Supersedes on ADR-0009.
- ADR-218 declared itself "ADR-0175" -- an unfinished rename.
- The 0011 PRD moves from the non-canonical "Draft" to "Legacy".
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* test: capture stderr via spawnSync; record ADR-0010 draft supersession
Two fixes surfaced by the first gsd-test run and by regenerating the index:
- tests/adr-index-gate.test.cjs used execFileSync, which only surfaces stderr
through the thrown error on non-zero exit. The `--write` path exits 0 while
reporting outstanding violations on stderr, so the helper always saw ''.
spawnSync captures both streams on both outcomes.
- The hand-maintained index recorded 0010-skill-surface-budget-module.md as
"earlier draft superseded by ADR-0011" while the file itself still said
Proposed. Deriving the index from the files would have dropped that
assertion and resurrected a superseded draft as a live decision, so it is
recorded at its source, with the reciprocal Supersedes on ADR-0011.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* fix: drop the dead sdk/ model-catalog candidate retired by ADR-0174
src/model-catalog.cts resolved model-catalog.json through three candidates, the
second being sdk/shared/model-catalog.json three levels up. That was the legacy
source-repo fallback kept by the #3288 fix ("check the co-located path FIRST,
before the legacy source-repo path").
ADR-0174 then retired the @opengsd/gsd-sdk package boundary and deleted the sdk/
tree (11918dcc3), so the candidate can no longer resolve in any layout: a source
repo has no sdk/, and an install layout points it at ~/.claude/sdk/shared/, which
the installer never writes -- the original #3288 bug. It was dead weight implying
a package boundary this repo no longer has.
No test depends on it: the #3288 regression tests in tests/install.test.cjs write
their own synthetic old-path fixture and assert it throws.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* docs: ratify nine shipped ADRs; record why ten others stay Proposed
The corpus carried 19 Proposed ADRs, most describing architecture that had
already shipped. A Proposed label on live architecture tells contributors and
agents the decision is an unbuilt idea -- the capability system and EoS were
both being misread that way.
Audited all 19 against the shipped tree and GitHub. Each candidate flip then had
to survive two independent reviewers instructed to refute it.
Ratified Proposed -> Accepted, each with a dated Ratification section carrying
the verified evidence (file:line, symbols, tests, issue state):
857 capability system 894 declaration format 1244 capability ecosystem
1577 injection boundary 1610 size-budget ratchet 1990 existing-code onboarding
15 cross-AI convergence 22 plan-drift guard 0011 default reviewers
Held ten, each now carrying a "Why this is still Proposed" section naming the
blocker and its unblock condition, so the audit is not repeated:
2264 its own headline acceptance criterion is unmet in the tree
230 live branch protection contradicts the decided spec (1 approval, not 2)
660 the namesake release/<version> re-cut is manual, not automated
959 issue #2346 is approved and plans its graduation as its own ADR
1213 the shipped writer's return shape differs from the decided interface
443 the orchestrator override path has no live caller
1143 / 1606 each states its own bar for acceptance; neither is met
612 / 1671 legitimately open
Shipped code proved necessary but not sufficient: eight ADRs had every named
module, symbol, and test present with their epics closed, and still failed the
bar. That lesson is written into README.md's ratification procedure.
Also corrected ADR-857's "Supersedes (generalizes)" to "Subsumes": taken
literally it would have marked two live seams dead -- ADR-0011 (surface.cts:348)
and ADR-58 (runtime-artifact-install-plan.cts:82). Both keep Accepted status and
gain Subsumed-by pointers.
Index: Active 39->48, Proposed 19->10, Superseded/Legacy 7. 65 total.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* fix: harden gen-adr-index against hostile titles and non-ADR filenames (#2356)
Three findings from the pre-PR orthogonal security review, all confirmed:
- An ADR title containing the literal ADR-INDEX:END marker was emitted verbatim
into its table cell, relocating the splice boundary so the NEXT --write
spliced against the wrong marker and truncated README.md. Titles now render
through cellText(), which escapes pipes and angle brackets -- making an HTML
comment (and any other HTML) unformable from ADR-authored text.
- A docs/adr/*.md without a numeric prefix crashed on match(...)[1] of null.
Such a file is also invisible to the index -- the very failure this gate
exists to prevent -- so it is now reported as a naming-convention violation
naming the file and the fix.
- Tests leaked their mkdtemp dirs. They now use helpers.createTempDir/cleanup
via t.after(); helpers.cleanup carries the Windows-EBUSY retry budget that a
raw fs.rmSync lacks (caught by local/no-raw-rmsync-in-tests).
Adds five regression tests: marker hijack, HTML injection, pipe cell-break,
non-conforming filename, and splice stability across repeated writes.
Refs #2356
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* fix: close two gate false-passes; read ## Supersedes sections (#2356)
Second round of confirmed findings from the pre-PR orthogonal code review. Both
false-passes matter more than a false-fail: a gate that silently misses a
violation is worse than no gate, because it is trusted.
- A relation field mixing a link with a bare id silently dropped the bare claim:
the check tested `rel.links.length` (does this field have ANY link?) instead
of whether THAT id was linked. `Supersedes: [ADR-0001](...), ADR-0011` passed
clean -- accepting exactly the ambiguous bare reference the rule forbids. Now
each bare id is checked against the ids actually linked in the same field, so
a repeat in trailing prose stays quiet while an unlinked claim is flagged.
- The ratification guard (`statusToken !== 'Accepted'`) skipped BOTH relation
directions, which killed the IN check entirely: `supersedes.in` is only ever
populated on an ADR whose status IS `Superseded`, so a dangling `Superseded by
X` where X never claims it always passed. The guard now applies to OUT only --
a prospective claim must not obligate its target, but an ADR's statement about
ITSELF is always owed a reciprocal.
- Fixing that surfaced a parser gap: ADR-0174 declares its supersessions in a
`## Supersedes` table SECTION, not a header field, and headerBlock() stops at
the first `##`. The repo's best-documented supersession was invisible. Section
form is now parsed for both relations.
- Replaced a vacuous test: the em-dash negation case passed whether or not
NEGATED_RELATION_RE matched (a mutation to /$^/ survived). It now carries a
link that would create a failing asymmetric relation if negation did not fire.
Also removes docs/adr/9401-test-target.md -- a synthetic fixture a reviewer
created in the worktree while reproducing a finding, swept in by `git add -A`.
Adds regression tests for each: mixed link+bare, linked-and-repeated-in-prose,
dangling superseded-by from a non-Accepted ADR, and the ADR-0174 section shape.
Refs #2356
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* fix: escape backslashes before pipes in the ADR index cell renderer (#2356)
CodeQL js/incomplete-sanitization (high) on scripts/gen-adr-index.cjs: cellText()
escaped `|` -> `\|` without first escaping the backslash. Markdown's escape
character is the backslash, so the input `\|` became `\\|`, which renders as a
literal backslash followed by an UNESCAPED pipe -- re-opening the cell break the
pipe escape exists to prevent. Order is load-bearing: escape the escape
character first, then everything that emits one.
Same class as the index-marker hijack fixed earlier: ADR-authored text breaking
out of the cell it is rendered into.
Adds a regression test asserting a `\|`-bearing title leaves exactly the row's
own 5 unescaped delimiters and cannot forge a Status cell. Uses split(/\r?\n/)
per local/no-crlf-fragile-split -- a literal "\n" split is CRLF-fragile on the
Windows CI leg.
Refs #2356
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
17 KiB
ADR-2264: Redesign golden-install-parity — single-source manifest builder + split invariant
- Status: Proposed
- Date: 2026-07-14
- Issue: #2264 (epic); Phase 0 tracked by #2265
- Supersedes: nothing; amends the ADR-1239 Phase-B safety-net harness
- Relationship to prior work: Evolves
tests/golden-install-parity.test.cjs(ADR-1239 Phase B). Related: #2086 (claude-local realpath normalization), #2095/#2100/#2117 (exclusion-set drift incidents), #1691 (scoped-CI drift guard).
Why this is still Proposed (audited 2026-07-17)
Audited 2026-07-17 against the live tree and GitHub. Phase 1 shipped cleanly and is genuinely done: buildParityManifest, buildInstallTree, and the four exclusion constants (VOLATILE_FILES, HOOK_CONFIG_FILES, HOOK_CONFIG_RELATIVE_PATHS, EXCLUDED_PREFIXES) live as the single source of truth in tests/helpers/install-shared.cjs (lines 104-234); scripts/gen-golden-install-parity-zcode.cjs now imports them instead of re-declaring them; the anti-divergence guard (tests/golden-parity-single-source.test.cjs) enforces no second copy; scripts/ci-test-scope.cjs (lines 121, 145, 175-176) selects the golden suite on the wider path set the Amendment describes; npm run gen:golden (package.json:93) exists; and all five issues (#2264-#2268) are closed as completed.
The blocker: Acceptance criteria 3 and 4 name mechanisms that were never built. AC3 requires "A simulated converter bug ... caught by the converted-artifact golden" and AC4 requires "A simulated verbatim-copy corruption ... caught by the copy-parity property test" — neither tests/fixtures/converted-artifacts/ nor any *copy-parity* test file exists anywhere in the tree (confirmed absent by direct filesystem check). The ADR's own same-day Amendment explains why (§3/§4 were found "unsound" in the Phase 2 spike) and states the old monolithic content-hash golden "is retained as-is" — but the Acceptance Criteria section itself was never edited to drop or reword AC1/AC3/AC4 to match the revised design. That leaves AC1 — the document's headline must-have, "editing the content of a verbatim/path-injected copied shipped file (e.g. a workflows/*.md) requires zero manual fixture regeneration" — literally unmet: tests/golden-install-parity.test.cjs still content-hashes every emitted file via the retained buildParityManifest (confirmed at install-shared.cjs:218, crypto.createHash('sha256')), and EXCLUDED_PREFIXES (install-shared.cjs:154) excludes only gsd-core/bin/lib/ — workflows/*.md is still fully inside the hashed manifest, so editing one still requires npm run gen:golden. The functional invariants AC3/AC4 care about are still covered, but only by the legacy hash golden this ADR set out to partly replace, not by the mechanisms the criteria name.
Unblock condition: Edit the Acceptance Criteria section (items 1, 3, 4) to match the shipped, amended design — replace "zero manual fixture regeneration" and the named converted-artifact/copy-parity mechanisms with the criteria the Amendment actually delivers (file-set snapshot catches structural drift; the retained content-hash golden catches converter and copy corruption; npm run gen:golden is the one-command fix for legitimate content changes) — then flip Status. No further code work is required; this is a documentation edit against already-shipped, already-closed work.
Context
tests/golden-install-parity.test.cjs snapshots the installer output for 18 runtime layouts. For each runtime it runs a real runMinimalInstall, walks every emitted file, normalizes volatile bits (temp root → <HOME>, package version → <VERSION>, macOS realpath /private → <HOME>), SHA-256s each file (16-char slice), and compares the entire path→hash map against a committed fixture under tests/fixtures/golden-install-parity/*.json (18 files, ~520 KB, ~7,500 hash lines).
It was created as a refactor fence: proof that moving installRuntimeArtifacts (ADR-1239) changed zero emitted bytes. That invariant is valuable and rarely triggered.
Four problems make it a recurring tax on ordinary code updates:
-
It conflates two invariants. ~95% of each manifest is "the installer copied a source file (
workflows/*.md,agents/*.md,templates/config.json,bin/shared/*.json) to a destination." Those source files are already version-controlled. Storing a derived checksum of an already-tracked file adds ~zero review signal, yet every content edit to such a file trips the golden and forces a full 18-fixture regeneration. Only the ~5% of output that is transformed (per-runtime skill/command/agent projections produced byruntime-artifact-conversion: path rewrites, frontmatter edits,@-reference rewrites) is genuinely non-derivable from git and worth a content snapshot. -
Regeneration runs through a hand-maintained duplicate. Local
node --testis hook-blocked (.claude/hooks/block-local-node-test.sh), so regeneration goes throughscripts/gen-golden-install-parity-zcode.cjs, which re-declares the exclusion set and re-implementsbuildParityManifestinline, kept in sync only by a comment: "Must match tests/golden-install-parity.test.cjs exactly." Its own comments record two prior drift incidents that shipped broken fixtures (#2100 missingsettings.local.json; #2117 missing.kimi/config.toml). -
The duplicate has drifted again — a live divergence. The test normalizes the macOS realpath form (
fs.realpathSync(root)→ collapse/private/var/...) added in #2086. The driver atscripts/gen-golden-install-parity-zcode.cjs:51does not — it only collapses barerootandPKG_VERSION. Regenerating any realpath-embedding layout (e.g.claude-local) on macOS via the driver bakes a literal/private<HOME>into the hashed content, which fails golden-parity on the Linux benches — the exact #2086 bug, reintroduced in the copy that was never fixed. -
The feedback loop is remote-only and the diff is unreviewable. The suite runs solely in the
gsd-testdocker lane (and scoped CI whensrc//bin//installer paths change, perscripts/ci-test-scope.cjs:117-145) — never in localnpm test. The loop is: edit → push → remote matrix fails → regenerate via the duplicate → re-push → re-run. A one-linemodel-catalog.jsonchange rewrites hundreds of hash lines across 18 fixtures, burying the real change.
Decision
Split the single monolithic content-hash manifest into three assertions with different change cadences, and collapse the manifest logic to a single source of truth so regeneration cannot drift.
1. Single-source manifest builder (Phase 1 — prerequisite refactor)
Lift buildParityManifest and the exclusion constants (VOLATILE_FILES, HOOK_CONFIG_FILES, HOOK_CONFIG_RELATIVE_PATHS, EXCLUDED_PREFIXES) out of the test into tests/helpers/install-shared.cjs (which already exports walk, RUNTIME_META, runMinimalInstall, BUILD_SCRIPT). The test and any generator import the one copy. Delete the inline re-implementation in scripts/gen-golden-install-parity-zcode.cjs. The #2086 realRoot divergence dies with the duplicate; the #2100/#2117 class of drift becomes structurally impossible. A guard test fails if a second inline copy of the exclusion set is reintroduced.
2. Emitted file-set snapshot — the tree shape (Phase 2a)
Per runtime, snapshot the sorted list of emitted relative paths (after the shared exclusions), with no content hashes → tests/fixtures/install-tree/<runtime>.json (a JSON array). This catches added / removed / renamed / moved files — the "installer stopped shipping X" or "installer emitted an unexpected Y" regression — and changes only when the file set changes, not when a file's content changes. The diff is proportional to the change (a few added/removed lines), not a rewrite of every hash.
3. Copy-parity property test — derive from source, store nothing (Phase 2b)
For every emitted file that is a copy (verbatim or copy-with-path-injection, e.g. copyWithPathReplacement), assert its normalized content is derivable from its git-tracked source — computed live at test time, no committed hash. The injected install path is the only variable and is already collapsed to <HOME> by normalization, so normalize(emitted) is the source content modulo a known, invertible substitution.
Spike/risk (resolve in Phase 2 before committing to "fixture-free"): validate that the path injection is cleanly invertible for every copied surface, so normalize(emitted) === reference(source) holds by pure derivation. Where a surface's injection is not cleanly invertible, that surface falls back to a small stored reference — but even then the reference is re-derived from source at test time, so a content edit to the source propagates automatically and needs no manual regeneration. This is the core win regardless of the spike outcome: content edits to copied files stop requiring hand-regenerated fixtures.
4. Converted-artifact golden — small and high-signal (Phase 2c)
Only the transformed outputs (per-runtime projections from runtime-artifact-conversion) keep a content-hash golden → tests/fixtures/converted-artifacts/<runtime>.json. This is the ~5% git cannot review (source is correct; the projection is derived and a converter bug corrupts it silently). The fixture is small and changes only when the converter logic or a converted source changes — exactly the changes that should require a human to bless. This gate stays a hard failure and is never auto-regenerated/auto-committed.
Phases
- Phase 0 — this ADR (#2265, docs-only PR on
docs/2265-golden-parity-adr; PRCloses #2265, not the epic). - Phase 1 — single-source manifest builder (#2266,
refactor:). Extract the shared builder + exclusions; delete the duplicate driver's inline copies; add the no-second-copy guard test. Expected fixture diff: none (byte-identical), which is the safety proof. Resolves the #2086 realRoot divergence. - Phase 2 — split invariant (#2267,
refactor:/test:). Land the file-set snapshot (§2), the copy-parity property test + invertibility spike (§3), and the converted-artifact golden (§4). Migrate/replace the 18 monolithic fixtures once; delete the old per-file hash fixtures. - Phase 3 — optional, CI-owned regen (#2268, stretch). On file-set or converted-golden drift, CI regenerates and posts the exact patch as a PR artifact/comment (jest
--ciposture: fail on new snapshot, regenerate deliberately) — never silent auto-commit for the converted golden. Optionally adopt Node's first-partycontext.assert.snapshot+--test-update-snapshotsfor §4 to delete the bespokeUPDATE_GOLDENenv + hand-rolled read/write/compare code.
Acceptance criteria (must-haves)
- Editing the content of a verbatim/path-injected copied shipped file (e.g. a
workflows/*.md) requires zero manual fixture regeneration and the parity suite still passes. (Failing-first test: tweak a copied file, assert no fixture diff is needed.) - Adding/removing/renaming a shipped file is caught by the file-set snapshot with a diff proportional to the change.
- A simulated converter bug (corrupt a transformed projection) is caught by the converted-artifact golden as a hard failure.
- A simulated verbatim-copy corruption (installer truncates a copied file) is caught by the copy-parity property test.
- The engine deep-refactor fence is preserved: the suite still proves byte-identical emitted output across all 18 runtimes.
- Exactly one implementation of the manifest/exclusion logic exists; a guard test fails if a second copy is introduced.
- macOS-generated fixtures match Linux-bench hashes (realRoot divergence resolved) — the #2086 class cannot reappear because there is one code path.
Consequences
- Positive: the dominant churn trigger (content edits to copied files) becomes fixture-free; fixtures shrink from ~520 KB to a few KB; diffs become reviewable; the duplicate-driver drift class (#2100/#2117/#2086-realRoot) is eliminated; the refactor fence and converter-bug detection are preserved and sharpened.
- Negative / risk: copy-parity depends on modeling each surface's path injection (§3 spike). If a surface's injection is not cleanly invertible, it retains a small re-derived reference (still no manual regen). One-time migration churn to replace the 18 fixtures.
- Neutral: Phase 3 (CI-owned regen /
context.assert.snapshot) is optional polish; the churn win lands in Phase 2.
References
tests/golden-install-parity.test.cjs— current harnessscripts/gen-golden-install-parity-zcode.cjs— duplicate generator (to be deleted)tests/helpers/install-shared.cjs— shared install harness (target for the single-source builder)scripts/ci-test-scope.cjs:117-145— scoped-CI selection of the golden test- ADR-1239 (Phase B safety net); issues #2086, #2095, #2100, #2117, #1691
- Node.js test runner:
context.assert.snapshot+--test-update-snapshots - Jest
--cisnapshot posture (fail on new snapshot, deliberate-uregeneration)
Amendment (2026-07-14): Phase 2 redesign — the copy/transform split was unsound
Implementing Phase 2 began with an empirical spike classifying every emitted install file. It overturned the §2–§4 premise:
- The copy/transform boundary is not clean. Nearly every emitted file passes through a deterministic rewrite (path-prefix canonicalization,
{{GSD_VERSION}}stamping, hyphen-normalization) — even for claude, the reference host. Only ~36% of claude's files are byte-identical to source; ~64% are "transformed." A "content-hash only the transformed ~5%" golden (§4) was the wrong model. - The §3 from-source copy-parity property test is unsound. Asserting
emitted == transform(source)by calling the installer's own transform functions is largely tautological (it catches only non-determinism) — strictly weaker regression coverage than the current golden. Making it independent means reimplementing the transform in the test — the exact duplication this epic fights. It is also noisier than the golden it replaces: the harness'sconfigDir == $HOMEcollapses path canonicalization differently than a real install, mis-classifying ~147 of claude's files as transforms. - The real defect was stale fixtures, not platform divergence. The Phase-1 red (
gsd-statusline.js+ 3 claude-local files) was deterministic (macOS hash == Linux-bench hash for every entry); the fixtures were simply stale becausegolden-install-paritywas not selected by CI when the emitting source (ahooks/file) changed, so it merged undetected.
Revised Phase 2 (implemented in #2267):
-
File-set snapshot —
tests/golden-install-tree.test.cjs+tests/fixtures/install-tree/*.json: a per-runtime sorted list of emitted paths (no hashes), reusing the single-source exclusions viabuildInstallTree(= sorted keys ofbuildParityManifest). Cheap structural coverage; changes only when the file set changes, giving a clean reviewable diff instead of hash noise. -
Anti-staleness CI selection —
scripts/ci-test-scope.cjsgains a rule selectinggolden-install-parity+ the file-set snapshot whenever an installed-source path changes: the fourgsd-core/content subtrees (workflows,templates,references,contexts) +gsd-core/bin/shared/*.json, plushooks/**,commands/**,agents/**,skills/**, and the shippedscripts/*files (scripts/changeset/,scripts/lib/, and three named generators) — not justsrc//installer paths.gsd-core/bin/**(tsc-compiled) is deliberately excluded (already covered by the installer rule). This makes the #2266 silent-staleness class impossible: a source edit that changes emitted output re-verifies the fixtures at PR time. -
Regeneration convenience (Phase 3, #2268) — an
npm run gen:goldenone-command regenerator (both fixture sets, each now self-buildinghooks/dist) that the golden-parity/tree failure messages point at, so drift caught by (2) is a one-command fix. The full CI-auto-comment (auto-posting the fixture patch on drift, jest--ciposture) is deferred: it needs a write-token workflow running on PR code (an injection surface) that cannot be verified locally.
Deferred as an optional future refinement: the §3-style content-dedup of verbatim copies. The safe subset (structurally raw-copied non-.md/.js data files) is modest, and the broad form is unsound — a .md file that is byte-equal today transforms the moment a self-reference is added, producing false property-test failures. Since the anti-staleness rule already removes the root pain (silent stale merges) and the file-set snapshot adds structural coverage, the content-hash golden is retained as-is; churn on transformed output is legitimate (you should review transformed output when you change its source).