Source-anchor resolution and freshness

Source-anchor resolution and freshness A sequence diagram generated by Archify. Capture draft evidence Captured bytes or read error Validate anchors against the snapshot Load this anchor's file Source bytes or absence If hash passes: parse and scope Syntax and optional symbol range Resolved anchors or explicit refusal Confirm draft evidence is current Unchanged source or stale error Story validator · Sequence participant · The CLI's validateStory operation, invoked by topo story validate, needs to establish whether a draft's anchors still identify current code. It checks the draft structure, captures referenced files, delegates anchor resolution, then rechecks bytes and Git state before returning the resolved document. This is draft validation, not rendering or publication. These are explicit checkpoints, not a continuously held source-code lock. Valid anchors do not establish the explanation's semantic truth. Story validator Source snapshot · Sequence participant · captureSourceSnapshot deduplicates and sorts paths, then reads regular files with path, symlink, inode and modification checks. The captured map provides bytes (or absence) to the resolver. assertSourceSnapshot rereads and compares those bytes. Source changing during capture or after capture causes an explicit error. The reader/map are grouped as a data boundary, not a network service. Source snapshot Anchor resolver · Sequence participant · resolveStoryDocument checks each path and refuses absent source. resolveAnchor checks a supplied whole-file SHA-256 BEFORE parsing, establishes a file or symbol scope, then finds the exact authored pattern and derives current lines/excerpts. Unscoped patterns must be unique. Missing symbols/patterns and stale hashes are errors. There is no fuzzy matching or automatic repair of renamed/moved code. Without a pattern, the selected file/symbol range is returned. Anchor resolver Language lookup · Sequence participant · TypeScript/JavaScript anchors use an AST walk for the first declaration with the requested identifier; this is not the full type-checker resolution used by scanning. Rust delegates to its lexical/parser-backed symbol resolver. Text anchors do not accept symbol lookup. The parser returns syntax/range information. Exact snippet matching and final source locations belong to the anchor resolver. Language lookup