diff --git a/config/contracts/registry-change-evidence.json b/config/contracts/registry-change-evidence.json index 10de93e0..2a765018 100644 --- a/config/contracts/registry-change-evidence.json +++ b/config/contracts/registry-change-evidence.json @@ -115,6 +115,7 @@ }, { "changeId": "FE-REG-ROUTE:REFERENCE_RESOURCE_DETAIL:path:field-changed", + "after": "/examples/reference-resources/items/:resourceId", "versionBump": "The reference detail route moves from /examples/reference-resources/:resourceId to /examples/reference-resources/items/:resourceId (maturity review 08-13), so a server id equal to the static segments new or status opens its detail instead of the form or status screen.", "migration": "The only in-app link (reference-resource-page.tsx) builds the new path from the contract route. The reference feature is a sample; downstream features that copied it keep their own paths.", "compatibilityWindow": "None for bookmarked sample detail URLs: an old /examples/reference-resources/ URL no longer matches the detail route; new and status keep opening the form and status screens.", diff --git a/docs/operations/ci-quality-gates.md b/docs/operations/ci-quality-gates.md index 1634e3af..5ddce76f 100644 --- a/docs/operations/ci-quality-gates.md +++ b/docs/operations/ci-quality-gates.md @@ -64,7 +64,7 @@ package script 그래프로 닿거나, 게이트가 이미 돌리는 Vitest 경 | 기준선 | 파일 | 갱신 방법 | 검사 위치 | |---|---|---|---| | CI 계약 크기·게이트 모양 | `config/ci/contract-baseline.json` | `update:ci-contract-baseline` (`CI_CONTRACT_BASELINE_OWNER`·`_REASON` 필수) | `scripts/contracts/ci-gates.ts` `assertCiContractBaseline` | -| registry 스냅샷과 승인 | `config/contracts/registry-baseline.json`, `registry-baseline.approval.json` | `update:registry-baseline` (`REGISTRY_BASELINE_OWNER`·`_REASON` 필수). 기준선을 새로 찍지 않고 breaking 변경을 유지하려면 `config/contracts/registry-change-evidence.json`에 항목을 추가 | `scripts/check-registries.ts`의 baseline 비교 | +| registry 스냅샷과 승인 | `config/contracts/registry-baseline.json`, `registry-baseline.approval.json` | `update:registry-baseline` (`REGISTRY_BASELINE_OWNER`·`_REASON` 필수). 기준선을 새로 찍지 않고 breaking 변경을 유지하려면 `config/contracts/registry-change-evidence.json`에 항목을 추가(`changeId`, 그 변경 뒤 값 `after`(삭제는 생략, 값은 JSON 그대로이고 키·원시값 배열 순서는 상관없다), `versionBump`·`migration`·`compatibilityWindow`·`rollback`·`owner`). 같은 칸을 다시 바꾸면 `after`가 달라 새 항목이 필요하다 | `scripts/check-registries.ts`의 baseline 비교 | | 커버리지 모듈 수 하한 | `config/testing/risk-coverage.json`의 `repositoryBaseline` | 직접 수정. 지운 production 모듈 수만큼 줄인다(`scripts/test-sample-removal.ts`가 같은 계산을 한다) | `scripts/lib/risk-coverage.ts` "repository module baseline" | | 기능 끄기 설정 | `config/runtime/.json`의 `FEATURE_OVERRIDES` | 직접 수정. 지운 기능의 키를 뺀다(`scripts/test-sample-removal.ts`가 같은 일을 한다) | 없음. 남은 키는 조용히 무시된다(리뷰 09-09) | | 의존성 목록 | `config/security/dependency-baseline.json`, `dependency-baseline.approval.json` | `update:dependency-baseline` (`DEPENDENCY_BASELINE_OWNER`·`_REASON` 필수) | `scripts/generate-supply-chain.ts` | diff --git a/scripts/lib/registry-compatibility.ts b/scripts/lib/registry-compatibility.ts index aefd7ade..9dbcdf25 100644 --- a/scripts/lib/registry-compatibility.ts +++ b/scripts/lib/registry-compatibility.ts @@ -389,6 +389,22 @@ export function validateBreakingEvidence( failures.push(`breaking change missing evidence: ${change.changeId}`); continue; } + // 0929/07-01. The changeId names a row and field, not a value. Without + // the value, evidence for one change would also pass the next change of + // the same field. Removals have no value to name. + if (change.after !== undefined) { + if (!Object.hasOwn(entry, "after")) { + failures.push( + `breaking change ${change.changeId} evidence needs after (the canonical JSON value it explains)`, + ); + } else if ( + canonicalRegistryJson(entry.after) !== canonicalRegistryJson(change.after) + ) { + failures.push( + `breaking change ${change.changeId} evidence explains after=${canonicalRegistryJson(entry.after)}, the change is after=${canonicalRegistryJson(change.after)}`, + ); + } + } for (const field of [ "versionBump", "migration", diff --git a/tests/unit/registry-compatibility.test.ts b/tests/unit/registry-compatibility.test.ts index 1373851b..197eacfa 100644 --- a/tests/unit/registry-compatibility.test.ts +++ b/tests/unit/registry-compatibility.test.ts @@ -150,6 +150,7 @@ describe("registry compatibility evidence", () => { changes: [ { changeId, + after: "/after", versionBump: "2", migration: "dual-read", compatibilityWindow: "one release", @@ -160,4 +161,60 @@ describe("registry compatibility evidence", () => { }).passed, ).toBe(true); }); + + // 0929/07-01. Evidence is for one value, not for every later change of the + // same row and field. + describe("evidence bound to the value it explains", () => { + const evidence = (extra: Readonly>) => ({ + changes: [ + { + changeId: "FE-REG-TEST:A:path:field-changed", + versionBump: "2", + migration: "dual-read", + compatibilityWindow: "one release", + rollback: "restore previous registry snapshot", + owner: "platform", + ...extra, + }, + ], + }); + const moved = diffRegistrySnapshots( + snapshot({ A: { path: "/a" } }), + snapshot({ A: { path: "/entries" } }), + ); + + it("rejects evidence written for another value of the same field", () => { + expect(validateBreakingEvidence(moved, evidence({ after: "/items" })).failures).toEqual([ + 'breaking change FE-REG-TEST:A:path:field-changed evidence explains after="/items", the change is after="/entries"', + ]); + }); + + it("requires the explained value", () => { + expect(validateBreakingEvidence(moved, evidence({})).failures).toEqual([ + "breaking change FE-REG-TEST:A:path:field-changed evidence needs after (the canonical JSON value it explains)", + ]); + }); + + it("compares canonical values, so key and primitive order do not matter", () => { + const reordered = diffRegistrySnapshots( + snapshot({ A: { path: { b: ["y", "x"], a: 1 } } }), + snapshot({ A: { path: { a: 2, b: ["x", "y"] } } }), + ); + expect( + validateBreakingEvidence(reordered, evidence({ after: { b: ["y", "x"], a: 2 } })).passed, + ).toBe(true); + }); + + it("needs no value for a removal", () => { + const removed = diffRegistrySnapshots( + snapshot({ A: { path: "/a" } }), + snapshot({}), + ); + expect( + validateBreakingEvidence(removed, { + changes: [{ ...evidence({}).changes[0], changeId: "FE-REG-TEST:A:*:removed" }], + }).passed, + ).toBe(true); + }); + }); }); diff --git a/tests/unit/registry-governance.test.ts b/tests/unit/registry-governance.test.ts index f939e3cf..e188da79 100644 --- a/tests/unit/registry-governance.test.ts +++ b/tests/unit/registry-governance.test.ts @@ -286,6 +286,7 @@ describe("registry governance manifest", () => { validateBreakingEvidence(diff, { changes: breakingChanges.map((change) => ({ changeId: change.changeId, + after: change.after, versionBump: "2", migration: `migrate ${tamperCase.name}`, compatibilityWindow: "one release",