Skip to content

an open-source alternative to the dots, bots and muses of the world, run an office of claude code/codex like agents on your laptop, sandboxes or anywhere, uses your existing subscriptions

fix the 425 test-file resolution: keep both test blocks intact

chaitanyagirid652ee243563
diff --git a/test/breaker.test.cjs b/test/breaker.test.cjs
index 3802dfc2..3a7eeafb 100644
--- a/test/breaker.test.cjs
+++ b/test/breaker.test.cjs
@@ -204,56 +204,6 @@ test('the floor-wide token budget still counts all kinds (only the per-agent arm
const d = beat(b, 'a', s, true, T0);
assert.equal(d.state.level, 'steering', `reason: ${d.state.reason}`);
assert.ok(d.state.reason.startsWith('token cap: floor total'), d.state.reason);
-// ── #376: a live human conversation counts as progress ──────────────────────
-// A conversation is prose in, prose out — no hive files, no tool spans — and
-// the measured incidents fired 19s and 30s after an operator prompt, while the
-// file-based progress signal had been stale for over an hour.
-
-test('a recent human prompt exempts the no-progress trip (mid-conversation)', () => {
- const b = makeBreaker();
- beat(b, 'a', sample('a', T0, 0), false, T0);
- // The incident shape: operator prompts ~30s before each beat; the agent
- // answers in prose (Δoutput > 0) and touches nothing else.
- b.recordUserPrompt('a', T0 + BEAT - 30_000);
- beat(b, 'a', sample('a', T0 + BEAT, 800), false, T0 + BEAT);
- b.recordUserPrompt('a', T0 + 2 * BEAT - 19_000);
- const d = beat(b, 'a', sample('a', T0 + 2 * BEAT, 1600), false, T0 + 2 * BEAT);
- assert.equal(d.state.level, 'healthy', `reason: ${d.state.reason}`);
-});
-
-test('one prompt covers a long answer for the whole progress window', () => {
- const b = makeBreaker();
- beat(b, 'a', sample('a', T0, 0), false, T0);
- b.recordUserPrompt('a', T0 + 1000); // one question, then a long prose answer
- for (let i = 1; i <= 9; i++) { // 9 beats = 4.5 min, inside the 300s window
- const t = T0 + i * BEAT;
- const d = beat(b, 'a', sample('a', t, i * 700), false, t);
- assert.equal(d.state.level, 'healthy', `beat ${i}: ${d.state.reason}`);
- }
-});
-
-test('the conversation clock EXPIRES: a stale prompt does not blind the arm', () => {
- const b = makeBreaker();
- beat(b, 'a', sample('a', T0, 0), false, T0);
- b.recordUserPrompt('a', T0); // one prompt, then the agent burns tokens alone
- const t1 = T0 + 320_000; // past the 300s window
- const t2 = t1 + BEAT;
- beat(b, 'a', sample('a', t1, 5000), false, t1);
- const d = beat(b, 'a', sample('a', t2, 6000), false, t2);
- assert.equal(d.state.level, 'steering', `reason: ${d.state.reason}`);
-});
-
-test('a human prompt does not exempt the loop, error-storm, or velocity arms', () => {
- const b = makeBreaker();
- b.recordUserPrompt('a', T0 - 1000);
- for (let i = 0; i < 8; i++) b.recordToolUse('a', 'Bash', { cmd: 'same' });
- assert.equal(beat(b, 'a', null, true, T0).state.level, 'steering'); // loop still trips
-
- const b2 = makeBreaker();
- b2.recordUserPrompt('a', T0 - 1000);
- beat(b2, 'a', sample('a', T0, 0), true, T0);
- const d = beat(b2, 'a', sample('a', T0 + BEAT, 40_000), true, T0 + BEAT); // 80k/min
- assert.equal(d.state.level, 'steering', `reason: ${d.state.reason}`); // velocity still trips
});
// ── fix 2: recent distinct tool activity counts as progress ─────────────────
@@ -390,4 +340,112 @@ test('a healthy beat de-escalates one level', () => {
assert.equal(d.state.level, 'healthy');
});
+// ── #376: a live human conversation counts as progress ──────────────────────
+// A conversation is prose in, prose out — no hive files, no tool spans — and
+// the measured incidents fired 19s and 30s after an operator prompt, while the
+// file-based progress signal had been stale for over an hour.
+
+test('a recent human prompt exempts the no-progress trip (mid-conversation)', () => {
+ const b = makeBreaker();
+ beat(b, 'a', sample('a', T0, 0), false, T0);
+ // The incident shape: operator prompts ~30s before each beat; the agent
+ // answers in prose (Δoutput > 0) and touches nothing else.
+ b.recordUserPrompt('a', T0 + BEAT - 30_000);
+ beat(b, 'a', sample('a', T0 + BEAT, 800), false, T0 + BEAT);
+ b.recordUserPrompt('a', T0 + 2 * BEAT - 19_000);
+ const d = beat(b, 'a', sample('a', T0 + 2 * BEAT, 1600), false, T0 + 2 * BEAT);
+ assert.equal(d.state.level, 'healthy', `reason: ${d.state.reason}`);
+});
+
+test('one prompt covers a long answer for the whole progress window', () => {
+ const b = makeBreaker();
+ beat(b, 'a', sample('a', T0, 0), false, T0);
+ b.recordUserPrompt('a', T0 + 1000); // one question, then a long prose answer
+ for (let i = 1; i <= 9; i++) { // 9 beats = 4.5 min, inside the 300s window
+ const t = T0 + i * BEAT;
+ const d = beat(b, 'a', sample('a', t, i * 700), false, t);
+ assert.equal(d.state.level, 'healthy', `beat ${i}: ${d.state.reason}`);
+ }
+});
+
+test('the conversation clock EXPIRES: a stale prompt does not blind the arm', () => {
+ const b = makeBreaker();
+ beat(b, 'a', sample('a', T0, 0), false, T0);
+ b.recordUserPrompt('a', T0); // one prompt, then the agent burns tokens alone
+ const t1 = T0 + 320_000; // past the 300s window
+ const t2 = t1 + BEAT;
+ beat(b, 'a', sample('a', t1, 5000), false, t1);
+ const d = beat(b, 'a', sample('a', t2, 6000), false, t2);
+ assert.equal(d.state.level, 'steering', `reason: ${d.state.reason}`);
+});
+
+test('a human prompt does not exempt the loop, error-storm, or velocity arms', () => {
+ const b = makeBreaker();
+ b.recordUserPrompt('a', T0 - 1000);
+ for (let i = 0; i < 8; i++) b.recordToolUse('a', 'Bash', { cmd: 'same' });
+ assert.equal(beat(b, 'a', null, true, T0).state.level, 'steering'); // loop still trips
+
+ const b2 = makeBreaker();
+ b2.recordUserPrompt('a', T0 - 1000);
+ beat(b2, 'a', sample('a', T0, 0), true, T0);
+ const d = beat(b2, 'a', sample('a', T0 + BEAT, 40_000), true, T0 + BEAT); // 80k/min
+ assert.equal(d.state.level, 'steering', `reason: ${d.state.reason}`); // velocity still trips
+});
+
+// ── fix 2: recent distinct tool activity counts as progress ─────────────────
+
+test('recent distinct tool calls exempt the no-progress trip', () => {
+ const b = makeBreaker();
+ beat(b, 'a', sample('a', T0, 0), false, T0);
+ // Varied tool stream (background workflow / interactive work) right before each beat.
+ b.recordToolUse('a', 'Read', { file: 'x' }, T0 + BEAT - 1000);
+ beat(b, 'a', sample('a', T0 + BEAT, 5000), false, T0 + BEAT);
+ b.recordToolUse('a', 'Read', { file: 'y' }, T0 + 2 * BEAT - 1000);
+ const d = beat(b, 'a', sample('a', T0 + 2 * BEAT, 9000), false, T0 + 2 * BEAT);
+ assert.equal(d.state.level, 'healthy', `reason: ${d.state.reason}`);
+});
+
+test('REPEATED identical tool calls do not count as progress', () => {
+ const b = makeBreaker();
+ b.recordToolUse('a', 'Bash', { cmd: 'same' }, T0 - 10 * 60_000); // distinct stamp long ago
+ beat(b, 'a', sample('a', T0, 0), false, T0);
+ b.recordToolUse('a', 'Bash', { cmd: 'same' }, T0 + BEAT - 1000); // repeat — no fresh stamp
+ beat(b, 'a', sample('a', T0 + BEAT, 500), false, T0 + BEAT);
+ b.recordToolUse('a', 'Bash', { cmd: 'same' }, T0 + 2 * BEAT - 1000);
+ const d = beat(b, 'a', sample('a', T0 + 2 * BEAT, 1000), false, T0 + 2 * BEAT);
+ assert.equal(d.state.level, 'steering', `reason: ${d.state.reason}`);
+ assert.match(d.state.reason, /no-progress/);
+});
+
+// ── toolKey stays cheap AND discriminating on huge inputs ────────────────────
+
+test('huge identical Write inputs still register as repeats (loop arm)', () => {
+ const b = makeBreaker();
+ const huge = { file_path: '/x.txt', content: 'A'.repeat(1_000_000) };
+ for (let i = 0; i < 8; i++) b.recordToolUse('a', 'Write', huge);
+ const d = beat(b, 'a', null, true, T0);
+ assert.equal(d.state.level, 'steering');
+ assert.match(d.state.reason, /looping/);
+});
+
+test('huge inputs differing early still count as distinct calls', () => {
+ const b = makeBreaker();
+ for (let i = 0; i < 8; i++) {
+ b.recordToolUse('a', 'Write', { file_path: `/f${i}.txt`, content: 'A'.repeat(500_000) });
+ }
+ const d = beat(b, 'a', null, true, T0);
+ assert.equal(d.state.level, 'healthy', `reason: ${d.state.reason}`);
+});
+
+// ── recovery still works ─────────────────────────────────────────────────────
+
+test('a healthy beat de-escalates one level', () => {
+ const b = makeBreaker();
+ for (let i = 0; i < 8; i++) b.recordToolUse('a', 'Bash', { cmd: 'same' });
+ beat(b, 'a', null, true, T0); // → steering
+ b.recordToolUse('a', 'Read', { file: 'new' }); // distinct call clears the loop
+ const d = beat(b, 'a', null, true, T0 + BEAT);
+ assert.equal(d.state.level, 'healthy');
+});
+
process.exit(failures ? 1 : 0);