diff --git a/.changeset/37549-retired-key-19-region.md b/.changeset/37549-retired-key-19-region.md new file mode 100644 index 00000000000..6a42bb67580 --- /dev/null +++ b/.changeset/37549-retired-key-19-region.md @@ -0,0 +1,10 @@ +--- +'@objectstack/spec': patch +--- + +fix(spec): the migration registry template opens its major-19 retired-key and retired-def regions + +Clause-②: no +Metadata-protocol: none + +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. diff --git a/packages/runtime/src/domains/mcp-authoring.test.ts b/packages/runtime/src/domains/mcp-authoring.test.ts index cbddf3ef466..ed123972f14 100644 --- a/packages/runtime/src/domains/mcp-authoring.test.ts +++ b/packages/runtime/src/domains/mcp-authoring.test.ts @@ -38,7 +38,7 @@ import { // paid here, during collection, never inside a clocked case. import { MetadataManager } from '@objectstack/metadata'; import { canonicalMetaUrlType } from '@objectstack/spec/shared'; -import { DEFAULT_METADATA_TYPE_REGISTRY, getMetadataCreateSeed, getMetadataTypeSchema } from '@objectstack/spec/kernel'; +import { DEFAULT_METADATA_TYPE_REGISTRY, getMetadataCreateSeed, getMetadataTypeSchema, SEMVER_2_0_0_VERSION_PATTERN } from '@objectstack/spec/kernel'; import { z } from 'zod'; import { PLATFORM_PROVIDED_TOOL_NAMES, PLATFORM_TOOL_FAMILY_PREFIXES } from '@objectstack/spec/system'; import { handleMcpRequest } from './mcp.js'; @@ -944,7 +944,15 @@ describe('save_metadata_draft saves a draft and answers with its publish verdict /** [#34774] `clientSpecVersion` on the save (#34659 ruling D4 = A). */ describe('[#34774] save_metadata_draft judges the client\'s declared spec version', () => { const SERVER = (createRequire(import.meta.url)('@objectstack/spec/package.json') as { version: string }).version; - const [major, minor] = SERVER.split('.').map(Number); + // Parsed with the SemVer 2.0.0 grammar the door itself judges with, never a + // `split('.')`: on a prerelease line (`19.0.0-next.0`) the third dot-field is + // `0-next`, and a patch read from it is NaN. The prerelease is DROPPED from + // every version built below: each case is about major and minor, and a plain + // release triple is the one shape every case means. The prerelease itself is + // exercised by its own case, declared verbatim. + const parsed = SEMVER_2_0_0_VERSION_PATTERN.exec(SERVER); + if (!parsed) throw new Error(`@objectstack/spec resolves to ${SERVER}, which is not a SemVer 2.0.0 version`); + const [major, minor, patch] = parsed.slice(1, 4).map(Number); const SAVE = { type: 'flow', name: 'lead_intake', item: FLOW_DRAFT, package: 'com.acme.crm' }; const writes = (calls: unknown[]) => calls.filter((c: any) => ['saveMetaItem', 'draftPublishJudgement'].includes(c[0])); const save = async (clientSpecVersion?: unknown) => { @@ -959,11 +967,21 @@ describe('[#34774] save_metadata_draft judges the client\'s declared spec versio expect(without.tool.parameters.properties.clientSpecVersion).toMatchObject({ type: 'string' }); expect(without.tool.parameters.required).toEqual(['type', 'name', 'item']); expect(Object.keys(without.body)).toEqual(['saved', 'verdict', 'review']); - const same = await save(`${major}.${minor}.${Number(SERVER.split('.')[2]) + 1}`); + const same = await save(`${major}.${minor}.${patch + 1}`); expect(same.result.output.value).toBe(without.result.output.value); expect(same.writes).toEqual(without.writes); }); + it('a prerelease of the same major and minor saves as before, and so does the server\'s own version verbatim', async () => { + const without = await save(); + for (const declared of [SERVER, `${major}.${minor}.0-next.0`]) { + const { result, writes: written } = await save(declared); + expect(result.isError, declared).toBeUndefined(); + expect(result.output.value, declared).toBe(without.result.output.value); + expect(written, declared).toEqual(without.writes); + } + }); + it('done when: a client declaring the previous major is refused with the command to run, and nothing is written', async () => { for (const declared of [`${major - 1}.${minor}.0`, `${major + 1}.0.0`]) { const { body, writes: written } = await save(declared); diff --git a/packages/spec/scripts/build-migration-registry-entry.test.ts b/packages/spec/scripts/build-migration-registry-entry.test.ts index 1212f23249e..05869239b5c 100644 --- a/packages/spec/scripts/build-migration-registry-entry.test.ts +++ b/packages/spec/scripts/build-migration-registry-entry.test.ts @@ -22,6 +22,8 @@ import fs from 'node:fs'; import os from 'node:os'; import path from 'node:path'; import { fileURLToPath } from 'node:url'; +import { KINDS, TEMPLATE_PATH } from './build-migration-registry'; +import { PROTOCOL_MAJOR } from '../src/kernel/protocol-version'; const HERE = path.dirname(fileURLToPath(import.meta.url)); const PKG = path.resolve(HERE, '..'); @@ -74,3 +76,45 @@ describe('build-migration-registry.ts — run, it speaks; import, it runs nothin expect(r.stderr).toBe(''); }); }); + +// --------------------------------------------------------------------------- +// Every major an entry can register under has a region in the template. +// +// `build-schemas.ts` prescribes every new retired-key / retired-def entry under +// the SPEC PACKAGE's major (`CURRENT_MAJOR`, parsed from its version), and an +// author opening a protocol move registers semantic entries under +// `PROTOCOL_VERSION`'s major. The generator refuses an entry whose major has no +// marked region — correctly, since the alternative is a silent drop — so a +// template that trails either major only reds once something registers there. +// On `main` that is never: the package version moves only on the Version PR, +// so the gap surfaced as a required check failing on the release tree. This +// pins the regions on every tree instead, for both majors, each kind. +// --------------------------------------------------------------------------- + +describe('registry.ts.template — a region for each major an entry can register under', () => { + const template = fs.readFileSync(path.join(PKG, TEMPLATE_PATH), 'utf8'); + const specVersion: string = JSON.parse(fs.readFileSync(path.join(PKG, 'package.json'), 'utf8')).version; + const specMajor = Number.parseInt(specVersion, 10); + const majors = [...new Set([specMajor, PROTOCOL_MAJOR])].sort((a, b) => a - b); + + it('reads two real majors', () => { + expect(Number.isInteger(specMajor) && specMajor > 0, `spec version ${specVersion}`).toBe(true); + expect(Number.isInteger(PROTOCOL_MAJOR) && PROTOCOL_MAJOR > 0).toBe(true); + }); + + it.each(majors.flatMap((major) => KINDS.map(({ kind }) => [kind, major] as const)))( + 'opens and closes `%s:%i`', + (kind, major) => { + const lines = template.split('\n'); + const open = lines.indexOf(` // `); + const close = lines.indexOf(` // `); + expect( + open, + `${TEMPLATE_PATH} has no \`\` region, but major ${major} is current ` + + `(spec package ${specVersion}, PROTOCOL_VERSION major ${PROTOCOL_MAJOR}); an entry registered there ` + + 'is refused by gen:migration-registry. Open the region beside the previous major\'s.', + ).toBeGreaterThanOrEqual(0); + expect(close, `region \`${kind}:${major}\` is never closed`).toBeGreaterThan(open); + }, + ); +}); diff --git a/packages/spec/src/migrations/registry.ts.template b/packages/spec/src/migrations/registry.ts.template index f9172188748..6062347b83c 100644 --- a/packages/spec/src/migrations/registry.ts.template +++ b/packages/spec/src/migrations/registry.ts.template @@ -3896,6 +3896,17 @@ export const RETIRED_KEYS_BY_MAJOR: Readonly> // // ], + // The v19 line: `PROTOCOL_VERSION` reads 19 (step19 above), and once the + // spec package itself moves to 19 every retirement `check:authorable-surface` + // prescribes is registered under major 19. Opened empty so that first entry + // has a region to land in. + 19: [ + // One file per entry under `entries/retired-keys/`, concatenated here sorted by + // entry id by `gen:migration-registry` (#7297). Add an entry by adding a + // FILE — never by editing between the markers, which is generated. + // + // + ], }; /** @@ -4025,4 +4036,14 @@ export const RETIRED_DEFS_BY_MAJOR: Readonly> // // ], + // The v19 line, for the same reason as RETIRED_KEYS_BY_MAJOR[19] above: the + // manifest deletion gate prescribes each removal under the spec package's + // own major. Opened empty so that first entry has a region to land in. + 19: [ + // One file per entry under `entries/retired-defs/`, concatenated here sorted by + // entry id by `gen:migration-registry` (#7297). Add an entry by adding a + // FILE — never by editing between the markers, which is generated. + // + // + ], }; diff --git a/ui/scripts/__tests__/doc-version-claims.test.ts b/ui/scripts/__tests__/doc-version-claims.test.ts index f2bca5ea5a1..abf425bff85 100644 --- a/ui/scripts/__tests__/doc-version-claims.test.ts +++ b/ui/scripts/__tests__/doc-version-claims.test.ts @@ -6,6 +6,7 @@ import { fileURLToPath } from 'node:url'; import { rootWorkflowsDir } from './helpers/root-ci'; import { labelPath, skillBundleBase, skillsWalk } from '../skill-bundle-root.mjs'; +import { workspaceRoot } from '../workspace-root.mjs'; /** * objectui#3697: nothing in this repository looks at a version literal written @@ -1046,6 +1047,17 @@ const PEER_19 = 'react' + TICK + ' ^19.0.0'; const PEER_RESTATEMENT_OK = '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.'; +/** + * The major of `@objectstack/spec` this tree builds, read from that package's own + * manifest. The objectui skill's `compatibility:` pin states it, and the version step + * rewrites the pin together with the manifest, so its KNOWN_CLAIMS row is keyed on this + * value rather than on a literal major that the next release would leave stale. + */ +const SPEC_MAJOR = Number.parseInt( + (JSON.parse(fs.readFileSync(path.join(workspaceRoot(), 'packages/spec/package.json'), 'utf8')) as { version: string }).version, + 10, +); + const KNOWN_CLAIMS: KnownClaim[] = [ // --- content/docs ------------------------------------------------------------ { @@ -1159,7 +1171,7 @@ const KNOWN_CLAIMS: KnownClaim[] = [ // the measurement and for why two of these blocks anchor and one does not. { file: 'skills/objectui/SKILL.md', - claim: '@objectstack/spec 18.x', + claim: `@objectstack/spec ${SPEC_MAJOR}.x`, kind: 'anchored', 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.', },