Skip to content

Commit 27c3561

Browse files
committed
wip: Test Core runs the vouched-reference census gate, red and green
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L9qibvynRbCtMndW8EHNGc
1 parent e0b4c21 commit 27c3561

5 files changed

Lines changed: 46 additions & 2 deletions

File tree

‎package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@
206206
"check:stall-guard-headroom": "node scripts/measure-stall-guard-headroom.mjs --self-test",
207207
"check:swallow-census-controls": "node scripts/measure-durability-swallow-family.mjs --self-test=gated",
208208
"check:system-context-census": "node scripts/check-system-context-census.mjs --self-test && node scripts/check-system-context-census.mjs",
209+
"check:vouch-for-reference-callers": "node scripts/check-vouch-for-reference-callers.mjs --self-test && node scripts/check-vouch-for-reference-callers.mjs",
209210
"gen:platform-object-tenancy-census": "node scripts/platform-object-tenancy-census.mjs --write",
210211
"check:platform-object-tenancy-census": "node scripts/check-platform-object-tenancy-census.mjs --self-test && node scripts/check-platform-object-tenancy-census.mjs"
211212
},
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
2+
3+
/**
4+
* The call-site census of the vouched-reference mark (`vouchForReference`,
5+
* `./vouched-reference.ts`), run where `Test Core` runs it: the gate's own
6+
* self-test (its red and green cases, with the battery floor and the verdict
7+
* handshake), then the scan of this tree, which must be green — every
8+
* production file that sets the mark is in the gate's `ALLOWED_CALLERS` with
9+
* its exact call-site count. The gate's header is the authority on the rule.
10+
*/
11+
12+
import { describe, expect, it } from 'vitest';
13+
import { spawnSync } from 'node:child_process';
14+
import { dirname, resolve } from 'node:path';
15+
import { fileURLToPath } from 'node:url';
16+
17+
const HERE = dirname(fileURLToPath(import.meta.url));
18+
const REPO_ROOT = resolve(HERE, '../../../..');
19+
const GATE = resolve(HERE, '../../../../scripts/check-vouch-for-reference-callers.mjs');
20+
21+
const run = (...args: string[]) =>
22+
spawnSync(process.execPath, [GATE, ...args], { cwd: REPO_ROOT, encoding: 'utf8' });
23+
24+
describe('check:vouch-for-reference-callers', () => {
25+
it('its self-test reaches its verdict: every red and green case holds, and no battery fell below its floor', () => {
26+
const out = run('--self-test');
27+
expect(out.stderr).toBe('');
28+
expect(out.status).toBe(0);
29+
expect(out.stdout).toMatch(/self-test: \d+ cases pass/);
30+
});
31+
32+
it('this tree is green: the only production caller is the file-attachments writer, at its pinned count', () => {
33+
const out = run();
34+
expect(out.stderr).toBe('');
35+
expect(out.status).toBe(0);
36+
expect(out.stdout).toContain('packages/services/service-storage/src/file-attachment-service.ts (2)');
37+
});
38+
});

‎packages/core/vitest.repo-tests.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44
"src/security/operation-private-keys.pin.test.ts",
55
"src/security/row-serving-door-exposure.pin.test.ts",
66
"src/security/second-object-read-exposure.pin.test.ts",
7+
"src/security/vouched-reference-callers.pin.test.ts",
78
"src/utils/import-runner-sandbox-fault-row.test.ts"
89
]

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,10 @@ export const CROSS_PACKAGE_TEST_INPUTS = {
349349
// hints: the case flipped from true to false with the added glob itself as
350350
// the covering hint. ⇒ Extensions and glob widen together or not at all,
351351
// and that pin's header carries the measurement of what the boundary costs.
352-
globs: ['packages/**/*.ts'],
352+
//
353+
// src/security/vouched-reference-callers.pin.test.ts runs the census gate
354+
// of the vouched-reference mark, a root script, over the same `.ts` scan.
355+
globs: ['packages/**/*.ts', 'scripts/check-vouch-for-reference-callers.mjs'],
353356
},
354357
'@objectstack/types': {
355358
// src/driver-error-classification.callers.test.ts is the #13440 gate: it

‎turbo.json‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,8 @@
806806
"!coverage/**",
807807
"!.turbo/**",
808808
"!**/node_modules/**",
809-
"$TURBO_ROOT$/packages/**/*.ts"
809+
"$TURBO_ROOT$/packages/**/*.ts",
810+
"$TURBO_ROOT$/scripts/check-vouch-for-reference-callers.mjs"
810811
]
811812
},
812813
"@objectstack/types#test:repo": {

0 commit comments

Comments
 (0)