Skip to content

Commit 5b8ca36

Browse files
fix(pm): dispatch-gates ui/scripts suite roots cover the whole ui tree (#38118)
<!-- claude-projects-attribution: {"github_login":"os-elon-musk"} --> _Requested by **Elon** · [project thread](https://claude.ai/code/project/chan_01WedDzV26nniwxv7jC88B9D?thread=cmsg_01WedDzV26nniwxv7jC88B9DDypKu7B9nwbu5WuV7AEio8)_ Fixes #37254 Clause-②: no Metadata-protocol: none ## 维护者速读 - 用户无感:开发代理改动界面包里任何文件(包括各包自带的脚本目录)时,派发门禁清单现在会提示它先跑界面脚本测试套件。 - 属于车队开发效率治理,替那些因清单漏报、等 CI 才发现界面测试变红的开发代理解决问题。 - 若出错,最坏是界面改动多跑一次约五分钟的测试套件,或继续漏报;只改一张数据表,可直接撤回。 - 无。 ## What changes - `UI_SCRIPTS_SUITE_ROOTS` in `scripts/pm/dispatch-gates.data.mjs` is widened from five sub-tree roots (`ui/packages/**/src`, `ui/packages/**/src/**`, `ui/apps/**`, `skills/objectui/**`, `ui/scripts/**`) to `ui`, `ui/**` and `skills/objectui/**`. The row's `kind` and `why` prose follow. - **Widen, not derive** — the reading on origin/main 93fa911: - `ui/scripts/check-ui-root-lookups.mjs` walks `SCAN_ROOTS = ['scripts', 'packages', 'apps']` under the ui root, with no exclusion for a package's own `scripts/` directory, and `check-ui-root-lookups.test.ts` runs that scan (`scan(repoRoot)`, `scanned > 100`). Six such directories exist today (`components`, `fields`, `i18n`, `plugin-gantt`, `plugin-grid`, `plugin-kanban`). - Files under `ui/scripts/` and `ui/scripts/__tests__/` that name each top-level ui directory: `packages` 210, `scripts` 239, `apps` 121, `docs` 58, `examples` 53, `e2e` 26, `eslint-rules` 13, `patches` 8. Ui root files: `package.json` 144, `.changeset` 36, `tsconfig.json` 35, `vitest.config.mts` 32, `eslint.config.js` 15, `playwright.config.ts` 4. - So the suite reads every top-level part of the ui tree. Building the list from what the suite reads would mean parsing about 180 tests' read sites, and it would still end up at roughly `ui/**`. CI's own `ui` path filter in `ci.yml` is `ui/**` too. Including the few unread root files (`cliff.toml`, `.gitattributes`) costs one extra suite run. Leaving a reader out costs a red CI round trip. - The old control `ui/packages/core/package.json` ("outside the roots") was wrong: `package-files-exist.test.ts` reads every ui package manifest. It is now a specimen. ## Tests - `scripts/pm/dispatch-gates.self-test.mjs`: specimens are now keyed by the reader that makes them suite inputs. New ones are `ui/packages/components/scripts/new-script.mjs` (the card's miss), `ui/packages/core/package.json` and `ui/vitest.config.mts`. Each one is checked through the predicate, the whole table and the runnable union. The directory case now covers `ui/packages/fields/scripts` and bare `ui`. A `uikit/...` control checks that the `ui` root does not over-match on a shared prefix. - Reverse check: run against the old five roots, `readByUiScriptsSuite` returns `false` for all three new specimens, so the new cases fail on the pre-fix list. <details><summary>Self-test and Done-when readings at 20a777d</summary> ``` ✓ dispatch-gates self-test (fast tier): 2369 cases pass; 9 slow section(s) deferred. os-verify-lock: VERDICT command-exit 0 ✓ a path under a ui package's own scripts/ directory is read by the ui/scripts suite (ui/packages/components/scripts/new-script.mjs) ✓ through the whole table, a diff under a ui package's own scripts/ directory derives the suite, anchored on the delimiter ✓ CONTROL: uikit/packages/core/scripts/x.mjs is outside the roots node scripts/pm/dispatch-gates.mjs --commands ui/packages/components/scripts/build-css.mjs -> exit 0, prints: pnpm --dir ui exec vitest run scripts/ old roots: ui/packages/components/scripts/new-script.mjs false · ui/packages/core/package.json false · ui/vitest.config.mts false ``` </details> ## Acceptance notes - The slow tier of the self-test (`pnpm check:pm-dispatch-gates`) is not measured locally. It runs longer than the foreground limit, so CI runs the full battery. - Ran locally, all exit 0: `check:nul-bytes`, `check:issue-citations` and its census, `check-declaration-mirrors`, `check-self-test-wired`, `check:pm-governed-prose`, `check:scripts-symbol-anchors`, `check:ratchet-remedy-authority`, `check-published-list-mirrors`, `check-comment-mask-corpus`, plus the fast self-test. This is a declared narrowing: `--ran` reports 54 of 63 derived families unrun, and those are left to CI. - Read first: (1) `UI_SCRIPTS_SUITE_ROOTS` and its docblock in `dispatch-gates.data.mjs`, the riskiest hunk because a wider root changes every ui card's gate list; (2) the specimen and control tables in the self-test. ## Verification Two-minute check: `node scripts/pm/dispatch-gates.mjs --commands ui/packages/components/scripts/build-css.mjs | grep 'vitest run scripts/'` should print `pnpm --dir ui exec vitest run scripts/`. On main it prints nothing. --- _Generated by [Claude Code](https://claude.ai/code/session_016WV4cxRDKprCtjpEdtiPFW)_ Co-authored-by: Claude <noreply@anthropic.com>
1 parent fcdeb3e commit 5b8ca36

2 files changed

Lines changed: 37 additions & 25 deletions

File tree

‎scripts/pm/dispatch-gates.data.mjs‎

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1170,14 +1170,14 @@ export const CHANGE_KIND_ROWS = [
11701170
],
11711171
},
11721172
{
1173-
kind: 'edits a file the ui/scripts/__tests__ suite reads (ui package source, the ui apps, the objectui skill bundle, or ui/scripts itself)',
1173+
kind: 'edits a file the ui/scripts/__tests__ suite reads (anywhere in the ui tree, or the objectui skill bundle)',
11741174
matches: 'ui-scripts-suite-input',
11751175
gates: [
11761176
{
11771177
name: 'pnpm --dir ui exec vitest run scripts/',
11781178
ciJob: 'Test UI',
11791179
ciRunner: 'pnpm --dir ui exec vitest run',
1180-
why: "the 178 test files under ui/scripts/__tests__ belong to no package and run only in CI's 16 Test UI shards, where the affected-test selector adds them to every run, so no package suite and no check family covers them: they pin turbo build inputs, the skill-examples floor, the SchemaRenderer channel keys and the other facts a change under ui package source, the ui apps, skills/objectui or ui/scripts moves. The whole suite, never a subset: measured at about five minutes on a 4-vCPU container (284 s and 286 s, 178 files passing, import-bound), against the CI round trip of about 25 minutes it saves. It needs the seven @objectstack packages Test UI builds first, or about twenty files red on an import of a missing dist — build them exactly as the job does: pnpm exec turbo run build --filter=@objectstack/spec... --filter=@objectstack/client... --filter=@objectstack/core... --filter=@objectstack/formula... --filter=@objectstack/lint... --filter=@objectstack/sdui-parser... --filter=@objectstack/types... . Positional filter, no bare `--`, from the repo root: ui/scripts/vitest-invocation-guard.mjs refuses every other spelling",
1180+
why: "the 178 test files under ui/scripts/__tests__ belong to no package and run only in CI's 16 Test UI shards, where the affected-test selector adds them to every run, so no package suite and no check family covers them: they pin turbo build inputs, the skill-examples floor, the SchemaRenderer channel keys and the other facts a change anywhere in the ui tree or under skills/objectui moves. The whole suite, never a subset: measured at about five minutes on a 4-vCPU container (284 s and 286 s, 178 files passing, import-bound), against the CI round trip of about 25 minutes it saves. It needs the seven @objectstack packages Test UI builds first, or about twenty files red on an import of a missing dist — build them exactly as the job does: pnpm exec turbo run build --filter=@objectstack/spec... --filter=@objectstack/client... --filter=@objectstack/core... --filter=@objectstack/formula... --filter=@objectstack/lint... --filter=@objectstack/sdui-parser... --filter=@objectstack/types... . Positional filter, no bare `--`, from the repo root: ui/scripts/vitest-invocation-guard.mjs refuses every other spelling",
11811181
},
11821182
],
11831183
},
@@ -1408,20 +1408,23 @@ export const CHANGE_KIND_ROWS = [
14081408
];
14091409

14101410
/**
1411-
* The roots whose change the `ui/scripts/__tests__` suite can see (#26318), in CI's own `paths:` language
1412-
* — the engine matches them with `triggerListCovers`, the reader of every workflow trigger. They are the
1413-
* card's four, as written there: ui package SOURCE (any depth below `ui/packages`, so a nested package
1414-
* counts), the ui apps, the objectui skill bundle the suite reads through `ui/scripts/skill-bundle-root.mjs`,
1415-
* and the suite's own tree. The bare `src` directory form is listed beside its subtree because a dispatch
1416-
* surface is often given as that directory, and the trigger language reads a directory only through a
1417-
* pattern's literal prefix.
1411+
* The roots whose change the `ui/scripts/__tests__` suite can see, in CI's own `paths:` language — the engine
1412+
* matches them with `triggerListCovers`, the reader of every workflow trigger. They are the WHOLE ui tree and the
1413+
* objectui skill bundle the suite reads through `ui/scripts/skill-bundle-root.mjs`, because the suite reads the
1414+
* whole ui tree: `check-ui-root-lookups` scans every source under `ui/scripts`, `ui/packages` and `ui/apps` (a
1415+
* package's own `scripts/` directory included), and the rest of the suite reads every other top-level ui
1416+
* directory (`docs`, `e2e`, `examples`, `eslint-rules`, `patches`) and the ui root's manifests and configs
1417+
* (`package.json`, `vitest.config.mts`, the tsconfigs, `eslint.config.js`, `.changeset`). A narrower list was
1418+
* measured missing a new `ui/packages/<pkg>/scripts/*.mjs`, which reds `check-ui-root-lookups.test.ts`.
1419+
* ⛔ Never narrow it back to the sub-trees a reader names today: the next reader of a ui path is one more
1420+
* silent miss, and the cost of the width is one suite run on a card that touches ui at all. The bare `ui`
1421+
* directory is listed beside its subtree because a dispatch surface is often given as that directory, and the
1422+
* trigger language reads a directory only through a pattern's literal prefix.
14181423
*/
14191424
export const UI_SCRIPTS_SUITE_ROOTS = Object.freeze([
1420-
'ui/packages/**/src',
1421-
'ui/packages/**/src/**',
1422-
'ui/apps/**',
1425+
'ui',
1426+
'ui/**',
14231427
'skills/objectui/**',
1424-
'ui/scripts/**',
14251428
]);
14261429

14271430
/**

‎scripts/pm/dispatch-gates.self-test.mjs‎

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5493,32 +5493,41 @@ export function selfTest({ tier = 'full' } = {}) {
54935493
// The 178 files run only in CI's Test UI shards, so no family named them and a
54945494
// card under ui package source or skills/objectui learned of a red one CI round
54955495
// later. The entry stands in for that CI JOB (`ciJobRunsRunner`): pinned here
5496-
// are the predicate on all four roots and outside them, the rendering and the
5496+
// are the predicate on every reader's specimen and outside them, the rendering and the
54975497
// runnable union through the whole table, the `--ran` verdict without it, the
54985498
// STALE branch, and the binding against the live workflows.
54995499
const UI_SUITE = 'pnpm --dir ui exec vitest run scripts/';
5500+
// Keyed by the reader that makes each specimen a suite input, so a root list
5501+
// narrowed back to sub-trees reds on the specimen it drops.
55005502
const UI_SUITE_SPECIMENS = Object.freeze({
5501-
'ui/packages/**/src': 'ui/packages/sdui-parser/src/expression-carriage.ts',
5502-
'ui/apps/**': 'ui/apps/console/src/App.tsx',
5503-
'skills/objectui/**': 'skills/objectui/SKILL.md',
5504-
'ui/scripts/**': 'ui/scripts/check-skill-examples.mjs',
5503+
'ui package source': 'ui/packages/sdui-parser/src/expression-carriage.ts',
5504+
'the ui apps': 'ui/apps/console/src/App.tsx',
5505+
'the objectui skill bundle': 'skills/objectui/SKILL.md',
5506+
'the suite\'s own tree': 'ui/scripts/check-skill-examples.mjs',
5507+
// check-ui-root-lookups scans every source under ui/packages, a package's
5508+
// own scripts/ directory included: the miss this specimen pins.
5509+
'a ui package\'s own scripts/ directory': 'ui/packages/components/scripts/new-script.mjs',
5510+
// package-files-exist reads every ui package manifest.
5511+
'a ui package manifest': 'ui/packages/core/package.json',
5512+
// the vitest-config tests read the ui root's config.
5513+
'the ui root config': 'ui/vitest.config.mts',
55055514
});
55065515
const UI_SUITE_CONTROLS = Object.freeze([
55075516
'packages/core/src/x.ts',
5508-
'ui/packages/core/package.json',
5517+
'uikit/packages/core/scripts/x.mjs',
55095518
'skills/objectstack/SKILL.md',
55105519
'scripts/pm/dispatch-gates.mjs',
55115520
]);
55125521
const uiEntry = CHANGE_KIND_GATES.filter((k) => k.gates.some((g) => g.name === UI_SUITE));
55135522
t('exactly one entry in the table names the ui/scripts suite, bound to the Test UI job',
55145523
uiEntry.length === 1 && uiEntry[0].matches('ui/scripts/x.mjs') && uiEntry[0].gates[0].ciJob === 'Test UI' && UI_SUITE.startsWith(`${uiEntry[0].gates[0].ciRunner} `));
5515-
t('the roots are the card\'s four, in the trigger language', ['ui/packages/**/src/**', 'ui/apps/**', 'skills/objectui/**', 'ui/scripts/**'].every((r) => UI_SCRIPTS_SUITE_ROOTS.includes(r)));
5524+
t('the roots are the whole ui tree and the objectui skill bundle, in the trigger language', ['ui', 'ui/**', 'skills/objectui/**'].every((r) => UI_SCRIPTS_SUITE_ROOTS.includes(r)));
55165525
for (const [root, specimen] of Object.entries(UI_SUITE_SPECIMENS)) {
55175526
t(`a path under ${root} is read by the ui/scripts suite (${specimen})`, readByUiScriptsSuite(specimen));
55185527
}
5519-
t('a dispatch surface given as a ui package\'s src DIRECTORY counts too', readByUiScriptsSuite('ui/packages/core/src') && readByUiScriptsSuite('./ui/scripts'));
5528+
t('a dispatch surface given as a ui DIRECTORY counts too', readByUiScriptsSuite('ui/packages/core/src') && readByUiScriptsSuite('./ui/scripts') && readByUiScriptsSuite('ui/packages/fields/scripts') && readByUiScriptsSuite('ui'));
55205529
for (const control of UI_SUITE_CONTROLS) {
5521-
t(`CONTROL: ${control} is outside the four roots`, !readByUiScriptsSuite(control));
5530+
t(`CONTROL: ${control} is outside the roots`, !readByUiScriptsSuite(control));
55225531
}
55235532
// A resolver that resolves a family by its `pnpm` spelling and a CI-job gate by
55245533
// its own name — the shape `derive`'s resolver has.
@@ -5532,18 +5541,18 @@ export function selfTest({ tier = 'full' } = {}) {
55325541
t(`…and ${control} derives no suite line and no suite command`,
55335542
!throughTableUi(control) && !commandsFor({ kindGroups: changeKindGates([control], uiResolved) }).includes(UI_SUITE));
55345543
}
5535-
const uiLine = changeKindLines([UI_SUITE_SPECIMENS['skills/objectui/**']], uiResolved, uiEntry).find((l) => l.includes(`- ${UI_SUITE} —`)) ?? '';
5544+
const uiLine = changeKindLines([UI_SUITE_SPECIMENS['the objectui skill bundle']], uiResolved, uiEntry).find((l) => l.includes(`- ${UI_SUITE} —`)) ?? '';
55365545
t('the suite line states its build prerequisite, runnably', /seven @objectstack packages/.test(uiLine) && uiLine.includes('turbo run build') && uiLine.includes('--filter=@objectstack/sdui-parser...'));
55375546
t('…and says it is the whole suite, never a subset', /The whole suite, never a subset/.test(uiLine));
5538-
const uiDerived = commandsFor({ kindGroups: changeKindGates([UI_SUITE_SPECIMENS['ui/apps/**']], uiResolved) });
5547+
const uiDerived = commandsFor({ kindGroups: changeKindGates([UI_SUITE_SPECIMENS['the ui apps']], uiResolved) });
55395548
const uiWithout = runReconciliation({
55405549
derived: uiDerived,
55415550
record: parseRunRecord(uiDerived.filter((c) => c !== UI_SUITE).map((c) => `${c} :: exit 0`).join('\n')),
55425551
});
55435552
t('⭐ a run record carrying every derived command BUT the suite is NOT ok, and names the suite unrun', !uiWithout.ok && uiWithout.unrun.some((u) => u.command === UI_SUITE));
55445553
const uiWith = runReconciliation({ derived: uiDerived, record: parseRunRecord(uiDerived.map((c) => `${c} :: exit 0`).join('\n')) });
55455554
t('CONTROL: the same record WITH the suite is ok', uiWith.ok);
5546-
const uiStale = changeKindLines([UI_SUITE_SPECIMENS['ui/scripts/**']], () => null, uiEntry);
5555+
const uiStale = changeKindLines([UI_SUITE_SPECIMENS['the suite\'s own tree']], () => null, uiEntry);
55475556
t('an unresolvable binding renders STALE, naming the job and the runner it lost',
55485557
uiStale.filter((l) => l.includes(`⚠ ${UI_SUITE}: STALE`) && l.includes("job named 'Test UI…'") && l.includes("'pnpm --dir ui exec vitest run'")).length === 1);
55495558
// The binding itself, against fixtures and then the LIVE workflows.

0 commit comments

Comments
 (0)