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(view): measure the harness with many projects [N26,N40]
Corey Olsonf1106628659e
diff --git a/test/cockpit/perf.test.js b/test/cockpit/perf.test.jsindex b5df7b55..b61e7cf7 100644--- a/test/cockpit/perf.test.js+++ b/test/cockpit/perf.test.js@@ -1,9 +1,57 @@/** Exercise the deterministic stress fixture and the real-Chrome performance harness [N26]. */import assert from 'node:assert/strict';-import { test } from 'node:test';+import { existsSync, readFileSync } from 'node:fs';+import { dirname, join, resolve } from 'node:path';+import { after, test } from 'node:test';+import { cleanupFixtureChildren, runFixtureChildAsync } from '../fixture-child.js';import { generateStressBoard, removeStressBoard } from './perf/generate.mjs';import { assertRequiredNetworkEvidence, selectNetworkTarget, withPerfSlot } from './perf/run.mjs';+after(cleanupFixtureChildren);++test('the harness measures with eight registered projects [N26,N40]', async (t) => {+ const fixtures = [];+ t.after(() => {+ if (t.passed) for (const fixture of fixtures) removeStressBoard(fixture);+ });+ const root = resolve(import.meta.dirname, '../..');+ for (const projects of [8, 1]) {+ const result = await runFixtureChildAsync(process.execPath, [join(root, 'test/cockpit/perf/run.mjs'),+ ...(projects > 1 ? ['--projects', String(projects)] : []),+ '--size', '5', '--runs', '1', '--idle', '1', '--live-every', '1', '--keep'],+ { cwd: root, env: process.env });+ assert.equal(result.status, 0, result.context);+ const kept = /^Generated board kept at (.+)$/mu.exec(result.stdout);+ assert.ok(kept, 'the CLI retains its private fixture for independent registry checks');+ const workspace = dirname(kept[1]);+ const fixture = { ...JSON.parse(readFileSync(join(workspace, 'stress-board.json'), 'utf8')), workspace };+ fixtures.push(fixture);+ const end = result.stdout.indexOf('\n\n| action |');+ assert.ok(end > 0, 'the harness prints its JSON before the existing table');+ const report = JSON.parse(result.stdout.slice(0, end));+ assert.equal(report.projects, projects, 'the JSON records the measured project count');+ assert.equal(report.projectNames.length, projects, 'the real view lists every requested project');+ assert.equal(new Set(report.projectNames).size, projects, 'the projects have distinct names');+ const registered = JSON.parse(readFileSync(join(fixture.home, 'projects.json'), 'utf8')).projects;+ assert.equal(registered.length, projects, 'the stress home contains the requested real projects');+ assert.equal(new Set(registered.map((project) => project.root)).size, projects);+ for (const project of registered) {+ assert.ok(existsSync(join(project.root, '.git/pullboard/board.sqlite')), 'each project has its own board');+ }+ const switching = report.actions.filter((action) => action.name === 'switchProject');+ assert.equal(switching.length, projects > 1 ? 1 : 0,+ 'only a multi-project run measures a real project switch');+ for (const action of switching) {+ assert.ok(action.samples.every((sample) => sample.stable === true), 'the switch reaches the stress board');+ assert.ok(Number.isFinite(action.medianMs) && Number.isFinite(action.worstMs), 'switch latency is measured');+ }+ assert.deepEqual(report.actions.filter((action) => action.name !== 'switchProject').map((action) => action.name),+ ['firstLoad', 'tab:shouts', 'tab:spec', 'tab:doctrine', 'tab:activity', 'tab:roadmap', 'tab:items',+ 'openSmallItem', 'openLongestHistoryItem', 'search', 'idleWithLiveWrites'], 'the eleven existing actions stay intact');+ assert.equal(report.size, 5, 'the measured stress-board size is preserved');+ }+});+/** Check every observed JSON request is represented in the rendered action row. */async function tableListsRequestBytes(t) {let fixture = null;diff --git a/test/cockpit/perf/run.mjs b/test/cockpit/perf/run.mjsindex 768fc003..31dbf4bf 100644--- a/test/cockpit/perf/run.mjs+++ b/test/cockpit/perf/run.mjs@@ -14,7 +14,7 @@ The default size follows the measured 605-item board shape and scales its statusThe generated board, home, machine state and browser profile are temporary after a successful run. Use `--keep` to retain the generated board for inspection; local view keys are kept in process memory and are not included in output. A failed run retains its private board, browser profile and failure summary for diagnosis.*//** Measure each frozen cockpit action on a generated board in an isolated machine and browser profile. */-import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';+import { mkdirSync, readFileSync, realpathSync, writeFileSync } from 'node:fs';import { join, resolve } from 'node:path';import { spawn } from 'node:child_process';import { parseArgs } from 'node:util';@@ -26,6 +26,7 @@ import * as resources from '../../../src/resources.js';import { findChromeExecutable, startChrome } from '../../chrome-fixture.js';import { press, stableChrome } from '../stable.js';import { generateStressBoard, removeStressBoard } from './generate.mjs';+import { runFixtureChild, runFixtureGit } from '../../fixture-child.js';const ROOT = resolve(import.meta.dirname, '../../..');const BIN = join(ROOT, 'bin', 'pullboard.js');@@ -42,6 +43,25 @@ const VIEWER_ACTIONS = [['tab:items', 'items', '#chain .row'],];+/** Validate the number of real projects before allocating their private fixtures. */+function projectCount(value) {+ if (!Number.isSafeInteger(value) || value < 1) throw new RangeError('projects must be a positive integer');+ return value;+}++/** Initialize lightweight additional boards in the stress fixture's isolated home through the CLI. */+function registerHarnessProjects(board, projects) {+ for (let index = 1; index < projects; index += 1) {+ const root = join(board.workspace, 'projects', `project-${index + 1}`);+ mkdirSync(root, { recursive: true });+ const git = runFixtureGit(['init', '-q', '-b', 'main'], { cwd: root, env: board.env, encoding: 'utf8' });+ if (git.status !== 0) throw new Error(git.failure ?? git.stderr);+ const initialized = runFixtureChild(process.execPath, [BIN, 'init', '--model', 'Stress fixture'],+ { cwd: root, env: board.env, encoding: 'utf8' });+ if (initialized.status !== 0) throw new Error(initialized.failure ?? initialized.stderr);+ }+}+/** Hold the real shared browser pool for fixture setup, Chrome actions and teardown. */export async function withPerfSlot(action) {if (typeof action !== 'function') throw new TypeError('the performance slot needs an action');@@ -393,7 +413,8 @@ async function beginAction(chrome, name, eventType) {}/** Capture one run's first load, six tabs, two item opens, search and live idle interval. */-async function measureRun(board, runIndex, executable, idleMs, liveEveryMs) {+async function measureRun(board, runIndex, executable, idleMs, liveEveryMs, projects) {+ const measuredRoot = realpathSync(board.root);const profile = join(board.workspace, `chrome-${runIndex + 1}`);mkdirSync(profile, { recursive: true, mode: 0o700 });let view = null;@@ -418,7 +439,31 @@ async function measureRun(board, runIndex, executable, idleMs, liveEveryMs) {const browserVersion = await chrome.send('Browser.getVersion', {}, 'pin the isolated browser runtime', ACTION_TIMEOUT_MS);await chrome.navigate(view.link.href);actions.push(await waitPaintedAndStable(chrome, network, 'firstLoad', '#chain .row',- `document.readyState === 'complete' && !document.body.classList.contains('loading')`, true));+ `document.readyState === 'complete' && !document.body.classList.contains('loading') && view.root === ${JSON.stringify(measuredRoot)}`, true));++ const listed = JSON.parse(await chrome.stable(`JSON.stringify([...document.querySelectorAll('#proj-list .repo[data-root]')]+ .map(node => ({ root: node.dataset.root, name: node.querySelector('.pname')?.textContent })))`));+ if (listed.length !== projects || listed.some(project => typeof project.name !== 'string')) {+ throw new Error(`the view listed ${listed.length} projects; expected ${projects} initialized boards`);+ }+ actions.projectNames = listed.map(project => project.name);+ if (projects > 1) {+ const other = listed.find(project => project.root !== measuredRoot);+ if (!other) throw new Error('the project-switch sample needs another registered board');+ if (await chrome.stable("getComputedStyle(document.querySelector('#side .side-body')).display === 'none'")) {+ await press(chrome, "document.querySelector('#proj-switch')");+ }+ /** Find the listed project without interpolating fixture paths into a CSS selector. */+ const row = root => `[...document.querySelectorAll('#proj-list .repo[data-root]')].find(node => node.dataset.root === ${JSON.stringify(root)})`;+ await beginAction(chrome, 'switchProjectSetup', 'mousedown');+ await press(chrome, row(other.root));+ await waitPaintedAndStable(chrome, network, 'switchProjectSetup', '#status-board',+ `view.root === ${JSON.stringify(other.root)} && data?.root === ${JSON.stringify(other.root)}`);+ await beginAction(chrome, 'switchProject', 'mousedown');+ await press(chrome, row(measuredRoot));+ actions.push(await waitPaintedAndStable(chrome, network, 'switchProject', '#chain .row',+ `view.root === ${JSON.stringify(measuredRoot)} && data?.root === ${JSON.stringify(measuredRoot)}`));+ }for (const [name, tab, target] of VIEWER_ACTIONS) {await beginAction(chrome, name, 'mousedown');@@ -583,17 +628,20 @@ function renderTable(actions) {/** Run the user-facing harness with an isolated generated board and headless real Chrome. */async function runPerfHarnessInSlot({ board, runs = 1, idleMs = 30_000, liveEveryMs = 5_000,- executable = findChromeExecutable() } = {}, lease) {+ executable = findChromeExecutable(), projects = 1 } = {}, lease) {if (!board?.workspace || !board?.boardFile) throw new TypeError('board must come from generateStressBoard');if (!Number.isSafeInteger(runs) || runs < 1 || runs > 20) throw new RangeError('runs must be an integer from 1 through 20');if (!Number.isSafeInteger(idleMs) || idleMs < 0 || idleMs > 300_000) throw new RangeError('idleMs must be an integer from 0 through 300000');if (!Number.isSafeInteger(liveEveryMs) || liveEveryMs < 1_000 || liveEveryMs > 60_000) throw new RangeError('liveEveryMs must be an integer from 1000 through 60000');if (!executable) throw new Error('Chrome was not found; install Chrome or set PULLBOARD_CHROME.');+ projectCount(projects);+ registerHarnessProjects(board, projects);const capture = async (lease) => {const captured = [];- for (let index = 0; index < runs; index += 1) captured.push(await measureRun(board, index, executable, idleMs, liveEveryMs));+ for (let index = 0; index < runs; index += 1) captured.push(await measureRun(board, index, executable, idleMs, liveEveryMs, projects));const actions = summarize(captured);const report = { version: 1, seed: board.seed, size: board.size, digest: board.digest,+ projects: captured[0].projectNames.length, projectNames: captured[0].projectNames,gate: { browser: lease.browser === true, waitMs: lease.waitMs },boardShape: { statuses: board.statusTotals, lanes: board.laneTotals, agents: board.agentCount,itemEvents: board.itemEvents, shouts: board.shoutCount, milestones: board.milestoneCount,@@ -616,20 +664,22 @@ export async function runPerfHarness(options = {}) {async function main(argv) {const parsed = parseArgs({ args: argv, options: {seed: { type: 'string', default: 'pullboard-perf-606' }, size: { type: 'string', default: '3000' },+ projects: { type: 'string', default: '1' },runs: { type: 'string', default: '5' }, idle: { type: 'string', default: '30' }, 'live-every': { type: 'string', default: '5' },keep: { type: 'boolean', default: false }, help: { type: 'boolean', default: false },} });if (parsed.values.help) {- process.stdout.write('Usage: node test/cockpit/perf/run.mjs [--seed text] [--size 3000] [--runs 5] [--idle 30] [--live-every 5] [--keep]\n');+ process.stdout.write('Usage: node test/cockpit/perf/run.mjs [--seed text] [--size 3000] [--projects 1] [--runs 5] [--idle 30] [--live-every 5] [--keep]\n');return;}let board = null;let completed = false;+ const projects = projectCount(Number(parsed.values.projects));try {await withPerfSlot(async (run) => {board = generateStressBoard({ seed: parsed.values.seed, size: Number(parsed.values.size) });try {- const report = await run({ board, runs: Number(parsed.values.runs), idleMs: Number(parsed.values.idle) * 1_000,+ const report = await run({ board, projects, runs: Number(parsed.values.runs), idleMs: Number(parsed.values.idle) * 1_000,liveEveryMs: Number(parsed.values['live-every']) * 1_000 });process.stdout.write(`${JSON.stringify(report, null, 2)}\n\n${report.table}\n`);if (parsed.values.keep) process.stdout.write(`Generated board kept at ${board.root}\n`);