Skip to main content

Module anchor

Module anchor 

Source
Expand description

Code anchors (C0 1.9): where in the code a fact, or a piece of task evidence, applies.

An anchor names a repo-relative path, optionally a symbol in it, and the digest of what it covered when it was written. The engine resolves anchors against its local code graph; Cloud only stores them.

The digest (section 3) is anchor_digest of the covered bytes: the exact bytes of the symbol’s syntax node (without the comments before it), or of the whole file without a symbol, normalized by normalize_anchor_content. vectors.json → anchor_digest holds the reference cases every implementation reproduces.

Structs§

CodeAnchorV1
One code anchor.

Constants§

MAX_ANCHORS
MAX_ANCHOR_PATH_BYTES
MAX_ANCHOR_SYMBOL_CHARS

Functions§

anchor_digest
sha256: + lowercase hex of the normalized content.
normalize_anchor_content
The covered content as it is hashed: a leading UTF-8 byte-order mark dropped, every \r\n and lone \r turned into \n, and trailing spaces and tabs removed from every line. Nothing else changes: indentation, blank lines and the final newline (or its absence) stay.
validate_anchor_path
A repo-relative, /-separated path without . or .. segments (the rule for anchors and, 1.9 section 8, the code graph). 1.9 R3: no : (drive letters, alternate data streams) and no invisible format characters.
validate_anchors
A list of anchors: at most MAX_ANCHORS, sorted by (path, symbol) (no symbol first), without repeats.