Skip to content

fix: resolve silent Write failures in background memory updater#94

Merged
dean0x merged 1 commit intomainfrom
fix/memory-updater-write-failure
Mar 8, 2026
Merged

fix: resolve silent Write failures in background memory updater#94
dean0x merged 1 commit intomainfrom
fix/memory-updater-write-failure

Conversation

@dean0x
Copy link
Owner

@dean0x dean0x commented Mar 8, 2026

Summary

  • Root cause: Claude Code enforces Read-before-Write on existing files, but the background updater only had --tools "Write". Every Write attempt failed silently with "File has not been read yet" (confirmed 758 times in debug logs over 5+ days), while the script logged "Update completed" because claude exits 0 regardless.
  • Fix: Expand --tools to Read,Write,Bash with scoped --allowedTools — adds Read permission for memory files, read-only git commands for fresh context, and a Read instruction in the prompt template.
  • Observability: Add post-write mtime validation to detect silent failures, and redirect stdout to the log file instead of /dev/null so model output is captured for debugging.

Changes

File What
scripts/hooks/background-memory-update Expand tool permissions (Read, Write, Bash), add mtime validation, redirect stdout to log, prepend Read instruction to both template branches
CLAUDE.md Update hook permission description

Test plan

  • npm run build passes
  • npm test — all 185 tests pass
  • Manual: trigger Stop hook, wait ~30s, verify .memory/WORKING-MEMORY.md mtime updated
  • Manual: check .memory/.working-memory-update.log shows "Update completed" (not "file was not modified")

Claude Code enforces Read-before-Write on existing files, but the
background updater only had Write permission. Every Write attempt
failed silently ("File has not been read yet") while the script
logged "Update completed" because claude exits 0 regardless.

- Expand --tools to Read,Write,Bash with scoped --allowedTools
- Add Read permission for both memory files (critical fix)
- Add read-only git commands for fresh context
- Prepend Read instruction to both INSTRUCTION template branches
- Add post-write mtime validation to detect silent failures
- Redirect stdout to log file instead of /dev/null for debugging
- Update CLAUDE.md to reflect expanded permission model
@dean0x dean0x merged commit e701cec into main Mar 8, 2026
4 checks passed
@dean0x dean0x deleted the fix/memory-updater-write-failure branch March 8, 2026 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant