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(core): harden API provenance checks [A5,A6]
Corey Olsonb3783a247b4c
diff --git a/src/api.js b/src/api.jsindex ec07e4a0..b2d08ccf 100644--- a/src/api.js+++ b/src/api.js@@ -5,7 +5,7 @@ import { dirname, join } from 'node:path';import { fileURLToPath } from 'node:url';import * as store from './board.js';import { COORDINATOR, loadConfig } from './config.js';-import { repoInfo } from './git.js';+import { repoInfo, tryGit } from './git.js';import { refusalDocument } from './json.js';import { laneNames } from './lanes.js';import { listApiProjects } from './projects.js';@@ -17,6 +17,11 @@ const ADDRESS = '127.0.0.1';const VERSION = 1;const CODE_ROOT = dirname(dirname(fileURLToPath(import.meta.url)));+/** Whether this API module came from a Git main checkout, rather than a linked worktree. */+function codeIsFromMain() {+ return tryGit(CODE_ROOT, ['rev-parse', '--show-toplevel']).status === 0 && repoInfo(CODE_ROOT).isMain;+}+/** Read a registered board and release its SQLite connection on every path.** @param {string} root@@ -26,7 +31,7 @@ const CODE_ROOT = dirname(dirname(fileURLToPath(import.meta.url)));function withBoard(root, read, isMain) {const info = repoInfo(root);loadConfig(info.root);- const board = store.openBoard(join(info.commonDir, 'pullboard', 'board.sqlite'), undefined, { isMain: repoInfo(CODE_ROOT).isMain && isMain !== false });+ const board = store.openBoard(join(info.commonDir, 'pullboard', 'board.sqlite'), undefined, { isMain: codeIsFromMain() && isMain !== false });try { return read(board, info); } finally { store.closeBoard(board); }}@@ -175,7 +180,7 @@ function createRequest(root, body, isMain) {export function createLocalApiHandler({ secret, getPort, runCommand, projects = listApiProjects, isMain } = {}) {if (typeof getPort !== 'function') throw new TypeError('createLocalApiHandler needs a bound-port getter');if (typeof runCommand !== 'function') throw new TypeError('createLocalApiHandler needs the actual CLI entry point as runCommand');- const codeIsMain = repoInfo(CODE_ROOT).isMain && isMain !== false;+ const codeIsMain = codeIsFromMain() && isMain !== false;const key = Buffer.from(secret);return createApiHandler({authenticate: (req) => {diff --git a/src/cli.js b/src/cli.jsindex a56e40ac..e1b46cbe 100644--- a/src/cli.js+++ b/src/cli.js@@ -349,8 +349,8 @@ function sayBrief(io, brief) {*/function context(io) {const info = repoInfo(io.cwd);- const code = repoInfo(CODE_ROOT);- const allowSchemaUpgrade = code.isMain;+ const codeIsInGit = tryGit(CODE_ROOT, ['rev-parse', '--show-toplevel']).status === 0;+ const allowSchemaUpgrade = codeIsInGit && repoInfo(CODE_ROOT).isMain;const config = configHere(info);const file = join(info.commonDir, 'pullboard', 'board.sqlite');return { info, config, file, allowSchemaUpgrade, doctrine: loadDoctrine(info.root, config), io, clock: io.clock ?? store.systemClock };