The loop book
A loop’s state is a file of entries, and every phase is computed from it. The agent declares only what the extension cannot observe; everything else is read from evidence.
The first todo create opens an inline loop, and a kind call opens or changes one.
How a loop opens, and what the agent declares
The first todo create opens an inline loop: its intent is the first todo’s subject, and its anchor is a Reality anchor: line or the todo’s metadata.anchor.
A kind call also opens or changes a loop.
Task records need the todo tool of @juicesharp/rpiv-todo, whose tool_result details {tasks, nextId} and rpiv-todo-state entries the book reads.
The agent declares only what the extension cannot observe, with anchorloop_stage:
kind: to choosequick,reviewed, ordurable, with an intent and the anchor command; changing a kind the agent chose takes areason.verify: a check not run in bash.fresh-read,friction(tried,found,led_by), andreflect.skipandback.close, and the queryread.
The book also records each todo with its anchor, ref (<path>#<heading>, resolved to line ranges), and followup metadata.
Where books live, and how they end
One YAML book per open loop lives under ~/.pi/agent/anchorloop/books/; ANCHORLOOP_BOOKS_DIR overrides the directory, and empty project and agents/ directories are removed.
Subagent books live under agents/; a child that closes keeps its book for the main session.
session_start sweeps books whose session is gone or that have not changed in 7 days.
Its notice gives one line of counts (open books of this project, stale books deleted), the three newest open books, and the directory holding the rest.
close answers closed (landed). Clear the todo list., adding only the phases not shown complete and the unreflected friction.
It never refuses over phases or friction.
It refuses only while a pending or in-progress todo lacks metadata.followup: a ticket id, memory, or drop — <reason>.