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
chore(merge): integrate accepted pairing and rule ids [H17,H15,A5]
Corey Olsonea86dc44a1c6
diff --cc relay/service.jsindex e112d5de,4352f1c5..a7ba9063--- a/relay/service.js+++ b/relay/service.js@@@ -6,8 -7,7 +7,9 @@@ import { createApiHandler, apiJson, apiimport { Refused } from '../src/refused.js';import { createRelayJournal } from './journal.js';import { createRelayRetention } from './retention.js';+import { createPairingStore } from './pairing-store.js';+import { createPairingHandler } from './pairing-http.js';+ import { createRelayBrowserHandler } from './browser-page.js';const SNAPSHOT_BODY = 14_000_000;const STORED_BYTES = 10_000_000;@@@ -170,8 -165,8 +173,9 @@@ export function createRelayHandler({ di/** Add authenticated snapshot replacement and deletion to the common versioned read/move paths. */async function handle(req, res) {+ if (await pairing(req, res)) return;try {+ if (browser && await browser(req, res)) return;let url;try { url = new URL(req.url ?? '/', 'http://127.0.0.1'); }catch { throw new Refused('BAD_REQUEST', 'use a valid path under /api/v1/boards'); }diff --cc src/approved-rows.jsindex d44601ef,d44601ef..4bebc72e--- a/src/approved-rows.js+++ b/src/approved-rows.js@@@ -104,8 -104,8 +104,9 @@@ export function approvedRowProblems(roo}/** List every frozen item whose cited row text has changed, retaining historical accepted receipts. */--export function staleFrozenItems(items, rows) {-- const current = new Map(rows.map((row) => [row.id, row.text]));++export function staleFrozenItems(items, rows, doctrineRows = []) {++ const current = new Map([...rows.map((row) => [row.id, row.text]),++ ...doctrineRows.map((row) => ['doctrine:' + row.id, row.text])]);return items.flatMap((item) => {if (!item.item_frozen) return [];const frozen = JSON.parse(item.item_frozen);diff --cc src/cli.jsindex 27159653,8ef4d045..ed6da54c--- a/src/cli.js+++ b/src/cli.js@@@ -63,7 -61,7 +63,8 @@@ import { exportBoard, importBoard } froimport { addSigner, assertRequiredSigners, defaultPrincipal, hasSignerFile } from './signature.js';import { loadMachineSettings, setGateSlots } from './settings.js';import { relayLinked, relayOff, relayOn, relayOperation, relayStatus, syncRelay } from './relay.js';+import { relayJoin, relayPair } from './relay-pairing-client.js';+ import { executePersonRequests } from './relay-request-execution.js';const PACKAGE = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8'));export const VERSION = PACKAGE.version;@@@ -917,7 -887,7 +918,7 @@@ function resumeHere(io)};});const { me } = card;-- card.stale = staleFrozenItems(card.all, loadSpec(root, ctx.config).rows).map((item) => ({ ...item, ...staleItemFinding(item) }));++ card.stale = staleFrozenItems(card.all, loadSpec(root, ctx.config).rows, ctx.doctrine.rows).map((item) => ({ ...item, ...staleItemFinding(item) }));const say = (line) => io.say(line);const plural = (n, word) => `${n} ${word}${n === 1 ? '' : 's'}`;say(`resume: ${me.id}${me.family ? ` (${me.family})` : ''}, ${me.lane} lane${isMain ? ', the main checkout' : ''}, at ${root}`);@@@ -2361,19 -2304,9 +2372,19 @@@ async function runCommand(argv, io)if (command === 'hook') return await hookCommand(io, args);if (command === 'settings') return settingsCommand(io, args);if (command === 'relay') {+ if (first === 'pair') {+ if (second || rest.length || values.url) throw new Refused('USAGE', 'pullboard relay pair');+ const ctx = context(io);+ return await relayPair(ctx.info.root, io);+ }+ if (first === 'join') {+ if (!second || rest.length) throw new Refused('USAGE', 'pullboard relay join <code> [--url <address>]');+ const ctx = context(io);+ return await relayJoin(ctx.info.root, second, values.url, io);+ }if (second || rest.length || (first && !['on', 'off'].includes(first)) || (values.url && first !== 'on')) throw new Refused('USAGE', 'pullboard relay [on|off] [--url <address>]');const ctx = context(io);- if (!first) await syncRelay(ctx.info.root, io);+ if (!first) { await syncRelay(ctx.info.root, io); await executePersonRequests(ctx.info.root, io, main); }const result = first === 'on' ? await relayOn(ctx.info.root, values.url, io): first === 'off' ? await relayOff(ctx.info.root, io) : relayStatus(ctx.info.root);io.result?.(result);diff --cc src/doctor.jsindex 1a235ce5,1a235ce5..287b262c--- a/src/doctor.js+++ b/src/doctor.js@@@ -10,6 -10,6 +10,7 @@@ import { BLANKS, STATES, storeTriggersimport { readEventLogVersion, SCHEMA_VERSION } from './board.js';import { staleFrozenItems, staleItemFinding } from './approved-rows.js';import { loadSpec } from './spec.js';++import { loadDoctrine } from './doctrine.js';const blankCharacters = new Set(BLANKS.map((point) => String.fromCodePoint(point)));/** Offer a working tracked or untracked rename without rewriting the repo's doctrine [D1,D2]. */@@@ -49,7 -49,7 +50,7 @@@ export function doctorProblems(file, ro...(layout.itemPins ? pinProblems(db, root, tryGit) : []),...(layout.verdicts ? verdictProblems(db, root, tryGit) : []),...(layout.itemAudit ? submissionProblems(db, root) : []),-- ...(layout.itemAudit && config ? staleFrozenItems(db.prepare('SELECT * FROM item ORDER BY item_id').all(), loadSpec(root, config).rows).map(staleItemFinding) : []),++ ...(layout.itemAudit && config ? staleFrozenItems(db.prepare('SELECT * FROM item ORDER BY item_id').all(), loadSpec(root, config).rows, loadDoctrine(root, config).rows).map(staleItemFinding) : []),];} finally {db.close();diff --cc test/relay-client-fixture.jsindex e2a3ef37,ad3dc9f7..e3c7df1f--- a/test/relay-client-fixture.js+++ b/test/relay-client-fixture.js@@@ -55,50 -54,62 +55,83 @@@ export async function relayClientFixturGIT_AUTHOR_NAME: 'Relay Fixture', GIT_AUTHOR_EMAIL: '[email protected]',GIT_COMMITTER_NAME: 'Relay Fixture', GIT_COMMITTER_EMAIL: '[email protected]',};+ for (const name of ['PULLBOARD_RELAY_KEY', 'PULLBOARD_RELAY_TOKEN']) delete env[name];const provider = await githubFixture(t);provider.state.deviceAuthorized = true;+ const authDatabase = join(scratch, 'auth.sqlite');- const auth = createRelayAuth({ database: authDatabase, github: createGitHubClient(provider.config) });+ let auth;let time = Date.now();let override = null;+ let refuseEventReads = false;+ let refuseSnapshotWrites = false;+ let refuseRequestWrites = false;let signIn;let api;const calls = [];+ const transit = [];+ const moveAcks = [];+ const privateKeys = new Set();+ let keyLeaked = false;const server = createServer(async (req, res) => {- calls.push({ method: req.method, path: req.url });+ const requestChunks = [];+ const responseChunks = [];+ const request = new Transform({+ transform(chunk, _encoding, callback) {+ requestChunks.push(Buffer.from(chunk));+ callback(null, chunk);+ },+ });+ Object.assign(request, { method: req.method, url: req.url, headers: req.headers });+ req.pipe(request);+ /** Capture a response chunk for boolean-only transport audits without changing the response. */+ function captureResponse(chunk) {+ if (chunk !== undefined && chunk !== null && typeof chunk !== 'function') responseChunks.push(Buffer.from(chunk));+ }+ const write = res.write.bind(res);+ res.write = (chunk, ...args) => { captureResponse(chunk); return write(chunk, ...args); };const end = res.end.bind(res);- res.end = (chunk, ...args) => { captureResponse(chunk); return end(chunk, ...args); };+ res.end = (chunk, ...args) => {++ captureResponse(chunk);+ if (req.method === 'POST' && /\/api\/v1\/boards\/[0-9a-f]{32}\/moves$/.test(req.url ?? '') && (typeof chunk === 'string' || Buffer.isBuffer(chunk))) {+ try {+ const response = JSON.parse(Buffer.isBuffer(chunk) ? chunk.toString('utf8') : chunk);+ if (typeof response.event?.sealed === 'string') moveAcks.push(response.event);+ } catch { /* Capture only valid move acknowledgements; the production response remains unchanged. */ }+ }+ return end(chunk, ...args);+ };+ res.once('finish', () => transit.push({ method: req.method, path: req.url,+ request: Buffer.concat(requestChunks), response: Buffer.concat(responseChunks) }));+ calls.push({ method: req.method, path: req.url, accept: req.headers.accept ?? '' });+ if ([...privateKeys].some(key => JSON.stringify({ url: req.url, headers: req.headers }).includes(key))) keyLeaked = true;+ if (refuseEventReads && req.method === 'GET' && /\/events(?:\?|$)/.test(req.url)) {+ res.writeHead(503, { 'content-type': 'application/json' });+ res.end(JSON.stringify({ version: 1, error: { code: 'RELAY_UNAVAILABLE', message: 'fixture read outage' } }));+ return;+ }if (override && req.method === 'DELETE') {res.writeHead(override.status, { 'content-type': 'application/json' });res.end(JSON.stringify({ version: override.version ?? 1, error: { code: override.code, message: 'fixture refusal' } }));return;}+ if (refuseRequestWrites && req.method === 'POST' && /\/api\/v1\/boards\/[0-9a-f]{32}\/requests$/.test(req.url ?? '')) {+ res.writeHead(503, { 'content-type': 'application/json' });+ res.end(JSON.stringify({ version: 1, error: { code: 'RELAY_UNAVAILABLE', message: 'fixture request outage' } }));+ return;+ }+ if (refuseSnapshotWrites && req.method === 'PUT' && /\/api\/v1\/boards\/[0-9a-f]{32}\/state$/.test(req.url ?? '')) {+ res.writeHead(503, { 'content-type': 'application/json' });+ res.end(JSON.stringify({ version: 1, error: { code: 'RELAY_UNAVAILABLE', message: 'fixture snapshot outage' } }));+ return;+ }- if (await signIn(req, res)) return;- await api(req, res);+ if (await signIn(request, res)) return;+ await api(request, res);});server.listen(0, '127.0.0.1');await once(server, 'listening');const relayPort = server.address().port;const origin = 'http://127.0.0.1:' + relayPort;- auth = createRelayAuth({ database: join(scratch, 'auth.sqlite'), github: createGitHubClient({ ...provider.config, callbackURL: origin + '/auth/github/callback' }) });++ auth = createRelayAuth({ database: authDatabase, github: createGitHubClient({ ...provider.config, callbackURL: origin + '/auth/github/callback' }) });signIn = createAuthHandler({ auth, publicOrigin: origin });api = createRelayHandler({ directory: join(scratch, 'relay'), auth, publicOrigin: origin, pollMs: 10, maintenanceMs: 0, now: () => time });t.after(async () => {@@@ -160,47 -171,39 +196,71 @@@assert.equal((await run('relay', 'on', '--url', origin)).code, 0, 'second device signs in independently');return (await run('relay', 'off')).code;}+ /** Clone the same committed project into a separate repository/home, then join through a printed code. */+ async function otherDeviceJoin(code) {+ const bare = join(scratch, 'project.git');+ const otherRoot = join(scratch, 'paired-clone');+ const otherHome = join(scratch, 'paired-home');+ mkdirSync(otherHome, { mode: 0o700 });+ const otherEnv = { ...env, HOME: otherHome, PULLBOARD_HOME: join(otherHome, '.pullboard'), PULLBOARD_MACHINE_HOME: join(scratch, 'paired-machine') };+ assert.equal(spawnSync('git', ['clone', '--bare', root, bare], { cwd: scratch, env: otherEnv }).status, 0, 'fixture project creates a private bare remote');+ assert.equal(spawnSync('git', ['clone', bare, otherRoot], { cwd: scratch, env: otherEnv }).status, 0, 'second device is a real clone');+ assert.equal(spawnSync('git', ['remote', 'set-url', 'origin', '[email protected]:fixture/repository.git'], { cwd: otherRoot, env: otherEnv }).status, 0, 'clone names the same authorized repository');+ const run = (...args) => childResult(otherRoot, otherEnv, [CLI, ...args, '--json']);+ assert.equal((await run('init')).code, 0, 'the cloned project initializes its private local board');+ const joined = await run('relay', 'join', code, '--url', origin);+ const document = joined.document;+ if (joined.code !== 0) throw new Error('real clone did not join the one-use pairing code');+ const exported = await run('export');+ if (exported.code !== 0) throw new Error('paired clone could not read its restored board');+ const link = JSON.parse(readFileSync(join(otherRoot, '.git', 'pullboard', 'relay.json'), 'utf8'));+ const otherKeyFile = join(otherEnv.PULLBOARD_HOME, 'relay-keys', link.board + '.key');+ const environmentKey = readFileSync(otherKeyFile, 'utf8').trim();+ /** Run a real linked-clone command with only the environment key, after removing its key file. */+ async function syncWithEnvironmentKey(...args) {+ rmSync(otherKeyFile, { force: true });+ assert.equal(existsSync(otherKeyFile), false, 'the paired clone has no stored board-key file');+ const envKey = { ...otherEnv, PULLBOARD_RELAY_KEY: environmentKey };+ return childResult(otherRoot, envKey, [CLI, ...args, '--json']);+ }+ return { joined: document, exported: exported.document, syncWithEnvironmentKey,+ /** Check that the paired clone still has no persisted board-key file. */+ keyFileExists() { return existsSync(otherKeyFile); } };+ }+ /** Link another independently initialized synthetic board through the same real person account. */+ async function additionalBoard(title) {+ const nextRoot = join(scratch, 'additional-board');+ const nextHome = join(scratch, 'additional-home');+ mkdirSync(nextRoot);+ mkdirSync(nextHome, { mode: 0o700 });+ const nextEnv = { ...env, HOME: nextHome, PULLBOARD_HOME: join(nextHome, '.pullboard') };+ /** Run this separate board without retaining credentials in diagnostic output. */+ const run = (...args) => childResult(nextRoot, nextEnv, [CLI, ...args, '--json']);+ assert.equal(spawnSync('git', ['init', '-q', '-b', 'main'], { cwd: nextRoot, env: nextEnv }).status, 0);+ assert.equal((await run('init')).code, 0);+ assert.equal(spawnSync('git', ['remote', 'add', 'origin', '[email protected]:fixture/repository.git'], { cwd: nextRoot, env: nextEnv }).status, 0);+ assert.equal((await run('add', lane, title)).code, 0);+ assert.equal((await run('relay', 'on', '--url', origin)).code, 0);+ const state = JSON.parse(readFileSync(join(nextRoot, '.git', 'pullboard', 'relay.json'), 'utf8'));+ const encoded = readFileSync(join(nextEnv.PULLBOARD_HOME, 'relay-keys', state.board + '.key'), 'utf8').trim();+ privateKeys.add(encoded);+ return { id: state.board, encoded, cli: run };+ }/** Run multiple production commands in one process, emitting only safe counters. */async function script(source) {return childResult(root, env, ['--input-type=module', '-e', source]);}return {- root, env, origin, lane, before, linkFile, keyFile, calls, transit,- relayDirectory: join(scratch, 'relay'), authDatabase,- cli, link, otherDeviceOff, otherDeviceJoin, script, stopRelay, restartRelay,++ transit, relayDirectory: join(scratch, 'relay'), authDatabase, otherDeviceJoin,+ root, env, origin, lane, before, linkFile, keyFile, calls, moveAcks, cli, link, otherDeviceOff, additionalBoard, script, stopRelay, restartRelay,advance(days) { time = Date.now() + days * 86400000; },overrideDelete(value) { override = value; },+ refuseSnapshotWrites(value) { refuseSnapshotWrites = value; },+ refuseRequestWrites(value) { refuseRequestWrites = value; },mainURL: new URL('../src/cli.js', import.meta.url).href,+ keyInRequest() { return keyLeaked; },+ /** Revoke the actual synthetic person session, including its current live streams. */+ revokeSession() { const state = JSON.parse(readFileSync(linkFile, 'utf8')); return auth.revoke(state.token, state.tokenId); },+ refuseReads(value) { refuseEventReads = value; },};}diff --cc test/stale-frozen-items.test.jsindex 56f607d9,56f607d9..7d0146b2--- a/test/stale-frozen-items.test.js+++ b/test/stale-frozen-items.test.js@@@ -228,3 -228,3 +228,28 @@@ test('[S19,V3] doctor and resume list sconst historical = (snapshot) => snapshot.items.filter((item) => item.item_status === 'verified');assert.deepEqual(historical(receiptSnapshot(box)), historical(before), 'refreezing active work preserves every accepted historical receipt');});++++++test('[A5,S19,V3] doctor and resume distinguish unchanged doctrine citations from changed doctrine text', (t) => {++ const box = project(t);++ const doctrineItem = addItem(box, 'Doctrine citation', 'doctrine:PB1');++ claim(box, doctrineItem);++ succeeds(box, box.web, 'release', String(doctrineItem));++ const specItem = addItem(box, 'Unchanged spec citation', 'G3');++ claim(box, specItem);++ succeeds(box, box.web, 'release', String(specItem));++ const baseline = receiptSnapshot(box);++ const before = JSON.parse(succeeds(box, box.root, 'resume', '--json').stdout);++ assert.deepEqual(before.stale, [], 'a namespaced citation with unchanged inherited text is current');++ const doctorBefore = JSON.parse(box.pullboard(box.root, 'doctor', '--json').stdout);++ assert.deepEqual(doctorBefore.problems.filter(problem => problem.code === 'STALE_ITEM'), []);++ const path = join(box.root, 'DOCTRINE.md');++ writeFileSync(path, readFileSync(path, 'utf8') + '\n## Local override\n- PB1 [approved, must] Updated inherited rule. | gate: true\n');++ const after = JSON.parse(succeeds(box, box.root, 'resume', '--json').stdout);++ assert.deepEqual(after.stale.map(item => [item.id, item.rows]), [[doctrineItem, ['doctrine:PB1']]]);++ const doctorAfter = JSON.parse(box.pullboard(box.root, 'doctor', '--json').stdout);++ const findings = doctorAfter.problems.filter(problem => problem.code === 'STALE_ITEM');++ assert.equal(findings.length, 1);++ assert.match(findings[0].message, /old text of doctrine:PB1/);++ assert.deepEqual(receiptSnapshot(box), baseline, 'diagnostics preserve frozen evidence and unrelated SPEC citations');++});