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(tour): own gate slots, named slowest steps [N10,C7]

Corey Olson744a1064c2b7
diff --git a/src/tour.js b/src/tour.js
index 03110731..89f758d4 100644
--- a/src/tour.js
+++ b/src/tour.js
@@ -12,6 +12,7 @@ import {
realpathSync,
writeFileSync,
} from 'node:fs';
+import { performance } from 'node:perf_hooks';
import { tmpdir } from 'node:os';
import { join } from 'node:path';
import { fileURLToPath } from 'node:url';
@@ -73,6 +74,17 @@ const typed = (args) => args.map((arg) => (/[\s"'$|()]/.test(arg) ? JSON.stringi
*/
class TourStopped extends Error {}
+/**
+ * The three slowest commands the tour ran, with their times, so a slow tour says where its time went (N10).
+ *
+ * @param {{ label: string, ms: number }[]} timings
+ * @returns {string}
+ */
+function slowestSteps(timings) {
+ const slowest = [...timings].sort((a, b) => b.ms - a.ms).slice(0, 3);
+ return `slowest steps: ${slowest.map(({ label, ms }) => `${label} ${Math.round(ms)} ms`).join('; ')}`;
+}
+
/**
* Block for a moment, so a person can read along.
*
@@ -99,11 +111,12 @@ export async function tour(io) {
// Nothing of the person's git setup reaches the tour: no config files, and no GIT_ variable, such
// as GIT_DIR from a hook or GIT_CONFIG_COUNT pairs, which git reads as config too.
const env = Object.fromEntries(Object.entries(process.env).filter(([name]) => !name.startsWith('GIT_') && name !== 'NODE_TEST_CONTEXT'));
- Object.assign(env, { PATH: `${shims}:${process.env.PATH}`, GIT_CONFIG_GLOBAL: '/dev/null', GIT_CONFIG_NOSYSTEM: '1', PULLBOARD_HOME: join(dir, '.pullboard') });
+ Object.assign(env, { PATH: `${shims}:${process.env.PATH}`, GIT_CONFIG_GLOBAL: '/dev/null', GIT_CONFIG_NOSYSTEM: '1', PULLBOARD_HOME: join(dir, '.pullboard'), PULLBOARD_MACHINE_HOME: join(dir, '.pullboard-machine') });
const repo = join(dir, 'greeter');
const app = `${repo}-app-1`;
const review = `${repo}-review-1`;
const where = { coordinator: repo, 'app-1': app, 'review-1': review };
+ const timings = [];
/**
* Run one command as an agent, show it and the lines of its output worth reading.
@@ -111,11 +124,13 @@ export async function tour(io) {
const run = (who, file, args, { label = `${file} ${typed(args)}`, show = /./, fails = false, tone } = {}) => {
pause(400 * pace);
if (label) io.say(` ${paint(displayAgentName({ agent_id: who, agent_model: who === 'coordinator' ? null : 'Scripted' }), PROMPT_COLOR[who], color)} $ ${label}`);
+ const started = performance.now();
const result = spawnSync(file, args, {
cwd: where[who],
encoding: 'utf8',
env: { ...env, GIT_AUTHOR_NAME: who, GIT_AUTHOR_EMAIL: `${who}@tour.invalid`, GIT_COMMITTER_NAME: who, GIT_COMMITTER_EMAIL: `${who}@tour.invalid` },
});
+ timings.push({ label: label || `${file} ${typed(args)}`, ms: performance.now() - started });
if ((result.status === 0) === fails) {
const said = `${result.stdout ?? ''}${result.stderr ?? ''}${result.error?.message ?? ''}`;
throw new TourStopped(`${label || `${file} ${typed(args)}`} ${fails ? 'passed, and should have failed' : `exited ${result.status}`}\n${said}`);
@@ -193,11 +208,13 @@ export async function tour(io) {
if (!(error instanceof TourStopped)) throw error;
io.say(`\nThe tour stopped: ${error.message.trimEnd()}`);
io.say(`The repo is at ${repo}`);
+ io.err(slowestSteps(timings));
return 1;
}
await registerProjectAndLink(repo, new Date(), loadConfig(repo), io);
io.say('\nNothing shipped until a second agent verified it.');
io.say(`Look around: cd ${repo} && pullboard log`);
io.say('see it: pullboard view');
+ io.err(slowestSteps(timings));
return 0;
}
diff --git a/test/e2e-cli.test.js b/test/e2e-cli.test.js
index 788aeac9..8aeb6d6b 100644
--- a/test/e2e-cli.test.js
+++ b/test/e2e-cli.test.js
@@ -63,6 +63,24 @@ test('init adds a Claude Code session hook that runs resume, and keeps every oth
assert.equal(bare.stdout, '');
});
+test('a slow tour names its slowest steps [N10]', () => {
+ const box = sandbox();
+ const real = spawnSync('sh', ['-c', 'command -v git'], { encoding: 'utf8' }).stdout.trim();
+ const slowBin = join(box.dir, 'slow-bin');
+ mkdirSync(slowBin);
+ // A git that sleeps before each commit: the slow step the tour must name, through a shim it calls, not a switch.
+ writeFileSync(join(slowBin, 'git'), `#!/bin/sh\ncase "$*" in *"feat(app)"*) sleep 15 ;; esac\nexec ${JSON.stringify(real)} "$@"\n`);
+ chmodSync(join(slowBin, 'git'), 0o755);
+ const plainEnv = { ...box.env, TMPDIR: box.dir, PATH: `${slowBin}:${process.env.PATH}` };
+ delete plainEnv.NO_COLOR;
+ delete plainEnv.FORCE_COLOR;
+ const shown = spawnSync(process.execPath, [BIN, 'tour'], { cwd: box.dir, env: plainEnv, encoding: 'utf8' });
+ assert.equal(shown.status, 0, `${shown.stdout}${shown.stderr}`);
+ const slowest = shown.stderr.split('\n').find((line) => line.startsWith('slowest steps:'));
+ assert.ok(slowest, 'the tour names its slowest steps');
+ assert.match(slowest, /git commit -q -m "feat\(app\)[^;]*? ([0-9]{5,}) ms/u, 'the slowed commit is named with its time');
+});
+
test('the tour runs a reject and its rework on a throwaway repo, in under thirty seconds [N10]', () => {
const box = sandbox();
const plainEnv = { ...box.env, TMPDIR: box.dir };
@@ -71,7 +89,8 @@ test('the tour runs a reject and its rework on a throwaway repo, in under thirty
const started = Date.now();
const shown = spawnSync(process.execPath, [BIN, 'tour'], { cwd: box.dir, env: plainEnv, encoding: 'utf8' });
assert.equal(shown.status, 0, `${shown.stdout}${shown.stderr}`);
- assert.ok(Date.now() - started < 30_000, 'thirty seconds'); // budget: approved row N10 states thirty seconds.
+ const slowest = shown.stderr.split('\n').find((line) => line.startsWith('slowest steps:')) ?? 'the tour named no slowest steps';
+ assert.ok(Date.now() - started < 30_000, `thirty seconds; ${slowest}`); // budget: approved row N10 states thirty seconds.
assert.doesNotMatch(shown.stdout, /\u001b\[/, 'piped output stays plain');
assert.match(shown.stdout, /review-1 \(Scripted\) \$ pullboard verify 1 reject --reason BEHAVIOR_MISMATCH/);
assert.match(shown.stdout, /sent back: #1 BEHAVIOR_MISMATCH by review-1 \(Scripted\): greet\(''\) returns "Hello, !"/);