Expand description
Hash-anchored line identifiers — the shared spine of anchored editing (epic #1008 / GL#1009).
Each source line is tagged with a short content hash so an agent can edit
“by reference” (line number + hash) instead of reproducing the exact old
text byte-for-byte (the str_replace exact-recall tax). The anchor format
is N:hh|content — N = 1-based line number, hh = the first
ANCHOR_HASH_LEN hex chars of blake3(trim_end(line)).
Two design choices make anchors safe and cheap:
- Whitespace-tolerant: the hash is computed over the line with trailing whitespace trimmed, so re-indentation or a stray trailing space does not spuriously invalidate an anchor while still pinning the meaningful content.
- Determinism-native (#498): an anchor is a pure function of the line’s
bytes, so
ctx_read(mode="anchored")is byte-stable across identical re-reads and provider prompt caching still applies.
This module is the single source of truth for the hash + rendering so the
read side (crate::tools::ctx_read) and the edit side
(crate::tools::ctx_patch) can never compute anchors differently.
Constants§
- ANCHOR_
HASH_ LEN - Hex chars of the per-line BLAKE3 digest carried in an anchor.
Functions§
- annotate
- Render
contentas anchored linesN:hh|text, numbering fromstart_line(1-based). Pure function of(content, start_line)for determinism (#498). - hash_
matches - Whether
providedis the anchor hash ofline(case-insensitive, trimmed). - line_
hash - The anchor hash of a single line.