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): conservatively place unresolved CommonJS registrations [C7]
Corey Olson4e73b5c31038
diff --git a/docs/api.md b/docs/api.mdindex 02b76a24..58d576d9 100644--- a/docs/api.md+++ b/docs/api.md@@ -678,7 +678,7 @@ A board-recorded item merge covers its introduced commits only when its exact suThe JSON result includes `verification` entries with PR number, exact head, state, assurance, receipt identities, and any unverified commit IDs. GitHub statuses are shared by PRs with the same head: if an outside or unproven PR shares a commit with a proven proposal, the shared status stays red rather than lending the proposal's green status to it. Publishing observes and posts statuses; it never merges a PR or requires outside authors to use Pullboard.-A Node test that intentionally generates CPU load declares `{ cpuLoad: true }` in its test options. `bin/run-tests.js` discovers declarations without running the module and places the selected files on a registered runner, even with local-first admission or an inherited coordinator lease. While runners are registered it waits for a compatible runner instead of using local or short capacity; browser and GUI requirements still apply. A runner failure never permits this load to fall back locally. With no runners registered it uses the ordinary local admission and prints the reason. Source must be clean and committed for remote execution. Discovery conservatively places the whole selected file, including when a name filter selects only some cases; comments and string/template examples do not declare load. Options that cannot be read statically count as declared load: computed property names, object spreads, opaque option expressions, unresolved test-function uses and unreadable test-context member uses require runner placement. Readable direct subtests and ordinary context lifecycle hooks retain their ordinary classification. Discovery never evaluates those expressions. A directly readable literal `cpuLoad: false` remains ordinary work.+A Node test that intentionally generates CPU load declares `{ cpuLoad: true }` in its test options. `bin/run-tests.js` discovers declarations without running the module and places the selected files on a registered runner, even with local-first admission or an inherited coordinator lease. While runners are registered it waits for a compatible runner instead of using local or short capacity; browser and GUI requirements still apply. A runner failure never permits this load to fall back locally. With no runners registered it uses the ordinary local admission and prints the reason. Source must be clean and committed for remote execution. Discovery conservatively places the whole selected file, including when a name filter selects only some cases; comments and string/template examples do not declare load. Options that cannot be read statically count as declared load: computed property names, object spreads, opaque option expressions, unresolved test-function uses and unreadable test-context member uses and unresolved CommonJS registration paths require runner placement. Readable direct subtests and ordinary context lifecycle hooks retain their ordinary classification. Discovery never evaluates those expressions. A directly readable literal `cpuLoad: false` remains ordinary work.`pullboard why <file>[:<line>] --json` uses the `why file` catalog shape; this names the file form, not a literal `file` argument. It traces commits on the repository's actual primary branch, then resolves their item trailers, served row IDs and answered decisions in one board query. The legacy `why <id>` shape is unchanged. Answered decisions carry their recorded origin, statement, rationale, decider and relayer; absent historical provenance remains `unknown`. Row and item origins are also `unknown` unless recorded, rather than inferred from a related decision. An agent may label a relayed or inherited answer but cannot use that label to mint a person-origin record. Unproven original decider identities remain unknown, with the answering relay seat recorded separately.diff --git a/src/module-imports.js b/src/module-imports.jsindex 189a2ada..8e6d0a2a 100644--- a/src/module-imports.js+++ b/src/module-imports.js@@ -320,6 +320,7 @@ function unreadableTestOptions(source, quoted) {/** Find CPU-load options without evaluating a test module; unknown identifier values require runner admission. */export function cpuLoadOptionsIn(sources) {+ const commonJs = commonJsIn(sources);const quoted = sources.map(quotedProperties);const occurrences = sources.map((source, index) => [...source.matchAll(/(?:\bcpuLoad\b|["']cpuLoad["'])/gu), ...source.matchAll(UNICODE_ESCAPE),@@ -340,7 +341,7 @@ export function cpuLoadOptionsIn(sources) {const parsed = look([...sources, ...variants]);let next = sources.length;return sources.map((source, index) => {- let found = !parsed[index].compiles || unreadableTestOptions(source, quoted[index]);+ let found = !parsed[index].compiles || commonJs[index] || unreadableTestOptions(source, quoted[index]);for (const { disabled } of occurrences[index]) {if (!parsed[next].compiles && !disabled) found = true;next += 1;diff --git a/test/cpu-load-test-fixture.js b/test/cpu-load-test-fixture.jsindex 47c25e82..b2386050 100644--- a/test/cpu-load-test-fixture.js+++ b/test/cpu-load-test-fixture.js@@ -9,8 +9,9 @@ import { HOST, installSshStandIn } from './runner-ssh-fixture.js';const SOURCE = resolve(import.meta.dirname, '..');/** Build an ordinary CLI fixture whose declared test reports its actual checkout and live holder. */-export function cpuLoadFixture(e2e, { declaration = '{ cpuLoad: true }', binding = 'test', subtest = null } = {}) {- const box = e2e.project('node bin/run-tests.js test/cpu-probe.test.js');+export function cpuLoadFixture(e2e, { declaration = '{ cpuLoad: true }', binding = 'test', subtest = null, commonjs = false } = {}) {+ const probeFile = `cpu-probe.test.${commonjs ? 'cjs' : 'js'}`;+ const box = e2e.project(`node bin/run-tests.js test/${probeFile}`);const bin = join(box.dir, 'ssh-bin');const remoteHome = join(box.dir, 'runner-home');const remoteMachineHome = join(remoteHome, '.pullboard');@@ -19,8 +20,9 @@ export function cpuLoadFixture(e2e, { declaration = '{ cpuLoad: true }', bindingcpSync(join(SOURCE, 'src'), join(box.repo, 'src'), { recursive: true });cpSync(join(SOURCE, 'bin'), join(box.repo, 'bin'), { recursive: true });writeFileSync(join(box.repo, 'package.json'), JSON.stringify({ name: 'pullboard', version: '1.0.0', type: 'module' }) + '\n');- writeFileSync(join(box.repo, 'test', 'cpu-probe.test.js'), `import { test${binding === 'test' ? '' : ` as ${binding}`}, after as finish } from 'node:test';-import { DatabaseSync } from 'node:sqlite';+ writeFileSync(join(box.repo, 'test', probeFile), `${commonjs+ ? `const { test: ${binding}, after: finish } = require('node:test');\nconst { DatabaseSync } = require('node:sqlite');`+ : `import { test${binding === 'test' ? '' : ` as ${binding}`}, after as finish } from 'node:test';\nimport { DatabaseSync } from 'node:sqlite';`}// Example text is not a declaration: { cpuLoad: true }const example = '{ cpuLoad: true }';finish(() => {});@@ -29,7 +31,7 @@ ${subtest ? `${binding}('parent', async t => { t.after(() => {}); await ${subtesconst row = db.prepare('SELECT * FROM holder WHERE token=?').get(process.env.PULLBOARD_GATE_SLOT_TOKEN);db.close();console.log('CPU_LOAD_EXECUTOR ' + JSON.stringify({ cwd: process.cwd(), home: process.env.HOME,- gatePool: process.env.PULLBOARD_GATE_SLOT_POOL, liveLease: Boolean(row), runnerExecution: row?.runner_execution === 1 }));+ gatePool: process.env.PULLBOARD_GATE_SLOT_POOL, liveLease: Boolean(row), runnerExecution: row?.runner_execution === 1, browserLease: row?.browser === 1 }));});${subtest ? '});' : ''}`);@@ -44,7 +46,8 @@ ${subtest ? '});' : ''}assert.equal(result.code, 0, result.err || result.out);return JSON.parse(result.out);}- command('runner', 'add', HOST, '--slots', '1', '--browser', '0');+ // CommonJS conservatively needs browser admission; this private worker supplies a genuine browser slot.+ command('runner', 'add', HOST, '--slots', '1', '--browser', commonjs ? '1' : '0');command('settings', 'gate.runnersFirst', 'off');command('settings', 'gateSlots', '1');const cli = join(SOURCE, 'bin', 'pullboard.js');@@ -54,9 +57,9 @@ ${subtest ? '});' : ''}requestsMade() { return existsSync(requests) ? readFileSync(requests, 'utf8').trim().split('\n').filter(Boolean).map(JSON.parse) : []; },/** Commit a harmless source change so the next public gate executes instead of reusing a green tree. */commitProbeChange() {- const probe = join(box.repo, 'test', 'cpu-probe.test.js');+ const probe = join(box.repo, 'test', probeFile);writeFileSync(probe, readFileSync(probe, 'utf8') + '\n// A new fixture revision exercises ordinary gate execution again.\n');- box.git(box.repo, 'add', 'test/cpu-probe.test.js');+ box.git(box.repo, 'add', `test/${probeFile}`);box.git(box.repo, 'commit', '-q', '-m', 'test: advance the CPU placement fixture source');},/** Run the public landing gate under its ordinary lease and wait on its original child promise. */diff --git a/test/cpu-load-tests.test.js b/test/cpu-load-tests.test.jsindex fdca9c6e..c4bc2937 100644--- a/test/cpu-load-tests.test.js+++ b/test/cpu-load-tests.test.js@@ -162,3 +162,16 @@ test('a readable false direct subtest and context lifecycle hook stay local [C7]assert.equal(local.executor?.liveLease, true);assert.equal(local.executor?.runnerExecution, false);});+++// AFTER-only: unresolved CommonJS registration is conservatively placed without executing it.+test('opaque CommonJS registration uses its genuine runner and browser lease [C7]', async () => {+ const box = cpuLoadFixture(e2e, { commonjs: true, binding: 'register',+ declaration: 'Object.fromEntries([[ ["cpu", "Load"].join(""), true ]])' });+ const remote = await box.runGate();+ assert.equal(remote.result.status, 0, remote.result.context);+ assert.equal(box.requestsMade().length, 1);+ assert.equal(remote.executor?.runnerExecution, true);+ assert.equal(remote.executor?.browserLease, true, 'the conservative CommonJS browser requirement has a real private holder');+ assert.notEqual(remote.executor?.cwd, box.repo);+});