Skip to content

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.

fix(api): read settings registry without refreshing it [O5,O6]

Corey Olson41477679a4a8
diff --git a/src/api.js b/src/api.js
index f5a5ee13..73dad22f 100644
--- a/src/api.js
+++ b/src/api.js
@@ -40,6 +40,7 @@ import { MACHINE } from './machine.js';
import {
listApiProjects,
registryFile,
+ registeredProjectRootsSnapshot,
} from './projects.js';
import { milestoneRoadmap } from './roadmap.js';
import { proofStats } from './stats.js';
@@ -826,6 +827,10 @@ export function createLocalApiHandler({ secret, getPort, runCommand, projects =
throw new TypeError('createLocalApiHandler sessionCookie needs a cookie name and a canonical base64url value with at least 128 bits of random capacity');
}
const projectScope = apiProjectScope(projects, scope);
+ // Other API reads refresh the registry; settings must not prune or rewrite its saved metadata.
+ const settingsProjects = projects === listApiProjects
+ ? () => (registeredProjectRootsSnapshot() ?? []).map(root => ({ root })) : projects;
+ const settingsScope = apiProjectScope(settingsProjects, scope);
const apiProjects = projectScope.projects;
const scopeCommonDir = projectScope.commonDir;
const codeIsMain = codeIsFromMain() && isMain !== false;
@@ -1026,7 +1031,7 @@ export function createLocalApiHandler({ secret, getPort, runCommand, projects =
if (req.headers.origin && req.headers.origin !== 'http://' + req.headers.host && !permittedOrigins.has(req.headers.origin)) throw new Refused('API_ORIGIN', 'use the API from its own origin');
return { local: true };
},
- settings: (selected) => settingsInventory(apiProjects(), selected),
+ settings: (selected) => settingsInventory(settingsScope.projects(), selected),
boards: () => withGitReadFacts(() => apiBoardListing(apiProjects, codeIsMain)),
board: (id) => withGitReadFacts(() => findBoard(id, apiProjects, codeIsMain)),
state: (board, who, seen, options) => withGitReadFacts(() => localState(board, seen, options).state),
diff --git a/test/settings-api-fixture.js b/test/settings-api-fixture.js
index dbb0a4ef..28e1030d 100644
--- a/test/settings-api-fixture.js
+++ b/test/settings-api-fixture.js
@@ -48,7 +48,6 @@ export async function proveSettingsApi() {
const config = { ...defaults(), gate: 'node --test', health: { sentinel: false }, testConcurrency: { files: 3, browser: 1 }, claim: { reopenFirstRefusalMinutes: 30 }, lanes: { app: { owns: ['app/'], specs: ['O5'], ignoredSecret: canary } } };
writeFileSync(join(repo, 'pullboard.json'), JSON.stringify(config));
writeFileSync(join(home, 'settings.json'), JSON.stringify({ gateSlots: 3, browserSlots: 2, gate: { queue: { reviewsFirst: true }, shortSlots: 1 }, relay: { offerAtInit: false }, unknown: { token: canary } }));
- writeFileSync(join(home, 'projects.json'), JSON.stringify({ fixture: canary }));
mkdirSync(join(home, 'relay-machine'));
writeFileSync(join(home, 'relay-machine', 'state.json'), JSON.stringify({ v: 1, autoLink: true, session: { token: canary, account: 'fixture', url: 'https://relay.example.invalid' }, approvals: [{ sealed: canary }], devices: [], excluded: [] }));
writeFileSync(join(privateDir, 'relay.json'), JSON.stringify({ version: 1, board: id, url: 'https://relay.example.invalid', token: canary, agentTokens: { fixture: { token: canary } }, snapshot: canary }));
@@ -69,9 +68,12 @@ export async function proveSettingsApi() {
oldBoard.exec('CREATE TABLE board_meta(meta_key TEXT PRIMARY KEY, meta_value TEXT)');
oldBoard.prepare('INSERT INTO board_meta VALUES (?, ?)').run('board_id', legacyId);
oldBoard.close();
+ writeFileSync(join(home, 'projects.json'), JSON.stringify({
+ projects: [repo, legacy, missing, join(root, 'gone')].map(root => ({ root, name: 'stale fixture name', project: '', added: '2026-01-01' })),
+ unknown: { token: canary },
+ }));
let port;
- handler = createLocalApiHandler({ secret: 'api-fixture', getPort: () => port, runCommand: async () => 0,
- projects: () => [repo, legacy, missing].map(root => ({ root, name: 'fixture', project: '', added: '2026-01-01' })) });
+ handler = createLocalApiHandler({ secret: 'api-fixture', getPort: () => port, runCommand: async () => 0 });
server = createServer(handler);
await new Promise(resolve => server.listen(0, '127.0.0.1', resolve));
port = server.address().port;
@@ -84,6 +86,7 @@ export async function proveSettingsApi() {
const result = JSON.parse(text);
assert.equal(result.version, 1);
assert.equal(result.warnings[0].root, missing);
+ assert.ok(result.warnings.some(warning => warning.root === join(root, 'gone')), 'missing registered folders are reported without pruning');
const rows = result.settings;
const find = (scope, key) => rows.find(row => row.scope === scope && row.key === key);
for (const row of rows) {