Skip to content

Commit 29ffad5

Browse files
committed
tooling(ui-wiring): workspace globs and root turbo tasks for the ui/ tree (objectstack#25697)
pnpm-workspace.yaml gains ui, ui/packages/*, ui/apps/* and ui/examples/*. They match no directory until objectui is imported under ui/, so `pnpm install --frozen-lockfile` and `pnpm install --lockfile-only` leave pnpm-lock.yaml byte-identical and `pnpm -r ls --depth -1` is unchanged. objectui declares no onlyBuiltDependencies, so the union is this list. turbo.json gains the four task names objectui's packages use and the root lacks: type-check, lint, test:dist, test:watch, with objectui's inputs, outputs, dependsOn and cache settings. Its repo-root inputs are re-rooted under $TURBO_ROOT$/ui/. Two dependsOn edges are not carried: //#lint:root and //#type-check:e2e bind objectui's ROOT manifest, which is the `ui` member here, and a package-named dependsOn on a package that does not exist yet makes turbo refuse the whole run. The ui CI jobs run those two programs as their own steps instead. Its globalDependencies (pin plumbing) are not ported. `turbo run build --dry=json` lists the same 84 tasks with the same 84 hashes before and after. Two gates read "turbo.json describes something absent" as a defect, which is right except for a tree that is about to arrive: - check-turbo-task-graph: type-check, lint and test:dist are held by no member until the import. GENERIC_TASKS_AWAITING_UI_IMPORT holds them only while ui/package.json is absent; the hold is void once it exists, and a held key turbo.json does not declare is itself a finding. - check-cross-package-test-inputs: `ui` is a top-level segment git does not track yet. TOP_LEVEL_DIRECTORIES_AWAITING_IMPORT excuses it only while untracked; once tracked it owes a recognised or pending entry. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RSDL3SFtJaKzcymvCD8RsU
1 parent b77bb37 commit 29ffad5

4 files changed

Lines changed: 194 additions & 9 deletions

File tree

‎pnpm-workspace.yaml‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,23 @@ packages:
1010
- packages/connectors/*
1111
- apps/*
1212
- examples/*
13+
# The objectui tree, once it is imported under ui/ (objectstack#25677). Until
14+
# then these globs match no directory and pnpm resolves exactly the workspace
15+
# above: the lockfile, `pnpm install` and `pnpm -r ls` are unchanged. `ui`
16+
# itself is a member because objectui's root package.json carries the scripts
17+
# its CI runs (`lint:root`, `type-check:e2e`, the `check:*` gates). objectui's
18+
# own `docs` workspace entry is not carried: it names no package.
19+
# objectui's pnpm overrides and its patchedDependencies entry arrive with the
20+
# import, not here: an unused patch fails `pnpm install` and an override
21+
# rewrites this lockfile.
22+
- ui
23+
- ui/packages/*
24+
- ui/apps/*
25+
- ui/examples/*
1326

27+
# objectui declares no onlyBuiltDependencies of its own (neither in its
28+
# pnpm-workspace.yaml nor in its package.json `pnpm` field), so the union of
29+
# the two allowlists is this list unchanged.
1430
onlyBuiltDependencies:
1531
- better-sqlite3
1632
- esbuild

‎scripts/check-cross-package-test-inputs.mjs‎

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ const SELF_TEST_BATTERIES = Object.freeze({
426426
// turbo.json declares, one per recognised name -- so the pin moves when either
427427
// set does. That is the point: a directory dropping out of turbo.json is a
428428
// declaration disappearing, which is worth a red.
429-
'the TOP-LEVEL WHITELIST, reconciled against turbo.json (#18342)': 26,
429+
'the TOP-LEVEL WHITELIST, reconciled against turbo.json (#18342)': 30,
430430
});
431431

432432
// DELETING an entry silences that battery's floor exactly as effectively as
@@ -1435,6 +1435,22 @@ export const TOP_LEVEL_DIRECTORIES_PENDING = Object.freeze({
14351435
'.github': 'over-collection census (#18342): two literals, both non-reads; disposition reserved to the seat',
14361436
});
14371437

1438+
/**
1439+
* Top-level directories a `$TURBO_ROOT$` input declares AHEAD of their arrival in
1440+
* the tree, each with the reason. A name here is excused from the "tracked as
1441+
* neither file nor directory" case ONLY while git tracks nothing under it; the
1442+
* moment it is tracked it lands in `directories` and owes a place in
1443+
* `RECOGNISED_TOP_LEVEL_DIRECTORIES` or `TOP_LEVEL_DIRECTORIES_PENDING` like any
1444+
* other, so the import commit decides how this collector treats it.
1445+
*
1446+
* `ui`: the objectui tree, imported under `ui/` (objectstack#25677). turbo.json's
1447+
* `type-check` and `lint` tasks carry objectui's repo-root inputs re-rooted there.
1448+
* Retire the entry with the import.
1449+
*/
1450+
export const TOP_LEVEL_DIRECTORIES_AWAITING_IMPORT = Object.freeze({
1451+
ui: 'the objectui import (objectstack#25677): turbo.json declares its type-check and lint inputs ahead of the tree',
1452+
});
1453+
14381454
/** Repo-root FILES declared as `$TURBO_ROOT$` inputs -- the fourth shape, pinned, not collected. */
14391455
export const TURBO_ROOT_FILE_INPUTS = Object.freeze(['sdui.manifest.json']);
14401456

@@ -4353,7 +4369,27 @@ function selfTest() {
43534369
// Non-vacuity first: a reading of zero would green every per-directory case
43544370
// below by having none of them run.
43554371
ok('turbo.json still declares $TURBO_ROOT$ inputs at all', live.directories.size > 0);
4356-
ok('no declared top-level segment is tracked as neither file nor directory', live.unknown.size === 0);
4372+
const awaitingImport = new Set(Object.keys(TOP_LEVEL_DIRECTORIES_AWAITING_IMPORT));
4373+
const unexcused = [...live.unknown].filter((name) => !awaitingImport.has(name));
4374+
ok(
4375+
`no declared top-level segment is tracked as neither file nor directory (unexcused: ${unexcused.join(', ') || 'none'})`,
4376+
unexcused.length === 0,
4377+
);
4378+
// The excuse is narrow in both directions: it covers only the names it lists,
4379+
// and only while git tracks nothing under them.
4380+
ok(
4381+
'an unknown segment the awaiting-import map does not list is still unexcused',
4382+
[...new Set(['zzqq-25697', ...live.unknown])].filter((name) => !awaitingImport.has(name)).includes('zzqq-25697'),
4383+
);
4384+
ok(
4385+
'an awaiting-import name git already tracks is NOT excused here (it must be recognised or pending)',
4386+
[...awaitingImport].every((name) => !live.directories.has(name) || recognised.has(name) || pending.has(name)),
4387+
);
4388+
ok('the awaiting-import map holds exactly the measured arrivals', [...awaitingImport].sort().join() === 'ui');
4389+
ok(
4390+
'every awaiting-import entry carries a reason',
4391+
Object.values(TOP_LEVEL_DIRECTORIES_AWAITING_IMPORT).every((r) => typeof r === 'string' && r.length > 0),
4392+
);
43574393
for (const dir of [...live.directories].sort()) {
43584394
ok(
43594395
`turbo.json declares "${dir}/" and the collector accounts for it (recognised, or pending with a reason)`,

‎scripts/check-turbo-task-graph.mjs‎

Lines changed: 107 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,8 @@
159159
* this gate read nothing -- never that it found nothing.
160160
*/
161161

162-
import { readFileSync } from 'node:fs';
162+
import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
163+
import { tmpdir } from 'node:os';
163164
import { join } from 'node:path';
164165
import { fileURLToPath } from 'node:url';
165166

@@ -224,6 +225,36 @@ export const DECLARED_WATCH_HINTS = [
224225
'examples/*/package.json',
225226
];
226227

228+
/**
229+
* Generic keys that are declared AHEAD of the packages that hold them: the
230+
* objectui tree is imported under `ui/` (objectstack#25677), and its packages
231+
* spell these task names, which no package of this workspace declares. The
232+
* root turbo.json carries their definitions from the wiring PR onwards so the
233+
* CI jobs for `ui/` are written once and run on the import commit.
234+
*
235+
* This is a hold, not an exemption from the rule above, and it has three limits:
236+
*
237+
* - it applies ONLY while `UI_IMPORT_MARKER` is absent from the checkout. Once
238+
* `ui/package.json` exists the hold is void and every key below is judged
239+
* like any other generic key, so a key the imported tree does not hold reds
240+
* on the import commit itself;
241+
* - no root script wraps any of these keys, so the shape this limb was written
242+
* for (`pnpm <task>` exiting 0 over nothing, #12373) is not reachable here.
243+
* The only callers are the `ui/` jobs in ci.yml, which skip while the tree
244+
* is absent;
245+
* - a listed key that turbo.json does not carry is itself a finding, so the
246+
* list cannot outlive the entries it holds.
247+
*
248+
* Retire the whole map, and `UI_IMPORT_MARKER` with it, once the import has
249+
* landed: from then on the hold can never apply.
250+
*/
251+
export const UI_IMPORT_MARKER = 'ui/package.json';
252+
export const GENERIC_TASKS_AWAITING_UI_IMPORT = Object.freeze({
253+
'type-check': "objectui's per-package tsc script (`type-check`, hyphenated); run by the Type Check UI job",
254+
lint: "objectui's per-package eslint script; run by the Lint UI job",
255+
'test:dist': "objectui's built-dist suite of @object-ui/components (dependsOn build)",
256+
});
257+
227258
/** The file this gate judges, as the reader spells it on disk. */
228259
const TURBO_CONFIG_FILE = 'turbo.json';
229260

@@ -347,17 +378,32 @@ export function holdersOf(task, scriptsByPackage) {
347378
* @param {Record<string, unknown>} tasks turbo.json's `tasks` table
348379
* @param {Map<string, Set<string>>} scriptsByPackage package name -> script names
349380
* @param {Set<string>} rootScripts the ROOT manifest's script names, for `//#<task>`
350-
* @returns {{ problems: string[], judged: number, genericJudged: number, rootJudged: number }}
381+
* @param {Set<string>} [held] generic keys under the `GENERIC_TASKS_AWAITING_UI_IMPORT`
382+
* hold for THIS checkout -- empty once the import marker exists (see `heldGenericTasks`)
383+
* @returns {{ problems: string[], judged: number, genericJudged: number, rootJudged: number, heldJudged: number }}
351384
*/
352-
export function verdict(tasks, scriptsByPackage, rootScripts) {
385+
export function verdict(tasks, scriptsByPackage, rootScripts, held = new Set()) {
353386
const problems = [];
354387
let judged = 0;
355388
let genericJudged = 0;
356389
let rootJudged = 0;
390+
let heldJudged = 0;
391+
for (const key of held) {
392+
if (!Object.hasOwn(tasks, key)) {
393+
problems.push(
394+
`"${key}" is held as awaiting the ui/ import, but ${TURBO_CONFIG_FILE} declares no such key.\n` +
395+
` Delete it from GENERIC_TASKS_AWAITING_UI_IMPORT: a hold over nothing is a leftover.`,
396+
);
397+
}
398+
}
357399
for (const key of Object.keys(tasks)) {
358400
const split = splitTaskKey(key);
359401
if (!split) {
360402
genericJudged += 1;
403+
if (holdersOf(key, scriptsByPackage).length === 0 && held.has(key)) {
404+
heldJudged += 1;
405+
continue;
406+
}
361407
if (holdersOf(key, scriptsByPackage).length === 0) {
362408
const declaredAnywhere = new Set();
363409
for (const scripts of scriptsByPackage.values()) for (const name of scripts) declaredAnywhere.add(name);
@@ -434,7 +480,20 @@ export function verdict(tasks, scriptsByPackage, rootScripts) {
434480
);
435481
}
436482
}
437-
return { problems, judged, genericJudged, rootJudged };
483+
return { problems, judged, genericJudged, rootJudged, heldJudged };
484+
}
485+
486+
/**
487+
* The generic keys the ui/ import hold covers on the checkout at `root`: every
488+
* key of `GENERIC_TASKS_AWAITING_UI_IMPORT` while `UI_IMPORT_MARKER` is absent,
489+
* and none at all once it exists.
490+
*
491+
* @param {string} root
492+
* @returns {Set<string>}
493+
*/
494+
export function heldGenericTasks(root) {
495+
if (existsSync(join(root, UI_IMPORT_MARKER))) return new Set();
496+
return new Set(Object.keys(GENERIC_TASKS_AWAITING_UI_IMPORT));
438497
}
439498

440499
/**
@@ -563,7 +622,13 @@ function main() {
563622
throw err;
564623
}
565624

566-
const { problems, judged, genericJudged, rootJudged } = verdict(tasks, scriptsByPackage, rootScripts);
625+
const held = heldGenericTasks(ROOT);
626+
const { problems, judged, genericJudged, rootJudged, heldJudged } = verdict(
627+
tasks,
628+
scriptsByPackage,
629+
rootScripts,
630+
held,
631+
);
567632

568633
if (genericJudged === 0) {
569634
console.error(
@@ -615,7 +680,12 @@ function main() {
615680
: '') +
616681
` — every package-scoped one names a package that exists (or the root token ` +
617682
`"${ROOT_PACKAGE_TOKEN}") and a script it declares, and every generic one is declared by at ` +
618-
`least one member.`,
683+
`least one member` +
684+
(heldJudged
685+
? `, except ${heldJudged} held for the ui/ import while ${UI_IMPORT_MARKER} is absent ` +
686+
`(${[...held].sort().join(', ')})`
687+
: '') +
688+
`.`,
619689
);
620690
}
621691

@@ -659,7 +729,7 @@ function main() {
659729
// not red. A battery BELOW its floor means cases stopped running; the remedy is
660730
// to find what stopped registering.
661731
const SELF_TEST_BATTERIES = Object.freeze({
662-
'check-turbo-task-graph self-test': 49,
732+
'check-turbo-task-graph self-test': 56,
663733
});
664734

665735
// DELETING an entry silences that battery's floor exactly as effectively as
@@ -869,6 +939,36 @@ export function selfTest() {
869939
t('a near-miss of the root token is still an unknown package', notRoot.problems.length === 1);
870940
t('a near-miss of the root token is not in the root population', notRoot.rootJudged === 0);
871941

942+
// ── The ui/ import hold, both directions ──
943+
// Held: a generic key nobody declares is NOT a finding while it is held.
944+
const heldGeneric = verdict({ 'type-check': {} }, workspace, rootScripts, new Set(['type-check']));
945+
t('a generic key held for the ui/ import is not a finding', heldGeneric.problems.length === 0);
946+
t('a held generic key is counted in the held population', heldGeneric.heldJudged === 1);
947+
t('a held generic key is still counted in the generic population', heldGeneric.genericJudged === 1);
948+
// Not held (the marker exists, so the hold set is empty): the same key reds.
949+
const unheldGeneric = verdict({ 'type-check': {} }, workspace, rootScripts, new Set());
950+
t('the same key without the hold is a finding again', unheldGeneric.problems.length === 1);
951+
// The hold names keys, not a shape: an unlisted inert key beside a held one still reds.
952+
const heldBeside = verdict({ 'type-check': {}, 'test:e2e': {} }, workspace, rootScripts, new Set(['type-check']));
953+
t('an inert key the hold does not list still reds beside a held one', heldBeside.problems.length === 1
954+
&& heldBeside.problems[0]?.includes('"test:e2e"'));
955+
// A hold over a key turbo.json does not carry is a leftover.
956+
const heldNothing = verdict({ build: {} }, workspace, rootScripts, new Set(['type-check']));
957+
t('a held key turbo.json does not declare is a finding', heldNothing.problems.length === 1
958+
&& heldNothing.problems[0]?.includes('a hold over nothing'));
959+
// The marker decides: an existing marker empties the hold, an absent one fills it.
960+
t('the hold is void on a checkout carrying the import marker', (() => {
961+
const dir = mkdtempSync(join(tmpdir(), 'turbo-task-graph-ui-hold-'));
962+
try {
963+
const without = heldGenericTasks(dir).size;
964+
mkdirSync(join(dir, 'ui'));
965+
writeFileSync(join(dir, UI_IMPORT_MARKER), '{}');
966+
return without === Object.keys(GENERIC_TASKS_AWAITING_UI_IMPORT).length && heldGenericTasks(dir).size === 0;
967+
} finally {
968+
rmSync(dir, { recursive: true, force: true });
969+
}
970+
})());
971+
872972
// ── Direction 2: the rule must stay GREEN on every legitimate shape ──
873973
// `gen:schema` stands where `test:e2e` used to: a generic key held by exactly
874974
// ONE package is legitimate, and this case is what keeps the limb above from

‎turbo.json‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,39 @@
3434
"outputs": [],
3535
"inputs": ["$TURBO_DEFAULT$", "!dist/**", "!coverage/**", "!.turbo/**"]
3636
},
37+
"type-check": {
38+
"dependsOn": ["^build"],
39+
"outputs": [],
40+
"cache": true,
41+
"inputs": [
42+
"$TURBO_DEFAULT$",
43+
"$TURBO_ROOT$/ui/scripts/vite-*.ts",
44+
"$TURBO_ROOT$/ui/vitest.config.mts",
45+
"$TURBO_ROOT$/ui/tsconfig.json",
46+
"$TURBO_ROOT$/ui/tsconfig.tier-base.json",
47+
"$TURBO_ROOT$/ui/apps/console/src/lib/auth-preflight.ts",
48+
"$TURBO_ROOT$/ui/eslint-rules/no-unprefixed-query-params.js",
49+
"$TURBO_ROOT$/ui/packages/cli/src/commands/generate.ts",
50+
"$TURBO_ROOT$/ui/packages/cli/src/utils/authoring-face.ts",
51+
"$TURBO_ROOT$/ui/packages/cli/src/utils/issue-path.ts",
52+
"$TURBO_ROOT$/ui/packages/cli/src/utils/union-arm-diagnostics.ts",
53+
"$TURBO_ROOT$/ui/scripts/check-doc-component-types.mjs",
54+
"$TURBO_ROOT$/ui/scripts/markdown-fence-scan.mjs"
55+
]
56+
},
57+
"lint": {
58+
"outputs": [],
59+
"cache": true,
60+
"inputs": ["$TURBO_DEFAULT$", "$TURBO_ROOT$/ui/eslint.config.js", "$TURBO_ROOT$/ui/eslint-rules/*.js"]
61+
},
62+
"test:dist": {
63+
"dependsOn": ["build"],
64+
"cache": false
65+
},
66+
"test:watch": {
67+
"cache": false,
68+
"persistent": true
69+
},
3770
"@objectstack/docs#build": {
3871
"dependsOn": ["^build"],
3972
"outputs": ["dist/**", "json-schema/**", ".next/**", "!.next/cache/**", "public/llms-full.txt"],

0 commit comments

Comments
 (0)