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(ci): report fixed view performance budgets [N40,C7]
Corey Olsonacaa237cc30d
diff --git a/.github/workflows/gate.yml b/.github/workflows/gate.ymlindex 121e91e9..aadc59bc 100644--- a/.github/workflows/gate.yml+++ b/.github/workflows/gate.yml@@ -58,3 +58,36 @@ jobs:node-version: ${{ matrix.node }}- run: node bin/pullboard.js spec check- run: npm test -- --shard=${{ matrix.shard }}/${{ matrix.shards }}++ perf:+ name: view performance (3000 items, eight projects)+ if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request'+ runs-on: ubuntu-latest+ # Hang ceiling for browser setup and five samples; the view budgets remain 100/250 ms.+ timeout-minutes: 30+ steps:+ - uses: actions/checkout@v4+ with:+ fetch-depth: 0+ - uses: actions/setup-node@v4+ with:+ node-version: '24'+ - name: Measure the view outside the gate+ shell: bash+ run: |+ mkdir -p artifacts/performance+ export PULLBOARD_CHROME="$(command -v google-chrome || command -v chromium || command -v chromium-browser || true)"+ if [[ -z "$PULLBOARD_CHROME" ]]; then+ echo "::error::Chrome is required for the view performance measurement"+ exit 1+ fi+ node test/cockpit/perf/run.mjs --seed main-ci-n40 --size 3000 --projects 8 --runs 5 --idle 30 --live-every 5 > artifacts/performance/harness-output.txt+ - name: Report fixed budgets and idle observations+ if: always()+ run: node bin/check-perf-budgets.js artifacts/performance/harness-output.txt artifacts/performance+ - uses: actions/upload-artifact@v4+ if: always()+ with:+ name: view-performance+ path: artifacts/performance/+ if-no-files-found: errordiff --git a/bin/check-perf-budgets.js b/bin/check-perf-budgets.jsnew file mode 100644index 00000000..a1e54e5c--- /dev/null+++ b/bin/check-perf-budgets.js@@ -0,0 +1,32 @@+#!/usr/bin/env node+/** Save the main CI performance artifacts and warn by action against the fixed view budgets [N40,C7]. */+import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';+import { join, resolve } from 'node:path';+import { evaluatePerfBudgets, perfBudgetTable, readPerfReport } from '../src/perf-budgets.js';++/** Parse the saved harness output; artifacts live outside the harness's disposable workspace. */+function main(args) {+ if (args.length !== 2) throw new Error('usage: node bin/check-perf-budgets.js <harness-output> <artifact-directory>');+ const report = readPerfReport(readFileSync(resolve(args[0]), 'utf8'));+ const result = evaluatePerfBudgets(report);+ const directory = resolve(args[1]);+ mkdirSync(directory, { recursive: true });+ writeFileSync(join(directory, 'performance.json'), JSON.stringify(report, null, 2) + '\n');+ writeFileSync(join(directory, 'budgets.json'), JSON.stringify(result, null, 2) + '\n');+ writeFileSync(join(directory, 'performance.md'), (typeof report.table === 'string' ? report.table + '\n\n' : '') + perfBudgetTable(result) + '\n');+ for (const warning of result.warnings) {+ // Names come only from the fixed action registry, so harness content cannot inject annotations.+ console.log('::warning::' + warning.name + ': median ' + warning.medianMs + ' ms (budget 100 ms), worst '+ + warning.worstMs + ' ms (budget 250 ms)');+ }+ for (const error of result.errors) console.error('perf budgets: ' + error);+ console.log('View interaction budgets: ' + result.interactions.length + ' checked, ' + result.warnings.length+ + ' warning(s); idleWithLiveWrites is a 30000 ms observation with no latency budget.');+ process.exitCode = result.errors.length ? 1 : 0;+}++try { main(process.argv.slice(2)); }+catch (error) {+ console.error('perf budgets: ' + (error instanceof SyntaxError ? 'invalid JSON or incomplete harness output' : error.message));+ process.exitCode = 1;+}diff --git a/src/perf-budgets.js b/src/perf-budgets.jsnew file mode 100644index 00000000..749d3b24--- /dev/null+++ b/src/perf-budgets.js@@ -0,0 +1,114 @@+/** Apply the person's fixed interaction budgets to the main CI harness report [N40,C7]. */+export const PERF_INTERACTIONS = Object.freeze([+ 'firstLoad', 'switchProject', 'tab:shouts', 'tab:spec', 'tab:doctrine', 'tab:activity',+ 'tab:roadmap', 'tab:items', 'openSmallItem', 'openLongestHistoryItem', 'search',+]);+export const PERF_BUDGETS = Object.freeze(Object.fromEntries(PERF_INTERACTIONS.map(name =>+ [name, Object.freeze({ medianMs: 100, worstMs: 250 })])));+const IDLE = 'idleWithLiveWrites';++/** Read JSON alone or the harness's JSON followed by its identical Markdown table. */+export function readPerfReport(output) {+ const marker = '\n\n| action |';+ const split = output.indexOf(marker);+ const report = JSON.parse(split < 0 ? output : output.slice(0, split));+ if (split >= 0 && output.slice(split + 2).trim() !== report.table) {+ throw new Error('the JSON and printed harness table disagree');+ }+ return report;+}++/** A measurement is a finite nonnegative number, including a real zero. */+function measured(value) {+ return typeof value === 'number' && Number.isFinite(value) && value >= 0;+}++/** Report malformed or missing evidence as errors; exceeding a fixed interaction budget only warns. */+export function evaluatePerfBudgets(report, budgets = PERF_BUDGETS) {+ const errors = [], warnings = [], interactions = [], observations = [];+ if (!report || typeof report !== 'object' || Array.isArray(report)) {+ return { errors: ['the harness report must be an object'], warnings, interactions, observations };+ }+ if (report.version !== 1) errors.push('the harness report version must be 1');+ if (report.size !== 3000) errors.push('the measured stress board must have 3000 items');+ if (report.projects !== 8) errors.push('the measured home must have eight projects');+ if (!Number.isSafeInteger(report.runs) || report.runs < 1) errors.push('the harness run count is missing or invalid');+ if (report.idleMs !== 30_000) errors.push(IDLE + ' must record its fixed 30000 ms observation window');+ if (typeof report.table !== 'string' || !report.table.startsWith('| action |')) errors.push('the harness table is missing');+ if (!Array.isArray(report.actions)) {+ errors.push('the measured actions are missing');+ return { errors, warnings, interactions, observations };+ }+ const actions = new Map();+ for (const action of report.actions) {+ if (!action || typeof action.name !== 'string') { errors.push('a measured action has no name'); continue; }+ if (actions.has(action.name)) { errors.push('duplicate measured action ' + JSON.stringify(action.name)); continue; }+ actions.set(action.name, action);+ if (action.name !== IDLE && !Object.hasOwn(budgets, action.name)) {+ errors.push('measured action ' + JSON.stringify(action.name) + ' has no budget entry');+ }+ if (action.name !== IDLE && !PERF_INTERACTIONS.includes(action.name)) {+ errors.push('unknown measured interaction ' + JSON.stringify(action.name));+ }+ if (!measured(action.medianMs) || !measured(action.worstMs) || action.medianMs > action.worstMs) {+ errors.push('invalid median/worst measurement for ' + JSON.stringify(action.name));+ }+ }+ for (const name of PERF_INTERACTIONS) {+ if (!Object.hasOwn(budgets, name)) errors.push('required interaction ' + name + ' has no budget entry');+ if (!actions.has(name)) errors.push('budget entry ' + name + ' has no measured action');+ }+ for (const [name, budget] of Object.entries(budgets)) {+ if (!PERF_INTERACTIONS.includes(name)) errors.push('unknown budget entry ' + JSON.stringify(name));+ if (!actions.has(name) && !PERF_INTERACTIONS.includes(name)) errors.push('budget entry ' + JSON.stringify(name) + ' has no measured action');+ if (!budget || budget.medianMs !== 100 || budget.worstMs !== 250) {+ errors.push('budget for ' + JSON.stringify(name) + ' must remain median 100 ms and worst 250 ms');+ continue;+ }+ const action = actions.get(name);+ if (!action || !measured(action.medianMs) || !measured(action.worstMs) || action.medianMs > action.worstMs) continue;+ const over = action.medianMs > budget.medianMs || action.worstMs > budget.worstMs;+ const row = { name, medianMs: action.medianMs, worstMs: action.worstMs, budget, status: over ? 'warning' : 'within budget' };+ interactions.push(row);+ if (over) warnings.push(row);+ }+ const idle = actions.get(IDLE);+ if (!idle) errors.push('missing observation ' + IDLE);+ else if (!Array.isArray(idle.samples) || idle.samples.length !== report.runs) errors.push(IDLE + ' is missing per-run live-render observations');+ else {+ const runs = [];+ for (const [index, sample] of idle.samples.entries()) {+ if (!sample || !Number.isSafeInteger(sample.liveWrites) || sample.liveWrites < 0+ || !Array.isArray(sample.liveWriteOffsetsMs) || sample.liveWriteOffsetsMs.length !== sample.liveWrites+ || !sample.liveWriteOffsetsMs.every(measured)+ || !Array.isArray(sample.renderedAtMs) || sample.renderedAtMs.length !== sample.liveWrites+ || !sample.renderedAtMs.every(value => value === null || measured(value))) {+ errors.push(IDLE + ' run ' + (index + 1) + ' has malformed live-render times');+ continue;+ }+ runs.push({ run: index + 1, liveWriteOffsetsMs: sample.liveWriteOffsetsMs, renderedAtMs: sample.renderedAtMs });+ }+ observations.push({ name: IDLE, windowMs: report.idleMs, budget: null, runs });+ }+ return { errors, warnings, interactions, observations };+}++/** Render budgets separately from the unbudgeted idle window and its raw observed render offsets. */+export function perfBudgetTable(result) {+ const lines = [+ '| action | median ms | worst ms | median budget ms | worst budget ms | result |',+ '|---|---:|---:|---:|---:|---|',+ ...result.interactions.map(row => '| ' + row.name + ' | ' + row.medianMs + ' | ' + row.worstMs+ + ' | ' + row.budget.medianMs + ' | ' + row.budget.worstMs + ' | ' + row.status + ' |'),+ ];+ for (const observation of result.observations) {+ lines.push('| ' + observation.name + ' | — | — | none | none | ' + observation.windowMs + ' ms observation; no latency budget |');+ lines.push('', '| idleWithLiveWrites run | live-write offsets ms | rendered offsets ms |',+ '|---:|---|---|');+ for (const run of observation.runs) {+ lines.push('| ' + run.run + ' | ' + run.liveWriteOffsetsMs.join(', ') + ' | '+ + run.renderedAtMs.map(value => value === null ? 'not observed' : value).join(', ') + ' |');+ }+ }+ return lines.join('\n');+}diff --git a/test/perf-budgets.test.js b/test/perf-budgets.test.jsnew file mode 100644index 00000000..0cc26d6e--- /dev/null+++ b/test/perf-budgets.test.js@@ -0,0 +1,119 @@+/** CI evaluates synthetic reports without a private 3000-item browser burner [N40,C7]. */+import assert from 'node:assert/strict';+import { mkdtempSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';+import { tmpdir } from 'node:os';+import { join, resolve } from 'node:path';+import { test } from 'node:test';+import { runFixtureChild } from './fixture-child.js';++const ROOT = resolve(import.meta.dirname, '..');+const BIN = join(ROOT, 'bin/check-perf-budgets.js');+const ACTIONS = [+ 'firstLoad', 'switchProject', 'tab:shouts', 'tab:spec', 'tab:doctrine', 'tab:activity',+ 'tab:roadmap', 'tab:items', 'openSmallItem', 'openLongestHistoryItem', 'search',+];++/** Synthetic schema-shaped measurements prove policy handling, never actual view speed or browser timing. */+function report() {+ return {+ version: 1, size: 3000, projects: 8, runs: 1, idleMs: 30_000,+ actions: [+ ...ACTIONS.map(name => ({ name, medianMs: 100, worstMs: 250 })),+ { name: 'idleWithLiveWrites', medianMs: 30_020, worstMs: 30_020,+ samples: [{ liveWrites: 2, liveWriteOffsetsMs: [0, 5000], renderedAtMs: [18, 5031] }] },+ ],+ table: '| action | median stable ms | worst stable ms |\n|---|---:|---:|\n'+ + ACTIONS.map(name => '| ' + name + ' | 100 | 250 |').join('\n')+ + '\n| idleWithLiveWrites | 30020 | 30020 |',+ };+}++test('perf budgets warn by name and fail on a missing action [N40,C7]', async t => {+ const directory = mkdtempSync(join(tmpdir(), 'pullboard-perf-budgets-'));+ t.after(() => rmSync(directory, { recursive: true, force: true }));+ let sequence = 0;+ /** Run the actual reporter against a saved harness-shaped file and read its separate artifacts. */+ const run = (value, { combined = false } = {}) => {+ const fixture = join(directory, 'case-' + (++sequence));+ const inputDirectory = join(fixture, 'disposable-workspace');+ const outputDirectory = join(fixture, 'artifacts');+ mkdirSync(inputDirectory, { recursive: true });+ const input = join(inputDirectory, 'harness-output.txt');+ writeFileSync(input, JSON.stringify(value, null, 2) + (combined ? '\n\n' + value.table + '\n' : '\n'));+ const child = runFixtureChild(process.execPath, [BIN, input, outputDirectory], { cwd: ROOT, env: process.env, encoding: 'utf8' });+ return { child, inputDirectory, outputDirectory };+ };+ const under = run(report(), { combined: true });+ assert.equal(under.child.status, 0, under.child.stderr);+ assert.ok(!under.child.stdout.includes('::warning::'));+ const underSummary = JSON.parse(readFileSync(join(under.outputDirectory, 'budgets.json'), 'utf8'));+ assert.equal(underSummary.interactions.length, 11, 'all eleven eight-project interactions have fixed budgets');+ assert.deepEqual(underSummary.errors, []);+ assert.deepEqual(underSummary.warnings, []);+ assert.deepEqual(underSummary.observations, [{+ name: 'idleWithLiveWrites', windowMs: 30_000, budget: null,+ runs: [{ run: 1, liveWriteOffsetsMs: [0, 5000], renderedAtMs: [18, 5031] }],+ }], 'idle is the full window and exact observed offsets, with no latency threshold');+ const markdown = readFileSync(join(under.outputDirectory, 'performance.md'), 'utf8');+ assert.ok(markdown.includes('| idleWithLiveWrites | — | — | none | none | 30000 ms observation; no latency budget |'));+ assert.ok(markdown.includes('| 1 | 0, 5000 | 18, 5031 |'));+ rmSync(under.inputDirectory, { recursive: true });+ assert.equal(JSON.parse(readFileSync(join(under.outputDirectory, 'performance.json'), 'utf8')).projects, 8,+ 'the JSON and table survive cleanup of the disposable input workspace');+ assert.ok(readFileSync(join(under.outputDirectory, 'performance.md'), 'utf8').includes('switchProject'));++ const over = report();+ over.actions.find(action => action.name === 'search').medianMs = 101;+ over.actions.find(action => action.name === 'search').worstMs = 251;+ const warned = run(over);+ assert.equal(warned.child.status, 0, warned.child.stderr);+ assert.ok(warned.child.stdout.includes('::warning::search: median 101 ms (budget 100 ms), worst 251 ms (budget 250 ms)'));+ assert.equal(warned.child.stdout.match(/::warning::/gu).length, 1, 'one named warning covers that action’s exceeded values');+ assert.ok(!warned.child.stdout.includes('::warning::idleWithLiveWrites'));++ const unknown = report();+ unknown.actions.push({ name: 'unbudgetedAction', medianMs: 1, worstMs: 1 });+ const noBudget = run(unknown);+ assert.equal(noBudget.child.status, 1);+ assert.match(noBudget.child.stderr, /unbudgetedAction.*has no budget entry/u);+ const missing = report();+ missing.actions = missing.actions.filter(action => action.name !== 'switchProject');+ const noMeasurement = run(missing);+ assert.equal(noMeasurement.child.status, 1);+ assert.match(noMeasurement.child.stderr, /budget entry switchProject has no measured action/u);++ for (const mutate of [+ value => { value.actions.push({ ...value.actions[0] }); },+ value => { value.actions[0].medianMs = '100'; },+ value => { value.actions[0].worstMs = -1; },+ value => { value.actions[0].worstMs = 99; },+ value => { value.projects = 1; },+ value => { value.size = 150; },+ value => { value.actions.find(action => action.name === 'idleWithLiveWrites').samples[0].renderedAtMs = []; },+ ]) {+ const malformed = report(); mutate(malformed);+ assert.equal(run(malformed).child.status, 1, 'malformed or incomplete measurement evidence cannot pass');+ }+ const zero = report(); zero.actions[0].medianMs = 0; zero.actions[0].worstMs = 0;+ assert.equal(run(zero).child.status, 0, 'a measured zero is distinct from missing evidence');++ // The configuration reader also fails closed if its declared budget registry is incomplete.+ const { evaluatePerfBudgets, PERF_BUDGETS } = await import('../src/perf-budgets.js');+ const incomplete = { ...PERF_BUDGETS }; delete incomplete.search;+ assert.match(evaluatePerfBudgets(report(), incomplete).errors.join('\n'), /search.*has no budget entry/u);+ const extra = { ...PERF_BUDGETS, absentMeasurement: { medianMs: 100, worstMs: 250 } };+ assert.match(evaluatePerfBudgets(report(), extra).errors.join('\n'), /absentMeasurement.*has no measured action/u);+});++test('main CI saves the eight-project performance report outside the gate [N40,C7]', () => {+ const workflow = readFileSync(join(ROOT, '.github/workflows/gate.yml'), 'utf8');+ const perf = workflow.match(/\n perf:\n([\s\S]*)$/u)?.[1];+ assert.ok(perf, 'performance is its own job beside the gate’s matrix jobs');+ assert.match(perf, /if: github\.ref == 'refs\/heads\/main' && github\.event_name != 'pull_request'/u);+ assert.match(perf, /runs-on: ubuntu-latest/u);+ assert.match(perf, /--size 3000 --projects 8 --runs 5 --idle 30 --live-every 5/u);+ assert.match(perf, /node bin\/check-perf-budgets\.js artifacts\/performance\/harness-output\.txt artifacts\/performance/u);+ assert.match(perf, /actions\/upload-artifact@v4\n\s+if: always\(\)/u);+ assert.match(perf, /path: artifacts\/performance\//u);+ assert.ok(!/npm (?:test|run gate)|node bin\/run-tests\.js/u.test(perf), 'the large observation runs separately from the gate’s tests');+});