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): project a caller-owned staged board [N26,H16]
Corey Olson9658ad270240
diff --git a/src/serve.js b/src/serve.jsindex a1a7ee7b..1670673e 100644--- a/src/serve.js+++ b/src/serve.js@@ -149,16 +149,17 @@ function rememberPort(port) {* @template T* @param {string} root* @param {(board: any, info: any, config: any) => T} read+ * @param {any | null} [providedBoard] Borrow a staged connection without closing it.* @returns {T}*/-function withProject(root, read) {+function withProject(root, read, providedBoard = null) {const info = repoInfo(root);const config = loadConfig(info.root);- const board = store.openBoard(join(info.commonDir, 'pullboard', 'board.sqlite'));+ const board = providedBoard ?? store.openBoard(join(info.commonDir, 'pullboard', 'board.sqlite'));try {return read(board, info, config);} finally {- store.closeBoard(board);+ if (!providedBoard) store.closeBoard(board);}}@@ -167,10 +168,10 @@ function withProject(root, read) {* it also counts every shout since, which the forty it sends cannot always show.** @param {string} root- * @param {{ seen?: number | null }} [options]+ * @param {{ seen?: number | null, board?: any }} [options] A supplied board stays owned by its caller.* @returns {any}*/-export function projectState(root, { seen = null } = {}) {+export function projectState(root, { seen = null, board: providedBoard = null } = {}) {return withProject(root, (board, info, config) => {const all = store.listItems(board, { all: true });const status = new Map(all.map((item) => [item.item_id, item.item_status]));@@ -232,7 +233,7 @@ export function projectState(root, { seen = null } = {}) {// Each product's progress, counted as pullboard status counts it (N28).products: productSummaries(config, loadSpec(info.root, config), all),};- });+ }, providedBoard);}/** The most lines one code reference shows (B23). */diff --git a/test/cockpit.test.js b/test/cockpit.test.jsindex 1195bb41..0424fd60 100644--- a/test/cockpit.test.js+++ b/test/cockpit.test.js@@ -14,9 +14,11 @@ import { after, test } from 'node:test';import vm from 'node:vm';import { loadConfig } from '../src/config.js';import { loadDoctrine } from '../src/doctrine.js';+import { addItem, closeBoard, openBoard } from '../src/board.js';+import { exportBoard, importBoard } from '../src/exchange.js';import { MACHINE } from '../src/machine.js';import { cockpitPage } from '../src/cockpit.js';-import { portableSnapshot } from '../src/serve.js';+import { portableSnapshot, projectState } from '../src/serve.js';const BIN = resolve(import.meta.dirname, '../bin/pullboard.js');const scratch = [];@@ -83,6 +85,29 @@ function project(box, name, spec = SPEC, extra = {}) {return { repo, web, branch };}+test('borrowed board presentation keeps parity, shows staged rows, and leaves the caller connection open [N26,H16]', () => {+ const box = machine();+ const p = project(box, 'projector');+ box.run(p.repo, 'add', 'web', 'Existing projection row', '--criterion', 'same native data');+ const source = openBoard(join(p.repo, '.git', 'pullboard', 'board.sqlite'));+ const staged = openBoard(':memory:');+ try {+ importBoard(staged, exportBoard(source));+ const ordinary = projectState(p.repo);+ assert.deepEqual(projectState(p.repo, { board: staged }), ordinary, 'borrowed and ordinary projections share the same fields and values');+ const before = exportBoard(source);+ const stagedId = addItem(staged, { by: 'coordinator', lane: 'web', title: 'Staged recovery row', criterion: 'visible only in staged snapshot' });+ const stagedState = projectState(p.repo, { board: staged });+ assert.ok(stagedState.items.some(item => item.id === stagedId && item.title === 'Staged recovery row'));+ assert.ok(!projectState(p.repo).items.some(item => item.title === 'Staged recovery row'), 'staged-only rows never change the native board');+ assert.deepEqual(exportBoard(source), before, 'projection from the staged connection does not mutate source rows');+ assert.equal(staged.db.prepare('SELECT 1 AS open').get().open, 1, 'the caller-owned staged connection stays open');+ } finally {+ closeBoard(staged);+ closeBoard(source);+ }+});+/*** web-1 builds an item: claims it, commits a file in its lane through the hooks, and submits it.*/