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
fix: split hosted multi-row decision ids [B26,N26]
Corey Olson5884c1226ad4
diff --git a/src/view/page-script-4.js b/src/view/page-script-4.jsindex 9d974dc5..a2254e79 100644--- a/src/view/page-script-4.js+++ b/src/view/page-script-4.js@@ -555,7 +555,7 @@ async function decideRow(kind, command, args, anchor) {if (snapshot || (readOnly && !requests)) return false;const requestMode = requests;const root = view.root, scroll = window.scrollY;- const ids = String(args.ids).split(/\s+/);+ const ids = String(args.ids).split(/\\s+/);const prefix = kind + ':';const rows = [...$(kind + '-list').querySelectorAll('[data-row]')];const index = rows.findIndex((row) => row.dataset.row === prefix + ids[0]);diff --git a/test/cockpit/spec.test.js b/test/cockpit/spec.test.jsindex f7fae9d9..e4f21d88 100644--- a/test/cockpit/spec.test.js+++ b/test/cockpit/spec.test.js@@ -1,14 +1,104 @@/** Cockpit spec checks, using the shared real-board fixtures [N26]. */import assert from 'node:assert/strict';-import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';+import { mkdirSync, mkdtempSync, readdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { join } from 'node:path';import { after, test } from 'node:test';+import vm from 'node:vm';import { standardDoctrine } from '../../src/doctrine.js';import { loadConfig } from '../../src/config.js';+import { pageScriptPart4 } from '../../src/view/page-script-4.js';import { AGENT_SHELL_MARKERS, SSH_SHELL_MARKERS } from '../../src/person.js';import { tapTarget, SPEC, machine, project, build, startView, styleOf, openPage, boardOf, chromeExecutable, openSnapshotChrome, closeSnapshotChrome, watchSpecDecisionWait, press } from './fixture.js';+/** Return regex-literal bodies while skipping comments and quoted strings in a hosted script part. */+function regexLiterals(source) {+ const found = [];+ let quote = '', comment = '', canStart = true;+ for (let i = 0; i < source.length;) {+ const c = source[i], next = source[i + 1];+ if (comment === 'line') { if (c === '\n') comment = ''; i++; continue; }+ if (comment === 'block') { if (c === '*' && next === '/') { comment = ''; i += 2; } else i++; continue; }+ if (quote) { if (c === '\\') i += 2; else { if (c === quote) quote = ''; i++; } continue; }+ if (c === '/' && next === '/') { comment = 'line'; i += 2; continue; }+ if (c === '/' && next === '*') { comment = 'block'; i += 2; continue; }+ if (c === "'" || c === '"' || c === '`') { quote = c; canStart = false; i++; continue; }+ if (c === '/' && canStart) {+ let body = '', j = i + 1, escaped = false, inClass = false;+ for (; j < source.length; j++) {+ const x = source[j];+ if (!escaped && x === '[') inClass = true;+ if (!escaped && x === ']') inClass = false;+ if (!escaped && x === '/' && !inClass) break;+ body += x;+ if (!escaped && x === '\\') escaped = true; else escaped = false;+ }+ if (j < source.length) { found.push({ body, index: i }); i = j + 1; while (/[a-z]/i.test(source[i] || '')) i++; canStart = false; continue; }+ }+ canStart = /[([{,:;=!?&|+*%^~<>-]/.test(c);+ if (!/\s/.test(c)) i++; else i++;+ }+ return found;+}++test('no hosted page script part loses a regex backslash', () => {+ const offenders = [];+ for (const name of readdirSync(new URL('../../src/view/', import.meta.url)).filter((file) => /^page-script-\d+\.js$/u.test(file))) {+ const source = readFileSync(new URL(`../../src/view/${name}`, import.meta.url), 'utf8');+ const start = source.indexOf('return `') + 'return `'.length;+ const body = source.slice(start, source.lastIndexOf('`;'));+ for (const literal of regexLiterals(body)) {+ if (/(?<!\\)\\[sdwbSDWB]/u.test(literal.body)) {+ const line = body.slice(0, literal.index).split('\n').length + 10;+ offenders.push(`src/view/${name}:${line}`);+ }+ }+ }+ assert.deepEqual(offenders, [], `hosted regex escapes need a doubled template-literal backslash: ${offenders.join(', ')}`);+});++test('emitted page script splits decision ids on whitespace', () => {+ const served = pageScriptPart4({});+ const split = /String\(args\.ids\)\.split\((\/.*?\/)\)/u.exec(served);+ assert.ok(split, 'the served decideRow implementation splits its ids');+ const ids = Function(`return String('G1 G2').split(${split[1]})`)();+ assert.deepEqual(ids, ['G1', 'G2'], 'the emitted page script gives decideRow two row ids');+ const rows = ['spec:G0', 'spec:G1', 'spec:G2', 'spec:G3'];+ const next = rows.slice(rows.findIndex((row) => row === `spec:${ids[0]}`) + 1).find((row) => !ids.includes(row.slice('spec:'.length)));+ assert.equal(next, 'spec:G3', 'after deciding G1 and G2, the next undecided row is G3');+ assert.equal(ids.map((id) => `doctrine:${id}`).join(' '), 'doctrine:G1 doctrine:G2', 'each doctrine row keeps its own qualified id');+});++test('a decision on two spec rows splits their ids on whitespace', async () => {+ const served = pageScriptPart4({});+ const start = served.indexOf('async function decideRow(');+ const end = served.indexOf('\n}\n\n/**\n * Run a public API move', start) + 2;+ assert.ok(start >= 0 && end > start, 'the test extracts the production decideRow from the served page script');+ const window = { scrollY: 275, scrolls: [], scrollTo(position) { this.scrolls.push(position); } };+ const rowsFor = (kind, ids) => ids.map((id) => ({ dataset: { row: `${kind}:${id}` }, getBoundingClientRect: () => ({ top: 20, bottom: 40 }), scrollIntoView() { throw Error('the next row is already visible'); } }));+ let rows = rowsFor('spec', ['G0', 'G1', 'G2', 'G3']);+ const moves = [];+ const view = { root: 'repo', row: { spec: 'G1', doctrine: 'D1' } };+ const context = {+ snapshot: false, readOnly: false, requests: false, view, window, innerHeight: 900,+ $: (id) => ({ querySelectorAll: () => id === 'spec-list' ? rows : rowsFor('doctrine', ['D1', 'D2', 'D3']) }),+ render() {}, setTimeout() {},+ pageMove: (command, args) => ({ body: { command, args } }),+ boardPath: () => '/moves', api: async (path, body) => { moves.push(body); return { result: {} }; },+ moveMessage: () => 'recorded', refresh: async () => {},+ };+ const decideRow = vm.runInNewContext(`(${served.slice(start, end)})`, context);+ const anchor = { closest: () => null };+ assert.equal(await decideRow('spec', 'spec-approve', { ids: 'G1 G2' }, anchor), true);+ assert.equal(view.row.spec, 'G3', 'the next pick skips both decided rows and keeps the reading position');+ assert.equal(moves[0].args.ids, 'G1 G2', 'the hosted page sends the two spec ids');+ assert.deepEqual(JSON.parse(JSON.stringify(window.scrolls)), [{ top: 275, behavior: 'instant' }, { top: 275, behavior: 'instant' }], 'the page restores the original scroll position');+ rows = rowsFor('doctrine', ['D1', 'D2', 'D3']);+ assert.equal(await decideRow('doctrine', 'spec-approve', { ids: 'D1 D2' }, anchor), true);+ assert.equal(view.row.doctrine, 'D3', 'the doctrine pick advances past both decided rows');+ assert.equal(moves[1].args.ids, 'doctrine:D1 doctrine:D2', 'each doctrine id receives its own prefix in the outgoing move');+});+/** Observe a real Spec control's native pointer sequence and any replacement inside its detail card. */async function watchSpecPress(chrome, selector) {await chrome.stable(`(() => {