The session loop
1
Start with status
status lists the stale and expired claims. For each one it
lists the sides that are not the same as at the mark, with a state and a
reason, and a next command. A side that cannot be found exactly also
lists candidates: units it could mean, each with an anchor, or with none when
the unit is identical, where it stands, to another unit. Add --detail to
include the current text of every side:2
Re-check each listed claim
Read the statement, then read what changed. For a
changed side,
status prints the unit’s text as it is now, and
hibi status --detail <id> prints the text of every side. That is the
current text, not a diff. To see the change itself, run git diff on
the side’s path for an edit that is not committed, or git log -p on it
when the change is committed. mark prints the text it accepted, as
“evidence 1 is now:” followed by the lines. Decide whether the statement
still holds against that text. Never mark several claims at once without
having read each change.next is what to run when the statement holds; it is not a verdict.
When a listed claim’s next is mark or reanchor, hibi prints the
reminder once per run: “Re-check each statement before
running its next command. If it no longer holds, fix the text or the
code, or retire the claim with hibi retire.”3
Re-anchor a side that no longer identifies its unit
A stored anchor identifies its unit by name or by place. A
#name
follows the declaration with that name while the name refers to as many
declarations as when the claim was made. A quote follows its words in
their container (the heading and paragraph, or the enclosing
declaration), with the text right around them unchanged. Anything else
makes the side missing (not_exact, or selector_not_found when the
anchor matches nothing where it points) or ambiguous, usually with
candidates:- the quoted words of a sentence, or the words right around a quoted phrase, were edited;
- the first 120 characters of the paragraph’s first sentence were edited, or the heading renamed;
- the sentence moved out of its paragraph or section, which keeps its
name (then the reason is
selector_not_found, with the sentence as a candidate); - the function around a quote was renamed;
- a name now has a second declaration.
next with its anchor, for example
hibi reanchor <id> --subject <anchor>. If the statement no longer
holds, fix the text or retire the claim. The right unit may not be among
the candidates: a function renamed while the claim names it with
#name, or one moved to another file, is not listed. Find it yourself and give its anchor. mark refuses a claim
with such a side, so the claim never silently follows a guess.mark is the step for a changed side: a declaration edited under its
#name, or a long sentence edited away from its quote. When the line of
a #name::<line> anchor was edited, the side is changed with
“the stored quote is no longer in this unit”, next is a reanchor,
and mark refuses it: give the new line. An edit to a neighbouring
sentence leaves the claim fresh, unless it is the paragraph’s first
sentence.4
Record what you found
5
Claim what you checked
When you write or verify a statement during the session, record it with
hibi claim right after the check, while the evidence is in front of
you.6
Look for gaps
--since lists only
units whose key and content are new since the base, so a sentence copied
within its file, with the original then edited, is not listed even when
no claim covers it. After copying text, run hibi cover without
--since. A unit that states
nothing checkable can be excluded in .hibi/hibi.toml with a reason;
exclusions are visible in every cover report, so agree on them with the
user.7
Before you finish
hibi status is the complete check. Resolve what they list, then commit
.hibi/ with the change.Reading next
next is one command line, or null. It is a template and is not
shell-quoted. Replace each <anchor> before you run it, quoting the anchor
for your shell, because a shell reads < and > as redirections. A fix
line that repeats a reanchor command quotes the arguments you gave for a
POSIX shell, and can hold <anchor> or <text>, which you replace the same
way. Commands that hibi prints, in
next and in fix lines, assume the same working directory and the same
--root as the command that printed them; add --root yourself when you
used it. hibi picks the first row that
applies:
next never contains a candidate. Where a side has to be anchored again it
says <anchor>, and you choose the anchor after reading the candidates.
Here the sentence was reworded from “doubles each time” to “doubles every
time”. The quoted words changed, so the subject is missing and the reworded
sentence is listed as a candidate:
output
mark refuses the claim, because its subject resolves to no unit:
output
output
status no longer lists it:
output
JSON for agents
In an agent’s shell tool standard output is not a terminal, so each command prints one JSON object, excepthibi completions, hibi schema <name> and
--help, which print text. The fields an agent reads from status:
sameFingerprint is true when the candidate’s content equals the content
at the reference mark: the unit has the content that was checked, at
another place or under another path, for example a sentence moved to
another paragraph or a field whose struct was renamed. Content alone never
identifies a unit, so a copy of the text has true as well. Read the
candidate before you anchor to it. After you re-anchor to it, check that it
is the original and not a copy: look at its line in the file, or run
hibi cover and see whether the original is now uncovered. status cannot
tell you, because the claim is fresh either way.
Every write that adds a mark to an existing claim (claim on an existing
claim, mark, reanchor) reports what it accepted:
"accepted": {"was": <state before>, "sides": [{"index", "role", "loc", "state", "reason", "text"}]},
listing the sides that were not same. text, the whole text that was
marked, is present for a changed side and, from reanchor, for every
listed side the new claim keeps; a side that reanchor drops is listed
without text. For a new claim accepted is null.
In text this is a line such as
was stale: evidence 1 file:src/cache.rs changed (fingerprint_differs); now marked: make sure you re-checked it,
followed by the text of each changed side after “is now:”.
Every result that carries a next also carries nextNote.
Errors are {"ok": false, "command": <command>, "errors": [{"code", "message", "remediation"}]},
and an error from a --stdin element also has its index, with
exit status 1. remediation is text or a command that says how to fix the
cause, or null when hibi has none for that error.
Batches
claim and mark read a JSON array from standard input with --stdin. A
batch is written all or nothing: if any element fails, nothing is written and
every failing element is reported in the same run, each with its index:
output
cover item list carries an anchor object that can be
used as subject as it is, or null when no anchor selects the unit alone. hibi schema claim-input and
hibi schema mark-input print the schemas of these documents.
Who checked
--by (or the by field, or the HIBI_BY environment variable) is free text
stored with a mark for the record, for example agent:claude. hibi never
interprets it.
