Skip to content

Commit 0ba68b6

Browse files
test(core): give the vouched-reference census pin a scan budget and declare its census imports as inputs (#31105)
security#1 · os-tesla · session_01L9qibvynRbCtMndW8EHNGc Clause-②: no Metadata-protocol: none ## 维护者速读 - **改了什么**:vouched-reference 调用点普查的 core pin 两个测试各带显式时限 `SCAN_TIMEOUT_MS = 60_000`(与同目录 operation-private-keys 扫描 pin 同值);普查脚本 import 的 `scripts/js-comment-mask.mjs` 与 `scripts/invoked-as.mjs` 登记为 `@objectstack/core` 的跨包测试输入(声明表 + `turbo.json` 的 `core#test:repo`),并在声明表里以该 pin 作 `heldBy` 见证。 - **为什么改**:`--ts-only` 扫描读 `packages/` 下全部 `.ts`,闲机约 1 秒;繁忙 runner 上会越过 vitest 默认 5 秒,测试在任何断言前超时,把无关 PR 和合并队列批次一起拖红。另外普查导入的两个模块一改,pin 的判定就会变,但此前改它们不会重跑这个 pin,也不会让 turbo 缓存失效。 - **风险与回滚**:只改测试与仓根配置,不发布任何包、不改运行时;回滚即还原这 3 个文件。 - **先看**:① `packages/core/src/security/vouched-reference-callers.pin.test.ts` 的 `SCAN_TIMEOUT_MS` 及两处 `it` 末参;② `scripts/cross-package-test-inputs.mjs` 的 `@objectstack/core` 条目(`globs` 与新增 `heldBy`);③ `turbo.json` 的 `@objectstack/core#test:repo` inputs。 - **两分钟验证**:`pnpm check:cross-package-test-inputs`,预期末行 `OK: 32 package(s) read outside themselves, all declared, and turbo.json hashes every declared glob`。 - **需要你做的**:无,席位落地。 ## What changes - **Scan budget.** Both tests in `vouched-reference-callers.pin.test.ts` spawn the census (`--self-test`, then `--ts-only`) and ran under vitest's default 5000 ms test timeout. The `--ts-only` scan reads every `.ts` file under `packages/`. On a runner that is building the monorepo at the same time, it can overrun that timeout, and the test then fails with `Test timed out in 5000ms` before any assertion runs. Each `it` now passes `SCAN_TIMEOUT_MS` (60 s), and a one-paragraph docblock gives the reason. This is the same constant name, value and shape as the sibling scan pin `operation-private-keys.pin.test.ts`. No repo gate registers or spells per-test timeouts. The file-level `// test-budget:` header grammar in `scripts/measure-test-shard-timings.mjs` is for files over the 10 s wall line, and this file runs in about 1.2 s, so it does not apply. - **Census imports declared as inputs.** The census imports `./js-comment-mask.mjs`, which decides what counts as prose, and `./invoked-as.mjs`, which decides whether its dispatch runs. `js-comment-mask.mjs` also imports `invoked-as.mjs`. An edit to either file moves the pin's verdict, so both are now: - globs of the `@objectstack/core` entry in `scripts/cross-package-test-inputs.mjs`, next to the census script itself; - inputs of `@objectstack/core#test:repo` in `turbo.json`. The review asked for `js-comment-mask.mjs`. `invoked-as.mjs` belongs to the same import closure, so it is included as the same omission. - **`heldBy` witness.** `check:cross-package-test-inputs` cannot see from the pin's quoted paths that it reads these two files, because only the spawned child loads them. On the first commit it flagged both globs as "held by nothing". The entry now names the pin as their `heldBy` witness, which is that gate's second disposition: the read is real, and the scan cannot name it. ## Tests - Core `repo` project on `ce6158a02f`: 7 files and 96 tests pass. The two pin tests take 91 ms (`--self-test`) and 1091 ms (`--ts-only`) on a 4-core container while other gates run. - The census run alone on the same tree: `--self-test` takes 0.09 s and passes 39 cases. `--ts-only` takes 1.07 s to 1.15 s over 3 runs and stays green at `file-attachment-service.ts (2)`. The scan is not restructured in this PR. - `pnpm --filter @objectstack/core typecheck`: exit 0. The test layer holds at its pinned 4 signatures. ## Acceptance notes - Changeset: none. The diff is one `*.test.ts` in `@objectstack/core`, which ships only `dist`, plus root config (`turbo.json`, `scripts/`). Nothing published moves, so `skip-changeset` applies, the same as for the census PR. The label is not applied here; the seat applies it. - No ablation was run. The diff changes a test timeout and input declarations, not tested behaviour. - `check:dual-build-cjs-loads` is NOT MEASURED locally. It needs every package's `dist` (PREREQUISITE NOT MET, exit 3) and is left to CI's `Lint & Repo Gates`. ## Verification <details><summary>Derived gates on ce6158a: 69 derived, 68 exit 0, 1 NOT MEASURED</summary> `node scripts/pm/dispatch-gates.mjs --commands` (change set vs merge base `465c2bea3`, 3 files) derived 69 commands. Every one was run on `ce6158a02f`, and the exit code was captured before any pipe. 68 exited 0. `pnpm check:dual-build-cjs-loads` exited 3 (PREREQUISITE NOT MET). Reconciliation: ```text dispatch-gates --ran: 69 derived famil(ies) accounted for — 68 run, 1 NOT-MEASURED (1 DERIVED from a recorded exit 3). ``` `pnpm check:cross-package-test-inputs`, which was red on the first commit and is green after the `heldBy` witness: ```text All 261 self-test cases passed. OK: 32 package(s) read outside themselves, all declared, and turbo.json hashes every declared glob (6 of them on a split "test:repo" task) ``` </details> --- _Generated by [Claude Code](https://claude.ai/code/session_01L9qibvynRbCtMndW8EHNGc)_ --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent a61f61a commit 0ba68b6

3 files changed

Lines changed: 33 additions & 5 deletions

File tree

‎packages/core/src/security/vouched-reference-callers.pin.test.ts‎

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,18 @@ const HERE = dirname(fileURLToPath(import.meta.url));
2525
const REPO_ROOT = resolve(HERE, '../../../..');
2626
const GATE = resolve(HERE, '../../../../scripts/check-vouch-for-reference-callers.mjs');
2727

28+
/**
29+
* The budget of each test, which spawns the census once. The `--ts-only` scan
30+
* reads every `.ts` file under `packages/`, about a second on an idle machine;
31+
* a runner building the monorepo alongside the suite can push that past
32+
* vitest's default 5 s test timeout, and a timed-out test fails before any
33+
* assertion runs, so it says nothing about the mark it guards and reds every
34+
* batch it shares a shard with. The self-test is given the same budget because
35+
* it pays the same process start on the same runner. 60 s is the budget of the
36+
* sibling scan pin, `./operation-private-keys.pin.test.ts`.
37+
*/
38+
const SCAN_TIMEOUT_MS = 60_000;
39+
2840
const run = (...args: string[]) =>
2941
spawnSync(process.execPath, [GATE, ...args], { cwd: REPO_ROOT, encoding: 'utf8' });
3042

@@ -34,13 +46,13 @@ describe('check:vouch-for-reference-callers', () => {
3446
expect(out.stderr).toBe('');
3547
expect(out.status).toBe(0);
3648
expect(out.stdout).toMatch(/self-test: \d+ cases pass/);
37-
});
49+
}, SCAN_TIMEOUT_MS);
3850

3951
it('this tree is green on the .ts surface: the only production caller is the file-attachments writer, at its pinned count', () => {
4052
const out = run('--ts-only');
4153
expect(out.stderr).toBe('');
4254
expect(out.status).toBe(0);
4355
expect(out.stdout).toContain('(the .ts surface)');
4456
expect(out.stdout).toContain('packages/services/service-storage/src/file-attachment-service.ts (2)');
45-
});
57+
}, SCAN_TIMEOUT_MS);
4658
});

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

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,8 +360,22 @@ export const CROSS_PACKAGE_TEST_INPUTS = {
360360
// of the vouched-reference mark, a root script, with `--ts-only`: the same
361361
// `packages/` `.ts` surface as this glob. The census's other extensions,
362362
// and its `examples/` and `apps/` roots, are judged by its bare run in the
363-
// lint step, never by this pin.
364-
globs: ['packages/**/*.ts', 'scripts/check-vouch-for-reference-callers.mjs'],
363+
// lint step, never by this pin. The census imports `js-comment-mask.mjs`
364+
// (which code is prose) and `invoked-as.mjs` (whether its dispatch runs),
365+
// so an edit to either moves the pin's verdict and re-runs it.
366+
globs: [
367+
'packages/**/*.ts',
368+
'scripts/check-vouch-for-reference-callers.mjs',
369+
'scripts/js-comment-mask.mjs',
370+
'scripts/invoked-as.mjs',
371+
],
372+
heldBy: {
373+
// The pin names only the census; these two are the census's own relative
374+
// imports, loaded by the spawned child, so no path the pin quotes lands
375+
// in them and the pin itself is what holds them.
376+
'scripts/js-comment-mask.mjs': ['packages/core/src/security/vouched-reference-callers.pin.test.ts'],
377+
'scripts/invoked-as.mjs': ['packages/core/src/security/vouched-reference-callers.pin.test.ts'],
378+
},
365379
},
366380
'@objectstack/types': {
367381
// src/driver-error-classification.callers.test.ts is the #13440 gate: it

‎turbo.json‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -807,7 +807,9 @@
807807
"!.turbo/**",
808808
"!**/node_modules/**",
809809
"$TURBO_ROOT$/packages/**/*.ts",
810-
"$TURBO_ROOT$/scripts/check-vouch-for-reference-callers.mjs"
810+
"$TURBO_ROOT$/scripts/check-vouch-for-reference-callers.mjs",
811+
"$TURBO_ROOT$/scripts/js-comment-mask.mjs",
812+
"$TURBO_ROOT$/scripts/invoked-as.mjs"
811813
]
812814
},
813815
"@objectstack/types#test:repo": {

0 commit comments

Comments
 (0)