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(api): refresh registered labels [A2,A3,N33,N35]
Corey Olson792329db6287
diff --git a/src/api.js b/src/api.jsindex 9bd65d90..8daa5343 100644--- a/src/api.js+++ b/src/api.js@@ -1,6 +1,5 @@/** The local API v1: the CLI's moves, persistent board identities and live events (A2). */import { randomBytes, timingSafeEqual } from 'node:crypto';-import { readFileSync } from 'node:fs';import { createServer } from 'node:http';import { join } from 'node:path';import * as store from './board.js';@@ -8,7 +7,7 @@ import { COORDINATOR, loadConfig } from './config.js';import { repoInfo } from './git.js';import { refusalDocument } from './json.js';import { laneNames } from './lanes.js';-import { listProjects, registryFile } from './projects.js';+import { listApiProjects } from './projects.js';import { Refused } from './refused.js';import { codeAt, projectState } from './serve.js';import { createApiHandler } from './api-http.js';@@ -16,16 +15,6 @@ import { createApiHandler } from './api-http.js';const ADDRESS = '127.0.0.1';const VERSION = 1;-/** Read registry entries without pruning stale roots so the API can report them as warnings. */-function registeredProjects() {- try {- const entries = JSON.parse(readFileSync(registryFile(), 'utf8')).projects;- return Array.isArray(entries) ? entries.filter((project) => typeof project?.root === 'string') : [];- } catch {- return [];- }-}-/** Read a registered board and release its SQLite connection on every path. */function withBoard(root, read) {const info = repoInfo(root);@@ -35,15 +24,20 @@ function withBoard(root, read) {}/** Registered boards carry one persistent identity across local and relay addresses. */-export function apiBoards(projects = listProjects) {+export function apiBoards(projects = listApiProjects) {return projects().flatMap((project) => {try { return [withBoard(project.root, (board) => ({ ...project, id: store.boardId(board) }))]; }catch { return []; }});}-/** List readable registered boards and retain actionable warnings for entries that failed to open. */-function apiBoardListing(projects = registeredProjects) {+/**+ * List readable registered boards and retain actionable warnings for entries that failed to open.+ *+ * @param {() => { root: string, name: string, project: string, added: string }[]} projects+ * @returns {{ boards: object[], warnings: object[] }}+ */+function apiBoardListing(projects = listApiProjects) {const boards = [];const warnings = [];for (const project of projects()) {@@ -171,7 +165,7 @@ function createRequest(root, body) {}/** Create the authenticated local adapter used by the HTTP server and other local transports. */-export function createLocalApiHandler({ secret, getPort, runCommand, projects = registeredProjects } = {}) {+export function createLocalApiHandler({ secret, getPort, runCommand, projects = listApiProjects } = {}) {if (typeof getPort !== 'function') throw new TypeError('createLocalApiHandler needs a bound-port getter');if (typeof runCommand !== 'function') throw new TypeError('createLocalApiHandler needs the actual CLI entry point as runCommand');const key = Buffer.from(secret);@@ -202,7 +196,7 @@ export function createLocalApiHandler({ secret, getPort, runCommand, projects =}/** Serve the RFC 0002 API only on loopback, behind the same session-secret boundary as the view. */-export function serveApi({ port = 0, secret = randomBytes(18).toString('base64url'), runCommand, projects = registeredProjects } = {}) {+export function serveApi({ port = 0, secret = randomBytes(18).toString('base64url'), runCommand, projects = listApiProjects } = {}) {if (typeof runCommand !== 'function') throw new TypeError('serveApi needs the actual CLI entry point as runCommand');let bound;const handler = createLocalApiHandler({ secret, getPort: () => bound, runCommand, projects });diff --git a/src/projects.js b/src/projects.jsindex fdfebccf..87fdf8ec 100644--- a/src/projects.js+++ b/src/projects.js@@ -153,11 +153,12 @@ function writeRegistry(projects) {}/**- * Every registered project, oldest first. Refreshes valid live metadata and prunes missing roots.+ * Every registered project, oldest first. Refreshes valid live metadata and optionally prunes missing roots.*+ * @param {{ pruneMissing?: boolean }} [options]* @returns {{ root: string, name: string, project: string, added: string }[]}*/-export function listProjects() {+export function listProjects({ pruneMissing = true } = {}) {/*** Refresh and prune the latest on-disk entries.*@@ -169,7 +170,7 @@ export function listProjects() {const projects = [];for (const stored of storedProjects) {const root = resolve(stored.root);- if (!isDirectory(root)) {+ if (!isDirectory(root) && pruneMissing) {changed = true;continue;}@@ -201,6 +202,15 @@ export function listProjects() {});}+/**+ * Read the API's registered projects while preserving unreadable entries for warnings.+ *+ * @returns {{ root: string, name: string, project: string, added: string }[]}+ */+export function listApiProjects() {+ return listProjects({ pruneMissing: false });+}+/*** Add a project's main checkout once, preserving its original added timestamp on later registrations.*diff --git a/test/api-http.test.js b/test/api-http.test.jsindex 54f3261d..574f28e3 100644--- a/test/api-http.test.js+++ b/test/api-http.test.js@@ -9,6 +9,7 @@ import { test } from 'node:test';import { serveApi } from '../src/api.js';import { main } from '../src/cli.js';import { createApiHandler } from '../src/api-http.js';+import { registryFile, registerProject } from '../src/projects.js';import { Refused } from '../src/refused.js';import * as store from '../src/board.js';@@ -54,7 +55,7 @@ function fixture(t) {writeFileSync(join(root, 'PRACTICE.md'), '');git('add', '-A');git('commit', '-q', '-m', 'chore: private HTTP fixture');- return { root, dir, cli, run, commit: git('rev-parse', 'HEAD').trim() };+ return { root, dir, env, cli, run, commit: git('rev-parse', 'HEAD').trim() };}/** Serve this fixture's explicit project, avoiding any registry outside its private home. */@@ -129,6 +130,76 @@ test('[A2] local HTTP state accepts a safe seen cursor and committed code previe}});+test('[A2, N33, N35] API listing refreshes live labels and preserves missing-entry warnings', async (t) => {+ const box = fixture(t);+ const priorHome = process.env.PULLBOARD_HOME;+ process.env.PULLBOARD_HOME = box.env.PULLBOARD_HOME;+ t.after(() => { if (priorHome === undefined) delete process.env.PULLBOARD_HOME; else process.env.PULLBOARD_HOME = priorHome; });+ const second = join(box.dir, 'second-repo');+ mkdirSync(second);+ execFileSync('git', ['init', '-q', '-b', 'main'], { cwd: second, env: box.env, stdio: 'pipe' });+ box.cli(second, 'init');+ const secondConfigFile = join(second, 'pullboard.json');+ const secondConfig = JSON.parse(readFileSync(secondConfigFile, 'utf8'));+ writeFileSync(secondConfigFile, JSON.stringify({ ...secondConfig, name: 'Saved second', project: 'Saved group' }));+ registerProject(second, new Date('2026-02-03T04:05:06.000Z'));++ const api = await serveApi({ runCommand: main });+ t.after(() => api.close());+ const url = new URL(api.url);+ const key = url.searchParams.get('k');+ /** Fetch the authenticated board catalog through the real local HTTP server. */+ async function listing() {+ const response = await fetch(url.origin + '/api/v1/boards', { headers: { 'x-pullboard-key': key } });+ assert.equal(response.status, 200);+ return response.json();+ }++ const initial = await listing();+ assert.deepEqual(initial.boards.map((entry) => entry.root), [box.root, second]);+ assert.deepEqual(initial.warnings, []);+ const firstId = initial.boards[0].id;+ const firstAdded = initial.boards[0].added;+ const secondId = initial.boards[1].id;+ const secondAdded = initial.boards[1].added;+ const configFile = join(box.root, 'pullboard.json');+ const config = JSON.parse(readFileSync(configFile, 'utf8'));+ writeFileSync(configFile, JSON.stringify({ ...config, name: 'Fresh first', project: 'Fresh group' }));++ const refreshedBoth = await listing();+ assert.deepEqual(refreshedBoth.boards.map(({ root }) => root), [box.root, second]);+ assert.deepEqual(refreshedBoth.boards.map(({ id }) => id), [firstId, secondId]);+ assert.deepEqual(refreshedBoth.boards.map(({ added }) => added), [firstAdded, secondAdded]);+ assert.deepEqual(refreshedBoth.boards.map(({ name, project }) => ({ name, project })), [+ { name: 'Fresh first', project: 'Fresh group' },+ { name: 'Saved second', project: 'Saved group' },+ ]);+ rmSync(second, { recursive: true, force: true });++ const refreshed = await listing();+ assert.deepEqual(refreshed.boards.map(({ root, name, project }) => ({ root, name, project })), [+ { root: box.root, name: 'Fresh first', project: 'Fresh group' },+ ]);+ assert.equal(refreshed.boards[0].id, firstId);+ assert.equal(refreshed.boards[0].added, firstAdded);+ assert.equal(refreshed.warnings.length, 1);+ assert.equal(refreshed.warnings[0].root, second);+ assert.equal(refreshed.warnings[0].name, 'Saved second');+ assert.equal(refreshed.warnings[0].project, 'Saved group');+ assert.equal(refreshed.warnings[0].added, secondAdded);+ assert.equal(refreshed.warnings[0].error.version, 1);+ assert.equal(refreshed.warnings[0].error.error.code, 'BOARD_UNAVAILABLE');+ assert.match(refreshed.warnings[0].error.error.next, /pullboard forget/);+ assert.deepEqual(JSON.parse(readFileSync(registryFile(), 'utf8')).projects.map(({ root }) => root), [box.root, second]);++ const forgotten = box.cli(box.root, 'forget', box.root);+ assert.equal(forgotten.root, box.root);+ assert.deepEqual(JSON.parse(readFileSync(registryFile(), 'utf8')).projects.map(({ root }) => root), [second]);+ const afterForget = await listing();+ assert.deepEqual(afterForget.boards, []);+ assert.deepEqual(afterForget.warnings.map(({ root }) => root), [second]);+});+test('[A2] real HTTP state, moves and refusals use the CLI and exact committed events', async (t) => {const box = await httpBox(t);const one = box.cli(box.root, 'worktree', 'app');