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(needs): keep the block ledger out of browser-loaded refused.js [C6]

Corey Olson5c749e41ec4c
diff --git a/src/blocks.js b/src/blocks.js
new file mode 100644
index 00000000..9f5ed308
--- /dev/null
+++ b/src/blocks.js
@@ -0,0 +1,43 @@
+/** The block ledger: refusals that stopped someone's command. Not in refused.js, which the browser loads [C6]. */
+import { appendFileSync, existsSync, readFileSync } from 'node:fs';
+import { join } from 'node:path';
+
+/** The ledger of refusals that stopped someone's command, beside the board in Git's common folder. */
+export const BLOCKS_FILE = join('pullboard', 'blocks.jsonl');
+
+/**
+ * Append one block: its code, the command, who was stopped, who can clear it, and the plain reason
+ * and step. A ledger beside the board, not a board event, so recording a block never needs the
+ * board's lock or changes what the event log replays.
+ *
+ * @param {string} commonDir
+ * @param {{ at: string, code: string, command: string, by: string, path: string, audience: string, reason: string, step: string }} block
+ */
+export function recordBlock(commonDir, block) {
+ const folder = join(commonDir, 'pullboard');
+ // A repository without a board has no ledger yet; the refusal itself still prints.
+ if (!existsSync(folder)) return false;
+ appendFileSync(join(commonDir, BLOCKS_FILE), JSON.stringify(block) + '\n');
+ return true;
+}
+
+/**
+ * The blocks recorded at or after `since`, oldest first. A torn last line from a crash is skipped.
+ *
+ * @param {string} commonDir
+ * @param {{ since?: Date }} [options]
+ * @returns {any[]}
+ */
+export function readBlocks(commonDir, { since } = {}) {
+ const file = join(commonDir, BLOCKS_FILE);
+ if (!existsSync(file)) return [];
+ const from = since ? since.getTime() : -Infinity;
+ const blocks = [];
+ for (const line of readFileSync(file, 'utf8').split('\n')) {
+ if (!line.trim()) continue;
+ let block;
+ try { block = JSON.parse(line); } catch { continue; /* A torn line from an interrupted append carries no block. */ }
+ if (typeof block?.code === 'string' && Date.parse(block.at) >= from) blocks.push(block);
+ }
+ return blocks;
+}
diff --git a/src/needs-state.js b/src/needs-state.js
index c716bcd6..52b4e470 100644
--- a/src/needs-state.js
+++ b/src/needs-state.js
@@ -16,7 +16,7 @@ import {
undraftedRigor,
} from './rigor-notices.js';
import { personNeeds } from './needs.js';
-import { readBlocks } from './refused.js';
+import { readBlocks } from './blocks.js';
import { displayAgentName } from './agent-names.js';
import {
projectSpecApprovals,
diff --git a/src/next-steps.js b/src/next-steps.js
index 298b6806..a94e67d0 100644
--- a/src/next-steps.js
+++ b/src/next-steps.js
@@ -8,10 +8,8 @@
* every code raised in src/ has a row here.
*/
import { RECORDED_GENERIC_NEXT } from './recorded-refusal.js';
-import {
- Refused,
- recordBlock,
-} from './refused.js';
+import { Refused } from './refused.js';
+import { recordBlock } from './blocks.js';
/** Describe the queue's actual outstanding reviews and submission age [Q1,V15]. */
export function reviewQueueLine(ctx, queue, span) {
diff --git a/src/refused.js b/src/refused.js
index 18577d73..388d28eb 100644
--- a/src/refused.js
+++ b/src/refused.js
@@ -1,6 +1,3 @@
-import { appendFileSync, existsSync, readFileSync } from 'node:fs';
-import { join } from 'node:path';
-
/**
* A refused move: a rule said no. The code names the rule; the message says what to do next (P4).
*/
@@ -17,43 +14,3 @@ export class Refused extends Error {
if (typeof next === 'string' && next.trim()) this.next = next.trim();
}
}
-
-/** The ledger of refusals that stopped someone's command, beside the board in Git's common folder. */
-export const BLOCKS_FILE = join('pullboard', 'blocks.jsonl');
-
-/**
- * Append one block: its code, the command, who was stopped, who can clear it, and the plain reason
- * and step. A ledger beside the board, not a board event, so recording a block never needs the
- * board's lock or changes what the event log replays.
- *
- * @param {string} commonDir
- * @param {{ at: string, code: string, command: string, by: string, path: string, audience: string, reason: string, step: string }} block
- */
-export function recordBlock(commonDir, block) {
- const folder = join(commonDir, 'pullboard');
- // A repository without a board has no ledger yet; the refusal itself still prints.
- if (!existsSync(folder)) return false;
- appendFileSync(join(commonDir, BLOCKS_FILE), JSON.stringify(block) + '\n');
- return true;
-}
-
-/**
- * The blocks recorded at or after `since`, oldest first. A torn last line from a crash is skipped.
- *
- * @param {string} commonDir
- * @param {{ since?: Date }} [options]
- * @returns {any[]}
- */
-export function readBlocks(commonDir, { since } = {}) {
- const file = join(commonDir, BLOCKS_FILE);
- if (!existsSync(file)) return [];
- const from = since ? since.getTime() : -Infinity;
- const blocks = [];
- for (const line of readFileSync(file, 'utf8').split('\n')) {
- if (!line.trim()) continue;
- let block;
- try { block = JSON.parse(line); } catch { continue; /* A torn line from an interrupted append carries no block. */ }
- if (typeof block?.code === 'string' && Date.parse(block.at) >= from) blocks.push(block);
- }
- return blocks;
-}