fix: resolve silent Write failures in background memory updater#94
Merged
fix: resolve silent Write failures in background memory updater#94
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
--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" becauseclaudeexits 0 regardless.--toolstoRead,Write,Bashwith scoped--allowedTools— adds Read permission for memory files, read-only git commands for fresh context, and a Read instruction in the prompt template./dev/nullso model output is captured for debugging.Changes
scripts/hooks/background-memory-updateCLAUDE.mdTest plan
npm run buildpassesnpm test— all 185 tests pass.memory/WORKING-MEMORY.mdmtime updated.memory/.working-memory-update.logshows "Update completed" (not "file was not modified")