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(relay): open excluded tables with device storage [H5,H17]
Corey Olsona232254c2982
diff --git a/relay/device-store.js b/relay/device-store.jsindex 901ea63e..f23971d6 100644--- a/relay/device-store.js+++ b/relay/device-store.js@@ -5,7 +5,10 @@ import { DatabaseSync } from 'node:sqlite';import { Refused } from '../src/refused.js';import { approvalContext } from '../src/relay-approval.js';import { createPersonEnrollmentStore } from './person-enrollment-store.js';-import { createExcludedStore } from './excluded-store.js';+import {+ createExcludedStore,+ createExcludedTables,+} from './excluded-store.js';/** Keep device revocations durable so an in-flight native wrap cannot recreate deleted grants. */export function createDeviceStore({ directory, now = Date.now }) {@@ -32,6 +35,7 @@ export function createDeviceStore({ directory, now = Date.now }) {CREATE UNIQUE INDEX IF NOT EXISTS phone_approval_pending ON phone_approval(account,board,action) WHERE state='waiting';`);// The phone's last contact lets its owner see from the linked computer whether it still reads the boards.if (!opened.prepare('PRAGMA table_info(device)').all().some(column => column.name === 'seen')) opened.exec('ALTER TABLE device ADD COLUMN seen INTEGER');+ createExcludedTables(opened);db = opened;return db;} catch (error) { opened.close(); throw error; }diff --git a/relay/excluded-store.js b/relay/excluded-store.jsindex cd334122..cea01fcf 100644--- a/relay/excluded-store.js+++ b/relay/excluded-store.js@@ -7,19 +7,18 @@ export function excludedInventoryId(machine, account) {return createHash('sha256').update('pullboard-exclusions-v1:' + account + ':' + machine).digest('hex').slice(0, 32);}-/** Keep names sealed and disclose a wrap only after checking that account's active device. */-export function createExcludedStore({ database, active }) {- /** Open the existing owner-only device database lazily, without creating it for unrelated reads. */- function storage() {- const db = database();- db.exec(`CREATE TABLE IF NOT EXISTS excluded_inventory (+/** Install the opaque inventory schema whenever its existing device database is opened [H5,H17]. */+export function createExcludedTables(db) {+ db.exec(`CREATE TABLE IF NOT EXISTS excluded_inventory (account TEXT NOT NULL, machine TEXT NOT NULL, label TEXT NOT NULL, count INTEGER NOT NULL,engine INTEGER NOT NULL, sealed TEXT NOT NULL, PRIMARY KEY(account,machine));CREATE TABLE IF NOT EXISTS excluded_inventory_wrap (account TEXT NOT NULL, machine TEXT NOT NULL, device TEXT NOT NULL, wrapped TEXT NOT NULL,PRIMARY KEY(account,machine,device));`);- return db;- }+}++/** Keep names sealed and disclose a wrap only after checking that account's active device. */+export function createExcludedStore({ database, active }) {return {/** Replace one exact machine publication atomically; inclusion clears the last stale entry. */publish(account, value) {@@ -43,7 +42,7 @@ export function createExcludedStore({ database, active }) {ids.add(wrap.device);active(account, wrap.device);}- const db = storage();+ const db = database();db.exec('BEGIN IMMEDIATE');try {// Recheck under the write transaction: a concurrent revocation must win before publication.@@ -62,12 +61,12 @@ export function createExcludedStore({ database, active }) {},/** A signed-in browser without a key learns only this account's machine labels and counts. */metadata(account) {- return storage().prepare('SELECT machine,label,count FROM excluded_inventory WHERE account=? ORDER BY machine').all(account);+ return database().prepare('SELECT machine,label,count FROM excluded_inventory WHERE account=? ORDER BY machine').all(account);},/** Never return another device's wrap, including to a freshly signed-in revoked browser. */forDevice(account, device) {active(account, device);- return storage().prepare(`SELECT i.machine,i.label,i.count,i.engine,i.sealed,w.wrapped+ return database().prepare(`SELECT i.machine,i.label,i.count,i.engine,i.sealed,w.wrappedFROM excluded_inventory AS i JOIN excluded_inventory_wrap AS wON w.account=i.account AND w.machine=i.machine WHERE i.account=? AND w.device=? ORDER BY i.machine`).all(account, device).map(row => ({ ...row, id: excludedInventoryId(row.machine, account) }));diff --git a/test/relay-deploy.test.js b/test/relay-deploy.test.jsindex f7e963d1..f8b8af03 100644--- a/test/relay-deploy.test.js+++ b/test/relay-deploy.test.js@@ -826,6 +826,7 @@ function refusingStoragePage(t, { hash, board, sealed }) {const url = new URL(String(input), location.origin);const accept = new Headers(init.headers).get('accept');if (url.pathname === '/api/v1/boards') return reply({ version: 1, boards: [{ id: board, repository: 'acme/widgets' }] });+ if (url.pathname === '/api/v1/devices/exclusions') return reply({ version: 1, exclusions: [] });if (url.pathname === '/api/v1/devices/approvals') {approvalReads += 1;assert.equal(init.method ?? 'GET', 'GET', 'pending phone approvals are read-only');