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(pool): integrate landed gate improvements [C7,V4]
Corey Olsondfccaf6e0621
diff --cc src/cli.jsindex 72e5670c,59023459..0c5a4492--- a/src/cli.js+++ b/src/cli.js@@@ -2145,7 -2134,7 +2146,7 @@@ async function submitHere(ctx, id)withBoard(ctx, (board) => refuseUnverifiedStack(root, board, held, commit, trunk));// Every submit proves its frozen check and reachable tests anew on this exact commit (V4,V16).// A full-gate stamp never substitutes for either proof; only an actual full fallback may stamp.- const gate = await runSubmitGate(root, ctx.config, { base: claimHead, trunk: acceptedMain.commit, check: frozenCheck(held), agent: me.id, item: String(id), onWait: queuedItemLease(ctx, held, me.id, 'build') });- const gate = await runSubmitGate(root, ctx.config, { base: claimHead, trunk: acceptedMain.commit, check: frozenCheck(held), agent: me.id, item: String(id), onWait: gateWaitReporter(ctx.io), onBrowserFallback: browserAdmissionReporter(ctx.io, ctx.io.relayJson) });++ const gate = await runSubmitGate(root, ctx.config, { base: claimHead, trunk: acceptedMain.commit, check: frozenCheck(held), agent: me.id, item: String(id), onWait: queuedItemLease(ctx, held, me.id, 'build'), onBrowserFallback: browserAdmissionReporter(ctx.io, ctx.io.relayJson) });if (!gate.isGreen) {const message = `the submission proof is red at ${commit.slice(0, 12)}; fix it, commit, submit again. ${submitGateReport(gate)}`;// No submission can follow this verdict. Read-only main comparisons must not retain the seat's write lease.@@@ -2236,7 -2225,8 +2237,8 @@@ async function verifyHere(ctx, id, { seif (digest !== item.item_frozen_digest) throw new Refused('CRITERIA_CHANGED', 'the criterion changed; ask the coordinator to refreeze this item before checking it');const trunk = requireTrunkMerge(root, commit);refuseUnverifiedStack(root, board, item, commit, trunk);- check = await withGateSlot(root, (lease) => checkAtCommit(root, item, { waitMs: lease.waitMs, gateLease: lease }), { browser: true, agent: me.id, item: String(id), kind: 'review', itemCheck: true, onWait: queuedItemLease(ctx, item, me.id, 'review') });+ const browser = await checkNeedsBrowser(root, frozenCheck(item), { commit, onFallback: browserAdmissionReporter(ctx.io, ctx.io.relayJson) });- check = await withGateSlot(root, (lease) => checkAtCommit(root, item, { waitMs: lease.waitMs, gateLease: lease }), { browser, agent: me.id, item: String(id), kind: 'review', itemCheck: true, onWait: gateWaitReporter(ctx.io) });++ check = await withGateSlot(root, (lease) => checkAtCommit(root, item, { waitMs: lease.waitMs, gateLease: lease }), { browser, agent: me.id, item: String(id), kind: 'review', itemCheck: true, onWait: queuedItemLease(ctx, item, me.id, 'review') });verificationProfile = check.profile ?? null;const evidence = check.checked? `\nlast output lines (up to 40):\n${(check.outputTail ?? '(no output)').split('\n').map((line) => ` ${line}`).join('\n')}\nfull output file: ${check.outputPath ?? `(unavailable${check.outputError ? `: ${check.outputError}` : ''})`}`@@@ -2639,7 -2629,8 +2641,8 @@@ function workCommands(io, args)throw new Refused('CHECK_CONFIRM', `the check set by ${authorName} was not run: ${check}; run pullboard check ${item.item_id} --yes after reading the command, or answer yes at the prompt`);}}- const run = await withGateSlot(ctx.info.root, (lease) => runProfiledShell(ctx.info.root, check, { waitMs: lease.waitMs, artifactPrefix: `pullboard-check-${item.item_id}`, persistLog: true, gateLease: lease }), { browser: true, agent: caller, item: String(item.item_id), kind: 'check', itemCheck: true, onWait: queuedItemLease(ctx, item, caller, 'build') });+ const browser = await checkNeedsBrowser(ctx.info.root, check, { onFallback: browserAdmissionReporter(io, values.json) });- const run = await withGateSlot(ctx.info.root, (lease) => runProfiledShell(ctx.info.root, check, { waitMs: lease.waitMs, artifactPrefix: `pullboard-check-${item.item_id}`, persistLog: true, gateLease: lease }), { browser, agent: caller, item: String(item.item_id), kind: 'check', itemCheck: true, onWait: gateWaitReporter(io) });++ const run = await withGateSlot(ctx.info.root, (lease) => runProfiledShell(ctx.info.root, check, { waitMs: lease.waitMs, artifactPrefix: `pullboard-check-${item.item_id}`, persistLog: true, gateLease: lease }), { browser, agent: caller, item: String(item.item_id), kind: 'check', itemCheck: true, onWait: queuedItemLease(ctx, item, caller, 'build') });io.result?.({ id: item.item_id, green: run.isGreen, seconds: run.seconds, check, by, report: run.isGreen ? '' : digestOf(run.output) });const timings = timingDigest(run.profile);const compact = timings && !run.profile.files.length@@@ -2830,48 -2820,17 +2833,59 @@@ function resourceAgent(ctx)return ctx.info.isMain ? COORDINATOR : withBoard(ctx, board => store.agentAt(board, ctx.info.root)?.agent_id);}+/** Keep only this queued command's live item lease, using ordinary ordered board moves. */+function queuedItemLease(ctx, initial, agentId, kind) {+ const report = gateWaitReporter(ctx.io);+ // Naming somebody else's check remains read-only; it never extends their build claim.+ if (kind === 'build' && (initial.item_status !== 'claimed' || initial.item_owner !== agentId)) return report;+ const review = kind === 'review';+ if (review && initial.item_review_by !== agentId) return report;+ const field = review ? 'item_review_until' : 'item_lease_until';+ const owner = review ? 'item_review_by' : 'item_owner';+ const status = review ? 'submitted' : 'claimed';+ const leaseMs = review ? ctx.config.reviewLeaseMs : ctx.config.leaseMs;+ const expected = { digest: initial.item_frozen_digest, commit: initial.item_commit };+ let confirmedLeaseUntil = '';+ return async (state) => {+ if (!state.admitted) report(state);+ const now = ctx.clock.now().getTime();+ // Queue polling is frequent; reopen the board only when renewal is due or admission starts.+ if (!state.admitted && Date.parse(confirmedLeaseUntil) - now > leaseMs / 2) {+ return { leaseUntil: confirmedLeaseUntil };+ }+ return await withBoard(ctx, async (board) => {+ const current = store.getItem(board, initial.item_id);+ const expires = Date.parse(current[field]);+ if (current.item_status !== status || current[owner] !== agentId || !Number.isFinite(expires) || expires <= now+ || current.item_frozen_digest !== expected.digest || current.item_commit !== expected.commit) {+ throw new Refused('ITEM_LEASE_LOST', `the queued ${review ? 'review' : 'build'} lease for #${initial.item_id} changed or expired; claim or reserve the item again before retrying`);+ }+ if (state.admitted || expires - now <= leaseMs / 2) {+ const result = await ordered(ctx, board, review ? 'reserveReview' : 'claim', [initial.item_id, {+ agentId, leaseMs,+ ...(review ? { policy: ctx.config.verify.policy, familyPolicy: ctx.config.verify.family }+ : { lane: current.item_lane, freeze: claimFreezer(ctx), head: headCommit(ctx.info.root) }),+ }]);+ confirmedLeaseUntil = review ? result.item_review_until : result.leaseUntil;+ return { leaseUntil: confirmedLeaseUntil };+ }+ confirmedLeaseUntil = current[field];+ return { leaseUntil: confirmedLeaseUntil };+ });+ };+}++ /** Print the file and reason when conservative uncertainty reserves browser capacity.+ * @param {any} io+ * @param {boolean} jsonMode+ * @returns {(decision:{file:string,reason:string})=>void}+ */+ function browserAdmissionReporter(io, jsonMode = false) {+ return ({ file, reason }) => {+ if (!jsonMode) io.stderr.write(`browser admission fallback: ${file}: ${reason}\n`);+ };+ }+/** Build a de-duplicated queue message for a gate waiting on machine capacity. */function gateWaitReporter(io) {let last = '';diff --cc test/resources.test.jsindex 7f6c1851,7d8d81d0..a864a215--- a/test/resources.test.js+++ b/test/resources.test.js@@@ -11,23 -11,14 +11,26 @@@ import { createInterface } from 'node:rimport { after, test } from 'node:test';import { DatabaseSync } from 'node:sqlite';import { listResources, setResourceCapacity, takeResource } from '../src/resources.js';+import * as store from '../src/board.js';+import { createE2eHelpers } from './e2e-helpers.js';+ import { checkNeedsBrowser } from '../src/browser-admission.js';const TEMP = [];const CHILDREN = new Set();const MODULE = pathToFileURL(resolve(import.meta.dirname, '../src/resources.js')).href;const GATE_MODULE = pathToFileURL(resolve(import.meta.dirname, '../src/gate.js')).href;+const LEASE_HELPERS = createE2eHelpers();+const CLOCKED_CLI = `+import { readFileSync } from 'node:fs';+import { main } from ${JSON.stringify(pathToFileURL(resolve(import.meta.dirname, '../src/cli.js')).href)};+/** The private test alone controls the board clock; resource liveness still uses real OS time. */+const clock = { now: () => new Date(Number(readFileSync(process.env.PULLBOARD_FIXTURE_CLOCK, 'utf8'))) };+process.exitCode = await main(process.argv.slice(1), {+ cwd: process.cwd(), clock, stdin: process.stdin, stdout: process.stdout, stderr: process.stderr,+});+`;+ const BIN = resolve(import.meta.dirname, '../bin/pullboard.js');+ const TEST_RUNNER = resolve(import.meta.dirname, '../bin/run-tests.js');const POOL_MODULE_WORKER = `import { takeResource } from ${JSON.stringify(MODULE)};let announced = false;