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(gate): a long line can no longer push the summary out [V10]
Corey Olson695992494dc6
diff --git a/src/gate.js b/src/gate.jsindex b17dd8b5..7b2f26a7 100644--- a/src/gate.js+++ b/src/gate.js@@ -12,21 +12,41 @@ import { Refused } from './refused.js';const STAMP = 'pullboard-gate-green';const LOG = 'pullboard-gate.log';const DIGEST_CHARS = 3000;+const TAIL_CHARS = 1000;+const LINE_CHARS = 300;const FAILURE_RE = /fail|error|expected|received|assert|not ok|✗|×|cannot|undefined|exception/i;/**- * The lines of a failure worth an agent's attention: those that look like failures first, then the- * end of the output, capped, so a refusal or a retry carries the reason and not the whole log.+ * The lines of a failure worth an agent's attention: those that look like failures, then the end of+ * the output, within one cap, so a refusal or a retry carries the reason and not the whole log. The+ * end has its own share of the cap and every line is cut short, so no single long line can push the+ * summary out.** @param {string} output* @returns {string}*/export function digestOf(output) {- const lines = output.split('\n').map((line) => line.trimEnd()).filter(Boolean);- const failing = lines.filter((line) => FAILURE_RE.test(line)).slice(0, 25);- const tail = lines.slice(-15);- const kept = [...new Set([...failing, ...tail])].join('\n');- return kept.length > DIGEST_CHARS ? `${kept.slice(0, DIGEST_CHARS)}\n...` : kept;+ const lines = output+ .split('\n')+ .map((line) => line.trimEnd())+ .filter(Boolean)+ .map((line) => (line.length > LINE_CHARS ? `${line.slice(0, LINE_CHARS)}…` : line));+ const tail = [];+ let room = TAIL_CHARS;+ for (let at = lines.length - 1; at >= 0 && tail.length < 15 && lines[at].length < room; at -= 1) {+ tail.unshift(lines[at]);+ room -= lines[at].length + 1;+ }+ room = DIGEST_CHARS - (TAIL_CHARS - room);+ const failing = [];+ for (const line of lines.slice(0, lines.length - tail.length)) {+ if (failing.length === 25) break;+ if (FAILURE_RE.test(line) && line.length < room) {+ failing.push(line);+ room -= line.length + 1;+ }+ }+ return [...failing, ...tail].join('\n');}/**diff --git a/test/gate.test.js b/test/gate.test.jsnew file mode 100644index 00000000..2d38c409--- /dev/null+++ b/test/gate.test.js@@ -0,0 +1,21 @@+/**+ * The gate's digest (V10): what an agent reads of a red run.+ */+import assert from 'node:assert/strict';+import { test } from 'node:test';+import { digestOf } from '../src/gate.js';++test('a digest keeps the failures and the end within its cap, however long one line is [V10]', () => {+ const digest = digestOf(`not ok 1 - ${'x'.repeat(3500)}\n${'ok\n'.repeat(50)}# fail 1\nsummary: 1 failed`);+ assert.ok(digest.length <= 3000, `${digest.length} characters`);+ assert.match(digest, /^not ok 1 - x+…\n/);+ assert.match(digest, /# fail 1\nsummary: 1 failed$/);+});++test('a digest of many failures stays within its cap and still ends with the summary [V10]', () => {+ const failures = Array.from({ length: 200 }, (_, n) => `not ok ${n} - ${'y'.repeat(250)}`).join('\n');+ const digest = digestOf(`${failures}\n# tests 200\n# fail 200`);+ assert.ok(digest.length <= 3000, `${digest.length} characters`);+ assert.match(digest, /^not ok 0 - /);+ assert.match(digest, /# tests 200\n# fail 200$/);+});