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(gate): the positive control runs under the gate lease [C7,D1]
Corey Olson330f5cac1b9d
diff --git a/src/gate.js b/src/gate.jsindex 8920f7cf..6eaef78c 100644--- a/src/gate.js+++ b/src/gate.js@@ -562,7 +562,7 @@ function fullGateRun(root, config, trustStamp = false, { waitMs = 0, log = gitPaconst { isGreen, output, seconds, profile, profilePath } = run;writeFileSync(log, output);// The environment refusing a run says nothing about the gate, so only a real result is recorded (U41).- if (!run.sandboxBlocked) recordGateRun(root, gateRunRecord(root, config, isGreen));+ if (!run.sandboxBlocked) recordGateRun(root, gateRunRecord(root, config, isGreen, gateLease));refuseSandboxBlocked(run);if (isGreen && before !== null && committedTree(root) === before) writeFileSync(gitPath(root, STAMP), `${before}\n`);return { isGreen, isCached: false, output, seconds, log, profile, profilePath, ...(run.executionRoot ? { executionRoot: run.executionRoot } : {}), ...(stages ? { stages: run.stages } : {}) };@@ -570,17 +570,24 @@ function fullGateRun(root, config, trustStamp = false, { waitMs = 0, log = gitPa/*** The record one real gate run leaves for health: its result, and the positive control's result when the project- * declares one, so a gate that stops passing its known-good case shows up without a person reading the log.+ * declares one. The control runs under the gate's own lease, so a child that runs the gate again inherits the+ * admission it already holds instead of asking for another slot (U41). Its raw output and profile stay in the+ * gate evidence, next to the gate's own.** @param {string} root* @param {{ gate: string, positiveControl?: string }} config* @param {boolean} isGreen whether the gate itself passed- * @returns {{ at: string, green: boolean, control: boolean | null, gate: string, positiveControl: string | null }}+ * @param {object} [gateLease] the lease the gate runs under+ * @returns {{ at: string, green: boolean, control: boolean | null, gate: string, positiveControl: string | null, controlLog?: string, controlProfile?: string }}*/-function gateRunRecord(root, config, isGreen) {+function gateRunRecord(root, config, isGreen, gateLease) {+ const at = new Date().toISOString();const positiveControl = config.positiveControl?.trim() ? config.positiveControl : null;- const control = positiveControl ? runShell(root, positiveControl).isGreen : null;- return { at: new Date().toISOString(), green: isGreen, control, gate: config.gate, positiveControl };+ if (!positiveControl) return { at, green: isGreen, control: null, gate: config.gate, positiveControl };+ const control = runProfiledShell(root, positiveControl, { gateLease, artifactPrefix: 'pullboard-gate-control', persistLog: true });+ // A control the environment refused says nothing about the gate, the same rule that keeps a refused gate run out of the record.+ const result = control.sandboxBlocked ? null : control.isGreen;+ return { at, green: isGreen, control: result, gate: config.gate, positiveControl, controlLog: control.logPath, controlProfile: control.profilePath };}/** Quote a fixed executable or selected path without permitting shell expansion. */diff --git a/test/health.test.js b/test/health.test.jsindex 6c706219..2130bc77 100644--- a/test/health.test.js+++ b/test/health.test.js@@ -5,7 +5,7 @@import { submitFixture } from './board-submit-fixture.js';import assert from 'node:assert/strict';import { createHash } from 'node:crypto';-import { mkdirSync, mkdtempSync, readFileSync, realpathSync, rmSync, writeFileSync } from 'node:fs';+import { existsSync, mkdirSync, mkdtempSync, readFileSync, realpathSync, rmSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { join, resolve } from 'node:path';import { test } from 'node:test';@@ -14,6 +14,7 @@ import { pathToFileURL } from 'node:url';import * as store from '../src/board.js';import { main } from '../src/cli.js';import { boardHealth } from '../src/health.js';+import { gateRuns } from '../src/gate-control.js';import { JSON_SHAPES } from '../src/json.js';import { runFixtureChild, runFixtureGit } from './fixture-child.js';@@ -383,3 +384,19 @@ test('health reports a gate that refused every run [C7,D1]', async (t) => {assert.equal(alarm.subject, 'gate');assert.deepEqual(alarm.detail.runs.map((run) => run.green), [false, false, false], 'the finding lists the last runs, all refused');});++test('a positive control inherits the gate slot it runs under [C7,D1]', async (t) => {+ const box = repo(t);+ const resources = pathToFileURL(resolve('src/resources.js')).href;+ // The control asks whether it inherited the gate's admission; a child that does not is refused and reads red.+ const probe = `node --input-type=module -e "const { inheritedGateSlot } = await import('${resources}'); process.exit(inheritedGateSlot({ root: process.cwd() }) ? 0 : 1)"`;+ commitPolicy(box, { gate: 'true', positiveControl: probe });+ const { runGate } = await import('../src/gate.js');+ const config = JSON.parse(readFileSync(join(box.root, 'pullboard.json'), 'utf8'));+ const gate = await runGate(box.root, config, { trustStamp: false });+ assert.equal(gate.isGreen, true, 'the gate itself is green');+ const run = gateRuns(box.root).at(-1);+ assert.equal(run.control, true, 'the positive control saw the inherited gate slot and passed');+ assert.ok(run.controlLog && existsSync(run.controlLog), 'the control keeps its raw output in the gate evidence');+ assert.ok(run.controlProfile && existsSync(run.controlProfile), 'the control keeps its timing profile in the gate evidence');+});