mirror of
https://github.com/lukaszraczylo/claude-adam.git
synced 2026-07-08 03:44:31 +00:00
feat(v0.6.1): file_reread signal — catch offset-shifted same-file re-reads
Proposed and approved through ADAM's own /reflect harness_edit loop (MOSS §1): the analyst surfaced 23 tool_error_loop entries across 4 sessions whose context windows were really redundant re-reads of one file. retry_loop keys on argsHash of the full tool_input (including offset/limit), so consecutive Reads of the SAME file at different offsets escaped dedup and leaked into tool_error_loop fingerprints. The new file_reread signal catches them: same file Read >=3x in the 10-event window, offset-agnostic (keyed on file path), guarded by `sameToolArgs < RETRY_THRESHOLD` so byte-identical reads stay with retry_loop (no double-count). Fully wired end-to-end (not a half-dead signal): - adam-observe.mjs: detection + STRUGGLE_TYPES membership (so it carries context_window + active_skills like other struggle signals). - adam-window.mjs: 14-day sliding window (task-local, like retry_loop). - adam-score.mjs: severity divisor 3. - adam-batch.mjs: file-basename clustering. - agents/adam.md + README: signal tables, clustering rules, rubric, windows. Tests: 126 -> 132 (file_reread fires on 3x offset-shifted reads, not on 2x; byte-identical reads route to retry_loop not file_reread; carries context_window).
This commit is contained in:
@@ -1990,6 +1990,30 @@ else
|
||||
fi
|
||||
rm -f "$ROOT/rejected/2026-blk-31.md"
|
||||
|
||||
# --- Test 110: file_reread fires on 3x offset-shifted same-file reads, not 2x ---
|
||||
echo "Test 110: file_reread (offset-shifted same-file reads escape retry_loop)"
|
||||
reset_state
|
||||
for off in 0 100; do
|
||||
echo "{\"hook_event_name\":\"PostToolUse\",\"tool_name\":\"Read\",\"tool_input\":{\"file_path\":\"/tmp/big.go\",\"offset\":$off},\"tool_response\":{\"content\":\"ok\"},\"session_id\":\"sFR\",\"cwd\":\"/tmp/x\"}" \
|
||||
| HOOK_RUN >/dev/null 2>&1 || true
|
||||
done
|
||||
assert_no_grep "$ROOT/journal.jsonl" '"type":"file_reread"' "2x same-file reads does NOT emit file_reread"
|
||||
echo '{"hook_event_name":"PostToolUse","tool_name":"Read","tool_input":{"file_path":"/tmp/big.go","offset":200},"tool_response":{"content":"ok"},"session_id":"sFR","cwd":"/tmp/x"}' \
|
||||
| HOOK_RUN >/dev/null 2>&1 || true
|
||||
assert_grep "$ROOT/journal.jsonl" '"type":"file_reread"' "3x offset-shifted same-file reads emit file_reread"
|
||||
assert_no_grep "$ROOT/journal.jsonl" '"type":"retry_loop"' "offset-shifted reads do NOT emit retry_loop (argsHash differs)"
|
||||
assert_grep "$ROOT/journal.jsonl" '"type":"file_reread".*"context_window"' "file_reread carries context_window (in STRUGGLE_TYPES)"
|
||||
|
||||
# --- Test 111: byte-identical reread is caught by retry_loop, not double-counted as file_reread ---
|
||||
echo "Test 111: identical reads → retry_loop (file_reread guard avoids double-count)"
|
||||
reset_state
|
||||
for i in 1 2 3; do
|
||||
echo '{"hook_event_name":"PostToolUse","tool_name":"Read","tool_input":{"file_path":"/tmp/same.go"},"tool_response":{"content":"ok"},"session_id":"sFR2","cwd":"/tmp/x"}' \
|
||||
| HOOK_RUN >/dev/null 2>&1 || true
|
||||
done
|
||||
assert_grep "$ROOT/journal.jsonl" '"type":"retry_loop"' "3x byte-identical reads emit retry_loop"
|
||||
assert_no_grep "$ROOT/journal.jsonl" '"type":"file_reread"' "byte-identical reads NOT double-counted as file_reread (sameToolArgs>=RETRY guard)"
|
||||
|
||||
echo
|
||||
echo "Results: $PASS passed, $FAIL failed"
|
||||
[ "$FAIL" = "0" ]
|
||||
|
||||
Reference in New Issue
Block a user