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
fix(test): opt view fixtures out of background startup [N26]
Corey Olsonc3b8c4abfddb
diff --git a/test/cockpit/background-view-fixture.js b/test/cockpit/background-view-fixture.jsnew file mode 100644index 00000000..665dc54a--- /dev/null+++ b/test/cockpit/background-view-fixture.js@@ -0,0 +1,51 @@+/** Keep fixture-owned init commands from leaving an automatic view behind. */+import assert from 'node:assert/strict';+import { lstatSync, mkdirSync, readFileSync, realpathSync, writeFileSync } from 'node:fs';+import { userInfo } from 'node:os';+import { isAbsolute, join, relative, resolve, sep } from 'node:path';++/**+ * Disable background view startup in the effective machine home of a private test fixture.+ * This mirrors src/machine-home.js: PULLBOARD_MACHINE_HOME wins; otherwise the OS account home is used.+ * @param {NodeJS.ProcessEnv} env Environment that the fixture will pass to its init command.+ * @param {string} privateRoot Existing realpath root owned by this fixture.+ * @returns {{machineHome:string,settingsFile:string}}+ */+export function disableFixtureBackgroundView(env, privateRoot) {+ const root = realpathSync(privateRoot);+ const machineHome = resolve(env.PULLBOARD_MACHINE_HOME || join(userInfo().homedir, '.pullboard'));+ const pathFromRoot = relative(root, machineHome);+ assert.ok(pathFromRoot && pathFromRoot !== '..' && !pathFromRoot.startsWith('..' + sep) && !isAbsolute(pathFromRoot),+ 'fixture machine home must be inside its private root; refusing to touch the user machine home');++ let cursor = root;+ for (const component of pathFromRoot.split(sep)) {+ cursor = join(cursor, component);+ try {+ const info = lstatSync(cursor);+ assert.ok(info.isDirectory() && !info.isSymbolicLink(), `fixture machine-home path is not a real directory: ${cursor}`);+ } catch (error) {+ if (error.code !== 'ENOENT') throw error;+ mkdirSync(cursor);+ }+ }+ assert.equal(realpathSync(machineHome), machineHome, 'fixture machine home does not traverse a symlink');++ const settingsFile = join(machineHome, 'settings.json');+ let current = {};+ try {+ const info = lstatSync(settingsFile);+ assert.ok(info.isFile() && !info.isSymbolicLink() && info.nlink === 1,+ 'fixture settings must be a private regular file, not a symlink or hard link');+ current = JSON.parse(readFileSync(settingsFile, 'utf8'));+ } catch (error) {+ if (error.code !== 'ENOENT') throw error;+ }+ assert.ok(current && typeof current === 'object' && !Array.isArray(current), 'fixture settings must be a JSON object');+ const view = current.view === undefined ? {} : current.view;+ assert.ok(view && typeof view === 'object' && !Array.isArray(view), 'fixture settings.view must be a JSON object');+ if (view.background === false) return { machineHome, settingsFile };+ current.view = { ...view, background: false };+ writeFileSync(settingsFile, `${JSON.stringify(current, null, 2)}\n`, { mode: 0o600 });+ return { machineHome, settingsFile };+}diff --git a/test/cockpit/fixture.js b/test/cockpit/fixture.jsindex cc4b0ed2..eb243077 100644--- a/test/cockpit/fixture.js+++ b/test/cockpit/fixture.js@@ -10,6 +10,7 @@ import vm from 'node:vm';import { stableChrome, press, tapTouch } from './stable.js';import { closeBoard, openBoard } from '../../src/board.js';import { fetchFresh } from '../http-fixture.js';+import { disableFixtureBackgroundView } from './background-view-fixture.js';const BIN = resolve(import.meta.dirname, '../../bin/pullboard.js');@@ -51,6 +52,7 @@ function machine() {PULLBOARD_HOME: join(dir, 'home'),PULLBOARD_MACHINE_HOME: join(dir, 'machine-home'),};+ disableFixtureBackgroundView(env, dir);const git = (cwd, ...args) => execFileSync('git', args, { cwd, env, encoding: 'utf8', stdio: 'pipe' }).trim();const invocations = [];/** Run the CLI with an explicit environment and retain facts used by fixture checks. */@@ -75,6 +77,8 @@ function project(box, name, spec = SPEC, extra = {}) {box.git(repo, 'init', '-q', '-b', 'main');const initEnv = { ...box.env };delete initEnv.PULLBOARD_MODEL;+ // Set the fixture-only opt-out in the machine home that this exact init environment will use.+ disableFixtureBackgroundView(initEnv, box.dir);box.runWithEnv(repo, initEnv, 'init');const config = { gate: 'true', spec: 'SPEC.md', verify: 'any', lease: '2h', lanes: { web: { owns: ['web/'], specs: ['G'] } }, shared: [], ...extra };writeFileSync(join(repo, 'pullboard.json'), JSON.stringify(config, null, 2));diff --git a/test/cockpit/fixture.test.js b/test/cockpit/fixture.test.jsindex c73de5bd..fe7b3a4f 100644--- a/test/cockpit/fixture.test.js+++ b/test/cockpit/fixture.test.js@@ -28,6 +28,41 @@ test('the cockpit fixture inits its board without a model [N26]', () => {assert.equal(join.model, 'Test Model');});+test('the view fixture opts out of the background view [N26]', () => {+ const box = machine();+ const originalHome = box.env.PULLBOARD_MACHINE_HOME;+ const originalFile = join(originalHome, 'settings.json');+ assert.equal(JSON.parse(readFileSync(originalFile, 'utf8')).view.background, false,+ 'machine setup opts out before any CLI command runs');++ // A second machine in the same scratch root can override the effective home after machine().+ // Seed unrelated settings there to prove project() preserves them when it applies the opt-out.+ const overrideHome = join(box.dir, 'second-machine-home');+ mkdirSync(overrideHome);+ const overrideFile = join(overrideHome, 'settings.json');+ writeFileSync(overrideFile, JSON.stringify({ browserSlots: 1, view: { custom: 'keep', background: true } }));+ box.env.PULLBOARD_MACHINE_HOME = overrideHome;+ let checkedInit = false;+ const realRun = box.runWithEnv;+ /** Observe the real init boundary before delegating to the unchanged fixture CLI runner. */+ box.runWithEnv = (cwd, env, ...args) => {+ if (args[0] === 'init') {+ checkedInit = true;+ assert.equal(env.PULLBOARD_MACHINE_HOME, overrideHome, 'check the exact environment passed to init');+ assert.deepEqual(JSON.parse(readFileSync(join(env.PULLBOARD_MACHINE_HOME, 'settings.json'), 'utf8')),+ { browserSlots: 1, view: { custom: 'keep', background: false } },+ 'the effective machine opts out before the real init, without replacing its other settings');+ }+ return realRun(cwd, env, ...args);+ };+ project(box, 'background-view-opt-out');+ assert.equal(checkedInit, true, 'the fixture executes the actual init command');+ assert.equal(JSON.parse(readFileSync(originalFile, 'utf8')).view.background, false,+ 'changing the effective home leaves the first private machine alone');+ assert.equal(JSON.parse(readFileSync(overrideFile, 'utf8')).view.background, false,+ 'later copied or hooked CLI commands retain the effective machine opt-out');+});+test('the cockpit helper starts its view in the foreground [C7,N26]', async t => {const box = machine();project(box, 'foreground-view');diff --git a/test/cockpit/provenance.test.js b/test/cockpit/provenance.test.jsindex f5ddec61..f9685a39 100644--- a/test/cockpit/provenance.test.js+++ b/test/cockpit/provenance.test.js@@ -10,6 +10,7 @@ import { DatabaseSync } from 'node:sqlite';import { test } from 'node:test';import { addItem, closeBoard, openBoard } from '../../src/board.js';import { exportBoard, importBoard } from '../../src/exchange.js';+import { disableFixtureBackgroundView } from './background-view-fixture.js';/** Copy the actual candidate into a private primary repo and linked source checkout. */function fixture(t) {@@ -82,6 +83,10 @@ function fixture(t) {writeFileSync(join(root, 'SPEC.md'), '# View provenance fixture\n\n## G · Goals\n- G1 [approved, must] Keep the primary board unchanged. | gate: true\n');git(root, 'add', '-A');git(root, 'commit', '-q', '-m', 'chore: initialize provenance fixture');+ // This custom fixture initializes directly rather than through fixture.js project().+ disableFixtureBackgroundView(env, dir);+ assert.equal(JSON.parse(readFileSync(join(env.PULLBOARD_MACHINE_HOME, 'settings.json'), 'utf8')).view.background, false,+ 'the copied CLI sees the private opt-out before initialization');const initialized = cli(root, root, 'init');assert.equal(initialized.status, 0, `${initialized.stderr}${initialized.stdout}`);git(root, 'add', '-A');