From 5508f9f5e975b37923303f5fa6913e0b0bb5e9da Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 28 Nov 2026 01:36:13 +0000 Subject: [PATCH] test(ui): doc-version-claims reads the spec major from the package it resolves, not a fixed workspace path The module-top read of workspaceRoot()/packages/spec/package.json threw on load in a standalone objectui checkout, where no packages/spec exists. The manifest now comes from createRequire().resolve('@objectstack/spec/package.json'), which under the monorepo is the same workspace file the version step rewrites; a new describe pins that. Claude-Session: https://claude.ai/code/session_01L9qibxRSo4RBpRknKqBLmy Co-authored-by: Claude --- .../__tests__/doc-version-claims.test.ts | 37 ++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/ui/scripts/__tests__/doc-version-claims.test.ts b/ui/scripts/__tests__/doc-version-claims.test.ts index abf425bff85..c4617da6dc3 100644 --- a/ui/scripts/__tests__/doc-version-claims.test.ts +++ b/ui/scripts/__tests__/doc-version-claims.test.ts @@ -1,5 +1,6 @@ import { describe, expect, it } from 'vitest'; import fs from 'node:fs'; +import { createRequire } from 'node:module'; import os from 'node:os'; import path from 'node:path'; import { fileURLToPath } from 'node:url'; @@ -1047,6 +1048,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 `@objectstack/spec` manifest this tree resolves: the package its own dependency + * (`ui/package.json`, `workspace:^`) points at, found the way node finds it. Under the + * objectstack monorepo that is `packages/spec/package.json` in the workspace root, the + * file the version step rewrites, and the pin in "the source of the spec major" below holds + * it there. In a standalone objectui checkout it is the installed package. A fixed + * workspace path would name a file that layout does not have, and this file would + * throw on load before any test ran. + */ +const SPEC_MANIFEST = createRequire(import.meta.url).resolve('@objectstack/spec/package.json'); + /** * 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 @@ -1054,7 +1066,7 @@ const PEER_RESTATEMENT_OK = * 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, + (JSON.parse(fs.readFileSync(SPEC_MANIFEST, 'utf8')) as { version: string }).version, 10, ); @@ -2206,6 +2218,29 @@ const manifestVersionChecks: ManifestVersionCheck[] = KNOWN_CLAIMS.flatMap((entr ]; }); +describe('doc version claims - the source of the spec major', () => { + // The skill row's claim is keyed on SPEC_MAJOR, so the manifest it is read from is + // load-bearing: a resolution that drifted to some other copy of the package would key + // the row on that copy's major and stay green against a stale pin. + const workspaceManifest = path.join(workspaceRoot(), 'packages/spec/package.json'); + + it('under the monorepo, resolves the workspace spec package the version step rewrites', () => { + if (!fs.existsSync(workspaceManifest)) { + // Standalone objectui: there is no workspace spec package, so the resolution must + // land on an installed one rather than inside this tree's own sources. + expect(SPEC_MANIFEST.split(path.sep)).toContain('node_modules'); + return; + } + expect(fs.realpathSync(SPEC_MANIFEST)).toBe(fs.realpathSync(workspaceManifest)); + }); + + it('reads a real major from it', () => { + const { version } = JSON.parse(fs.readFileSync(SPEC_MANIFEST, 'utf8')) as { version: string }; + expect(Number.isInteger(SPEC_MAJOR) && SPEC_MAJOR > 0).toBe(true); + expect(version.startsWith(`${SPEC_MAJOR}.`)).toBe(true); + }); +}); + describe('doc version claims - the scan itself', () => { it('reads a plausible corpus, so a broken scan cannot report green', () => { // Every count below is a floor, not the measured value: docs are added and