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.

feat(submit): refuse or warn on commits naming this machine [C1]

Corey Olsondf0d0c69995f
diff --git a/src/cli.js b/src/cli.js
index fd7449a1..73214d79 100644
--- a/src/cli.js
+++ b/src/cli.js
@@ -145,6 +145,7 @@ import {
commitMsgProblems,
commitCitationWarnings,
installHooks,
+ machineNameProblems,
preCommitProblems,
prePushProblems,
pushesTrunk,
@@ -2742,6 +2743,7 @@ async function submitHere(ctx, id) {
if (!commit) throw new Refused('NO_COMMIT', 'nothing committed yet');
const trunk = requireTrunkMerge(root, commit);
withBoard(ctx, (board) => refuseUnverifiedStack(root, board, held, commit, trunk));
+ machineNameProblems(root, `${acceptedMain.commit}..${commit}`, { refuse: acceptedMain.config.commits.noHostName === true, say: (line) => ctx.io.say(line) });
// Doctrine counts only fall: accepted main's rules, at this exact commit (D1). No rule, no change.
const doctrine = hasSubmitRules(root, acceptedMain.commit, acceptedMain.config.practice)
? await withGateSlot(root, () => holdDoctrine(root, { mainCommit: acceptedMain.commit, commit, practice: acceptedMain.config.practice, timeoutMs: acceptedMain.config.check?.timeoutMs }),
diff --git a/src/config.js b/src/config.js
index 81779c58..46f60c7e 100644
--- a/src/config.js
+++ b/src/config.js
@@ -63,6 +63,8 @@ export function defaults() {
banned: [],
noEmoji: false,
noCoAuthor: false,
+ // Refuse a submit whose new commits name this machine; false only warns (C1).
+ noHostName: false,
},
protect: {
blocked: ['.env', '.env.*', '*.env', '.envrc'],
@@ -234,6 +236,7 @@ export function configProblems(config) {
if (!isStringList(config.commits.types)) problems.push('"commits.types" is a list of words');
if (!isStringList(config.commits.requireIds)) problems.push('"commits.requireIds" is a list of types');
if (!isStringList(config.commits.banned)) problems.push('"commits.banned" is a list of words');
+ if (typeof config.commits.noHostName !== 'boolean') problems.push('"commits.noHostName" is true or false: whether a submit naming this machine is refused');
if (!isStringList(config.protect.blocked) || !isStringList(config.protect.allowed)) {
problems.push('"protect.blocked" and "protect.allowed" are lists of file patterns');
}
diff --git a/src/hooks.js b/src/hooks.js
index 7f63d77a..dd31b179 100644
--- a/src/hooks.js
+++ b/src/hooks.js
@@ -4,6 +4,7 @@
* Each check returns its problems; an empty list lets git go on.
*/
import { spawnSync } from 'node:child_process';
+import { hostname } from 'node:os';
import {
chmodSync,
existsSync,
@@ -144,6 +145,44 @@ export function commitMsgProblems(raw, { rules, spec, doctrine = null }) {
return problems;
}
+/**
+ * This machine's names as a commit message would show them: the host name and its first label. Names
+ * under three characters are ignored, so a short word cannot refuse an honest message (C1).
+ *
+ * @returns {string[]} Lower-case names.
+ */
+export function machineNames() {
+ const full = hostname().trim().toLowerCase();
+ return [...new Set([full, full.split('.')[0]])].filter((name) => name.length >= 3);
+}
+
+/**
+ * Check the commits a submit adds for this machine's names in their messages (C1). With `refuse`, the
+ * first named commit stops the submit and the next step says how to reword it; without, each named
+ * commit is reported through `say` and the submit goes on. The names are never echoed, so the refusal
+ * cannot leak them into a shout or a board thread.
+ *
+ * @param {string} root - The worktree the commits are in.
+ * @param {string} range - The commits a submit adds, as `<trunk>..<head>`.
+ * @param {{ refuse: boolean, say: (line: string) => void, names?: string[] }} options
+ * @returns {void}
+ */
+export function machineNameProblems(root, range, { refuse, say, names = machineNames() }) {
+ if (!names.length) return;
+ const records = git(root, ['log', '--format=%H%x1f%B%x1e', range]).split('\x1e').filter(Boolean);
+ for (const record of records) {
+ const [sha, message = ''] = record.trim().split('\x1f');
+ const lower = message.toLowerCase();
+ if (!names.some((name) => lower.includes(name))) continue;
+ const short = sha.slice(0, 12);
+ if (refuse) {
+ throw new Refused('HOST_NAME', `commit ${short} names this machine in its message; a submit may not publish that name`,
+ `reword that commit's message without the machine's name, then run pullboard submit again`);
+ }
+ say(`warning: commit ${short} names this machine in its message; reword it before the branch is merged`);
+ }
+}
+
/**
* Colliding bare citations keep their SPEC.md meaning, but tell the author how to name doctrine.
*
diff --git a/src/land.js b/src/land.js
index e5d71fb6..1cb8fd16 100644
--- a/src/land.js
+++ b/src/land.js
@@ -153,7 +153,8 @@ async function mergeGroup(state, items) {
if (checked !== (entry.reviewedCommit ?? entry.commit ?? item.item_commit)) throw new Refused('LAND_ITEM_MOVED', `item #${item.item_id} was re-reviewed; rebuild its landing from the checked commit`);
const stale = verdictProjector(state.root, state.board, { main: batch.base }).state(item);
if (stale) throw staleVerdictRefusal(item, stale);
- const result = tryGit(batch.root, ['merge', '--no-ff', checked, '-m', landingSubject(item)]);
+ // The body is the item trailer alone: the subject carries the title, and no lane branch is named [B3,R3].
+ const result = tryGit(batch.root, ['merge', '--no-ff', checked, '-m', landingSubject(item), '-m', `Pullboard-Item: #${item.item_id}`]);
if (result.status !== 0) {
const files = tryGit(batch.root, ['diff', '--name-only', '--diff-filter=U']).stdout.split('\n').filter(Boolean);
if (!files.length) throw new Refused('LAND_MERGE', `merge of #${item.item_id} failed outside a conflict: ${result.stderr || result.stdout}; inspect ${batch.root} and its hooks before adopting`);
diff --git a/src/next-steps.js b/src/next-steps.js
index fa5403c1..f7538c74 100644
--- a/src/next-steps.js
+++ b/src/next-steps.js
@@ -273,6 +273,7 @@ export const NEXT_STEPS = Object.freeze({
GIT_GRAFTS: 'ask the coordinator to remove the git graft file: pullboard shout coordinator "please remove .git/info/grafts"',
HEAD_NOT_NEW: 'commit the rework, then pullboard submit <id>',
HELD: 'take another item: pullboard next',
+ HOST_NAME: 'reword the named commit\'s message without this machine\'s name (git rebase -i, then reword), then run pullboard submit <id> again',
HUMAN_REQUIRED: 'send it from the paired phone, or run pullboard relay on --all from the person\'s terminal',
IMPORT_FORMAT: 'make an export with pullboard export > board.json, then import that file',
IMPORT_NOT_EMPTY: 'import into a fresh repo whose board is empty: git init <dir> && cd <dir> && pullboard init',
diff --git a/test/land.test.js b/test/land.test.js
index 2610fe98..d1e827a8 100644
--- a/test/land.test.js
+++ b/test/land.test.js
@@ -482,6 +482,7 @@ test('land pushes one exact batch in verdict order and records each first-contai
assert.deepEqual(calls(box).slice(start), [[]], 'one full batch gate; pre-push reads its exact green tree stamp');
const merges = box.git(box.repo, 'rev-list', '--reverse', '--first-parent', `${base}..${result.batch.tip}`).split('\n');
for (const [index, id] of order.entries()) assert.equal(json(box, box.repo, 'show', String(id)).item_merged_commit, merges[index]);
+ for (const [index, id] of order.entries()) assert.equal(box.git(box.repo, 'log', '-1', '--format=%b', merges[index]).trim(), `Pullboard-Item: #${id}`, 'each train merge body is only its item trailer, naming no lane branch');
const receipt = events(box).filter((event) => event.event_kind === 'main-moved');
assert.equal(receipt.length, 1);
assert.equal(JSON.parse(receipt[0].event_detail).sha, result.batch.tip);
diff --git a/test/worktree-start.test.js b/test/worktree-start.test.js
index c21f683e..f0e1117a 100644
--- a/test/worktree-start.test.js
+++ b/test/worktree-start.test.js
@@ -2,10 +2,12 @@
import assert from 'node:assert/strict';
import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
import { basename, dirname, join, resolve } from 'node:path';
+import { hostname } from 'node:os';
import { after, test } from 'node:test';
import { createE2eHelpers } from './e2e-helpers.js';
import { runFixtureChild } from './fixture-child.js';
import { configProblems, defaults } from '../src/config.js';
+import { machineNameProblems } from '../src/hooks.js';
import { installStep } from '../src/worktree.js';
const e2e = createE2eHelpers();
@@ -249,3 +251,32 @@ test('worktree suggests no install for a zero-dependency project [I1,L3]', () =>
assert.deepEqual(installStep(loose), { command: 'npm ci', note: 'its own install from the committed npm-shrinkwrap.json, so its tests run its own code' },
'an npm-shrinkwrap.json in HEAD is a committed lockfile');
});
+
+test('the worktree and branch names Pullboard makes carry no host part [I1,I2]', () => {
+ const box = sandbox();
+ const { web } = project('true', box);
+ box.env.PULLBOARD_MODEL = 'Name Model';
+ const made = box.run(web, 'worktree', 'api', '--json');
+ assert.equal(made.code, 0, made.err || made.out);
+ const result = JSON.parse(made.out);
+ assert.equal(result.branch, 'api/1', 'the branch is <lane>/<n>');
+ const short = hostname().split('.')[0].toLowerCase();
+ for (const name of [result.branch, basename(result.path)]) {
+ assert.ok(!name.toLowerCase().includes(short), `"${name}" carries no host part`);
+ }
+});
+
+test('a submit naming a stand-in host refuses at HOST_NAME, and only warns when the setting is off [C1]', () => {
+ const box = sandbox();
+ const { repo } = project('true', box);
+ const base = box.git(repo, 'rev-parse', 'HEAD');
+ box.git(repo, 'commit', '-q', '--allow-empty', '-m', 'chore: note the stand-in-host branch');
+ const range = `${base}..HEAD`;
+ assert.throws(() => machineNameProblems(repo, range, { refuse: true, say: () => {}, names: ['stand-in-host'] }),
+ (error) => error.code === 'HOST_NAME' && /names this machine/u.test(error.message));
+ const said = [];
+ machineNameProblems(repo, range, { refuse: false, say: (line) => said.push(line), names: ['stand-in-host'] });
+ assert.equal(said.length, 1, 'the setting off warns once per named commit');
+ assert.match(said[0], /^warning: commit [0-9a-f]{12} names this machine/u);
+ machineNameProblems(repo, range, { refuse: true, say: () => {}, names: ['no-such-name-here'] });
+});