Skip to content

Commit 16f132f

Browse files
feat(adr-0087): refuse an added migration entry filed below PROTOCOL_MAJOR (#38436)
<!-- claude-projects-attribution: {"github_login":"os-project-manager"} --> _Requested by **Leehom** · [project thread](https://claude.ai/code/project/chan_01TenzsRopZj4jMbvjX8uz1X?thread=cmsg_01TenzsRopZj4jMbvjX8uz1XHogQ9ogKPxHhiFfT2UQgJi)_ Fixes #38240 Clause-②: no Metadata-protocol: none ## 维护者速读 - 用户能看到什么变化:用户无感;只有往平台升级说明里新增条目的开发者会碰到:条目编号低于当前协议大版本时,合并前的门禁直接拒绝,并告诉他改成哪个文件名。 - 为什么做:属于升级说明(ADR-0087 迁移账本)的守卫;此前已有三条 19 版的升级说明被误放在 18 下,按「从 18 升级」运行时永远看不到(已另行改正)。 - 出错会怎样:最坏是误拒一条合法的补登记说明;作者在变更说明里加一行补登记声明即可通过,门禁本身可直接撤回,不影响任何已发布内容。 - 要你做什么:无。 **Round 2** (contract review 7249162118, head `323f21d860`): S1 fixed (the refusal's printed backfill line carries `MINOR`, `PATCH` and `WHY` placeholders and the reason must name a release of the entry's own major in digits, so the line pasted unedited stays red, EM-R6); S2 fixed (the `ledgerAdded` conjunct applies only on a merge base from before the per-entry split, so an id the template already carries no longer hides a new entry, EM-R7); N1 fixed (`retired-keys/` and `retired-defs/` refusals give the tombstone aging cost read by `build-schemas.ts`). Also: EM-G7 (the L1-a nit), EM-R8 (a case at major 20), and EM-U2 no longer spells a spec version in prose (the `check:future-spec-major` red). Battery EM now has 50 cases; `origin/main` merged. _Where the sections below still describe round 1 (the `ledgerAdded` condition on every base, a 40-character-only backfill reason, 31 EM cases, test readings at `9982079f87`), the Round 2 line above supersedes them: delta contract review 7250195970 (PASS) and delta L1-a 7250194256 (ACCEPT) read head `323f21d860`._ ## What changes `scripts/check-adr-0087-registration.mjs` gains a second rule, judged on every diff (with or without a breaking changeset): - **Added entries.** For each of the three entry directories (`semantic/`, `retired-keys/`, `retired-defs/`), an entry file at HEAD is *added* when its key (the filename minus its `MAJOR.` prefix) is absent from the merge base's listing of the same directory. A `semantic/` entry must also be in `ledgerAdded`, the id set the R4 `registered` check already reads, so the two never disagree about what a PR registered. - **Refusal.** An added entry whose prefix is below `PROTOCOL_MAJOR` is refused. The message names the file, its prefix, the current `PROTOCOL_MAJOR` and where it was read, gives the `git mv` to `PROTOCOL_MAJOR.KEY.ts`, and says the one case that may sit lower is a backfill, with the exact line to write. - **Backfill escape.** The gate had no existing escape for this (its only text input is changeset bodies, and its one marker is the breaking-change disposition, of which a changeset may carry exactly one). So a minimal declaration form: an HTML-comment line in a changeset the PR adds, whose keyword is `adr-0087-backfill` plus a colon, followed by the entry path and the release that shipped the change (40 characters minimum, the same floor as a `not-required` reason). It is not an `adr-0087` disposition (that pattern needs the colon directly after `adr-0087`), and each one is printed and annotated as an exemption on every run. - **`PROTOCOL_MAJOR` source.** Read at HEAD from `packages/spec/src/kernel/protocol-version.ts` (`PROTOCOL_SOURCE`, imported from `scripts/sync-template-versions.mjs`) and evaluated by that module's `loadProtocolMajor`, the same reader the version lane uses. Nothing is hard-coded and no second copy is parsed. The reader is async and `scan()` is not, so it runs in a child `node` process, only when the diff adds an entry. A major that cannot be read is a red. - **Self-test.** New battery `EM (#38240)`, 31 cases, roster floor 60 to 61. The GR7 transition fixture now carries the protocol module, because its `beta` entry counts as added and is judged against it. ## The rule's reach Covers: - An entry the PR adds, in any of the three entry directories, whose prefix is below `PROTOCOL_MAJOR` at HEAD. That covers the three `semantic/18.*` entries #38142 moved to 19. - CI's `Check Changeset` job checks out the PR's merge commit. So a branch cut before a protocol move is judged against the major on `main` once its CI runs after the move. Does not cover: - **Entries stranded by the protocol move itself.** The 34 `semantic/18.*` entries #38256 carries were each filed while `PROTOCOL_MAJOR` read 18. They were at the major of their day, so this rule would not have refused any of them. Catching that shape takes a check at the protocol move (no unreleased entry left below the new major), not a check on added entries. That check is not built here. - **A move to a lower major.** A file renamed from `19.X.ts` to `18.X.ts` keeps its key, so it is not *added* (the card's R100 pin) and is not judged. - **A PR carrying `skip-changeset`.** The real scan runs in `Check Changeset`, which that label skips wholesale. Adding an entry publishes from `@objectstack/spec`, so such a PR owes a changeset anyway. - **A merge base from before the per-entry split.** The key alone decides added-ness in `retired-keys/` and `retired-defs/` (they have no `id:` line for `ledgerAdded` to see). From such a base, all of their files would read as added: a red, never a silent pass, and no open branch is that old. ## History reading From #38239's Acceptance notes: since the per-entry files exist (`f293d454b`, 2026-08-10), about **1,150** entries were added and **3** landed below the protocol major of their day, all three in #38142. No backfill was among them: the one explicit backfill (`5823d593db`) landed at the major of its day. A rule of "equal to `PROTOCOL_MAJOR`" would have refused the 717 entries filed ahead of the 17 to 18 bump. Re-measured for this PR from a blobless clone of `main`, first-parent `f293d454b..f42bcc1`, all three entry directories. An entry counts as added when its key appears as `A` and not as `D` in the same commit, so a move between majors is not an add. Major of the day is read by position against the two bump commits `4e9fe9ff6` (17 to 18) and `204356a6e` (18 to 19). | directory | added | above the major of the day | equal | below | |:--|--:|--:|--:|--:| | `semantic/` | 643 | 330 | 310 | 3 | | `retired-keys/` | 305 | 218 | 87 | 0 | | `retired-defs/` | 210 | 169 | 41 | 0 | | **total** | **1,158** | **717** | **438** | **3** | The three below: `publish-refuses-data-model-fields-that-save-and-do-not-work`, `define-form-studio-helper-renamed-define-metadata-form` and `form-type-define-form-and-packageless-list-at-form-name`, each `18.*` under protocol 19. ## Tests All readings are at head `9982079f87`, unless a line names another tree. - **Red before.** The `EM-R1` fixture (an added `semantic/18.*` while `PROTOCOL_VERSION` is `19.0.0`) run through `scan()` from `main`'s gate (`f42bcc18c6`) and from this branch's gate: main's is green, this branch's is red. The same battery run against this branch's gate with the refusal loop switched off: 15 failures, all in `EM-R1`, `EM-G5`, `EM-R3`, `EM-R4` and `EM-R5`. Nothing else in the self-test moved. - **Green after.** `node scripts/check-adr-0087-registration.mjs --self-test` printed `991 assertions` and exited 0. The battery floor holds, including `EM (#38240)` at 31. - **Replayed on real history.** `scan()` over `d9bc148e0` (#37513, the commit that filed `publish-refuses-data-model-fields-that-save-and-do-not-work` under 18 while protocol was 19) is red, naming that file. Over `216524a286` (#38239, three `R100` renames 18 to 19) it is green, with 0 entries counted as added. The CLI over `f42bcc18c6..origin/main` (`5df10eccaa`, three new `19.*` entries) prints `3 migration entries added, each at or above PROTOCOL_MAJOR 19.` <details><summary>Red before: main's scan() against this branch's, on the EM-R1 fixture</summary> ```text main f42bcc1: GREEN -- EM-R1 expected RED, got green (0 problem(s)) branch: RED (1 problem(s)) packages/spec/src/migrations/entries/semantic/18.late-note.ts: adds a migration entry under protocol major 18, below the current PROTOCOL_MAJOR 19 --- ablated gate (refusal loop off) --self-test: ✗ check-adr-0087-registration --self-test -- 15 failure(s) • EM-R1 an added semantic/18.* under PROTOCOL_MAJOR 19 is refused: expected RED, got green • EM-G5: the backfill is reported with where it was declared -- got [] • EM-R3 a backfill line with a short reason is refused: expected RED, got green • EM-R4 a backfill line naming another entry does not excuse this one: expected RED, got green • EM-R5 an added retired-keys/18.* under PROTOCOL_MAJOR 19 is refused: expected RED, got green (and ten message-match lines under those cases) ``` </details> <details><summary>Green after, and the replay on the commit that filed a 19 note under 18</summary> ```text ✓ check-adr-0087-registration --self-test: 991 assertions over real temp git repos (real scan()/assertInputs() path) replay d9bc148 (the commit that filed a 19 note under 18): protocolMajor 19 · added ["semantic/18.publish-refuses-data-model-fields-that-save-and-do-not-work.ts"] · 1 problem(s) packages/spec/src/migrations/entries/semantic/18.publish-refuses-data-model-fields-that-save-and-do-not-work.ts adds a migration entry under protocol major 18, below the current PROTOCOL_MAJOR 19 (evaluated from packages/spec/src/kernel/protocol-version.ts at d9bc148). The filename prefix alone decides which upgrade step lists an entry, and `os migrate meta --from N` replays only the steps above N. An entry filed below the current major is never shown to a project upgrading from 18, the readers it was written for. fix: file it under the current major -- git mv packages/spec/src/migrations/entries/semantic/18.publish-refuses-data-model-fields-that-save-and-do-not-work.ts packages/spec/src/migrations/entries/semantic/19.publish-refuses-data-model-fields-that-save-and-do-not-work.ts The one case that may sit lower is a BACKFILL: ... (the last line prints the exact backfill declaration for this path) replay 216524a (PR #38239, three R100 renames 18 -> 19): added 0 · 0 problem(s) $ node scripts/check-adr-0087-registration.mjs --base f42bcc1 --head origin/main ✓ check-adr-0087-registration: 1 declared-breaking changeset(s), each carrying an ADR-0087 disposition. ✓ check-adr-0087-registration: 3 migration entries added, each at or above PROTOCOL_MAJOR 19. ``` </details> <details><summary>Derived gate families: 34 derived, 34 run, all exit 0</summary> Derived with `node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack` at `9982079f87`. Each command ran under `os-verify-lock.sh`, and its exit code was captured before any pipe. - 33 commands in one runner: `VERDICT command-exit 0`. Every one exited 0: `check-adr-0087-registration` (`--base origin/main` and `--self-test`), `check-closing-keyword-parity` (both halves), `check-comment-mask-corpus`, `check-declaration-mirrors` (both), `check-self-test-wired` (both), `check-self-test-workflow-commands` (both), `check-whole-set-label-write` (both), `ci/plan-test-core-shards --self-test`, `pm/bare-root-worklist --self-test`, and the pnpm families `adr-anchors`, `agent-test-spelling`, `bash32-floor`, `changeset-gate-self-tests`, `ci-filter-parity`, `cli-command-ids`, `cross-package-test-inputs`, `driver-memory-census`, `entry-guard`, `gitlink-declared`, `nul-bytes`, `parse-guard`, `pnpm-filter-targets`, `pnpm-flag-spellings`, `ratchet-remedy-authority`, `refd-timer-probe`, `scripts-symbol-anchors` and `watch-hint-literal`. - `pnpm check:pm-dispatch-gates`: `VERDICT command-exit 0`, `dispatch-gates self-test (fast tier): 2459 cases pass`. - `dispatch-gates --ran`: `34 derived famil(ies) accounted for — 34 run, 0 NOT-MEASURED`. </details> ## Acceptance notes - **No changeset.** The diff is one file under `scripts/` and publishes nothing, so the PR carries `skip-changeset`. That label skips the real scan in `Check Changeset`. The gate's `--self-test` half still runs, unconditionally, in `Lint & Repo Gates` (`check:changeset-gate-self-tests`). - **Why a new declaration form for backfills.** The gate's only text input is changeset bodies. Its one marker is the breaking-change disposition, which a changeset may carry exactly once, and a backfill is not a breaking change. Reading the PR body instead would need the workflow to pass it in, which is a governed `.github/workflows/**` edit. The form is one line per entry, checked against the exact added path, with the same 40-character reason floor as `not-required`. A line that names no refused entry excuses nothing and is not itself an error. - **`PROTOCOL_MAJOR` runs in a child process.** `loadProtocolMajor` is async (it imports the type-stripped module) and `scan()` is synchronous and called synchronously across the whole self-test. So the reader is called in a child `node`, only when an entry is added. The reader file itself is untouched. Cost: one short spawn on a PR that adds an entry, nothing on any other. - **Seat routing on the scope (A).** The seat (repo:objectstack#5) read the card's ":570 entry dirs" as plural and ruled scope A: all three entry directories, decided by key, with `semantic/` also required in the R4 set. A stays within *added* entries, so it does not widen past the reach note 7237892858. The narrower B (`semantic/` only, exactly the R4 id set) was not taken. - **The R4 set and renames.** `ledgerAdded` (the R4 set) is an id set read from `id:` lines. Renames do not count in it, because an id survives a move. But it carries no file paths, and it cannot see `retired-keys/` or `retired-defs/`, whose entries declare `export const entry = '...'` and no `id:`. The card's directory scope and its ~1,150 reading both span all three directories, so added-ness is decided by the key in each directory, and `semantic/` additionally requires the id to be in `ledgerAdded`. EM-G3 (semantic) and EM-G6 (retired-keys) pin that a rename, here a downward one so a counting rule would red, is not counted. - **Predicate 4 untouched.** Nothing in `verifyTypeSurfaceOnly` or the prescription exemption moved (maintainer ruling 2026-08-30 on #13080). - **Not merged with `main`.** Since the branch point, `main` gained 8 commits. None touches this file, `sync-template-versions.mjs` or the protocol module (`overlap-check`: merges cleanly). The three entries `main` added are the CLI reading above. - **Follow-up filed: #38467.** As the reach note suggests, a second check could run at the protocol move: no entry absent from every released tag may stay below the new major. That shape is the one that stranded the 34. #38467 carries that check, a downward rename, a PR not re-judged after a protocol move, the `build-schemas.ts` remedy major, the README/ADR prose and `--list` (L2 N2, N3), and the delta L2 nits N1 (`retired-defs/` cost text) and N5 (capitalised placeholder words). ## Verification Read first (by risk): 1. `scan()`'s new tail block (the refusal and its backfill match) and `addedMigrationEntries`, the added-ness definition the rule stands on. 2. `protocolMajorAt`, the child process that evaluates `PROTOCOL_MAJOR` with `loadProtocolMajor`. 3. The `EM` battery, especially EM-G3 and EM-G6 (renames are not added) and EM-R2 (an unreadable major is red). Two-minute check: `node scripts/check-adr-0087-registration.mjs --self-test` prints the success line with no failures. Then run the gate on this branch with `node scripts/check-adr-0087-registration.mjs`. Its last line should read `this PR adds no migration entry.` --- _Generated by [Claude Code](https://claude.ai/code/session_01FEkQ5oPfjnm2yWHEwkiYrn)_ <!-- signed: repo:objectstack#5 · os-project-manager · session_01FEkQ5oPfjnm2yWHEwkiYrn --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 4bc5a0c commit 16f132f

1 file changed

Lines changed: 488 additions & 3 deletions

File tree

0 commit comments

Comments
 (0)