Repository navigation
fix(metadata-core)!: a package ahead of the runtime is told to upgrade, not to run migrate meta - #26530
Conversation
…, not to run migrate meta The OS_PROTOCOL_INCOMPATIBLE refusal turned every refused range's floor major into `objectstack migrate meta --from N`, so a package declaring '^19' on a protocol-18 runtime was sent to `--from 19`, which cannot apply. When the declared floor major is above the runtime's, the refusal now names the runtime upgrade or a build of the package for this protocol, and the diagnostic carries no migrateCommand. Code, status and the older-major prescription are unchanged. Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5kXo3UyYbZ5BSu2Zge
📓 Docs Drift CheckThis PR changes 3 package(s): 10 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
⛔ 4 release-owned page(s) also name something this change touched. These are read-only:
What this run could not see
Coarse fallback — 33 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin ac2028cab5f42821bd26fa50e520f69d41e573f4 && git checkout ac2028cab5f42821bd26fa50e520f69d41e573f4
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin f486e9c1ba5d79c400cf6b0223dd74768461a8b1 a085843323063280fd96067d816b6a049cd74acf && git checkout -B drift-repro f486e9c1ba5d79c400cf6b0223dd74768461a8b1 && git merge --no-ff a085843323063280fd96067d816b6a049cd74acf
node scripts/docs-audit/affected-docs.mjs --json f486e9c1ba5d79c400cf6b0223dd74768461a8b1
|
…surface narrowing ProtocolIncompatibleDiagnostic is exported from metadata-core's entry, and its migrateCommand member goes from string to optional, so the change narrows what the package exposes: Clause-② yes (narrowing), the BREAKING banner, and the ADR-0087 runtime-interface-only disposition naming the interface. Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5kXo3UyYbZ5BSu2Zge
Narrowing a published surface is declared Clause-② no (narrowing); yes is for widening it. Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5kXo3UyYbZ5BSu2Zge
Contract reviewServed-tier: Inputs read 2026-10-27T07:34Z: card #26480 body and all 3 comments (triage 6434187705, claim 6434943225, os-dev-report 6436225748; the earlier report 6435591073 on #25235 is superseded and was not used), PR #26530 body (the replaced one, updated 2026-10-27T07:29Z), its 7-file list, ① Derived judgments
② Semver level
③ Boundary flags
Implemented-by: VERDICT: PASS |
席位核对 · ACCEPT ·
|
| item | reading |
|---|---|
| Shape | Draft, base main, Fixes #26480, with a ! title. 7 files across metadata-core, cloud-connection and runtime. One patch changeset with a BREAKING banner and ADR-0087 not-required (runtime-interface-only …#ProtocolIncompatibleDiagnostic). Clause-②: no (narrowing) and Metadata-protocol: none appear in both the body (replaced at this head) and the changeset. |
| Fix | Triage 6434187705. A declared floor major above the runtime's is refused with a remedy naming the runtime upgrade, or a build for this major, and no migrateCommand. ProtocolIncompatibleDiagnostic.migrateCommand becomes optional, and error.details omits the key for an ahead package on both install doors, through the one shared answer. The older-major prescription, the accept set, the code and the 422 are unchanged. |
| Contract | Review 6436379810: the one public-surface change is the optional member, declared right, and no reader outside the tests dereferences it. |
| Evidence | CI on head a085843323: 41 succeeded, 13 expected skips, none failed or pending; mergeable clean. The full dogfood battery on this head is in 6436732434: VERDICT exit 0, 300 files and 2494 tests passed, 3 and 18 skipped, no failures (review-checklist.md :50). |
| Carried | Two follow-ups. The exclusive-comparator residue ('>18' and '<18' on 18 still get --from 18) is filed as #26546. The spec ledger comment for OS_PROTOCOL_INCOMPATIBLE (error-code-ledger.zod.ts :763–765) and ADR-0087 D1 (line 116) still describe migrateCommand as always present; these are comment-only and go to the spec seat, as noted on #26546. |
| Landing | 「按照 pm-dispatch 规则复核过的都授权」 (Leehom, 2026-10-25T11:35Z): ready and auto-merge through the relay. |
Generated by Claude Code
Requested by Leehom · project thread
Fixes #26480
Clause-②: no (narrowing)
Metadata-protocol: none
维护者速读
^19)时,OS_PROTOCOL_INCOMPATIBLE拒绝不再建议migrate meta --from 19,改为提示升级运行时或安装适配本主版本的包;details里不再带migrateCommand。migrate meta只能把旧主版本的元数据往前迁,对“包比运行时新”的情况是死路,运维会被误导。ProtocolIncompatibleDiagnostic.migrateCommand从必有变为可选,仓外若有 TypeScript 代码直接取用它会在编译时报错。拒绝的 code 与 422 状态不变,旧主版本(如^17)的提示完全不变。回滚即 revert 本 PR。packages/metadata-core/src/protocol-handshake.ts(checkProtocolCompat里ahead分支);packages/runtime/src/domains/packages-install-protocol-incompatible.test.ts(HTTP 门的新用例)。pnpm --filter @objectstack/metadata-core exec vitest run src/protocol-handshake.test.ts,预期 37/37 通过,其中[#26480]四条。What changes
checkProtocolCompat(@objectstack/metadata-core) now compares the declared floor major (declaredFloorMajor) with the runtime's protocol major before it writes the prescription:migrateCommand, and the message endsThe package is built for a newer protocol than this runtime implements. Upgrade the runtime to protocol 19, or install a build of 'ID' for protocol 18.Run: objectstack migrate meta --from NandmigrateCommandas before.protocolIncompatibleAnswerleavesmigrateCommandout ofdetailswhen the diagnostic has none (neverundefined), so both HTTP doors,POST /api/v1/packagesandPOST /api/v1/marketplace/install-local, answer four members for the ahead case.ProtocolIncompatibleDiagnostic.migrateCommandbecomes optional in the exported type. The refusal's code and status (422OS_PROTOCOL_INCOMPATIBLE) do not change. Two comments that said the diagnostic always namesmigrate meta(runtime/src/app-plugin.ts, the rehydrate line incloud-connection/src/marketplace-install-local-plugin.ts) now name both remedies. Changeset:@objectstack/metadata-corepatch, with the BREAKING banner and the ADR-0087 dispositionnot-required (runtime-interface-only packages/metadata-core/src/protocol-handshake.ts#ProtocolIncompatibleDiagnostic).BREAKING public-surface narrowing, shipped as
patchbecause it is not a metadata-protocol change:ProtocolIncompatibleDiagnosticis exported from@objectstack/metadata-core's entry (export * from './protocol-handshake.js'), and itsmigrateCommandmember goes fromstringto optional. A guaranteed output member that can now be absent narrows what the package exposes. pm-dispatchexecution-duties.md: "收窄已发布接受集的卡是Clause-②: no,不移车道;入队前欠一次契约复审档复核。" So the declaration isClause-②: no (narrowing), and the PR owes a contract-review pass before it is queued.No FROM → TO line, on purpose. AGENTS.md Post-Task Checklist step 3 asks for one when a change is "removing or renaming anything an author can write (a spec key, an export, a config field)"; this change removes and renames nothing, it makes one output member optional. The disposition it takes,
runtime-interface-only, "ALSO inherits theno-migration-prescriptionrefusal" (scripts/check-adr-0087-registration.mjsheader), so a rewrite prescription in the changeset would refuse the category. What a reader does instead is stated in prose: treat an absentmigrateCommandas "no command applies; readmessage"; a TypeScript reader that dereferences it is told by its compiler.Why
The card's reproduction: on a protocol-18 runtime,
POST /api/v1/packageswithengines.protocol: '^19'answereddetails.migrateCommand = objectstack migrate meta --from 19and "Run: objectstack migrate meta --from 19". Migration only moves metadata forward from an older major, so the operator was sent to a command that cannot apply. Ruling: triage 6434187705.Tests
Red first on
main(00874b9e09), then green on the fix:mainmetadata-coreprotocol-handshake.test.tsruntimepackages-install-protocol-incompatible.test.ts(both door arms)cloud-connectionmarketplace-install-local-protocol-handshake.test.ts(install door and rehydrate log line)[#26480]blocks assert the ADR-0112 envelope (code+status422),detailswithoutmigrateCommand, nomigrate metain the message, and the runtime upgrade named. The^17-style control (^10on an 11 runtime in the unit suite, and every existing older-major test) keeps--from N.scripts/ablation-replace.mjs):const ahead = targetMajor !== null && targetMajor > runtimeMajor;replaced byconst ahead = false;turns the 3 unit tests red (34 still pass, the control included); restored from the HEAD blobde811bf3863,git diff HEADempty afterwards.Whole packages at
43b9bd0d9:metadata-coretest 827/827 + typecheck exit 0;runtime8371 passed, 19 skipped + typecheck exit 0;cloud-connection747/747 + typecheck exit 0.eslint --no-inline-configon the six touched.tsfiles: exit 0.After merging
origin/main(d2ca7079b), the three targeted suites again ata08584332: 37/37, 8/8, 13/13.Dogfood battery (owed by the
(narrowing)arm):@objectstack/dogfood^...closure built, thenpnpm --filter @objectstack/dogfood testunder the lock at17bb14466: VERDICT command-exit 0, Test Files 300 passed, 3 skipped (303); Tests 2494 passed, 18 skipped (2512); no failures. The final heada08584332differs from17bb14466only in the changeset'sClause-②line (git diff --stat: 1 file, 1 line).Acceptance notes
details.migrateCommand. No in-repo code outside tests reads it. The console's not-loaded marker reads onlycodeandrequiredRange;os package installprints the server'serror.message; the artifact boot refusal (runtime/src/artifact-reference.ts) and theservice-packagerehydrate log embeddiagnostic.message; thecloud-connectionrehydrate line embeds the message and already says "install a version of the package built for protocol N". The CLI'scheckProtocolVersionGapalready stays silent when the declared major is at or above the installed one. None hard-codes the old text.OS_PROTOCOL_INCOMPATIBLE(packages/spec/src/api/error-code-ledger.zod.ts) listsmigrateCommandamong theerror.detailsmembers. That stays true for older majors and is now incomplete for the ahead case; it is a comment underpackages/spec, outside this lane, so it is left as is.--from N: on an 18 runtime,'>18'(which means 19 and up, so the package is ahead) and'<18'both answerobjectstack migrate meta --from 18. Measured on the builtdist/of this branch. The ruling covers a floor ABOVE the runtime's only, so it is reported to the seat rather than fixed here.Verification
Derived gate families (`dispatch-gates.mjs --commands`, run at 17bb144 after the main merge)
62 derived, 61 run with exit 0, 1 NOT MEASURED:
pnpm check:dual-build-cjs-loadsexit 3 (prerequisite not met, needs a full build; CI runs it).dispatch-gates.mjs --ran: "62 derived famil(ies) accounted for — 61 run, 1 NOT-MEASURED". The changeset families re-run on the final heada08584332:check-adr-0087-registration --base origin/mainexit 0 ("1 declared-breaking changeset(s), each carrying an ADR-0087 disposition",runtime-interface-onlyverified onProtocolIncompatibleDiagnostic);check-changeset-no-majorwith this body as the event exit 0 (LEVEL AXIS:no (narrowing),none,patch);check-empty-changesetexit 0.Human Minimum
packages/specholds no runtime logic. (Nopackages/specchange.)pnpm lintpasses. (Scoped to the touched files.)main, one pull request.packages/spectouched: its generated artifacts are regenerated and committed. (Not touched.)content/docs/references/,packages/*/CHANGELOG.mdorcontent/docs/releases/.🤖 Generated with Claude Code
https://claude.ai/code/session_01FEkQ5kXo3UyYbZ5BSu2Zge
Generated by Claude Code