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): keep live clocks and stable validators [A2,N26,H5,H17]

Corey Olson81e4e0d764ef
diff --git a/src/api-http.js b/src/api-http.js
index 545ae8cb..1f70af0b 100644
--- a/src/api-http.js
+++ b/src/api-http.js
@@ -40,7 +40,7 @@ function sendState(req, res, text, tagged, validator = text, reportValidator) {
const headers = { 'cache-control': 'no-store', 'referrer-policy': 'no-referrer', 'x-content-type-options': 'nosniff' };
if (typeof reportValidator === 'string' && /^[a-f0-9]{64}:[0-9]+$/u.test(reportValidator)) headers['x-pullboard-report-validator'] = reportValidator;
if (tagged) {
- const board = validator.replace(/"(asOf|ageMinutes)":(?:"[^"]*"|[-+.0-9eE]+|null)/gu, '"$1":null');
+ const board = validator.replace(/"(asOf|ageMinutes|observedAt)":(?:"[^"]*"|[-+.0-9eE]+|null)/gu, '"$1":null');
Object.assign(headers, { etag: '"' + createHash('sha256').update(board).digest('base64url').slice(0, 32) + '"' });
const held = String(req.headers['if-none-match'] ?? '').split(',').map((tag) => tag.trim().replace(/^W\//u, ''));
if (held.includes(headers.etag)) {
diff --git a/src/api.js b/src/api.js
index 1079274d..29cb9af1 100644
--- a/src/api.js
+++ b/src/api.js
@@ -793,7 +793,7 @@ function isLiteralIPv4(host) {
/** Share the local router with the person's view and other local transports; the standalone API explicitly denies person authority.
* @param {{ secret: string | Buffer, getPort: () => number, runCommand: Function, projects?: () => any[], scope?: { projectRoot: string }, isMain?: boolean, allowedOrigins?: string[], allowedHosts?: string[], onStateBuild?: Function, onItemBuild?: Function, personChannel?: string, stateDetail?: string, now?: () => number, sessionCookie?: {name:string,value:string} }} [options]
*/
-export function createLocalApiHandler({ secret, getPort, runCommand, projects = listApiProjects, scope, isMain, allowedOrigins = [], allowedHosts = [], onStateBuild, onItemBuild, personChannel = 'view', stateDetail = 'full', sessionCookie, now = Date.now } = {}) {
+export function createLocalApiHandler({ secret, getPort, runCommand, projects = listApiProjects, scope, isMain, allowedOrigins = [], allowedHosts = [], onStateBuild, onItemBuild, personChannel = 'view', stateDetail = 'full', sessionCookie, now = () => Date.now() } = {}) {
if (typeof now !== 'function') throw new TypeError('createLocalApiHandler needs an observation clock');
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');
@@ -1088,7 +1088,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. Its
* state sends item summaries unless asked for detail=full; each item's detail has its own path (A2).
*/
-export function serveApi({ port = 0, secret = randomBytes(18).toString('base64url'), runCommand, projects = listApiProjects, isMain, onStateBuild, onItemBuild, stateDetail = 'summary', now = Date.now, scope } = {}) {
+export function serveApi({ port = 0, secret = randomBytes(18).toString('base64url'), runCommand, projects = listApiProjects, isMain, onStateBuild, onItemBuild, stateDetail = 'summary', now = () => Date.now(), scope } = {}) {
if (typeof runCommand !== 'function') throw new TypeError('serveApi needs the actual CLI entry point as runCommand');
let bound;
// A serve key authenticates board access, never a person, even in an ordinary terminal.