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.
JavaScript agentic-codingai-agentsai-governanceautonomous-agentsclaude-codeclicode-reviewcodexcoding-agentsdeveloper-toolsgit-hooksllmlocal-firstmulti-agentsoftware-factoryspec-driven-developmentverificationvibe-coding
test(chrome): retain killed-launch clone evidence [C7]
Corey Olson1616322faf3e
diff --git a/test/chrome-clone-observer.js b/test/chrome-clone-observer.jsnew file mode 100644index 00000000..8f6f9344--- /dev/null+++ b/test/chrome-clone-observer.js@@ -0,0 +1,37 @@+/** Read only code-sign clones mapped by this launch's live process group [C7]. */+import { execFileSync } from 'node:child_process';+import { lstatSync, realpathSync } from 'node:fs';+import { dirname, join } from 'node:path';++/** Resolve Apple's per-user cleanup-on-boot directory without trusting a supplied environment path. */+function cloneRoot() {+ const user = execFileSync('/usr/bin/getconf', ['DARWIN_USER_DIR'], { encoding: 'utf8', timeout: 2_000 }).trim();+ return realpathSync(join(dirname(user.replace(/\/$/u, '')), 'X'));+}++/** Capture directory identities only while the direct owned leader still reserves its group. */+export function observedChromeClones(child) {+ if (process.platform !== 'darwin' || !child?.pid || child.exitCode !== null || child.signalCode !== null) return [];+ const output = execFileSync('/bin/ps', ['-ww', '-axo', 'pid=,ppid=,pgid=,comm='], {+ encoding: 'utf8', timeout: 2_000, maxBuffer: 8 * 1024 * 1024,+ });+ const rows = output.split('\n').flatMap(line => {+ const match = /^\s*(\d+)\s+(\d+)\s+(\d+)\s+(.+)$/u.exec(line);+ return match ? [{ pid: Number(match[1]), ppid: Number(match[2]), pgid: Number(match[3]), executable: match[4] }] : [];+ });+ if (!rows.some(row => row.pid === child.pid && row.ppid === process.pid && row.pgid === child.pid)) return [];+ const root = cloneRoot();+ const found = new Map();+ for (const row of rows.filter(row => row.pgid === child.pid)) {+ const directory = /^(.*\/(?:com\.google\.Chrome|org\.chromium\.Chromium)\.code_sign_clone\/code_sign_clone\.[A-Za-z0-9]{6})(?:\/|$)/u.exec(row.executable)?.[1];+ if (!directory) continue;+ try {+ const canonical = realpathSync(directory);+ if (canonical !== directory || dirname(dirname(canonical)) !== root) continue;+ const stat = lstatSync(canonical);+ if (!stat.isDirectory() || stat.isSymbolicLink() || stat.uid !== process.getuid()) continue;+ found.set(canonical, { path: canonical, dev: stat.dev, ino: stat.ino });+ } catch (error) { if (error.code !== 'ENOENT') throw error; }+ }+ return [...found.values()];+}diff --git a/test/chrome-fixture.test.js b/test/chrome-fixture.test.jsindex f5ed6070..d4971655 100644--- a/test/chrome-fixture.test.js+++ b/test/chrome-fixture.test.js@@ -1,13 +1,45 @@/** The shared Chrome fixture bounds startup and removes profiles only after the owned process group exits [C7]. */import assert from 'node:assert/strict';import { once } from 'node:events';-import { chmodSync, existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';+import { chmodSync, existsSync, lstatSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';import { createServer } from 'node:http';import { loadavg, tmpdir } from 'node:os';import { join } from 'node:path';import { monitorEventLoopDelay } from 'node:perf_hooks';import { test } from 'node:test';import { createEvaluator, createSender, createWaiter, findChromeExecutable, launchChromeProcess, startChrome, waitForTargetAbsent } from './chrome-fixture.js';+import { observedChromeClones } from './chrome-clone-observer.js';++test('a killed test Chrome leaves no code-sign clone [C7]', { skip: process.platform !== 'darwin' || !findChromeExecutable() }, async t => {+ const profile = mkdtempSync(join(tmpdir(), 'pullboard-clone-proof-'));+ let launched;+ let clones = [];+ t.after(async () => {+ await launched?.close();+ // Retain a genuine leak assertion while removing only this fixture's captured directory identities.+ for (const clone of clones) {+ try {+ const stat = lstatSync(clone.path);+ if (stat.isDirectory() && !stat.isSymbolicLink() && stat.dev === clone.dev && stat.ino === clone.ino) rmSync(clone.path, { recursive: true });+ } catch (error) { if (error.code !== 'ENOENT') throw error; }+ }+ rmSync(profile, { recursive: true, force: true });+ });+ launched = launchChromeProcess({ executable: findChromeExecutable(), args: ['--headless=new', '--disable-gpu',+ '--no-first-run', '--no-default-browser-check', '--disable-background-networking', '--disable-sync',+ '--disable-extensions', '--no-proxy-server', '--use-mock-keychain', '--password-store=basic',+ '--remote-debugging-port=0', `--user-data-dir=${profile}`, 'about:blank'] });+ const deadline = Date.now() + 15_000; // budget: observe the owned launch's native clone before deliberately killing it.+ while (!clones.length && Date.now() < deadline) {+ clones = observedChromeClones(launched.child);+ if (!clones.length) await pause(100);+ }+ assert.ok(clones.length, 'the real owned Chrome must expose a native clone before the kill proof');+ t.diagnostic(JSON.stringify({ ownedCloneCount: clones.length, paths: clones.map(clone => clone.path) }));+ launched.child.kill('SIGKILL');+ await launched.close();+ assert.deepEqual(clones.filter(clone => existsSync(clone.path)), [], 'teardown removes this killed launch\'s actual code-sign clones');+});/** Pause between checks while waiting for a fixture helper's readiness marker. */function pause(ms) {