Expand description
Re-anchoring resolver for durable review threads.
A persisted ReviewAnchor stores a drift-robust location (path +
side + line + content hash + a few context lines). The diff is
re-scanned on every overlay open, so the anchor must be re-resolved
to a fresh positional index into the new FileHunks.
resolve_anchor reports whether the line is still in place, moved,
or could not be placed at all.
Relocation requires one unambiguous match: the line, plus at least
one recorded neighbour agreeing within CONTEXT_RADIUS on each
side the candidate has neighbours. Anything less is left where it was
and marked outdated, because a comment silently attached to the wrong
code costs far more than one the reviewer has to go looking for.
A distance bound does not make that safer. Bounding how far a match may be found still leaves several candidates inside the bound, and choosing among them by proximity is exactly the guess uniqueness refuses to make.
Enums§
- Anchor
Placement - One anchor’s landing in the terms a view draws it: no positional indices into one scan’s arrays, just the line the anchor sits on now and, when it could not be placed, the resolver’s own reason.
- Anchor
Resolution - Where a re-resolved anchor landed against a fresh diff scan. Indices
address
files[file_idx].hunks[hunk_idx].lines[line_idx]. - Outdated
Reason - Why an anchor did not relocate. Attaching a comment to the wrong code costs more than leaving it behind, so anything short of one certain match lands here rather than being guessed at.
Constants§
- CONTEXT_
RADIUS - Lines captured on each side of an anchored line for fuzzy re-anchor disambiguation.
Functions§
- anchor_
hash - The hash to persist for a newly captured anchor. Whitespace-normalised
so a
cargo fmtreflow reads as the same line. - capture_
context - Capture up to
radiuslines on each side ofline_idxwithinhunk(excluding the line itself) as fuzzy-match context. - content_
hash content_hash_bytesover a diff line’s text.- content_
hash_ bytes - FNV-1a hash of raw bytes: what both a line’s text and a whole document go through, so one implementation pins both.
- place_
anchor_ in_ content resolve_anchor_in_content, narrowed to what a view draws.- place_
anchor_ in_ lines - One seat-tree anchor placed against a file’s whole current lines - the
files page’s resolution. The scope’s numbering IS the file’s own (the
seat’s tree is where the comment was written), so unlike a diff scope
whose numbering may belong to another base, the recorded line is
trusted: in place when it still carries the anchor’s text, otherwise
re-found by content plus neighbours, and
Gone/Ambiguousas the diff resolver reports them. - place_
anchor_ in_ lines_ with - The whole-file placement with the diff resolver’s trust rule: with
trust_line_numberthe recorded line is evidence too, because the file handed in is numbered the way the anchor was written; otherwise the match is earned by content and neighbours alone. - place_
document_ anchor - A document anchor placed against the document’s whole current lines: the thread’s FIRST captured line is the key, looked for by content.
- resolve_
anchor - Re-resolve
anchoragainst a freshfilesscan.trust_line_numbersays whetherfilesis numbered the same way the anchor was recorded in. Only then does the recorded line carry information; from another scope’s diff that number addresses whatever happens to sit there, so the match has to be earned by content and neighbours like any other. - resolve_
anchor_ in_ content - Re-resolve
anchoragainst the socket’s bounded content read, whose files carry hunks but not the overlay scan’s own shape. Same resolution asresolve_anchor, one implementation.