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): count cached tokens without seat metadata [O5,O6]

Corey Olsona46fbf012d60
diff --git a/src/settings-inventory.js b/src/settings-inventory.js
index bb65e0d0..42679a4d 100644
--- a/src/settings-inventory.js
+++ b/src/settings-inventory.js
@@ -157,7 +157,7 @@ function repositorySettings(rows, board) {
const environmentToken = process.env.PULLBOARD_RELAY_TOKEN;
add(rows, relayContext, 'relay.token', 'not set', { secret: true, value: environmentToken ?? relay.token,
source: environmentToken === undefined ? relayFile : 'environment:PULLBOARD_RELAY_TOKEN', origin: environmentToken === undefined && !relay.token ? 'default' : 'configured' });
- add(rows, relayContext, 'relay.agentTokens', 'not set', { secret: true, value: Object.values(relay.agentTokens ?? {}).some(value => Boolean(value?.token ?? value)) });
+ add(rows, relayContext, 'relay.agentTokens', 'not set', { secret: true, value: Object.values(relay.agentTokens ?? {}).some(value => typeof value?.token === 'string' && value.token.length > 0) });
const keyFile = join(process.env.PULLBOARD_HOME || join(homedir(), '.pullboard'), 'relay-keys', board.id + '.key');
const keyEnvironment = process.env.PULLBOARD_RELAY_KEY;
add(rows, { ...relayContext, file: keyFile }, 'relay.key', 'not set', { secret: true,
diff --git a/test/settings-api-fixture.js b/test/settings-api-fixture.js
index ae17204b..39dd9b73 100644
--- a/test/settings-api-fixture.js
+++ b/test/settings-api-fixture.js
@@ -136,6 +136,32 @@ export async function proveSettingsApi() {
assert.equal((await fetch(address)).status, 401);
assert.equal((await fetch(address, { method: 'POST', headers: { 'x-pullboard-key': 'api-fixture' } })).status, 400);
assert.deepEqual(snapshot(root), before, 'GET neither migrates credentials nor changes settings, registry, resources or board bytes');
+ const relayFile = join(privateDir, 'relay.json');
+ const relaySaved = readFileSync(relayFile);
+ const relayConfig = JSON.parse(relaySaved);
+ const metadata = { id: 'metadata-only', expires: 1, createdBy: 'coordinator' };
+ for (const [agentTokens, expected] of [
+ [{ fixture: metadata }, 'not set'],
+ [{}, 'not set'],
+ [undefined, 'not set'],
+ [{ fixture: {}, empty: { token: '' }, missing: null }, 'not set'],
+ [{ fixture: canary }, 'not set'],
+ [{ old: metadata, empty: { token: '' }, current: { ...metadata, token: canary } }, 'set'],
+ ]) {
+ writeFileSync(relayFile, JSON.stringify({ ...relayConfig, agentTokens }));
+ const saved = snapshot(root);
+ const credentialResponse = await fetch(address + '?board=' + id, { headers: { 'x-pullboard-key': 'api-fixture' } });
+ assert.equal(credentialResponse.status, 200);
+ const credentialText = await credentialResponse.text();
+ assert.ok(!credentialText.includes(canary), 'cached credential bytes never escape');
+ const credential = JSON.parse(credentialText).settings.find(row => row.scope === 'board' && row.key === 'relay.agentTokens');
+ assert.equal(credential.value, expected, 'only a cached token, not seat metadata, counts as a credential');
+ assert.equal(credential.default, 'not set');
+ assert.equal(credential.secret, true);
+ assert.equal(credential.source, relayFile);
+ assert.deepEqual(snapshot(root), saved, 'credential presence inspection changes no durable bytes');
+ }
+ writeFileSync(relayFile, relaySaved);
writeFileSync(join(repo, 'pullboard.json'), JSON.stringify({ ...config, verify: { ...config.verify, composeAtAdmission: false } }));
const falseSnapshot = snapshot(root);
const falseDocument = await (await fetch(address + '?board=' + id, { headers: { 'x-pullboard-key': 'api-fixture' } })).json();