From 7a4cb8c57030ad5d0b4e6b166bb07a29a6ab034a Mon Sep 17 00:00:00 2001 From: Lidang-Jiang Date: Sat, 28 Mar 2026 23:32:44 +0800 Subject: [PATCH] fix(observer): clean up prompt_file early and fix test for analysis_relpath - Remove prompt_file immediately after shell expansion into -p arg, avoiding stale temp files during long analysis windows (greptile feedback) - Update test assertion to check analysis_relpath instead of analysis_file, matching the cross-platform relative path change from earlier commits Signed-off-by: Lidang-Jiang --- skills/continuous-learning-v2/agents/observer-loop.sh | 5 ++++- tests/hooks/observer-memory.test.js | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/skills/continuous-learning-v2/agents/observer-loop.sh b/skills/continuous-learning-v2/agents/observer-loop.sh index 5df24140..e2cad9af 100755 --- a/skills/continuous-learning-v2/agents/observer-loop.sh +++ b/skills/continuous-learning-v2/agents/observer-loop.sh @@ -134,6 +134,9 @@ PROMPT --allowedTools "Read,Write" \ -p "$(cat "$prompt_file")" >> "$LOG_FILE" 2>&1 & claude_pid=$! + # prompt_file content was already expanded by the shell; remove early to avoid + # leaving stale temp files during the (potentially long) analysis window. + rm -f "$prompt_file" ( sleep "$timeout_seconds" @@ -147,7 +150,7 @@ PROMPT wait "$claude_pid" exit_code=$? kill "$watchdog_pid" 2>/dev/null || true - rm -f "$prompt_file" "$analysis_file" + rm -f "$analysis_file" if [ "$exit_code" -ne 0 ]; then echo "[$(date)] Claude analysis failed (exit $exit_code)" >> "$LOG_FILE" diff --git a/tests/hooks/observer-memory.test.js b/tests/hooks/observer-memory.test.js index 47ffe61d..8f91df40 100644 --- a/tests/hooks/observer-memory.test.js +++ b/tests/hooks/observer-memory.test.js @@ -175,7 +175,7 @@ test('prompt references analysis_file not full OBSERVATIONS_FILE', () => { assert.ok(heredocStart > 0, 'Should find prompt heredoc start'); assert.ok(heredocEnd > heredocStart, 'Should find prompt heredoc end'); const promptSection = content.substring(heredocStart, heredocEnd); - assert.ok(promptSection.includes('${analysis_file}'), 'Prompt should point Claude at the sampled analysis file, not the full observations file'); + assert.ok(promptSection.includes('${analysis_relpath}'), 'Prompt should point Claude at the sampled analysis file (via relative path), not the full observations file'); }); // ──────────────────────────────────────────────────────