Skip to content

Commit 4d0dca4

Browse files
committed
fix(scripts): ADR-0087 registration gate reads workspace globs and compiles .tsx
The gate's hand-kept PACKAGE_ROOTS predated the ui/ import, so no @object-ui/* package had a workspace manifest here. It now reads the package globs from pnpm-workspace.yaml at the judged rev, through workspace-enumerator's parse. The export reader's Program also sets `jsx`, without which every .tsx module failed to resolve (TS6142) and predicate 2 could not locate any declaration behind it. bare-root-worklist: the three PACKAGE_ROOTS rows are deleted (stale) and the declaration battery's floor follows (126 -> 122). Claude-Session: https://claude.ai/code/session_01Am8eYNReiNP66D2JihPS1q Co-authored-by: Claude <noreply@anthropic.com>
1 parent 5cb1c1a commit 4d0dca4

2 files changed

Lines changed: 83 additions & 31 deletions

File tree

‎scripts/check-adr-0087-registration.mjs‎

Lines changed: 79 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,10 @@ import { readClause2Line, readMetadataProtocolLine } from './pm/clause2-line.mjs
399399
// this gate into a sandbox (`objectui-changeset-digest.mjs`), because two hand
400400
// lists for one graph is how one of them goes stale unnoticed.
401401
import { stageFirstPartyClosure } from './first-party-closure.mjs';
402+
// #26220 — the workspace's package globs, through the repo's ONE parse of
403+
// `pnpm-workspace.yaml` rather than a hand-kept list of roots (see
404+
// `workspaceGlobsAt`).
405+
import { WORKSPACE_FILE, WorkspaceEnumerationError, isExclusionGlob, parseWorkspaceGlobs } from './workspace-enumerator.mjs';
402406

403407
// ── The self-test's own battery roster and floor (#13489) ──────────────────
404408
//
@@ -533,8 +537,6 @@ export const MIGRATION_LEDGER_ENTRY_DIRS = [
533537
const WITNESS_GENERATOR = 'packages/spec/scripts/build-spec-changes.ts';
534538
const WITNESS_INPUTS = ['packages/spec/src', 'packages/spec/scripts', 'packages/spec/package.json'];
535539

536-
/** Package roots holding workspace manifests, for the `unpublished` precondition. */
537-
const PACKAGE_ROOTS = ['packages', 'apps', 'examples'];
538540

539541
/**
540542
* The closed disposition vocabulary. Adding a category is a deliberate act.
@@ -2663,21 +2665,82 @@ export function assertInputs({ cwd, head, witness = generatedWitness }) {
26632665
// Workspace manifests -- the `unpublished` precondition
26642666
// ---------------------------------------------------------------------------
26652667

2668+
/**
2669+
* The workspace's package globs at a rev -- `pnpm-workspace.yaml` read from git and
2670+
* parsed by `workspace-enumerator.mjs`, the repo's one parse of it (#26220).
2671+
*
2672+
* This gate used to carry its own `PACKAGE_ROOTS = ['packages', 'apps', 'examples']`.
2673+
* That list predates the objectui import, so every `@object-ui/*` package (the
2674+
* `ui/packages/*`, `ui/apps/*` and `ui/examples/*` globs) had no workspace manifest
2675+
* here, and every disposition that reads one -- `unpublished`, `type-surface-only`
2676+
* predicate 1, `runtime-export-retired` predicate 1 -- refused a true claim about
2677+
* them. A hand-kept copy of the workspace's membership is the same drift #14378
2678+
* found in a different file; the workspace's own declaration cannot drift from
2679+
* itself. Read at the REV being judged, never from the working tree, so the gate
2680+
* stays a pure function of its two revs.
2681+
*
2682+
* A missing file, an empty or duplicate `packages:` block and a glob richer than
2683+
* `<dir>` / `<dir>/*` are REFUSED with `WorkspaceEnumerationError`, never read as an
2684+
* empty workspace: every disposition above would then answer "no workspace
2685+
* manifest" about a package that has one.
2686+
*
2687+
* @returns {string[]} the inclusion globs; an exclusion (`!pattern`) enumerates nothing
2688+
*/
2689+
export function workspaceGlobsAt(rev, cwd) {
2690+
const source = `${WORKSPACE_FILE} at ${rev.slice(0, 12)}`;
2691+
const text = showOrNull(rev, WORKSPACE_FILE, cwd);
2692+
if (text === null) {
2693+
throw new WorkspaceEnumerationError(
2694+
`${source} is missing -- the workspace's package globs cannot be read, so no package can be\n` +
2695+
' matched to its manifest. Refused rather than read as an empty workspace (#4690).',
2696+
);
2697+
}
2698+
const globs = parseWorkspaceGlobs(text, { source }).filter((g) => !isExclusionGlob(g));
2699+
for (const g of globs) {
2700+
if (g.replace(/\/\*$/, '').includes('*')) {
2701+
throw new WorkspaceEnumerationError(
2702+
`${source}: pattern ${JSON.stringify(g)} is richer than \`<dir>\` or \`<dir>/*\`, the two shapes\n` +
2703+
' `workspace-enumerator.mjs` expands. Teach both readers the new shape in one edit;\n' +
2704+
' matching fewer manifests would refuse true claims about the packages left out.',
2705+
);
2706+
}
2707+
}
2708+
return globs;
2709+
}
2710+
2711+
/**
2712+
* Is `manifest` (a repo-relative `<dir>/package.json`) a workspace member's
2713+
* manifest under `globs`? `<dir>` names that directory; `<dir>/*` names each
2714+
* directory directly under it -- the expansion `expandWorkspaceGlob` performs on a
2715+
* working tree, applied here to a path listed from a rev.
2716+
*/
2717+
export function isWorkspaceManifest(manifest, globs) {
2718+
if (!manifest.endsWith('/package.json') || manifest.includes('node_modules/')) return false;
2719+
const dir = manifest.slice(0, -'/package.json'.length);
2720+
const parent = posix.dirname(dir);
2721+
const leaf = posix.basename(dir);
2722+
return globs.some((g) => (g.endsWith('/*')
2723+
? parent === g.slice(0, -2) && !leaf.startsWith('.')
2724+
: dir === g));
2725+
}
2726+
26662727
/**
26672728
* name -> { private, file } for every workspace package at a rev.
26682729
*
26692730
* Read from git rather than the working tree so the whole gate is a pure function
26702731
* of two revs, which is what lets the self-test drive the shipping code path with
2671-
* real temp repositories instead of an imitation of it.
2732+
* real temp repositories instead of an imitation of it. The members are the ones
2733+
* the rev's own `pnpm-workspace.yaml` declares (`workspaceGlobsAt`).
26722734
*/
26732735
export function workspacePackagesAt(rev, cwd) {
26742736
const pkgs = new Map();
2737+
const globs = workspaceGlobsAt(rev, cwd);
26752738
let out;
26762739
try { out = git(['ls-tree', '-r', '--name-only', rev], cwd); } catch { return pkgs; }
26772740
const manifests = out
26782741
.split('\n')
26792742
.map((s) => s.trim())
2680-
.filter((p) => p.endsWith('/package.json') && !p.includes('node_modules/') && PACKAGE_ROOTS.some((r) => p.startsWith(`${r}/`)));
2743+
.filter((p) => isWorkspaceManifest(p, globs));
26812744
for (const [p, raw] of showManyOrNull(rev, manifests, cwd)) {
26822745
try {
26832746
const json = JSON.parse(raw);
@@ -4537,6 +4600,7 @@ function readExportSurface(rev, cwd, pkgName, pkgs, kit) {
45374600
const fromVirtual = (f) => (f.startsWith(VIRTUAL_ROOT) ? f.slice(VIRTUAL_ROOT.length) : null);
45384601
const options = {
45394602
noEmit: true, skipLibCheck: true, types: [], lib: ['lib.es2022.d.ts'],
4603+
jsx: ts.JsxEmit.Preserve,
45404604
target: ts.ScriptTarget.ES2022, module: ts.ModuleKind.ESNext, moduleResolution: ts.ModuleResolutionKind.Bundler,
45414605
};
45424606
const real = ts.createCompilerHost(options, true);
@@ -5587,7 +5651,16 @@ function selfTest() {
55875651
'# ADR-0087 (fixture)\n\n' +
55885652
cats.map((c) => `<!-- adr-0087: not-required (${c}) ... -->\n`).join('');
55895653

5590-
const build = ({ baseIds = ['old-entry-one', 'old-entry-two'], headIds = null, files = {}, baseFiles = {}, pkgs = null }) => {
5654+
// The fixture's `pnpm-workspace.yaml` (#26220): the real file's glob shapes,
5655+
// `ui/packages/*` among them, so a fixture package is a member exactly when it
5656+
// would be one in this repository. `workspace: null` writes none.
5657+
const WORKSPACE_YAML =
5658+
'packages:\n - packages/*\n - packages/apps/*\n - packages/drivers/*\n - packages/plugins/*\n' +
5659+
' - packages/qa/*\n - packages/triggers/*\n - packages/services/*\n - packages/adapters/*\n' +
5660+
' - packages/connectors/*\n - apps/*\n - examples/*\n' +
5661+
' # the objectui tree\n - ui\n - ui/packages/*\n - ui/apps/*\n - ui/examples/*\n';
5662+
5663+
const build = ({ baseIds = ['old-entry-one', 'old-entry-two'], headIds = null, files = {}, baseFiles = {}, pkgs = null, workspace = WORKSPACE_YAML }) => {
55915664
const dir = mkdtempSync(join(tmpdir(), 'adr0087-'));
55925665
const w = (rel, text) => {
55935666
mkdirSync(dirname(join(dir, rel)), { recursive: true });
@@ -5601,6 +5674,7 @@ function selfTest() {
56015674
w(LEDGER_SOURCES[1], CONV(['a-conversion']));
56025675
w(WITNESS_GENERATOR, WITNESS_GEN());
56035676
w(ADR_0087, ADR_DOC());
5677+
if (workspace !== null) w(WORKSPACE_FILE, workspace);
56045678
// stock: one declared-breaking changeset -- realistic mid-cycle stock for
56055679
// the inherited-changeset cases. (No longer needed to satisfy assertInputs:
56065680
// since #8658 its convention-rot control is synthetic and phase-independent.)

‎scripts/pm/bare-root-worklist.mjs‎

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1201,31 +1201,6 @@ const TRIAGE = new Map([
12011201
+ 'above: that gate walks the same root RECURSIVELY at 49 of 50, where the precise '
12021202
+ 'spelling buys one file of discrimination and its deferral is untouched by this row',
12031203
}],
1204-
['scripts/check-adr-0087-registration.mjs PACKAGE_ROOTS packages', {
1205-
verdict: 'SPELLABLE-UNDECLARED',
1206-
spelling: 'packages manifests',
1207-
why: 'workspace manifests only — 74 of 5275 (1.4%), re-measured 2026-08-26. The recorded '
1208-
+ 'spelling is live and reaches 74 of 74, 100% precise and complete. Deferred: six rows '
1209-
+ 'across two source files share this one population shape and no consumer has asked for '
1210-
+ 'any of them, so declaring here is a six-edit expansion ahead of demand — RE-COUNTED '
1211-
+ '2026-09-04. The "nine rows across three gates" this replaces counted CI invocation '
1212-
+ 'names, not source files: check:changeset-gate-self-tests runs THIS script --self-test, '
1213-
+ 'so it never was a third gate, and #15127 keying this table on the gate source file is '
1214-
+ 'what made that visible: the six are three roots each under this gate and its '
1215-
+ 'check-skill-compatibility-version.mjs sibling',
1216-
}],
1217-
['scripts/check-adr-0087-registration.mjs PACKAGE_ROOTS apps', {
1218-
verdict: 'SPELLABLE-UNDECLARED',
1219-
spelling: 'apps manifests',
1220-
why: 'workspace manifests only — 1 of 40 (2.5%), re-measured 2026-08-26; the spelling reaches '
1221-
+ '1 of 1, 100% precise and complete. Deferred with its packages half',
1222-
}],
1223-
['scripts/check-adr-0087-registration.mjs PACKAGE_ROOTS examples', {
1224-
verdict: 'SPELLABLE-UNDECLARED',
1225-
spelling: 'examples manifests',
1226-
why: 'workspace manifests only — 4 of 241 (1.7%), re-measured 2026-08-26; the spelling reaches '
1227-
+ '4 of 4, 100% precise and complete. Deferred with its packages half',
1228-
}],
12291204
['scripts/check-skill-compatibility-version.mjs PACKAGE_ROOTS packages', {
12301205
verdict: 'SPELLABLE-UNDECLARED',
12311206
spelling: 'packages manifests',
@@ -2093,7 +2068,10 @@ const SELF_TEST_BATTERIES = Object.freeze({
20932068
// 128 → 126 (#24037): the loop registers two cases per recorded row, and the
20942069
// four check-position-name-fold-loaders rows were withdrawn (134 → 126 on a
20952070
// run) — fewer rows to judge, not cases that stopped registering.
2096-
"The DECLARATION a row describes, read from the gate's own SOURCE": 126,
2071+
// 126 → 122 (#26220): the three check-adr-0087-registration PACKAGE_ROOTS rows
2072+
// were deleted — that gate now reads its package globs from the workspace file,
2073+
// so the bare words they judged no longer exist (128 → 122 on a run).
2074+
"The DECLARATION a row describes, read from the gate's own SOURCE": 122,
20972075
'CENSUS_REFUSE_WIDE, pinned on its OWN terms (#14695)': 5,
20982076
});
20992077

0 commit comments

Comments
 (0)