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: require sandbox-only outside intake verification [V1,V2,V3,B26]
Corey Olsond9efefb3ed51
diff --git a/test/intake-fixture.js b/test/intake-fixture.jsnew file mode 100644index 00000000..133a419e--- /dev/null+++ b/test/intake-fixture.js@@ -0,0 +1,119 @@+/** Private GitHub/Docker protocol stand-ins; neither is actual outside code or containment evidence. */+import assert from 'node:assert/strict';+import { randomUUID } from 'node:crypto';+import {+ mkdirSync,+ readFileSync,+ writeFileSync,+} from 'node:fs';+import { join } from 'node:path';+import { createE2eHelpers } from './e2e-helpers.js';++/** Quote an owned fixture path for the tiny executable shim. */+function word(value) { return "'" + value.replaceAll("'", "'\\''") + "'"; }++/** Install a private executable without changing the real user's PATH or tools. */+function executable(box, name, source) {+ const script = join(box.dir, name + '.cjs');+ writeFileSync(script, source);+ const path = join(box.dir, 'bin', name);+ writeFileSync(path, `#!/bin/sh\nexec ${word(process.execPath)} ${word(script)} "$@"\n`, { mode: 0o755 });+ return path;+}++/** Run a private CLI command that must succeed and parse its single JSON document. */+export function fixtureJSON(box, cwd, ...args) {+ const result = box.run(cwd, ...args, '--json');+ assert.equal(result.code, 0, `${args.join(' ')}: ${result.err}${result.out}`);+ return JSON.parse(result.out);+}++/** Build a real outside commit/ref and an independently initialized trusted receiving board. */+export function intakeFixture(t) {+ const helpers = createE2eHelpers();+ t.after(helpers.cleanup);+ const box = helpers.sandbox();+ box.env.PULLBOARD_MODEL = 'private intake fixture model';+ box.env.HOME = join(box.dir, 'empty-host-home');+ mkdirSync(box.env.HOME);+ for (const name of ['PULLBOARD_GATE_SLOT_HELD', 'PULLBOARD_GATE_SLOT_POOL', 'PULLBOARD_GATE_SLOT_TOKEN', 'PULLBOARD_BROWSER_SLOT_HELD']) delete box.env[name];+ // Fresh private canaries detect credential forwarding; they are never real account secrets.+ box.env.GH_TOKEN = randomUUID();+ box.env.HOST_SECRET = randomUUID();+ const made = helpers.project('node --test test/contribution.test.js', box);+ const base = box.git(made.repo, 'rev-parse', 'HEAD');+ const fork = join(box.dir, 'outside-fork');+ box.git(box.dir, 'clone', '-q', '--no-hardlinks', made.repo, fork);+ mkdirSync(join(fork, 'relay'), { recursive: true });+ mkdirSync(join(fork, 'test'), { recursive: true });+ writeFileSync(join(fork, 'relay', 'outside.js'), 'export const outside = true;\n');+ writeFileSync(join(fork, 'test', 'contribution.test.js'), "import { test } from 'node:test'; import assert from 'node:assert/strict';+import { randomUUID } from 'node:crypto'; import { outside } from '../relay/outside.js'; test('outside change [V2]',()=>assert.equal(outside,true));\n");+ box.git(fork, 'add', '-A');+ box.git(fork, 'commit', '-q', '--author', 'Outside Contributor <[email protected]>', '-m', 'feat: outside fixture\n\nSigned-off-by: Outside Contributor <[email protected]>');+ const commit = box.git(fork, 'rev-parse', 'HEAD');+ const tree = box.git(fork, 'rev-parse', 'HEAD^{tree}');+ const origin = join(box.dir, 'outside-origin.git');+ box.git(box.dir, 'clone', '-q', '--bare', made.repo, origin);+ box.git(origin, 'fetch', '-q', fork, 'HEAD:refs/pull/7/head');+ box.git(made.repo, 'remote', 'add', 'origin', 'https://github.com/fixture/project.git');+ box.git(made.repo, 'config', `url.file://${origin}.insteadOf`, 'https://github.com/fixture/project.git');+ const facts = join(box.dir, 'github-facts.json');+ const ghLog = join(box.dir, 'github-calls.jsonl');+ const pull = { number: 7, title: 'Outside fixture change', state: 'open', body: 'Fixes #6',+ html_url: 'https://github.com/fixture/project/pull/7', user: { login: 'outside-contributor' },+ head: { sha: commit, ref: 'outside-change', repo: { clone_url: 'https://github.com/fixture/project.git' } },+ base: { sha: base, ref: 'main', repo: { full_name: 'fixture/project' } },+ created_at: '2026-01-01T00:00:00Z', updated_at: '2026-01-02T00:00:00Z' };+ writeFileSync(facts, JSON.stringify({ pull, issue: { number: 6, title: 'Outside issue', body: 'The outside behavior works.', state: 'open',+ user: { login: 'issue-author' }, html_url: 'https://github.com/fixture/project/issues/6', created_at: '2026-01-01T00:00:00Z', updated_at: '2026-01-02T00:00:00Z' } }));+ executable(box, 'gh', `const fs=require('node:fs'); const args=process.argv.slice(2); fs.appendFileSync(${JSON.stringify(ghLog)},JSON.stringify(args)+'\\n');+const facts=JSON.parse(fs.readFileSync(${JSON.stringify(facts)},'utf8'));+const route=(args.find(arg=>arg.startsWith('repos/')||arg.startsWith('/repos/'))||'').replace(/^\\//,'');+let value;+if(args[0]==='repo'&&args[1]==='view') value={nameWithOwner:'fixture/project',defaultBranchRef:{name:'main'}};+else if(args[0]!=='api'||args.includes('--method')||args.includes('-X')) { process.stderr.write('fixture refuses posting or unknown commands'); process.exit(2); }+else if(route==='repos/fixture/project/pulls/7') value=facts.pull;+else if(route==='repos/fixture/project/pulls/7/files') value=[{filename:'relay/outside.js',status:'added'},{filename:'test/contribution.test.js',status:'added'}];+else if(route==='repos/fixture/project/pulls/7/reviews') value=[];+else if(route==='repos/fixture/project/issues/6') value=facts.issue;+else if(route==='repos/fixture/project/issues/6/comments') value=facts.issueComments||[];+else if(route==='repos/fixture/project/issues/7/comments') value=[{user:{login:'maintainer'},author_association:'MEMBER',body:'Recorded for review.'}];+else if(route==='repos/fixture/project') value={full_name:'fixture/project',default_branch:'main',owner:{login:'fixture'}};+else { process.stderr.write('unrecognized fixture GitHub route '+route); process.exit(2); }+process.stdout.write(JSON.stringify(value));\n`);+ return { ...made, ...box, base, commit, tree, fork, origin, facts, ghLog, pull };+}++/** Configure a Docker CLI protocol double, explicitly not a real container/runtime proof. */+export function configureFixtureSandbox(box) {+ const dockerLog = join(box.dir, 'docker-calls.jsonl');+ const minimum = 'node@sha256:' + '1'.repeat(64);+ const current = 'node@sha256:' + '2'.repeat(64);+ const docker = executable(box, 'fixture-docker', `const fs=require('node:fs'); const args=process.argv.slice(2);+fs.appendFileSync(${JSON.stringify(dockerLog)},JSON.stringify({args,secret:process.env.HOST_SECRET??null,credential:process.env.GH_TOKEN??null})+'\\n');+const image=args.find(arg=>arg.includes('@sha256:'))||''; const minimum=image===${JSON.stringify(minimum)};+if(args[0]==='image'&&args[1]==='inspect') process.stdout.write(JSON.stringify([{Id:'sha256:'+(minimum?'a':'b').repeat(64),RepoDigests:[image],Config:{Env:['PATH=/usr/local/bin:/usr/bin:/bin']}}]));+else if(args[0]==='info') process.stdout.write(JSON.stringify({ServerVersion:'29.0.0',OSType:'linux'}));+else if(args[0]==='version') process.stdout.write('29.0.0');+else if(args[0]==='run') {+ const cid=args.indexOf('--cidfile'); if(cid>=0) fs.writeFileSync(args[cid+1],'c'.repeat(64));+ if(args.includes('--version')) process.stdout.write(minimum?'v22.13.1':'v24.21.0');+ else if(args.includes('-p')||args.includes('--eval')) process.stdout.write(JSON.stringify({node:minimum?'22.13.1':'24.21.0',platform:'linux',arch:'arm64'}));+ else { const baseline=args.includes('pullboard.sandbox.stage=baseline'); process.stdout.write('TAP version 13\\n'+(baseline?'not ok':'ok')+' 1 - fixture sandbox stage\\n1..1\\n# tests 1\\n# pass '+(baseline?'0':'1')+'\\n# fail '+(baseline?'1':'0')+'\\n# skipped 0\\n'); if(baseline) process.exitCode=1; }+} else if(args[0]==='inspect') process.stdout.write('[]');+else if(!['rm','kill'].includes(args[0])) { process.stderr.write('unknown fixture Docker command'); process.exit(2); }\n`);+ const file = join(box.repo, 'pullboard.json');+ const config = JSON.parse(readFileSync(file, 'utf8'));+ config.sandbox = { provider: 'docker', executable: docker, endpoint: 'unix:///fixture/docker.sock', images: { minimum, current } };+ writeFileSync(file, JSON.stringify(config, null, 2));+ box.git(box.repo, 'add', 'pullboard.json');+ box.git(box.repo, 'commit', '-q', '-m', 'chore: configure private stand-in sandbox');+ return { dockerLog, minimum, current };+}++/** Read only this fixture's recorded transport calls. */+export function calls(path) {+ try { return readFileSync(path, 'utf8').trim().split('\n').filter(Boolean).map(line => JSON.parse(line)); }+ catch (error) { if (error.code === 'ENOENT') return []; throw error; }+}diff --git a/test/intake.test.js b/test/intake.test.jsnew file mode 100644index 00000000..dcc57a0d--- /dev/null+++ b/test/intake.test.js@@ -0,0 +1,96 @@+/** @pullboard-test-input source-tree */+/** Outside-source intake/guards use real Git/SQLite and declared transport stand-ins [V1,V2,V3,B26]. */+import assert from 'node:assert/strict';+import { test } from 'node:test';+import {+ readFileSync,+ writeFileSync,+} from 'node:fs';+import {+ calls,+ configureFixtureSandbox,+ fixtureJSON,+ intakeFixture,+} from './intake-fixture.js';++/** Parse a private native refusal without treating transport stand-ins as execution evidence. */+function refusal(result, expected) {+ assert.notEqual(result.code, 0, 'the unsafe operation must refuse');+ assert.equal(JSON.parse(result.out || result.err).error.code, expected, result.out + result.err);+}++test('an intaken pull request is verified only in the sandbox [V1,V2,V3,B26]', t => {+ const box = intakeFixture(t);+ const filed = fixtureJSON(box, box.repo, 'intake', box.pull.html_url,+ '--criterion', 'The contributed behavior works.', '--check', 'node --test test/contribution.test.js');+ const id = String(filed.item?.item_id ?? filed.id);+ let item = fixtureJSON(box, box.repo, 'show', id);+ assert.equal(item.item_status, 'submitted');+ assert.equal(item.item_commit, box.commit);+ assert.equal(item.item_tree, box.tree);+ assert.match(item.item_built_by, /outside-contributor/u);+ assert.equal(item.outside.kind, 'pull-request');+ assert.equal(item.outside.number, 7);+ assert.equal(item.outside.author, 'outside-contributor');+ assert.equal(item.outside.state, 'open');+ assert.equal(item.outside.maintainerReplied, true);+ assert.equal(item.outside.sensitive, true, 'relay code requires owner approval');+ assert.equal(box.git(box.repo, 'rev-parse', 'HEAD'), box.base, 'intake never checks out or executes the PR');+ refusal(box.run(box.web, 'verify', id, 'accept', '--note', 'unsafe host path', '--json'), 'OUTSIDE_SANDBOX_REQUIRED');+ refusal(box.run(box.web, 'verify', id, 'accept', '--sandbox', '--note', 'missing provider', '--json'), 'SANDBOX_PROVIDER_REQUIRED');++ // These simulated image versions/TAP rows prove adapter/receipt protocol only, never real containment.+ const provider = configureFixtureSandbox(box);+ const verdict = fixtureJSON(box, box.web, 'verify', id, 'accept', '--sandbox', '--note', 'private stand-in provider protocol');+ assert.equal(verdict.decision, 'ACCEPT');+ item = fixtureJSON(box, box.repo, 'show', id);+ assert.equal(item.item_status, 'verified');+ assert.equal(item.outside.sandbox.commit, box.commit);+ assert.equal(item.outside.sandbox.tree, box.tree);+ assert.deepEqual(item.outside.sandbox.runs.map(run => run.environment.node), ['22.13.1', '24.21.0']);+ assert.equal(item.outside.ownerApproval, null);+ refusal(box.run(box.repo, 'land', id, '--json'), 'OUTSIDE_OWNER_APPROVAL');+ assert.equal(box.git(box.repo, 'rev-parse', 'HEAD') === box.commit, false, 'sensitive PR never reaches the local trunk without its owner');+ fixtureJSON(box, box.repo, 'intake', 'approve', id);+ item = fixtureJSON(box, box.repo, 'show', id);+ assert.equal(item.outside.ownerApproval.commit, box.commit, 'person approval binds this exact outside commit');+ assert.equal(item.outside.ownerApproval.by, 'person');++ const transport = calls(provider.dockerLog);+ assert.ok(transport.some(call => call.args[0] === 'run'), 'the configured provider really receives the sandbox requests');+ for (const call of transport.filter(call => call.args[0] === 'run')) {+ assert.equal(call.args[call.args.indexOf('--network') + 1], 'none');+ assert.ok(call.args.includes('--read-only'));+ assert.ok(call.args.some(arg => arg.includes('target=/source') && arg.includes('readonly')), 'only a read-only private export is mounted as source');+ assert.equal(call.secret, null, 'no inherited host secret reaches the Docker client');+ assert.equal(call.credential, null, 'no inherited GitHub credential reaches the Docker client');+ }+ assert.equal(calls(box.ghLog).some(args => args.includes('--method') || args.includes('-X')), false, 'no outside reply is posted without a separate person action');+});+++test('outside issue intake retains source state and distinguishes a maintainer reply [V2,N2]', t => {+ const box = intakeFixture(t);+ const first = fixtureJSON(box, box.repo, 'intake', 'https://github.com/fixture/project/issues/6');+ const id = String(first.item?.item_id ?? first.id);+ let item = fixtureJSON(box, box.repo, 'show', id);+ assert.equal(item.outside.kind, 'issue');+ assert.equal(item.outside.author, 'issue-author');+ assert.equal(item.outside.state, 'open');+ assert.equal(item.outside.maintainerReplied, false);+ const facts = JSON.parse(readFileSync(box.facts, 'utf8'));+ facts.issueComments = [{ user: { login: 'another-outsider' }, author_association: 'CONTRIBUTOR', body: 'Following.' }];+ writeFileSync(box.facts, JSON.stringify(facts));+ fixtureJSON(box, box.repo, 'intake', 'https://github.com/fixture/project/issues/6');+ item = fixtureJSON(box, box.repo, 'show', id);+ assert.equal(item.outside.maintainerReplied, false, 'an arbitrary comment is not a maintainer response');+ facts.issue.state = 'closed';+ facts.issueComments.push({ user: { login: 'maintainer' }, author_association: 'MEMBER', body: 'Recorded on our board.' });+ writeFileSync(box.facts, JSON.stringify(facts));+ const refreshed = fixtureJSON(box, box.repo, 'intake', 'https://github.com/fixture/project/issues/6');+ assert.equal(String(refreshed.item?.item_id ?? refreshed.id), id, 'refresh updates the existing outside-source record');+ item = fixtureJSON(box, box.repo, 'show', id);+ assert.equal(item.outside.state, 'closed');+ assert.equal(item.outside.maintainerReplied, true);+ assert.equal(item.item_status, 'open', 'GitHub closure alone does not verify or land a local board item');+});