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
feat(submit): the host guard also names the computer name [C1]
Corey Olson34eb42449fce
diff --git a/src/hooks.js b/src/hooks.jsindex dd31b179..c836771e 100644--- a/src/hooks.js+++ b/src/hooks.js@@ -3,7 +3,10 @@* its folders, no secret or env file is committed, and a push sends exactly what the gate checked.* Each check returns its problems; an empty list lets git go on.*/-import { spawnSync } from 'node:child_process';+import {+ execFileSync,+ spawnSync,+} from 'node:child_process';import { hostname } from 'node:os';import {chmodSync,@@ -146,14 +149,32 @@ export function commitMsgProblems(raw, { rules, spec, doctrine = null }) {}/**- * 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).+ * This machine's computer name as macOS shows it, or null when the platform has no such name or the+ * lookup fails. The lookup has a short timeout, so a stuck scutil cannot stall a submit (C1).+ *+ * @returns {string | null}+ */+export function computerName() {+ if (process.platform !== 'darwin') return null;+ try {+ return execFileSync('/usr/sbin/scutil', ['--get', 'ComputerName'], { encoding: 'utf8', timeout: 2000, stdio: ['ignore', 'pipe', 'ignore'] }).trim() || null;+ } catch {+ return null;+ }+}++/**+ * This machine's names as a commit message would show them: the host name, its first label and the+ * computer name, matched case-insensitively. Names under three characters are ignored, so a short word+ * cannot refuse an honest message (C1). The sources are a parameter so a test can stand in for them.*+ * @param {{ host?: string, computer?: string | null }} [sources] - Defaults to this machine.* @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);+export function machineNames(sources = { host: hostname(), computer: computerName() }) {+ const host = String(sources.host ?? '').trim().toLowerCase();+ const computer = String(sources.computer ?? '').trim().toLowerCase();+ return [...new Set([host, host.split('.')[0], computer])].filter((name) => name.length >= 3);}/**diff --git a/test/worktree-start.test.js b/test/worktree-start.test.jsindex f0e1117a..050729f3 100644--- a/test/worktree-start.test.js+++ b/test/worktree-start.test.js@@ -7,7 +7,7 @@ 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 { machineNameProblems, machineNames } from '../src/hooks.js';import { installStep } from '../src/worktree.js';const e2e = createE2eHelpers();@@ -279,4 +279,11 @@ test('a submit naming a stand-in host refuses at HOST_NAME, and only warns whenassert.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'] });+ // A stand-in computer name is one of this machine's names, matched case-insensitively at submit.+ const computer = machineNames({ host: 'stand-in-host', computer: 'Stand In Box' });+ assert.ok(computer.includes('stand in box'), 'the computer name joins the machine names');+ const second = box.git(repo, 'rev-parse', 'HEAD');+ box.git(repo, 'commit', '-q', '--allow-empty', '-m', 'chore: note the STAND IN box in a message');+ assert.throws(() => machineNameProblems(repo, `${second}..HEAD`, { refuse: true, say: () => {}, names: computer }),+ (error) => error.code === 'HOST_NAME' && /names this machine/u.test(error.message), 'a stand-in computer name is refused');});