Skip to content

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.

chore(core): merge main for Git-fact refresh [C7]

Corey Olson6183dcf98fc2
diff --cc src/cli.js
index 1e459227,9e449ee5..e10d60e2
--- a/src/cli.js
+++ b/src/cli.js
@@@ -11,10 -11,11 +11,11 @@@ import { parseArgs } from 'node:util'
import * as store from './board.js';
import { CONFIG_FILE, COORDINATOR, loadConfig } from './config.js';
import { doctrineHistory, loadDoctrine } from './doctrine.js';
- import { requirePersonChannel } from './person.js';
+ import { agentSessionDigest, requirePersonChannel } from './person.js';
+ import { bindLocalSession } from './agent-session.js';
import { decisionProjection, planRowApply, prepareRowDecisions, restoreRowApply, writeRowApply } from './row-decisions.js';
import { digestOf, gateReport, runGate, runShell, withGateSlot } from './gate.js';
- import { bareWorktreeFinding, contains, differFromHead, git, headCommit, headTree, invalidateGitFacts, isClean, mainCheckout, repoInfo, resolveCommit, tryGit, untracked, withGitFacts } from './git.js';
-import { bareWorktreeFinding, contains, differFromHead, git, gitChildEnv, headCommit, headTree, isClean, mainCheckout, repoInfo, resolveCommit, tryGit, untracked } from './git.js';
++import { bareWorktreeFinding, contains, differFromHead, git, gitChildEnv, headCommit, headTree, invalidateGitFacts, isClean, mainCheckout, repoInfo, resolveCommit, tryGit, untracked, withGitFacts } from './git.js';
import {
FIX_NOTE,
applyFixers,
@@@ -2442,44 -2581,58 +2583,64 @@@ function rememberTrunk(io)
/** Run one command and emit its single versioned JSON result when requested (A1). */
export async function main(argv, streams) {
+ return withGitFacts(() => runMain(argv, streams));
+}
+
- /** Parse, synchronize and execute one command inside its isolated Git-fact cache. */
++/** Parse and execute one CLI command, binding its checkout session and Git-fact scope. */
+async function runMain(argv, streams) {
const io = commandOutput(argv, streams);
let sync = true;
+ let needsRepo = true;
+ let parsed;
+ let checkoutSession;
try {
- const parsed = parseArgs({ args: argv, options: OPTIONS, allowPositionals: true });
+ parsed = parseArgs({ args: argv, options: OPTIONS, allowPositionals: true });
const command = parsed.positionals[0];
io.relayCommand = { cliOperation: command === 'done' ? 'submit' : command, cwd: resolve(io.cwd),
positionals: parsed.positionals.slice(1),
values: Object.fromEntries(Object.keys(parsed.values).filter(key => key !== 'json').sort().map(key => [key, parsed.values[key]])) };
sync = Boolean(command) && !parsed.values.help && !parsed.values.version && !['help', 'version', 'hook', 'init', 'relay', 'tour'].includes(command);
- } catch { sync = false; }
+ needsRepo = !(parsed.values.help || parsed.values.version || command === 'help' || command === 'version');
+ } catch { sync = false; needsRepo = false; }
- /** A network refusal preserves offline reads; linked mutation dispatch requires an acknowledgement. */
- const retry = async () => {
- try { await syncRelay(io.cwd, io); }
- catch (error) {
+ if (parsed) {
+ try {
+ checkoutSession = await bindCheckoutSession(io, parsed.positionals, parsed.values);
+ if (checkoutSession?.lease) CHECKOUT_LEASES.set(io, checkoutSession.lease);
- }
- catch (error) {
++ } catch (error) {
if (!(error instanceof Refused)) throw error;
- if (!['NOT_A_REPO', 'NO_REPO', 'NO_CONFIG', 'CORE_BARE'].includes(error.code)) io.err(`pullboard: ${error.message}`);
+ io.refusal(error);
+ io.err(`pullboard: ${error.message}`);
+ io.flush(1);
+ return 1;
}
- };
- if (needsRepo) rememberTrunk(io);
- if (sync) {
- await retry();
- try { await executePersonRequests(io.cwd, io, main); }
- catch (error) {
- if (!(error instanceof Refused)) throw error;
- if (!['NOT_A_REPO', 'NO_REPO', 'NO_CONFIG', 'CORE_BARE'].includes(error.code)) io.err('pullboard: ' + error.message);
+ }
+ try {
+ /** A network refusal preserves offline reads; linked mutation dispatch requires an acknowledgement. */
+ const retry = async () => {
+ try { await syncRelay(io.cwd, io); }
+ catch (error) {
+ if (!(error instanceof Refused)) throw error;
+ if (!['NOT_A_REPO', 'NO_REPO', 'NO_CONFIG', 'CORE_BARE'].includes(error.code)) io.err(`pullboard: ${error.message}`);
+ }
+ };
- rememberTrunk(io);
++ if (needsRepo) rememberTrunk(io);
+ if (sync) {
+ await retry();
+ try { await executePersonRequests(io.cwd, io, main); }
+ catch (error) {
+ if (!(error instanceof Refused)) throw error;
- if (!['NOT_A_REPO', 'NO_REPO', 'NO_CONFIG', 'CORE_BARE'].includes(error.code)) io.err('pullboard: ' + error.message);
++ if (!['NOT_A_REPO', 'NO_REPO', 'NO_CONFIG', 'CORE_BARE'].includes(error.code)) io.err(`pullboard: ${error.message}`);
+ }
}
+ const code = await runCommand(argv, io);
+ if (code === 0) await checkoutSession?.finish?.();
+ if (sync && code === 0) await retry();
+ io.flush(code);
+ return code;
+ } finally {
+ CHECKOUT_LEASES.delete(io);
+ checkoutSession?.lease?.release();
}
- const code = await runCommand(argv, io);
- if (sync && code === 0) await retry();
- io.flush(code);
- return code;
}
/** Result-producing command names, including aliases, for API contract coverage (A1). */
diff --cc src/hooks.js
index 415a46a3,bb635557..ff464a06
--- a/src/hooks.js
+++ b/src/hooks.js
@@@ -4,9 -4,9 +4,9 @@@
* Each check returns its problems; an empty list lets git go on.
*/
import { spawnSync } from 'node:child_process';
- import { chmodSync, existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
+ import { chmodSync, existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from 'node:fs';
import { join, resolve } from 'node:path';
-import { git, gitChildEnv, gitPath, mainCheckout, refuseGrafts, tryGit } from './git.js';
+import { git, gitChildEnv, gitPath, gitConfig, invalidateGitFacts, mainCheckout, refuseGrafts, tryGit } from './git.js';
import { CONFIG_FILE, configFromSource, DOCTRINE_FILE, LEGACY_DOCTRINE_FILE } from './config.js';
import { Refused } from './refused.js';
import { outOfLane } from './lanes.js';
@@@ -454,9 -485,11 +486,11 @@@ export function installHooks(root, onWr
onWrite(`${HOOKS_DIR}/${hook}`);
notes.push(`wrote ${HOOKS_DIR}/${hook}`);
}
- const current = tryGit(root, ['config', '--get', 'core.hooksPath']).stdout;
+ const current = gitConfig(root, 'core.hooksPath').stdout;
if (current && current !== HOOKS_DIR) {
notes.push(`core.hooksPath is ${current}; left as is. Call pullboard hook <name> from those hooks`);
+ } else if (current === HOOKS_DIR) {
+ notes.push(`kept core.hooksPath at ${HOOKS_DIR}`);
} else {
git(root, ['config', 'core.hooksPath', HOOKS_DIR]);
notes.push(`set core.hooksPath to ${HOOKS_DIR}`);
diff --cc src/trusted-policy.js
index 99f72cd3,cfa862a6..90f1ae3b
--- a/src/trusted-policy.js
+++ b/src/trusted-policy.js
@@@ -1,12 -1,15 +1,15 @@@
/** Coordinator policy and immutable submission checks cannot come from a builder's candidate [V4,V16,L3,M3]. */
+ import { randomUUID } from 'node:crypto';
import { spawnSync } from 'node:child_process';
import { digestOf } from './gate.js';
- import { existsSync, mkdtempSync, mkdirSync, readFileSync, rmSync } from 'node:fs';
+ import { closeSync, existsSync, mkdtempSync, mkdirSync, openSync, readFileSync, readSync, rmSync, writeSync } from 'node:fs';
import { tmpdir } from 'node:os';
import { join } from 'node:path';
+ import { StringDecoder } from 'node:string_decoder';
import { fileURLToPath } from 'node:url';
import { configFromSource } from './config.js';
-import { cleanGitEnvironment, mainCheckout, refuseGrafts } from './git.js';
+import { cleanGitEnvironment, gitConfig, invalidateGitFacts, mainCheckout, refuseGrafts } from './git.js';
+ import { secretsIn } from './hooks.js';
import { outOfLane } from './lanes.js';
import { Refused } from './refused.js';