Skip to content

Autonomous development for real products. Governed agents build from specs you approve, follow the rules you set, and nothing merges until another agent proves it. Your decisions, judgement and taste are the bar that work must clear. Declare your vision and let agents build it.

test(core): name Chrome launchers missing GUI headers [C7,V4]

Corey Olsonb3e070ca37d1
diff --git a/test/gui-marker-fixture.js b/test/gui-marker-fixture.js
new file mode 100644
index 00000000..727eff6f
--- /dev/null
+++ b/test/gui-marker-fixture.js
@@ -0,0 +1,46 @@
+/** Read literal module edges for the explicit Chrome GUI annotation guard without running any source [C7,V4]. */
+import { readFileSync } from 'node:fs';
+import { posix, resolve } from 'node:path';
+import { importsIn } from '../src/module-imports.js';
+
+const LAUNCHERS = new Set(['test/chrome-fixture.js', 'test/chrome-launch-args.js', 'test/cockpit/fixture.js']);
+
+/** Find one literal in-repository module among the tracked paths; fixture strings are not import edges. */
+function localModule(files, importer, request) {
+ if (!request.startsWith('.')) return null;
+ const path = posix.normalize(posix.join(posix.dirname(importer), request.split(/[?#]/u)[0]));
+ if (path.startsWith('../')) return null;
+ return [path, ...['.js', '.mjs', '.cjs'].map(extension => path + extension)]
+ .find(candidate => files.has(candidate)) ?? null;
+}
+
+/** Return every tracked test whose literal import graph reaches a shared Chrome launcher, conservatively including helper-only bindings. */
+export function chromeLaunchingTests(root, tracked) {
+ const files = new Set(tracked);
+ const tests = tracked.filter(file => /\.test\.[cm]?js$/u.test(file));
+ const graph = new Map();
+ let frontier = tests;
+ while (frontier.length) {
+ const paths = [...new Set(frontier)].filter(path => !graph.has(path));
+ frontier = [];
+ for (let index = 0; index < paths.length; index += 64) {
+ const batch = paths.slice(index, index + 64);
+ const sources = batch.map(path => readFileSync(resolve(root, path), 'utf8'));
+ const edges = importsIn(sources);
+ batch.forEach((path, offset) => {
+ const local = edges[offset].map(request => localModule(files, path, request))
+ .filter(target => target && /\.[cm]?js$/u.test(target));
+ graph.set(path, local);
+ frontier.push(...local);
+ });
+ }
+ }
+ /** Walk already parsed edges with per-test cycle protection; no target source is evaluated. */
+ function reachesLauncher(path, seen = new Set()) {
+ if (LAUNCHERS.has(path)) return true;
+ if (seen.has(path)) return false;
+ seen.add(path);
+ return (graph.get(path) ?? []).some(target => reachesLauncher(target, seen));
+ }
+ return tests.filter(path => reachesLauncher(path)).sort();
+}
diff --git a/test/gui-marker-guard.test.js b/test/gui-marker-guard.test.js
new file mode 100644
index 00000000..0226c9a8
--- /dev/null
+++ b/test/gui-marker-guard.test.js
@@ -0,0 +1,47 @@
+/** @pullboard-test-input test-tree */
+/** @pullboard-test-input source-tree */
+/** @pullboard-test-input docs-tree */
+/** Chrome-launching test files declare GUI requirements explicitly; the guard keeps the list complete [C7,V4]. */
+import assert from 'node:assert/strict';
+import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';
+import { tmpdir } from 'node:os';
+import { dirname, join, resolve } from 'node:path';
+import { test } from 'node:test';
+import { testsNeedGui } from '../src/gui-admission.js';
+import { runFixtureGit } from './fixture-child.js';
+import { chromeLaunchingTests } from './gui-marker-fixture.js';
+
+/** Read actual tracked paths through Git, preserving the source index as the completeness boundary. */
+function trackedFiles(root) {
+ return runFixtureGit(['ls-files', '-z'], { cwd: root, stdio: 'pipe' }).split('\0').filter(Boolean);
+}
+
+test('the GUI marker guard follows literal launcher imports without evaluating fixture source [C7,V4]', t => {
+ const root = mkdtempSync(join(tmpdir(), 'pullboard-gui-guard-'));
+ t.after(() => rmSync(root, { recursive: true, force: true }));
+ runFixtureGit(['init', '-q', '-b', 'main'], { cwd: root, stdio: 'pipe' });
+ const sources = {
+ 'test/chrome-fixture.js': "throw new Error('the guard must never evaluate a launcher');",
+ 'test/bridge.js': "export { startChrome } from './chrome-fixture.js';",
+ 'test/direct.test.js': "import { startChrome } from './chrome-fixture.js';",
+ 'test/wrapped.test.mjs': "await import('./bridge.js');",
+ 'test/ordinary.test.js': "const example = \"import { startChrome } from './chrome-fixture.js';\";",
+ };
+ for (const [file, source] of Object.entries(sources)) {
+ mkdirSync(dirname(join(root, file)), { recursive: true });
+ writeFileSync(join(root, file), source);
+ }
+ runFixtureGit(['add', '.'], { cwd: root, stdio: 'pipe' });
+ const launchers = chromeLaunchingTests(root, trackedFiles(root));
+ assert.deepEqual(launchers, ['test/direct.test.js', 'test/wrapped.test.mjs']);
+ assert.deepEqual(launchers.filter(file => !testsNeedGui(root, [file])), launchers, 'the refusal names each missing file');
+ for (const file of launchers) writeFileSync(join(root, file), '/** @pullboard-test-gui */\n' + sources[file]);
+ assert.deepEqual(launchers.filter(file => !testsNeedGui(root, [file])), [], 'explicit headers satisfy the same guard');
+});
+
+test('every test importing a Chrome launcher explicitly declares its GUI requirement [C7,V4]', () => {
+ const root = resolve(import.meta.dirname, '..');
+ const launchers = chromeLaunchingTests(root, trackedFiles(root));
+ const missing = launchers.filter(file => !testsNeedGui(root, [file]));
+ assert.deepEqual(missing, [], 'missing @pullboard-test-gui header in Chrome-launching test files: ' + missing.join(', '));
+});