You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
E12: Content-hash anchored edits (hashline concept) for edit_file tool #24
When Tole gets an edit_file tool, adopt the hashline concept: every edit hunk is anchored to a content hash of the file, so stale anchors are rejected before they corrupt code.
Why
Adopted from oh-my-pi's hashline package (MIT). The classic edit-by-LLM failure mode: model recalls file content from stale context, patch applies to a changed file, silent corruption. Hashline binds each patch to a 4-hex content hash recorded at read time; on apply, the live file's hash must match or the patch is refused + session-aware recovery offered.
Design sketch
read_file (E7) returns content hash alongside content → model quotes it in edit_file(path, old_hash, ranges, new_text)
edit_file verifies live hash == quoted hash before applying
Mismatch → structured error telling the model to re-read (this is the loop-guard-compatible recovery path)
No new deps: simple content hash (std hasher) is enough at our scale
Acceptance criteria
edit_file refuses when quoted hash ≠ live hash
Matching hash applies cleanly, returns new hash
Model-facing error message instructs re-read
Depends on E7 (read-only file tools) landing first
Tier A tests: stale-anchor refusal, fresh-anchor apply, post-edit hash chaining
Un-parking: E7 tools are merged and E4.5 tool-calling is live-proven, so the edit_file era starts now. Two design decisions vs the original sketch (both strictly better, still zero new deps):
16-hex std hasher (DefaultHasher) instead of 4-hex — better collision resistance, still no new dependencies. Hash lifetime is a single session so cross-version hasher stability is irrelevant.
old_text -> new_text replacement instead of line ranges — anchors on content, not line numbers (line numbers rot when the model's context is stale; exact text match is the same evidence as the hash anchor). old_text must match exactly once; 0 or 2+ matches are actionable errors.
The model-facing stale-anchor error instructs a re-read, which is the loop-guard-compatible recovery path.
Activity
ajianaz commentedon Aug 27, 2026
Un-parking: E7 tools are merged and E4.5 tool-calling is live-proven, so the
edit_fileera starts now. Two design decisions vs the original sketch (both strictly better, still zero new deps):DefaultHasher) instead of 4-hex — better collision resistance, still no new dependencies. Hash lifetime is a single session so cross-version hasher stability is irrelevant.old_text->new_textreplacement instead of line ranges — anchors on content, not line numbers (line numbers rot when the model's context is stale; exact text match is the same evidence as the hash anchor).old_textmust match exactly once; 0 or 2+ matches are actionable errors.The model-facing stale-anchor error instructs a re-read, which is the loop-guard-compatible recovery path.