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.

fix(lanes): check committed policy and automatic merges [L1,L3]

Corey Olson092f10fc3ccf
diff --git a/docs/api.md b/docs/api.md
index d003ce8f..8e223f17 100644
--- a/docs/api.md
+++ b/docs/api.md
@@ -81,10 +81,13 @@ When `add` or `edit` supplies a new nonempty check, Pullboard measures it once i
| `spec decline` | `version:number`, `decisions:array` |
| `spec apply` | `version:number`, `applied:array`, `files:array` |
| `hook pre-commit` | `version:number`, `messages:array` |
+| `hook pre-merge-commit` | `version:number`, `messages:array` |
| `hook commit-msg` | `version:number`, `messages:array` |
| `hook pre-push` | `version:number`, `messages:array` |
<!-- api-command-shapes:end -->
+`hook pre-merge-commit` runs the same staged checks as `hook pre-commit` before Git creates an automatic merge commit. `init` and `hooks` install it; `doctor` names it when absent at Git's effective hook path. Lane ownership comes from `HEAD:pullboard.json`, so an unstaged configuration edit cannot grant a lane new folders. Lane-sensitive checks refuse a repository with `info/grafts` in its Git common directory because grafts alter ancestry even when replacement objects are disabled.
+
`join` and `worktree` accept an optional free-text `--family` declaration. Rejoining the same worktree preserves its agent id; a supplied family updates the declaration, while omitting `--family` preserves it. `resume` includes it as `me.family`; `show` includes `item_builder_family` and each verdict's `verdict_verifier_family`. These recorded fields are `null` when the agent did not declare a family, and later declarations do not rewrite prior submissions or verdicts.
`status.reviewQueue` contains `pending`, `reviewing` (distinct agents with live review leases), `reserved`, `oldestSubmittedAt` and `ageMs`. Age starts at each outstanding item's latest submit event; reserving or renewing its review does not reset it. An empty queue has `oldestSubmittedAt: null` and `ageMs: 0`.
diff --git a/src/cli.js b/src/cli.js
index ac2e81c4..8e69e599 100644
--- a/src/cli.js
+++ b/src/cli.js
@@ -166,7 +166,7 @@ Role guides
Gate and hooks
pullboard gate run the configured gate
- pullboard hook pre-commit|commit-msg|pre-push git runs these
+ pullboard hook pre-commit|pre-merge-commit|commit-msg|pre-push git runs these
${lifecycleHelp()}
@@ -179,7 +179,7 @@ const HELP_NAMES = [
'check', 'claim', 'release', 'submit', 'done', 'verify', 'shout', 'answer', 'pass', 'decisions', 'inbox', 'export', 'import',
'sweep', 'merged', 'withdraw', 'refreeze', 'hold', 'ledger', 'log', 'spec', 'spec check', 'spec view',
'spec show', 'spec unmet', 'spec signoff', 'spec signers', 'spec signers add', 'forget', 'prompt', 'gate', 'hook',
- 'hook pre-commit', 'hook commit-msg', 'hook pre-push', 'view export', 'version', 'lifecycle', 'help',
+ 'hook pre-commit', 'hook pre-merge-commit', 'hook commit-msg', 'hook pre-push', 'view export', 'version', 'lifecycle', 'help',
'roadmap', 'milestone',
];
@@ -223,8 +223,9 @@ const HELP_ALIASES = {
'spec signoff': { usage: 'pullboard spec signoff <ids> [--by <principal>] [--note "..."] [--note-file <file>]', source: 'spec show', onlyFlags: ['--by', '--note', '--note-file'], extraFlags: ['--note-file <file>'] },
'spec signers': { usage: 'pullboard spec signers add [--key <path>] [--by <principal>]', source: 'spec signers add' },
'spec signers add': { usage: 'pullboard spec signers add [--key <path>] [--by <principal>]', source: 'spec signers add' },
- hook: { usage: 'pullboard hook pre-commit|commit-msg|pre-push', source: 'hook' },
+ hook: { usage: 'pullboard hook pre-commit|pre-merge-commit|commit-msg|pre-push', source: 'hook' },
'hook pre-commit': { usage: 'pullboard hook pre-commit', source: 'hook' },
+ 'hook pre-merge-commit': { usage: 'pullboard hook pre-merge-commit', source: 'hook' },
'hook commit-msg': { usage: 'pullboard hook commit-msg <file>', source: 'hook' },
'hook pre-push': { usage: 'pullboard hook pre-push', source: 'hook' },
};
@@ -2177,7 +2178,7 @@ async function hookCommand(io, { first, second }) {
throw error;
}
let problems = [];
- if (first === 'pre-commit') {
+ if (first === 'pre-commit' || first === 'pre-merge-commit') {
applyFixers(info.root, ctx.config.fix).forEach((note) => io.err(`pullboard pre-commit: ${note}`));
const agent = info.isMain ? null : withBoard(ctx, (board) => store.agentAt(board, info.root));
problems = preCommitProblems({ root: info.root, isMain: info.isMain, config: ctx.config, agent, boardFile: ctx.file });
@@ -2192,7 +2193,7 @@ async function hookCommand(io, { first, second }) {
if (!gate.isGreen) problems = [`the gate is red; fix it before pushing. ${gateReport(gate)}`];
}
} else {
- throw new Refused('USAGE', 'pullboard hook pre-commit | commit-msg <file> | pre-push');
+ throw new Refused('USAGE', 'pullboard hook pre-commit | pre-merge-commit | commit-msg <file> | pre-push');
}
if (!problems.length) return 0;
io.err(`pullboard ${first}: blocked\n${problems.map((problem) => ` - ${problem}`).join('\n')}\n${FIX_NOTE}`);
diff --git a/src/doctor.js b/src/doctor.js
index de5c3959..69bba00e 100644
--- a/src/doctor.js
+++ b/src/doctor.js
@@ -7,6 +7,7 @@ import { BLANKS, STATES, storeTriggers } from './machine.js';
import { readEventLogVersion, SCHEMA_VERSION } from './board.js';
import { staleFrozenItems, staleItemFinding } from './approved-rows.js';
import { loadSpec } from './spec.js';
+import { preMergeHookProblems } from './hooks.js';
const blankCharacters = new Set(BLANKS.map((point) => String.fromCodePoint(point)));
/**
@@ -32,6 +33,7 @@ export function doctorProblems(file, root, tryGit, config) {
}
const layout = layoutProblems(db);
return [
+ ...preMergeHookProblems(root),
...triggerProblems(db),
...layout.problems,
...(layout.itemFields ? itemProblems(db) : []),
diff --git a/src/git.js b/src/git.js
index 28e8cfc3..00ebf3aa 100644
--- a/src/git.js
+++ b/src/git.js
@@ -250,3 +250,9 @@ export function contains(root, ancestor, descendant) {
export function gitPath(root, name) {
return resolve(root, git(root, ['rev-parse', '--git-path', name]));
}
+
+/** Refuse lane-sensitive history checks while grafts can rewrite commit ancestry despite replacement guards [L3]. */
+export function refuseGrafts(root) {
+ const file = gitPath(root, 'info/grafts');
+ if (existsSync(file)) throw new Refused('GIT_GRAFTS', `lane checks cannot trust history while ${file} exists; ask the coordinator to remove the graft file before retrying`);
+}
diff --git a/src/hooks.js b/src/hooks.js
index 3fab8157..3547d695 100644
--- a/src/hooks.js
+++ b/src/hooks.js
@@ -6,13 +6,14 @@
import { spawnSync } from 'node:child_process';
import { chmodSync, existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
import { join } from 'node:path';
-import { git, gitChildEnv, mainCheckout, tryGit } from './git.js';
+import { git, gitChildEnv, gitPath, mainCheckout, refuseGrafts, tryGit } from './git.js';
+import { CONFIG_FILE, configFromSource } from './config.js';
import { Refused } from './refused.js';
import { outOfLane } from './lanes.js';
import { citedIds, deletedIds, idProblems } from './spec.js';
import { approvedRowProblems } from './approved-rows.js';
-export const HOOKS = ['pre-commit', 'commit-msg', 'pre-push'];
+export const HOOKS = ['pre-commit', 'pre-merge-commit', 'commit-msg', 'pre-push'];
export const HOOKS_DIR = '.githooks';
export const HOOK_MARK = 'Installed by pullboard';
export const FIX_NOTE = 'Fix what each line names. Never work around a refusal with filler text.';
@@ -202,6 +203,7 @@ export function blockedPaths(paths, protect) {
* @returns {string[]}
*/
export function preCommitProblems({ root, isMain, config, agent, boardFile }) {
+ if (!isMain) refuseGrafts(root);
const { touched, written } = stagedPaths(root);
const problems = blockedPaths(written, config.protect).map(
(path) => `${path} is a blocked file (env or secrets); keep it out of git`,
@@ -225,13 +227,26 @@ export function preCommitProblems({ root, isMain, config, agent, boardFile }) {
}
const mergeBase = mainMergeBase(root);
const ownershipTouched = mergeBase ? stagedPaths(root, mergeBase).touched : touched;
- const foreign = outOfLane(config, agent.agent_lane, ownershipTouched);
+ const foreign = outOfLane(committedLaneConfig(root), agent.agent_lane, ownershipTouched);
problems.push(
...foreign.map((path) => `outside the ${agent.agent_lane} lane: ${path}; shout its owner instead`),
);
return problems;
}
+/** Read lane ownership from the committed checkout, so unstaged settings cannot grant new folders [L1,L3]. */
+function committedLaneConfig(root) {
+ const source = tryGit(root, ['show', 'HEAD:' + CONFIG_FILE]);
+ if (source.status !== 0) throw new Refused('NO_POLICY', 'lane checks need pullboard.json committed at HEAD; restore the committed policy or ask the coordinator to initialize it');
+ return configFromSource(source.stdout);
+}
+
+/** Report a missing merge check at Git's effective hook path without changing files [L3,A6]. */
+export function preMergeHookProblems(root) {
+ const file = gitPath(root, 'hooks/pre-merge-commit');
+ return existsSync(file) ? [] : [{ code: 'HOOK_MISSING', message: `merge hook ${file} is missing`, next: 'run pullboard hooks to install pre-merge-commit, then commit the hook files' }];
+}
+
/**
* The commit being merged, only when it is already part of the primary checkout's history.
*
diff --git a/src/json.js b/src/json.js
index a61589e7..042fec19 100644
--- a/src/json.js
+++ b/src/json.js
@@ -75,6 +75,7 @@ export const JSON_SHAPES = {
'spec decline': shape({ decisions: 'array' }),
'spec apply': shape({ applied: 'array', files: 'array' }),
'hook pre-commit': shape({ messages: 'array' }),
+ 'hook pre-merge-commit': shape({ messages: 'array' }),
'hook commit-msg': shape({ messages: 'array' }),
'hook pre-push': shape({ messages: 'array' }),
},
diff --git a/src/trusted-policy.js b/src/trusted-policy.js
index 6023dd0f..c97df1f5 100644
--- a/src/trusted-policy.js
+++ b/src/trusted-policy.js
@@ -4,7 +4,7 @@ import { mkdtempSync, mkdirSync, rmSync } from 'node:fs';
import { tmpdir } from 'node:os';
import { join } from 'node:path';
import { configFromSource } from './config.js';
-import { cleanGitEnvironment, mainCheckout } from './git.js';
+import { cleanGitEnvironment, mainCheckout, refuseGrafts } from './git.js';
import { outOfLane } from './lanes.js';
import { Refused } from './refused.js';
@@ -45,6 +45,7 @@ function pathObject(root, commit, path) {
/** Enforce the complete claim-base diff; accepted-main merges may carry only identical foreign objects. */
export function submissionPaths(root, item, commit, { config, mainCommit, dependencies = [] } = {}) {
+ refuseGrafts(root);
const policy = itemPolicy(root, item);
const base = item.item_claim_head;
if (!/^[0-9a-f]{40,64}$/.test(base ?? '')) throw new Refused('NO_POLICY', 'this item has no claim base; ask the coordinator to refreeze it and claim again');
diff --git a/test/api.test.js b/test/api.test.js
index a1a9cb49..9d810424 100644
--- a/test/api.test.js
+++ b/test/api.test.js
@@ -272,6 +272,7 @@ test('[A1] command results match the catalog across roots and subcommands', () =
const messageFile = join(box.dir, 'commit-message.txt');
writeFileSync(messageFile, 'chore: valid fixture\n');
json(box, repo, 'hook', ['pre-commit'], 'pre-commit');
+ json(box, repo, 'hook', ['pre-merge-commit'], 'pre-merge-commit');
json(box, repo, 'hook', ['commit-msg', messageFile], 'commit-msg');
json(box, repo, 'hook', ['pre-push'], 'pre-push');
diff --git a/test/doctor.test.js b/test/doctor.test.js
index b02cc321..13500d9a 100644
--- a/test/doctor.test.js
+++ b/test/doctor.test.js
@@ -1,12 +1,13 @@
/** Integrity checks use throwaway git repositories and real board databases (A6). */
import assert from 'node:assert/strict';
import { execFileSync, spawnSync } from 'node:child_process';
-import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
+import { chmodSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
import { tmpdir } from 'node:os';
import { join, resolve } from 'node:path';
import { after, test } from 'node:test';
import { DatabaseSync } from 'node:sqlite';
import { SCHEMA_VERSION } from '../src/board.js';
+import { hookScript } from '../src/hooks.js';
const BIN = resolve(import.meta.dirname, '../bin/pullboard.js');
const sandboxes = [];
@@ -37,6 +38,10 @@ function boardBox({ initialize = true, repoName = 'repo' } = {}) {
const git = (...args) => execFileSync('git', args, { cwd: root, env, encoding: 'utf8' }).trim();
const run = (...args) => spawnSync(process.execPath, [BIN, ...args], { cwd: root, env, encoding: 'utf8' });
git('init', '-q', '-b', 'main');
+ const mergeHook = join(root, '.git', 'hooks', 'pre-merge-commit');
+ mkdirSync(join(root, '.git', 'hooks'), { recursive: true });
+ writeFileSync(mergeHook, hookScript('pre-merge-commit'));
+ chmodSync(mergeHook, 0o755);
writeFileSync(join(root, 'pullboard.json'), JSON.stringify({ gate: 'true', lanes: {} }, null, 2));
git('add', '-A');
git('commit', '-q', '-m', 'chore: setup');
diff --git a/test/lane-bypass.test.js b/test/lane-bypass.test.js
new file mode 100644
index 00000000..bd020305
--- /dev/null
+++ b/test/lane-bypass.test.js
@@ -0,0 +1,179 @@
+/** Reproduce lane-policy bypasses with private Git repositories and their installed hooks [L1,L3]. */
+import assert from 'node:assert/strict';
+import { execFileSync, spawnSync } from 'node:child_process';
+import { chmodSync, existsSync, mkdirSync, mkdtempSync, readFileSync, realpathSync, rmSync, writeFileSync } from 'node:fs';
+import { tmpdir } from 'node:os';
+import { join, resolve } from 'node:path';
+import { after, test } from 'node:test';
+import { submissionPaths } from '../src/trusted-policy.js';
+
+const BIN = resolve(import.meta.dirname, '../bin/pullboard.js');
+const SANDBOXES = [];
+const SPEC = '# Lane bypass fixture\n\n## Goals\n- G1 [approved, must] The web lane owns its page. | gate: true\n- G2 [approved, must] The API lane owns its route. | gate: true\n';
+
+/** Remove all temporary repositories once the test file finishes. */
+function cleanupSandboxes() {
+ for (const directory of SANDBOXES) rmSync(directory, { recursive: true, force: true });
+}
+
+after(cleanupSandboxes);
+
+/** Quote a path for the shell shim installed into each private repository's PATH. */
+function shellWord(value) {
+ return `'${String(value).replaceAll("'", "'\\''")}'`;
+}
+
+/** Create private Git settings, HOME folders and a PATH shim that runs this checkout's source CLI. */
+function sandbox() {
+ const dir = realpathSync(mkdtempSync(join(tmpdir(), 'pullboard-lane-bypass-')));
+ SANDBOXES.push(dir);
+ const bin = join(dir, 'bin');
+ mkdirSync(bin);
+ writeFileSync(join(bin, 'pullboard'), `#!/bin/sh\nexec ${shellWord(process.execPath)} ${shellWord(BIN)} "$@"\n`);
+ chmodSync(join(bin, 'pullboard'), 0o755);
+ const env = { ...process.env };
+ for (const key of Object.keys(env)) if (key.startsWith('GIT_')) delete env[key];
+ Object.assign(env, {
+ HOME: join(dir, 'home'),
+ PULLBOARD_HOME: join(dir, 'pullboard-home'),
+ PULLBOARD_MACHINE_HOME: join(dir, 'machine-home'),
+ GIT_CONFIG_GLOBAL: '/dev/null',
+ GIT_CONFIG_NOSYSTEM: '1',
+ GIT_AUTHOR_NAME: 'Lane bypass fixture',
+ GIT_AUTHOR_EMAIL: '[email protected]',
+ GIT_COMMITTER_NAME: 'Lane bypass fixture',
+ GIT_COMMITTER_EMAIL: '[email protected]',
+ PATH: `${bin}:${process.env.PATH}`,
+ });
+ mkdirSync(env.HOME);
+ /** Run Git in a fixture repo and return trimmed output. */
+ function git(cwd, ...args) {
+ return execFileSync('git', args, { cwd, env, encoding: 'utf8', stdio: 'pipe' }).trim();
+ }
+ /** Run Git while preserving expected hook failures for assertions. */
+ function tryGit(cwd, ...args) {
+ return spawnSync('git', args, { cwd, env, encoding: 'utf8', timeout: 30_000 });
+ }
+ /** Run this checkout's CLI in the selected private working tree. */
+ function run(cwd, ...args) {
+ const result = spawnSync(process.execPath, [BIN, ...args], { cwd, env, encoding: 'utf8', timeout: 30_000 });
+ return { code: result.status, out: result.stdout, err: result.stderr };
+ }
+ return { dir, env, git, tryGit, run };
+}
+
+/** Initialize Pullboard and commit the two-lane policy on a private primary branch. */
+function project() {
+ const box = sandbox();
+ const repo = join(box.dir, 'repo');
+ mkdirSync(repo);
+ box.git(repo, 'init', '-q', '-b', 'main');
+ assert.equal(box.run(repo, 'init').code, 0);
+ const config = JSON.parse(readFileSync(join(repo, 'pullboard.json'), 'utf8'));
+ config.gate = 'true';
+ config.lanes = { web: { owns: ['web/'], specs: ['G1'] }, api: { owns: ['api/'], specs: ['G2'] } };
+ writeFileSync(join(repo, 'pullboard.json'), JSON.stringify(config, null, 2) + '\n');
+ writeFileSync(join(repo, 'SPEC.md'), SPEC);
+ mkdirSync(join(repo, 'web'));
+ mkdirSync(join(repo, 'api'));
+ writeFileSync(join(repo, 'web', 'page.txt'), 'web baseline\n');
+ writeFileSync(join(repo, 'api', 'route.txt'), 'api baseline\n');
+ box.git(repo, 'add', '-A');
+ box.git(repo, 'commit', '-q', '-m', 'chore: set up two lane fixture');
+ return { ...box, repo };
+}
+
+/** Make a real joined worktree and branch for a lane. */
+function laneWorktree(box, lane, branch) {
+ const path = join(box.dir, `${lane}-worktree`);
+ box.git(box.repo, 'worktree', 'add', '-q', path, '-b', branch);
+ const joined = box.run(path, 'join', lane);
+ assert.equal(joined.code, 0, joined.err);
+ return path;
+}
+
+test('[L1,L3] an unstaged config edit cannot widen the lane for a staged foreign path', () => {
+ const box = project();
+ const web = laneWorktree(box, 'web', 'web/one');
+ const configPath = join(web, 'pullboard.json');
+ const config = JSON.parse(readFileSync(configPath, 'utf8'));
+ config.lanes.web.owns.push('api/');
+ writeFileSync(configPath, JSON.stringify(config, null, 2) + '\n');
+ writeFileSync(join(web, 'api', 'bypass.txt'), 'foreign lane file\n');
+ box.git(web, 'add', '--', 'api/bypass.txt');
+
+ const refused = box.tryGit(web, 'commit', '-q', '-m', 'feat(web): cross lane policy [G1]');
+ assert.notEqual(refused.status, 0, `${refused.stdout}${refused.stderr}`);
+ assert.match(refused.stderr, /outside the web lane: api\/bypass\.txt/);
+ const committedForeign = box.tryGit(web, 'show', 'HEAD:api/bypass.txt');
+ assert.notEqual(committedForeign.status, 0, 'the foreign path never entered HEAD');
+ assert.ok(box.git(web, 'status', '--short').includes(' M pullboard.json'), 'the attempted policy widening remains unstaged');
+});
+
+test('[L3] a plain auto-committing merge of another lane is refused by the installed pre-merge hook', () => {
+ const box = project();
+ const web = laneWorktree(box, 'web', 'web/one');
+ const api = laneWorktree(box, 'api', 'api/one');
+ writeFileSync(join(web, 'web', 'work.txt'), 'web branch change\n');
+ box.git(web, 'add', '--', 'web/work.txt');
+ box.git(web, 'commit', '-q', '-m', 'feat(web): add lane work [G1]');
+ writeFileSync(join(api, 'api', 'foreign-route.txt'), 'api branch change\n');
+ box.git(api, 'add', '--', 'api/foreign-route.txt');
+ box.git(api, 'commit', '-q', '-m', 'feat(api): add lane route [G2]');
+
+ const webHead = box.git(web, 'rev-parse', 'HEAD');
+ const merged = box.tryGit(web, 'merge', 'api/one');
+ assert.notEqual(merged.status, 0, `${merged.stdout}${merged.stderr}`);
+ assert.match(merged.stderr + merged.stdout, /api\/foreign-route\.txt/);
+ assert.match(merged.stderr + merged.stdout, /pre-merge-commit|outside the web lane/i);
+ assert.equal(box.git(web, 'rev-parse', 'HEAD'), webHead, 'Git did not create the rejected merge commit');
+});
+
+test('[L3] init installs the pre-merge hook and doctor names it when missing', () => {
+ const box = project();
+ const hook = join(box.repo, '.githooks', 'pre-merge-commit');
+ assert.ok(existsSync(hook), 'init installed the merge hook');
+ const source = readFileSync(hook, 'utf8');
+ assert.match(source, /hook pre-merge-commit/);
+ assert.equal(box.run(box.repo, 'doctor', '--json').code, 0, 'the installed hook leaves a clean board');
+ rmSync(hook);
+
+ const doctor = box.run(box.repo, 'doctor', '--json');
+ assert.equal(doctor.code, 1, `${doctor.out}${doctor.err}`);
+ const problems = JSON.parse(doctor.out).problems;
+ assert.ok(problems.some(({ message, next }) => `${message} ${next}`.includes('.githooks/pre-merge-commit')),
+ `doctor names the missing hook: ${doctor.out}`);
+ assert.ok(!existsSync(hook), 'doctor does not repair the missing hook while diagnosing it');
+ box.git(box.repo, 'config', '--unset', 'core.hooksPath');
+ const defaultHooks = box.run(box.repo, 'doctor', '--json');
+ assert.equal(defaultHooks.code, 1, 'a missing hook is also reported at the default Git hook path');
+ assert.ok(JSON.parse(defaultHooks.out).problems.some(({ message }) => message.includes('.git/hooks/pre-merge-commit')));
+});
+
+test('[L3] a linked worktree refuses lane checks when the common Git directory has grafts', () => {
+ const box = project();
+ box.git(box.repo, 'commit', '--allow-empty', '-q', '-m', 'chore: create a graft parent');
+ const web = laneWorktree(box, 'web', 'web/one');
+ const added = box.run(box.repo, 'add', 'web', 'Graft proof', '--specs', 'G1', '--criterion', 'history remains genuine', '--json');
+ assert.equal(added.code, 0, added.err);
+ const id = JSON.parse(added.out).item.item_id;
+ assert.equal(box.run(web, 'claim', String(id)).code, 0);
+ const item = JSON.parse(box.run(web, 'show', String(id), '--json').out);
+ const commonDir = resolve(web, box.git(web, 'rev-parse', '--git-common-dir'));
+ const grafts = join(commonDir, 'info', 'grafts');
+ const [head, parent] = box.git(box.repo, 'rev-list', '--parents', '-n', '1', 'HEAD').split(' ');
+ assert.ok(parent, 'fixture has a parent for a valid graft entry');
+ assert.equal(grafts, join(box.repo, '.git', 'info', 'grafts'), 'the linked worktree uses the common Git directory');
+ writeFileSync(grafts, `${head} ${parent}\n`);
+ assert.throws(() => submissionPaths(web, item, head), { code: 'GIT_GRAFTS' }, 'submission lane backstops also refuse grafted history');
+ writeFileSync(join(web, 'web', 'graft-check.txt'), 'owned path\n');
+ box.git(web, 'add', '--', 'web/graft-check.txt');
+
+ const refused = box.tryGit(web, 'commit', '-q', '-m', 'feat(web): check graft state [G1]');
+ assert.notEqual(refused.status, 0, `${refused.stdout}${refused.stderr}`);
+ assert.match(refused.stderr + refused.stdout, /graft/i);
+ assert.match(refused.stderr + refused.stdout, /\.git\/info\/grafts|info\/grafts|grafts/);
+ rmSync(grafts);
+ const restored = box.tryGit(web, 'commit', '-q', '-m', 'feat(web): commit with genuine history [G1]');
+ assert.equal(restored.status, 0, `${restored.stdout}${restored.stderr}`);
+});
diff --git a/test/newcomer.test.js b/test/newcomer.test.js
index 2e3e0522..5abbe41f 100644
--- a/test/newcomer.test.js
+++ b/test/newcomer.test.js
@@ -45,7 +45,7 @@ test('init ends with a working staging line for exactly its own writes [I1,I2]',
'.claude/skills/pullboard-signoff/SKILL.md',
'.claude/skills/pullboard-spec-review/SKILL.md',
'.claude/skills/pullboard-verify/SKILL.md',
- '.githooks/commit-msg', '.githooks/pre-push',
+ '.githooks/commit-msg', '.githooks/pre-merge-commit', '.githooks/pre-push',
'AGENTS.md', 'PRACTICE.md', 'SPEC.md', 'pullboard.json',
]);
assert.equal(readFileSync(join(box.root, '.env.local'), 'utf8'), 'LOCAL=1\n');
@@ -56,7 +56,7 @@ test('init ends with a working staging line for exactly its own writes [I1,I2]',
const secondStage = rerun.stdout.trimEnd().split('\n').at(-1);
assert.match(secondStage, /^git add -f -- /);
assert.equal(spawnSync('sh', ['-c', secondStage], { cwd: box.root, env: box.env }).status, 0);
- assert.deepEqual(box.git('diff', '--cached', '--name-only').split('\n'), ['.githooks/commit-msg', '.githooks/pre-push']);
+ assert.deepEqual(box.git('diff', '--cached', '--name-only').split('\n'), ['.githooks/commit-msg', '.githooks/pre-merge-commit', '.githooks/pre-push']);
});
test('init detects language gates and gives an example in the same ecosystem [I1,I2]', (t) => {