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(tests): scan clock budgets before the suite [C7]
Corey Olsonbbc92b147add
diff --git a/package.json b/package.jsonindex 3880c1c7..a0150f04 100644--- a/package.json+++ b/package.json@@ -43,6 +43,6 @@"homepage": "https://pullboard.dev","scripts": {"test": "node bin/run-tests.js",- "gate": "node bin/pullboard.js spec check && npm test"+ "gate": "node test/wall-clock-budgets.js && node bin/pullboard.js spec check && npm test"}}diff --git a/test/gate.test.js b/test/gate.test.jsindex b7946574..3c5883f4 100644--- a/test/gate.test.js+++ b/test/gate.test.js@@ -4,7 +4,7 @@*/import assert from 'node:assert/strict';import { runFixtureExecFile as execFileSync, runFixtureChild as spawnSync, runFixtureChild, runFixtureGit } from './fixture-child.js';-import { cpSync, existsSync, mkdirSync, mkdtempSync, readFileSync, realpathSync, rmSync, writeFileSync } from 'node:fs';+import { copyFileSync, cpSync, existsSync, mkdirSync, mkdtempSync, readFileSync, realpathSync, rmSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { join, resolve } from 'node:path';import { after, test } from 'node:test';@@ -123,6 +123,52 @@ test('record real file ${id} [C7]', async () => {assert.throws(() => testConcurrency(root, 7), /browser must be 1 or 2/);});+test('the gate stops before the suite on a missing clock-budget comment [C7]', () => {+ const root = realpathSync(mkdtempSync(join(tmpdir(), 'pullboard-gate-clock-budget-')));+ dirs.push(root);+ mkdirSync(join(root, 'bin'));+ mkdirSync(join(root, 'test'));++ const actualPackage = JSON.parse(readFileSync(resolve(import.meta.dirname, '../package.json'), 'utf8'));+ const gateScript = actualPackage.scripts.gate;+ const fixturePackage = { ...actualPackage, scripts: { ...actualPackage.scripts, test: 'node test/suite-sentinel.js' } };+ assert.equal(fixturePackage.scripts.gate, gateScript, 'the real package gate command is preserved verbatim');+ writeFileSync(join(root, 'package.json'), JSON.stringify(fixturePackage, null, 2) + '\n');+ copyFileSync(resolve(import.meta.dirname, 'wall-clock-budgets.js'), join(root, 'test/wall-clock-budgets.js'));+ writeFileSync(join(root, 'bin/pullboard.js'), `if (process.argv.slice(2).join(' ') !== 'spec check') process.exit(2);+process.stdout.write('fixture spec check reached\\n');+`);+ const suiteMarker = join(root, 'suite-ran');+ writeFileSync(join(root, 'test/suite-sentinel.js'), `import { writeFileSync } from 'node:fs';+writeFileSync(${JSON.stringify(suiteMarker)}, 'ran');+`);+ const missingBudget = join(root, 'test/missing-budget.test.js');+ writeFileSync(missingBudget, `import assert from 'node:assert/strict';+const started = Date.now();+assert.ok(Date.now() - started < 500, 'planted assertion without a budget comment');+`);++ const env = { ...process.env, npm_config_update_notifier: 'false', npm_config_audit: 'false', npm_config_fund: 'false' };+ runFixtureGit(['init', '-q', '-b', 'main'], { cwd: root, env });+ runFixtureGit(['add', '-A'], { cwd: root, env });++ const refused = runFixtureChild('npm', ['run', 'gate'], { cwd: root, env, encoding: 'utf8' });+ const refusalOutput = `${refused.stdout ?? ''}\n${refused.stderr ?? ''}`;+ assert.notEqual(refused.status, 0, `${refused.context}\n${refusalOutput}`);+ assert.match(refusalOutput, /test\/missing-budget\.test\.js:3: literal elapsed-time margin/u,+ 'the real scanner reports the tracked file and exact line');+ assert.match(refusalOutput, /elapsed-time margin|clock budget|wall-clock/u,+ 'the refusal explains that the failure is a clock-budget violation');+ assert.ok(refused.elapsedMs < 5000, `${refused.elapsedMs}ms; scanner must refuse before the suite.`); // budget: declared #653 static-refusal ceiling is 5000ms.+ assert.equal(existsSync(suiteMarker), false, 'the suite sentinel did not run after the scanner refused');++ rmSync(missingBudget);+ runFixtureGit(['add', '-u'], { cwd: root, env });+ const clean = runFixtureChild('npm', ['run', 'gate'], { cwd: root, env, encoding: 'utf8' });+ assert.equal(clean.status, 0, `${clean.context}\n${clean.stdout ?? ''}\n${clean.stderr ?? ''}`);+ assert.equal(existsSync(suiteMarker), true, 'a clean scanner result continues into the suite');+});+/*** A repo whose coordinator holds item #1, with this gate. Every run of the gate first adds a line* to runs.log beside the repo, so a test can count the runs.diff --git a/test/wall-clock-budgets.js b/test/wall-clock-budgets.jsindex 64a1f623..cd2b1d33 100644--- a/test/wall-clock-budgets.js+++ b/test/wall-clock-budgets.js@@ -1,7 +1,8 @@/** Find unexplained wall-clock judgments in test source, without executing it [C7]. */import { execFileSync } from 'node:child_process';import { existsSync, lstatSync, readFileSync } from 'node:fs';-import { join } from 'node:path';+import { join, resolve } from 'node:path';+import { fileURLToPath } from 'node:url';/** Mask comments and quoted fixture text while retaining exact offsets and comment lines. */function codeOnly(source) {@@ -184,3 +185,12 @@ export function wallClockViolations(root) {}return found.sort();}++// Imports remain side-effect free; Pullboard's own gate invokes this same scanner directly.+if (process.argv[1] && resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {+ const violations = wallClockViolations(process.cwd());+ if (violations.length) {+ process.stderr.write(`${violations.join('\n')}\n`);+ process.exitCode = 1;+ }+}