Skip to main content
A mark holds one fingerprint per side. A claim is fresh only while the current fingerprint of every side is byte for byte equal to the one in some mark. Whether an edit stales a claim is therefore a question of whether it changes a fingerprint. A fingerprint looks like b3:ast-v1:fb3a4a42c90a9093fe98969b8a0018c0: the hash function (BLAKE3), the profile that normalized the text, and the first 16 bytes of the digest in hex.

Prose and plain text: prose-v1

Used for prose units (sentences, headings, list items, table rows, fenced blocks), for blocks of plain text, and for the whole-file unit of a file that has no syntax tree. The text is normalized to Unicode NFC, every run of whitespace becomes one space, and the result is trimmed. So re-wrapping a paragraph or changing indentation does not stale a claim. Changing any word, number or punctuation mark does.

Code: ast-v1

Used for declarations and top-level statements of TypeScript, TSX (and JavaScript), Python, Rust, Go and Java, and for the whole-file unit of a code file that parsed without error. The fingerprint is a hash of the unit’s syntax tree, not of its text. In short: reformatting that changes only whitespace, line breaks, comments or a trailing comma keeps the fingerprint the same, so a claim that anchors a declaration by name (#name or #name::<line>) stays fresh. The one line break that counts is a Python backslash continuation. A bare quote is different, because it is found by the text right around it inside its unit. Such an edit near the quote makes the side missing (not_exact), with the unit as a candidate: a comment inserted inside the quoted text, a comment or whitespace inserted between two tokens with no whitespace between them within 48 characters of the quote, a TSX {/* */} removed, or a trailing comma removed next to the quote. A comment or whitespace added right at the edge of the quote, between the quote and the token next to it, changes nothing; the same edit one token further away makes the side missing. A changed run of whitespace has no effect. Such an edit never makes a claim fresh that should be stale. A formatter that changes semicolons, quote style or parentheses stales claims, and each stale claim needs a re-check and a mark.

Examples

This Rust file was reformatted: the constant split over two lines, a comment added after it, and the function signature spread over three lines with a comment in its body:
The claim on it stayed fresh:
output
In TypeScript, splitting sum(a: number, b: number) and return [a, b]; over several lines with trailing commas left its claim fresh. Wrapping the returned array in parentheses, return ([a, b]);, made it stale:
output

A file that does not parse

A code file whose syntax the built-in grammar cannot parse cannot be anchored until it parses. Every side on it, whatever its anchor (a name, a quote or the whole file), is unavailable with reason resource_unavailable. The message names the line where the parser reports its first error. The mistake itself can be before or after that line, and by many lines. In this file the string on line 4 is not closed:
src/Conf.java
The parser reports line 1:
output
A new anchor on such a file fails like this until the file parses. For a side of a claim that exists, the side’s remediation repeats the message and gives the whole commands to move on without the file: for evidence, one that anchors the side to another resource and one that drops it; for the subject, one that re-points it and one that retires the claim. next is null, because no hibi command fixes a syntax error. Here src/size.ts has a claim on the whole file and one on a quote inside the declaration SIZE, and a syntax error was added on line 2:
output
A quote on top-level code, outside every declaration, is no different:
output
A new anchor on such a file fails:
output
cover reads no units from it and lists it as unavailable:
output
Fix the syntax error and every side on the file resolves again, with the marks it had:
output
If a file will never parse, for example because it uses syntax the grammar does not know, exclude it from the scope in .hibi/hibi.toml and anchor its statements elsewhere. An exclusion without unit means the file is not read at all (see coverage):
output
Two fingerprints of different profiles are never compared. profile_mismatch occurs when a later hibi ships a new profile version, and when an external provider changes the profile name it puts in its fingerprints. Renaming a file, also to another extension, is not a profile mismatch: the locator names the old path, so the side is missing and next asks for a new anchor. Renaming src/lim.rs to src/lim.py gives:
output

Versioning

The grammar versions are part of ast-v1. A hibi release that changes a grammar or a rule of the tree hash must use a new profile name, so the change shows as profile_mismatch instead of silently staling or freshening claims. hibi version lists the profiles and grammar versions of the build:
output