Skip to content

Commit dd6401f

Browse files
committed
wip(pm): dispatch-gates derives the ui/scripts/__tests__ suite for the four roots it reads
Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AYg1gtz1tWt66GpPnTo1QF
1 parent 6390fe5 commit dd6401f

2 files changed

Lines changed: 132 additions & 4 deletions

File tree

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

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -900,9 +900,45 @@ export const ESCAPABLE_LITERAL_LEDGER_ROWS = Object.freeze([
900900
* already has. ⛔ Nor does either gate happening to go quiet: three of the
901901
* five measured instances involved a green that proved nothing, because a
902902
* sweep that cannot see your file is not evidence about your file.
903+
* - ui-scripts-suite entry: when a workflow runs the `ui/scripts/__tests__`
904+
* suite as a step of its own, under an invocation the discovery reads, the
905+
* row can name that family instead of standing in for a CI job — and when
906+
* the `Test UI` job stops running the suite at all, the binding goes STALE
907+
* by itself. ⛔ A path predicate that narrows the four roots to the files
908+
* each test "really" reads does NOT qualify: that map is a second thing
909+
* that goes stale, and the run is cheap enough not to need one (measured
910+
* below).
903911
*
904912
*
905913
* Delete an entry the day its criterion is met, not before.
914+
*
915+
* ## Why the ui-scripts-suite entry stands in for a CI JOB (#26318)
916+
*
917+
* The 178 test files under `ui/scripts/__tests__/` belong to no package and run
918+
* only inside the 16 `Test UI` shards, as the "always-on" files the affected-test
919+
* selector adds to every run because no package owns them. They pin facts a
920+
* change under ui package source, the Console app, the objectui skill bundle or
921+
* `ui/scripts` itself moves — turbo build inputs, the skill-examples floor, the
922+
* SchemaRenderer channel keys — and no derived family named them: measured on
923+
* PR #26274's head 1ef5c482, three reds there were that PR's own and had passed
924+
* every derived local gate.
925+
*
926+
* Every other gate in this table is a family the workflows run, resolved by
927+
* name. This one cannot be: the only step that runs the suite is the `Test UI`
928+
* job's vitest line, which carries a shard and the selector's filter list, and
929+
* no workflow spells a narrower invocation. So its gate declares the job and the
930+
* runner prefix it narrows (`ciJob`, `ciRunner`), and the engine's
931+
* `ciJobRunsRunner` resolves it against the live workflows the same way a family
932+
* is resolved: a job renamed or a runner respelled renders it STALE, and the
933+
* census guard in the self-test reds on the PR that does it.
934+
*
935+
* It names the WHOLE suite, never an affected subset: a subset map is a second
936+
* list that rots, and the whole run is about a minute. What it does not see is
937+
* stated rather than hidden: a ui path outside the four roots (a ui package's
938+
* tests outside `src`, its `package.json`, a root config) is not named here,
939+
* though CI's `Test UI` job still schedules the suite for it — the full battery
940+
* on `main` remains the backstop for that, as it is for the selector's own
941+
* misses.
906942
*/
907943
export const CHANGE_KIND_ROWS = [
908944
{
@@ -1013,8 +1049,37 @@ export const CHANGE_KIND_ROWS = [
10131049
},
10141050
],
10151051
},
1052+
{
1053+
kind: 'edits a file the ui/scripts/__tests__ suite reads (ui package source, the ui apps, the objectui skill bundle, or ui/scripts itself)',
1054+
matches: 'ui-scripts-suite-input',
1055+
gates: [
1056+
{
1057+
name: 'pnpm --dir ui exec vitest run scripts/',
1058+
ciJob: 'Test UI',
1059+
ciRunner: 'pnpm --dir ui exec vitest run',
1060+
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: about a minute locally. 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",
1061+
},
1062+
],
1063+
},
10161064
];
10171065

1066+
/**
1067+
* The roots whose change the `ui/scripts/__tests__` suite can see (#26318), in CI's own `paths:` language
1068+
* — the engine matches them with `triggerListCovers`, the reader of every workflow trigger. They are the
1069+
* card's four, as written there: ui package SOURCE (any depth below `ui/packages`, so a nested package
1070+
* counts), the ui apps, the objectui skill bundle the suite reads through `ui/scripts/skill-bundle-root.mjs`,
1071+
* and the suite's own tree. The bare `src` directory form is listed beside its subtree because a dispatch
1072+
* surface is often given as that directory, and the trigger language reads a directory only through a
1073+
* pattern's literal prefix.
1074+
*/
1075+
export const UI_SCRIPTS_SUITE_ROOTS = Object.freeze([
1076+
'ui/packages/**/src',
1077+
'ui/packages/**/src/**',
1078+
'ui/apps/**',
1079+
'skills/objectui/**',
1080+
'ui/scripts/**',
1081+
]);
1082+
10181083
/**
10191084
* The globs that MANDATE a model tier for any card whose file surface touches
10201085
* them, as DATA. This is the one list in this file besides CHANGE_KIND_GATES,

‎scripts/pm/dispatch-gates.mjs‎

Lines changed: 67 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,7 @@ import {
473473
RETIRED_TIER_WORDS,
474474
ESCAPABLE_LITERAL_LEDGER_ROWS,
475475
CHANGE_KIND_ROWS,
476+
UI_SCRIPTS_SUITE_ROOTS,
476477
MANDATORY_TIER_GLOB_ROWS,
477478
SUSPECT_TIER_GLOB_ROWS,
478479
GENERATED_MODULE_SOURCES,
@@ -491,6 +492,7 @@ export {
491492
TIER_DEFAULT,
492493
RETIRED_TIER_WORDS,
493494
GENERATED_MODULE_SOURCES,
495+
UI_SCRIPTS_SUITE_ROOTS,
494496
};
495497

496498
// Re-exported so this tool's self-test drives the SAME predicates the gate
@@ -11043,6 +11045,45 @@ export function reachesMetadataFormModule(path, modulePaths) {
1104311045
return modulePaths.some((m) => m === path || m.startsWith(`${path}/`));
1104411046
}
1104511047

11048+
/**
11049+
* Does this input path sit under a root the `ui/scripts/__tests__` suite reads (#26318)?
11050+
*
11051+
* The roots are `UI_SCRIPTS_SUITE_ROOTS` in the data module, and they are matched in CI's own `paths:`
11052+
* language through `triggerListCovers`, so a directory surface counts exactly as it counts for a workflow
11053+
* trigger and this file grows no second glob dialect. A leading `./` is tolerated for the reason
11054+
* `isGateScriptPath` tolerates one: a seat pastes paths as its shell printed them.
11055+
*/
11056+
export function readByUiScriptsSuite(path, roots = UI_SCRIPTS_SUITE_ROOTS) {
11057+
return triggerListCovers(roots, path.replace(/^\.\//, '')) !== null;
11058+
}
11059+
11060+
/**
11061+
* Does a live workflow still run the CI job a change-kind gate is the local SUBSET of (#26318)?
11062+
*
11063+
* Every other gate in the change-kind roster is named by an invocation the workflows run, and it resolves
11064+
* against the discovered families. The `ui/scripts/__tests__` suite cannot: CI runs it only inside the
11065+
* `Test UI` job's vitest step, which passes a shard and the affected-test selector's filter list, so that
11066+
* step is no family a dev can paste and the workflows spell no narrower invocation. Such a gate declares
11067+
* `ciJob` (the job's display-name prefix) and `ciRunner` (the command prefix that job's step spells), and
11068+
* its own `name` is that prefix narrowed to the subset a card owes. It resolves to that `name` while some
11069+
* workflow job of that name still runs a `run:` line beginning with the prefix, and to null once none
11070+
* does — the STALE report a renamed family gets, so the row cannot outlive the job it stands in for.
11071+
*
11072+
* ⛔ Not a second discovery. It adds nothing to the families, the residue partition or any path verdict;
11073+
* it answers one question for one table row, from the same `workflowEntries` the discovery read.
11074+
*/
11075+
export function ciJobRunsRunner({ ciJob, ciRunner }, workflowEntries) {
11076+
for (const { text } of workflowEntries) {
11077+
for (const job of extractJobBlocks(text)) {
11078+
if (!job.name.startsWith(ciJob)) continue;
11079+
for (const command of runCommandTexts(job.text)) {
11080+
if (joinLineContinuations(command).split('\n').some((line) => line.trim().startsWith(`${ciRunner} `))) return true;
11081+
}
11082+
}
11083+
}
11084+
return false;
11085+
}
11086+
1104611087
/**
1104711088
* The change-kind roster is data: `CHANGE_KIND_ROWS` in `dispatch-gates.data.mjs` carries each kind, the
1104811089
* NAME of the predicate that recognises it, and the gates it names — with the docblock that governs the
@@ -11058,6 +11099,7 @@ const CHANGE_KIND_PREDICATES = Object.freeze({
1105811099
'error-code-literal': stampsAnErrorCodeLiteral,
1105911100
'http-status-emit': emitsAnHttpStatus,
1106011101
'durability-seam': guardsADurabilityCriticalCall,
11102+
'ui-scripts-suite-input': (path) => readByUiScriptsSuite(path),
1106111103
});
1106211104

1106311105
export function bindChangeKindRows(rows, predicates = CHANGE_KIND_PREDICATES) {
@@ -11069,6 +11111,17 @@ export function bindChangeKindRows(rows, predicates = CHANGE_KIND_PREDICATES) {
1106911111
`known: ${Object.keys(predicates).join(', ')}`,
1107011112
);
1107111113
}
11114+
// A CI-job-subset gate (`ciJobRunsRunner`) carries both halves of its binding, and its name narrows
11115+
// the runner it stands in for — refused at load, so a half-declared row cannot resolve by accident.
11116+
for (const gate of row.gates) {
11117+
const bound = gate.ciJob !== undefined || gate.ciRunner !== undefined;
11118+
if (bound && !(typeof gate.ciJob === 'string' && typeof gate.ciRunner === 'string' && gate.name.startsWith(`${gate.ciRunner} `))) {
11119+
throw new Error(
11120+
`dispatch-gates: change-kind row '${row.kind}' gate '${gate.name}' declares a CI-job binding that is not whole — ` +
11121+
'a gate standing in for a CI job carries both `ciJob` and `ciRunner`, and its name begins with that runner',
11122+
);
11123+
}
11124+
}
1107211125
return { ...row, matches };
1107311126
});
1107411127
}
@@ -11103,7 +11156,14 @@ export function changeKindGates(paths, resolveInvocation, kinds = CHANGE_KIND_GA
1110311156
groups.push({
1110411157
kind,
1110511158
hits,
11106-
gates: gates.map(({ name, why }) => ({ name, why, command: resolveInvocation(name) })),
11159+
// The gate rides into the resolver beside its name: a CI-job-subset gate resolves through its
11160+
// binding, never through the family map (`ciJobRunsRunner`).
11161+
gates: gates.map((gate) => ({
11162+
name: gate.name,
11163+
why: gate.why,
11164+
command: resolveInvocation(gate.name, gate),
11165+
...(gate.ciJob ? { ciJob: gate.ciJob, ciRunner: gate.ciRunner } : {}),
11166+
})),
1110711167
});
1110811168
}
1110911169
return groups;
@@ -11113,11 +11173,13 @@ export function changeKindLines(paths, resolveInvocation, kinds = CHANGE_KIND_GA
1111311173
const lines = [];
1111411174
for (const { kind, hits, gates } of changeKindGates(paths, resolveInvocation, kinds)) {
1111511175
lines.push(` ${kind}: ${hits.join(', ')}`);
11116-
for (const { name, why, command } of gates) {
11176+
for (const { name, why, command, ciJob, ciRunner } of gates) {
1111711177
lines.push(
1111811178
command
1111911179
? ` - ${command} — ${why}`
11120-
: ` - ⚠ ${name}: STALE — no workflow runs a gate under this name. It was renamed or retired; fix CHANGE_KIND_GATES in this script.`,
11180+
: ciJob
11181+
? ` - ⚠ ${name}: STALE — no workflow job named '${ciJob}…' runs '${ciRunner}' any more. The job was renamed or retired; fix CHANGE_KIND_GATES in this script.`
11182+
: ` - ⚠ ${name}: STALE — no workflow runs a gate under this name. It was renamed or retired; fix CHANGE_KIND_GATES in this script.`,
1112111183
);
1112211184
}
1112311185
}
@@ -14545,7 +14607,8 @@ function derive(paths, { showResidue = false, mode = 'human', runRecord = [], si
1454514607
// `--commands` list and the `--json` document are readings of these same
1454614608
// rows: the card this section answers is about two renderings of one
1454714609
// derivation drifting apart, so a second traversal here would reintroduce it.
14548-
const resolveInvocation = (name) => {
14610+
const resolveInvocation = (name, gate = null) => {
14611+
if (gate?.ciJob) return ciJobRunsRunner(gate, workflowEntries) ? name : null;
1454914612
const entry = byCheck.get(name);
1455014613
return entry ? runnableInvocation(entry) : null;
1455114614
};

0 commit comments

Comments
 (0)