Skip to content

Commit 083e040

Browse files
fix(spec,test): unblock the 19 Version PR: open the major-19 registry regions, parse prerelease versions in the MCP save test, key the objectui pin claim on the spec major (#37557)
Fixes #37549 Clause-②: no Metadata-protocol: none ## 维护者速读 - 用户无感:发版流程里,版本号升到 19 之后,有三处会红,这里一起修掉:迁移登记表的生成不会再拒收第 19 版的下线条目;MCP 保存草稿的一条测试不再把预发布版本号(19.0.0-next.0)读坏;界面仓的版本说法检查不再写死 18。"版本发布"那个 PR 的核心测试和界面测试可以变绿。 - 为什么做:给发第一个 19 预发布版(next 渠道)清掉阻断。版本 PR 的必过检查一直是红的,现在没法合并。 - 出错会怎样:只给模板加了两个空区段,另外改了三份测试;不改任何已发布行为。出问题直接撤回这个 PR 即可。 - 要你做什么:无。 ## What changes - `packages/spec/src/migrations/registry.ts.template`: opens an empty `retired-key:19` region in `RETIRED_KEYS_BY_MAJOR` and an empty `retired-def:19` region in `RETIRED_DEFS_BY_MAJOR`, each placed and shaped like its major-18 sibling. `semantic:19` and `step19` already existed, so the migration-step side needed nothing. - `retired-def:19` goes beyond the card's wording, as an in-place fix of the same defect class. `build-schemas.ts` prescribes new retired-def entry files under the same `CURRENT_MAJOR` (`renderNewEntryFiles`, used for both kinds). So the first whole-def removal on the 19 tree would have hit the same generator refusal. Same file, same gate family, same mechanical fix. - `scripts/build-migration-registry.ts` needs no change. Its lines ~422–441 are `--self-test` fixtures, not a region list: the generator discovers regions from the template's markers. - Pin (`packages/spec/scripts/build-migration-registry-entry.test.ts`, new `describe`): every kind in `KINDS` has an open and close marker in the template for each of two majors, the spec package's major (what `build-schemas.ts` registers new entries under) and `PROTOCOL_MAJOR`. On `main` today these are 18 and 19, so the pin reds on `main` before the fix and names the missing region and the major. - Why `PROTOCOL_MAJOR` and not "spec major + 1": the protocol major moves first, on `main` (it reads 19 while the package is still 18.6.0). It is the leading signal for the next major. - "spec major + 1" would also red the Version PR tree itself (19 + 1 = 20), unless a major-20 region were opened now. - Item 2 (seat-amended scope, card #37549): `packages/runtime/src/domains/mcp-authoring.test.ts`. The `[#34774]` describe parsed `SERVER` with `split('.')`, so on the Version PR tree (`19.0.0-next.0`) the patch field was `0-next` and the built version was `19.0.NaN`, which the door refuses as not SemVer. It now parses with `SEMVER_2_0_0_VERSION_PATTERN` from `@objectstack/spec/kernel`, the grammar the door itself judges with, and drops the prerelease from the versions it builds. A new case declares the server's own version verbatim and `${major}.${minor}.0-next.0`, and asserts both save byte-identically to no declaration. Test-only; `@objectstack/runtime` ships `dist` alone, so no runtime changeset is owed. - Item 3 (seat-amended scope): `ui/scripts/__tests__/doc-version-claims.test.ts`. The `skills/objectui/SKILL.md` KNOWN_CLAIMS row was the literal `@objectstack/spec 18.x`. It is now keyed on `SPEC_MAJOR`, read from `packages/spec/package.json` under `workspaceRoot()`. The literal in the skill can't go, because the root `check-skill-compatibility-version.mjs` requires the pin and rewrites it with the version step. So `skills/**` is not touched, and the PR stays off Tier H. - Changeset `.changeset/37549-retired-key-19-region.md` (patch; the template renders into the shipped `registry.ts`). ## Tests <details><summary>Pin reds on the pre-fix template (origin/main 1af67b2 template restored, then put back)</summary> ``` × opens and closes `retired-key:19` × opens and closes `retired-def:19` AssertionError: src/migrations/registry.ts.template has no `os-generated retired-key:19` region, but major 19 is current (spec package 18.6.0, PROTOCOL_VERSION major 19); an entry registered there is refused by gen:migration-registry. ... Tests 2 failed | 8 passed (10) os-verify-lock: VERDICT command-exit 1 ``` </details> <details><summary>Version tree: spec temporarily at 19.0.0-next.0 (not committed)</summary> `pnpm gen:migration-registry && pnpm exec vitest run --maxWorkers=2 scripts/build-migration-registry-entry.test.ts scripts/build-schemas-check-mode.retired-keys.test.ts` (both projects), with `packages/spec/package.json` version set to `19.0.0-next.0`. The run includes "the printed route registers: write exactly the files check (b) names, run the generator, and (b) is silent", the case that fails on #35129. ``` Test Files 2 passed (2) Tests 20 passed (20) os-verify-lock: VERDICT command-exit 0 ``` The version was restored to `18.6.0` afterwards; `git status` was clean apart from the intended diff. </details> <details><summary>18.6.0 tree: same two files</summary> ``` Test Files 2 passed (2) Tests 23 passed (23) os-verify-lock: VERDICT command-exit 0 ``` </details> <details><summary>Items 2 and 3 on the Version tree (spec at 19.0.0-next.0 and the objectui skill pin at 19.x, both temporary, restored after)</summary> ``` runtime mcp-authoring.test.ts Tests 57 passed (57) ui doc-version-claims.test.ts Tests 29 passed (29) ``` Ablation on the same tree with the origin/main 1af67b2 versions of the two tests: runtime `1 failed | 55 passed` (the `SemVer form (e.g. 18.6.0)` case), ui 2 failed (`skills/objectui/SKILL.md :: @objectstack/spec 18.x`), matching #35129's CI failures. On the 18.6.0 tree: runtime 57/57, ui 29/29. `ui` `scripts/` suite at the final head: `172 passed | 2 skipped` files, `5130 passed` tests. </details> <details><summary>Spec package, local project, at 2fd0411: `pnpm --filter @objectstack/spec test` and `pnpm typecheck`</summary> ``` Test Files 899 passed (899) Tests 28505 passed | 1 todo (28506) os-verify-lock: VERDICT command-exit 0 typecheck (tsc + check:scripts-typecheck + check:test-typecheck): VERDICT command-exit 0 ``` `test:repo` (the vitest `repo` project) belongs to CI's Test Core. Only its one touched-path file, `build-schemas-check-mode.retired-keys.test.ts`, was run locally (above). </details> ## Acceptance notes - In-flight spec PRs #37366, #37371 and #37422: `node scripts/pm/overlap-check.mjs --pr=37366,37371,37422` gives `VERDICT clean exit 0`. Their migration changes are major-18 semantic entry files only, and none touches the template. - L2: the template is the generator's skeleton for a gitignored generated file. The two regions are empty, so no exported value or key changes shape: `RETIRED_KEYS_BY_MAJOR[19]` / `RETIRED_DEFS_BY_MAJOR[19]` become empty arrays. Body amended by the seat (repo:objectstack#2 · os-sales · session_01L6bhgV6i8jfWwSXjpWJrjA) to cover the three items the card's scope grew to; the dev report on #37549 (7194227076) carries the full evidence. ## Verification Two-minute check: `pnpm --filter @objectstack/spec exec vitest run --project local --maxWorkers=2 scripts/build-migration-registry-entry.test.ts`, expected to show `Tests 10 passed (10)`. Then set the spec version to `19.0.0-next.0` and run `scripts/build-schemas-check-mode.retired-keys.test.ts`, which should also be green. Read first: (1) the two new template regions; (2) the pin's choice of majors (spec package major and `PROTOCOL_MAJOR`). Local gate subset at 2fd0411: derived by `node scripts/pm/dispatch-gates.mjs --commands`. Verdicts are in the dev report on the card. `check:doc-formula-expressions` is NOT MEASURED locally (PREREQUISITE NOT MET: `@objectstack/formula` and `@objectstack/lint` are not built in this worktree); CI runs it. The full farm belongs to CI. --- _Generated by [Claude Code](https://claude.ai/code/session_01L6bhgV6i8jfWwSXjpWJrjA)_ <!-- signed: repo:objectstack#2 · os-sales · session_01L6bhgV6i8jfWwSXjpWJrjA --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 0f6a1e5 commit 083e040

5 files changed

Lines changed: 109 additions & 4 deletions

File tree

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
'@objectstack/spec': patch
3+
---
4+
5+
fix(spec): the migration registry template opens its major-19 retired-key and retired-def regions
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
On the 19 version tree every retirement `check:authorable-surface` prescribes registers under major 19, and `gen:migration-registry` refused those entries because the template had regions only for 17 and 18. Both tables now carry an empty major-19 region, and a test pins a region of every kind for both the spec package's major and `PROTOCOL_VERSION`'s, so the next major is caught on `main` rather than on the Version PR.

‎packages/runtime/src/domains/mcp-authoring.test.ts‎

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ import {
3838
// paid here, during collection, never inside a clocked case.
3939
import { MetadataManager } from '@objectstack/metadata';
4040
import { canonicalMetaUrlType } from '@objectstack/spec/shared';
41-
import { DEFAULT_METADATA_TYPE_REGISTRY, getMetadataCreateSeed, getMetadataTypeSchema } from '@objectstack/spec/kernel';
41+
import { DEFAULT_METADATA_TYPE_REGISTRY, getMetadataCreateSeed, getMetadataTypeSchema, SEMVER_2_0_0_VERSION_PATTERN } from '@objectstack/spec/kernel';
4242
import { z } from 'zod';
4343
import { PLATFORM_PROVIDED_TOOL_NAMES, PLATFORM_TOOL_FAMILY_PREFIXES } from '@objectstack/spec/system';
4444
import { handleMcpRequest } from './mcp.js';
@@ -944,7 +944,15 @@ describe('save_metadata_draft saves a draft and answers with its publish verdict
944944
/** [#34774] `clientSpecVersion` on the save (#34659 ruling D4 = A). */
945945
describe('[#34774] save_metadata_draft judges the client\'s declared spec version', () => {
946946
const SERVER = (createRequire(import.meta.url)('@objectstack/spec/package.json') as { version: string }).version;
947-
const [major, minor] = SERVER.split('.').map(Number);
947+
// Parsed with the SemVer 2.0.0 grammar the door itself judges with, never a
948+
// `split('.')`: on a prerelease line (`19.0.0-next.0`) the third dot-field is
949+
// `0-next`, and a patch read from it is NaN. The prerelease is DROPPED from
950+
// every version built below: each case is about major and minor, and a plain
951+
// release triple is the one shape every case means. The prerelease itself is
952+
// exercised by its own case, declared verbatim.
953+
const parsed = SEMVER_2_0_0_VERSION_PATTERN.exec(SERVER);
954+
if (!parsed) throw new Error(`@objectstack/spec resolves to ${SERVER}, which is not a SemVer 2.0.0 version`);
955+
const [major, minor, patch] = parsed.slice(1, 4).map(Number);
948956
const SAVE = { type: 'flow', name: 'lead_intake', item: FLOW_DRAFT, package: 'com.acme.crm' };
949957
const writes = (calls: unknown[]) => calls.filter((c: any) => ['saveMetaItem', 'draftPublishJudgement'].includes(c[0]));
950958
const save = async (clientSpecVersion?: unknown) => {
@@ -959,11 +967,21 @@ describe('[#34774] save_metadata_draft judges the client\'s declared spec versio
959967
expect(without.tool.parameters.properties.clientSpecVersion).toMatchObject({ type: 'string' });
960968
expect(without.tool.parameters.required).toEqual(['type', 'name', 'item']);
961969
expect(Object.keys(without.body)).toEqual(['saved', 'verdict', 'review']);
962-
const same = await save(`${major}.${minor}.${Number(SERVER.split('.')[2]) + 1}`);
970+
const same = await save(`${major}.${minor}.${patch + 1}`);
963971
expect(same.result.output.value).toBe(without.result.output.value);
964972
expect(same.writes).toEqual(without.writes);
965973
});
966974

975+
it('a prerelease of the same major and minor saves as before, and so does the server\'s own version verbatim', async () => {
976+
const without = await save();
977+
for (const declared of [SERVER, `${major}.${minor}.0-next.0`]) {
978+
const { result, writes: written } = await save(declared);
979+
expect(result.isError, declared).toBeUndefined();
980+
expect(result.output.value, declared).toBe(without.result.output.value);
981+
expect(written, declared).toEqual(without.writes);
982+
}
983+
});
984+
967985
it('done when: a client declaring the previous major is refused with the command to run, and nothing is written', async () => {
968986
for (const declared of [`${major - 1}.${minor}.0`, `${major + 1}.0.0`]) {
969987
const { body, writes: written } = await save(declared);

‎packages/spec/scripts/build-migration-registry-entry.test.ts‎

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ import fs from 'node:fs';
2222
import os from 'node:os';
2323
import path from 'node:path';
2424
import { fileURLToPath } from 'node:url';
25+
import { KINDS, TEMPLATE_PATH } from './build-migration-registry';
26+
import { PROTOCOL_MAJOR } from '../src/kernel/protocol-version';
2527

2628
const HERE = path.dirname(fileURLToPath(import.meta.url));
2729
const PKG = path.resolve(HERE, '..');
@@ -74,3 +76,45 @@ describe('build-migration-registry.ts — run, it speaks; import, it runs nothin
7476
expect(r.stderr).toBe('');
7577
});
7678
});
79+
80+
// ---------------------------------------------------------------------------
81+
// Every major an entry can register under has a region in the template.
82+
//
83+
// `build-schemas.ts` prescribes every new retired-key / retired-def entry under
84+
// the SPEC PACKAGE's major (`CURRENT_MAJOR`, parsed from its version), and an
85+
// author opening a protocol move registers semantic entries under
86+
// `PROTOCOL_VERSION`'s major. The generator refuses an entry whose major has no
87+
// marked region — correctly, since the alternative is a silent drop — so a
88+
// template that trails either major only reds once something registers there.
89+
// On `main` that is never: the package version moves only on the Version PR,
90+
// so the gap surfaced as a required check failing on the release tree. This
91+
// pins the regions on every tree instead, for both majors, each kind.
92+
// ---------------------------------------------------------------------------
93+
94+
describe('registry.ts.template — a region for each major an entry can register under', () => {
95+
const template = fs.readFileSync(path.join(PKG, TEMPLATE_PATH), 'utf8');
96+
const specVersion: string = JSON.parse(fs.readFileSync(path.join(PKG, 'package.json'), 'utf8')).version;
97+
const specMajor = Number.parseInt(specVersion, 10);
98+
const majors = [...new Set([specMajor, PROTOCOL_MAJOR])].sort((a, b) => a - b);
99+
100+
it('reads two real majors', () => {
101+
expect(Number.isInteger(specMajor) && specMajor > 0, `spec version ${specVersion}`).toBe(true);
102+
expect(Number.isInteger(PROTOCOL_MAJOR) && PROTOCOL_MAJOR > 0).toBe(true);
103+
});
104+
105+
it.each(majors.flatMap((major) => KINDS.map(({ kind }) => [kind, major] as const)))(
106+
'opens and closes `%s:%i`',
107+
(kind, major) => {
108+
const lines = template.split('\n');
109+
const open = lines.indexOf(` // <os-generated ${kind}:${major}>`);
110+
const close = lines.indexOf(` // </os-generated ${kind}:${major}>`);
111+
expect(
112+
open,
113+
`${TEMPLATE_PATH} has no \`<os-generated ${kind}:${major}>\` region, but major ${major} is current ` +
114+
`(spec package ${specVersion}, PROTOCOL_VERSION major ${PROTOCOL_MAJOR}); an entry registered there ` +
115+
'is refused by gen:migration-registry. Open the region beside the previous major\'s.',
116+
).toBeGreaterThanOrEqual(0);
117+
expect(close, `region \`${kind}:${major}\` is never closed`).toBeGreaterThan(open);
118+
},
119+
);
120+
});

‎packages/spec/src/migrations/registry.ts.template‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3896,6 +3896,17 @@ export const RETIRED_KEYS_BY_MAJOR: Readonly<Record<number, readonly string[]>>
38963896
// <os-generated retired-key:18>
38973897
// </os-generated retired-key:18>
38983898
],
3899+
// The v19 line: `PROTOCOL_VERSION` reads 19 (step19 above), and once the
3900+
// spec package itself moves to 19 every retirement `check:authorable-surface`
3901+
// prescribes is registered under major 19. Opened empty so that first entry
3902+
// has a region to land in.
3903+
19: [
3904+
// One file per entry under `entries/retired-keys/`, concatenated here sorted by
3905+
// entry id by `gen:migration-registry` (#7297). Add an entry by adding a
3906+
// FILE — never by editing between the markers, which is generated.
3907+
// <os-generated retired-key:19>
3908+
// </os-generated retired-key:19>
3909+
],
38993910
};
39003911

39013912
/**
@@ -4025,4 +4036,14 @@ export const RETIRED_DEFS_BY_MAJOR: Readonly<Record<number, readonly string[]>>
40254036
// <os-generated retired-def:18>
40264037
// </os-generated retired-def:18>
40274038
],
4039+
// The v19 line, for the same reason as RETIRED_KEYS_BY_MAJOR[19] above: the
4040+
// manifest deletion gate prescribes each removal under the spec package's
4041+
// own major. Opened empty so that first entry has a region to land in.
4042+
19: [
4043+
// One file per entry under `entries/retired-defs/`, concatenated here sorted by
4044+
// entry id by `gen:migration-registry` (#7297). Add an entry by adding a
4045+
// FILE — never by editing between the markers, which is generated.
4046+
// <os-generated retired-def:19>
4047+
// </os-generated retired-def:19>
4048+
],
40284049
};

‎ui/scripts/__tests__/doc-version-claims.test.ts‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { fileURLToPath } from 'node:url';
66

77
import { rootWorkflowsDir } from './helpers/root-ci';
88
import { labelPath, skillBundleBase, skillsWalk } from '../skill-bundle-root.mjs';
9+
import { workspaceRoot } from '../workspace-root.mjs';
910

1011
/**
1112
* objectui#3697: nothing in this repository looks at a version literal written
@@ -1046,6 +1047,17 @@ const PEER_19 = 'react' + TICK + ' ^19.0.0';
10461047
const PEER_RESTATEMENT_OK =
10471048
'Restates this package peerDependencies.react verbatim; asserted against the manifest by the peer-line assertion below (objectui#3717), no longer by a human reading it.';
10481049

1050+
/**
1051+
* The major of `@objectstack/spec` this tree builds, read from that package's own
1052+
* manifest. The objectui skill's `compatibility:` pin states it, and the version step
1053+
* rewrites the pin together with the manifest, so its KNOWN_CLAIMS row is keyed on this
1054+
* value rather than on a literal major that the next release would leave stale.
1055+
*/
1056+
const SPEC_MAJOR = Number.parseInt(
1057+
(JSON.parse(fs.readFileSync(path.join(workspaceRoot(), 'packages/spec/package.json'), 'utf8')) as { version: string }).version,
1058+
10,
1059+
);
1060+
10491061
const KNOWN_CLAIMS: KnownClaim[] = [
10501062
// --- content/docs ------------------------------------------------------------
10511063
{
@@ -1159,7 +1171,7 @@ const KNOWN_CLAIMS: KnownClaim[] = [
11591171
// the measurement and for why two of these blocks anchor and one does not.
11601172
{
11611173
file: 'skills/objectui/SKILL.md',
1162-
claim: '@objectstack/spec 18.x',
1174+
claim: `@objectstack/spec ${SPEC_MAJOR}.x`,
11631175
kind: 'anchored',
11641176
why: 'The `compatibility:` pin of the frontmatter. The bundle moved into the objectstack monorepo\'s published `skills/` catalog at the cutover (decision C, objectstack#25803), and that catalog REQUIRES the pin: the repo root\'s `scripts/check-skill-compatibility-version.mjs` reds a skill that declares none and reds this one when its major differs from `packages/spec/package.json`, whose `--fix` derives it. That gate is the anchor, run outside this tree, so no field here can name it. The sentence this replaced stated no version for the reason this file exists; it now states one that a gate re-derives.',
11651177
},

0 commit comments

Comments
 (0)