From 6a2c61d5ee424fa30850da2a6513b3897b01288e Mon Sep 17 00:00:00 2001 From: Mikael Hugo Date: Fri, 15 May 2026 18:19:39 +0200 Subject: [PATCH] =?UTF-8?q?feat(halt-self-feedback):=20M003=20S03=20?= =?UTF-8?q?=E2=80=94=20HaltWatchdog=20self-feedback=20integration?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit T01: Added integration test auto-halt-self-feedback.test.mjs that proves: - HaltWatchdog.check() creates a self-feedback DB entry with kind=runaway-loop:idle-halt, severity=high, blocking=true - Markdown projection (.sf/SELF-FEEDBACK.md) is regenerated - Deduplication works (one entry per idle period) - New heartbeat resets and creates a new entry for the next idle period T02: Enhanced evidence string to include elapsedMs, iteration, and thresholdMs explicitly (R003 actionable context requirement). Tests: 36/36 pass across auto-halt-self-feedback, auto-halt-watchdog-notify, and self-feedback-db suites. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- src/resources/extensions/sf/auto/loop.js | 2 +- .../extensions/sf/tests/auto-halt-self-feedback.test.mjs | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/resources/extensions/sf/auto/loop.js b/src/resources/extensions/sf/auto/loop.js index e3c60140e..326175431 100644 --- a/src/resources/extensions/sf/auto/loop.js +++ b/src/resources/extensions/sf/auto/loop.js @@ -175,7 +175,7 @@ export class HaltWatchdog { kind: "runaway-loop:idle-halt", severity: "high", summary: `Autonomous loop stuck — no heartbeat for ${Math.round(elapsedMs / 1000)}s at iteration ${iteration}`, - evidence: `Last heartbeat at ${new Date(this.lastActionTimestamp).toISOString()}; threshold ${this.thresholdMs}ms`, + evidence: `Last heartbeat at ${new Date(this.lastActionTimestamp).toISOString()}; elapsed ${elapsedMs}ms; threshold ${this.thresholdMs}ms; iteration ${iteration}`, }, this.basePath, ); diff --git a/src/resources/extensions/sf/tests/auto-halt-self-feedback.test.mjs b/src/resources/extensions/sf/tests/auto-halt-self-feedback.test.mjs index aa7e8e837..74ec40929 100644 --- a/src/resources/extensions/sf/tests/auto-halt-self-feedback.test.mjs +++ b/src/resources/extensions/sf/tests/auto-halt-self-feedback.test.mjs @@ -65,7 +65,9 @@ test("HaltWatchdog.check()_when_idle_exceeds_threshold_creates_self_feedback_db_ assert.equal(entries[0].blocking, true); assert.match(entries[0].summary, /iteration 42/); assert.match(entries[0].summary, /no heartbeat for/); + assert.match(entries[0].evidence, /elapsed/); assert.match(entries[0].evidence, /threshold 10ms/); + assert.match(entries[0].evidence, /iteration 42/); const markdownPath = join(testDir, ".sf", "SELF-FEEDBACK.md"); assert.equal(existsSync(markdownPath), true);