Skip to content

Detect hand edits to generated files before overwriting them - #21

Merged
adityaramkumar merged 1 commit into
mainfrom
claude/drift-detection
Oct 22, 2026
Merged

adityaramkumar merged 1 commit into
mainfrom
claude/drift-detection

Conversation

@adityaramkumar

Copy link
Copy Markdown
Owner

Summary

Before this change, a hand fix to a generated file was silently erased on the next rebuild. The hash map recorded which files a spec produced, but not what was in them.

  • HashMapEntry gains output_hashes: the SHA-256 of each generated file as written. hashmap.modified_files() reports files whose contents changed since then. Deleted files aren't counted, since deleting them loses nothing.
  • build refuses to regenerate a node with edited output and lists the files. The check runs before any LLM call. --force overwrites.
  • status lists edited files under the table, and clean warns before deleting them.
  • Older hash-map.json files without output_hashes load unchanged and start tracking on their next build.

Testing

  • pytest tests/: 269 passed (7 new tests across hashmap, runner and CLI)
  • ruff check / ruff format --check: clean

Generated by Claude Code

Record a SHA-256 of each generated file in the hash map. build refuses
to regenerate a node whose output was edited since the last build
(before any LLM call) unless --force is passed; status lists edited
files and clean warns before deleting them. Older hash maps without
output_hashes load unchanged and start tracking on their next build.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FAykpfqqWA2GFjcC1p6FRy
@adityaramkumar
adityaramkumar merged commit 315b07e into main Oct 22, 2026
2 checks passed
@adityaramkumar
adityaramkumar deleted the claude/drift-detection branch October 22, 2026 01:42
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.

2 participants