Repository navigation
Conversation
What a read-only reviewer checks, in order, against the section of AGENTS.md that owns each rule; the question of silent acceptance; and how a finding and a report are written. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
scripts/agent-review/review.py runs Claude Code's /code-review in a fresh `claude -p` session and Codex in a fresh `codex exec` run on one commit, with the models and the effort pinned in the script alone, and saves each review outside the tree. With --stage, each run is a task of the branch's Yard Log. --probe checks that the Claude reviewer can call nothing but Agent, Bash, Read and Skill, with no MCP server, and that the Codex sandbox refuses a write. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… default Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…is asked The sequence from self-review and /simplify through two parallel read-only reviewers to the verified findings a person picks from; the pinned models and effort; what the reviewers are given; how the runner is driven and its setup checked; how a round is recorded; and how a review comment that states a general rule becomes guidance. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
AGENTS.md states the two rules and points at the procedure, the checklist and the runner; the sentence that kept a review from building or testing now names the reviewer, since the author verifies findings with focused tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A probe passes only when the reviewer ran (a Codex that never started wrote nothing either, and a Claude session that never answered still printed its start event); a review left by an earlier run on the same commit no longer passes for a failed one; a branch with no change against its base is refused rather than reviewed as empty; and the runner reads on the system's older Python. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… class The read-only rule lives in AGENTS.md, the review criteria in the checklist, the models and the effort in the runner's constants; the procedure and the prompt point at them instead of repeating them. The runner gives Claude and Codex a class each, builds each prompt once so that --dry-run prints what is sent, takes the allowed commands from the reviewer settings, enforces the effort floor through --effort, and runs the probe's two checks at once into files of their own, so that a probe no longer overwrites a saved review. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…de's tokens The task names the saved review by its file name alone, not by its path on the machine. The tokens of a Claude run are summed from each model's counts in modelUsage, since the top-level usage of a print-mode result reads zero. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…diff, and probe for real The runner reviews the checked-out commit of a clean tree against its base, and names both commits in the diff the reviewers are told to run. A run counts as a review only when its stream shows that exact diff run with success: Claude's in stream-json, Codex's in its command items. Each invocation has its own files and Yard tasks; each run records its end as it ends, and any failure becomes its task's reason rather than a traceback; a Yard write refused exits 1, and a --stage without loft, or without a host and session to write as, is refused. The host is inferred from the environment it runs in. A Codex error counts only when no turn completed, and git that cannot compare the commits is a usage error. The probe shows each refusal: Claude must try a write that dontAsk denies, asked without the read-only rule, which makes a model decline to try; Codex's read-only sandbox must refuse a write and allow a read, tried without a model, since codex exec shows no event for a command the sandbox refused. Both probe paths are new to the probe, so no file of the tree is removed. The runner is now review.py (the command), reviewers.py (the two reviewers) and probe.py. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CONTRIBUTING.md points at the agent review and the template's record of it; the checklist lists the changed files over the range reviewed; review.md runs the runner on the clean checked-out commit, names --host and the probe's --out, says what the probe proves, and says that the page's token totals do not count the reviewers yet. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s and CI The runner's tests run on fixture output alone and reach no reviewer: a run counts only when it read the round's diff, output it cannot read fails the run without raising, a Codex stream error followed by a completed turn is no failure, each invocation has its own files and task with no path of the machine in it, a refused Yard write is reported, git that cannot compare is no change, the host comes from the environment, and each probe passes only on a refusal it saw. They run on the system's Python 3.9 as on newer ones, and join the gates and CI. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…for the exact refusal A run reads the round's diff only when it ran exactly `git diff <base>...<head>`, unwrapped from Codex's shell: statistics, a path filter or a pipe no longer count, and /code-review is pointed at the commit range rather than the branch name. The tree, read with its untracked files whatever git's configuration hides, is checked again as each run ends, and a run during which it moved fails; when the branch itself changed, its task is not finalized into another branch's Yard Log. The records say no more than happened: a failed run's text is kept as -failed.md, Claude's task is assigned to its reviewer's session again, a reason names no directory of the machine, both hosts' variables set is a host to name rather than guess, any git exit but 0 or 1 is a failure to compare, and an empty --stage, or one beside --probe or --dry-run, is refused. Each run's files are reserved by exclusive creation, so no run overwrites another's. The probe requires the exact refusal: the denied Bash call that is its touch, and the sandbox's own words for a refused write, under an empty Codex home as the review ignores the user's configuration. Each probe writes only in a directory it created. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nd document the recheck Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A task assigned to a reviewer's session is written by its stage's owner alone, so a stage that is missing or someone else's is now a usage error before either reviewer starts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…cannot read it moved() gives a kind beside its words, so finish() decides by kind rather than by the start of a message: a run that ended on another branch, or on a tree git could not read, writes nothing to Yard Log. finish() is tested for each case. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The probe's turn is no review, so it no longer writes under names of --out, where it left a -failed.md beside the reviews and could overwrite one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…han cut paths A reason recorded in Yard Log has the output directory, the tree and the home directory, in each spelling the system gives them, replaced by <out>, <tree> and ~. The pattern it replaces mangled relative paths and addresses, and kept a user's name in a two-part or spaced path. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ndbox's wording A touch that could not start, which also writes nothing, exits otherwise and fails the probe, and a sandbox whose refusal reads in another language no longer does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Its files are reserved in --out alone, so a suffix two output directories share would name one Yard task for two runs; a longer suffix leaves that to chance alone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s fail without their fixes The stubbed git hides untracked files unless asked for all of them, as a configured git would, and each --stage refusal is checked by its own words rather than by exit 2 alone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…als, and the residual risks The tree is checked at a run's two ends, so the author leaves it alone meanwhile; --stage names the author's own stage, and the script's refusals and the task a branch switch leaves active are described; a new section lists what the runner does not catch, by choice. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A run no Loft hook sees, such as a reviewer a script starts, is recorded by a task assigned to its session; loft yard usage counts its requests toward that task's stage, through the page server or, without one, under its lock, and counts each event id once. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… Codex's 32 KiB Codex loads at most 32 KiB of a project's instructions and drops the rest, which cut off the Review section and everything after it. The release steps, needed only at a release, move word for word to docs/contributing/releasing.md, AGENTS.md keeps a pointer to them, and a guard fails once AGENTS.md is longer than Codex loads. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A run that no Loft hook sees, such as a reviewer a script starts, is recorded by the task assigned to its session: each request becomes a model request's event naming the task, posted to the page server while one runs, else recorded as the page server records it, under its lock. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each run keeps its requests by model, its task is assigned to the reviewer's session once that is known, and after its end is recorded the script counts the requests toward the stage. A loft without the command leaves the tokens in the task's text and says so. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s for The command records as the page server does, and the server's module already uses the commands, so living among them made a cycle and widened their directory past fifteen entries. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A closed turn per run, a re-recorded untimed request keeping its first time, a waiting second recorder, the number counted taken from what was new, and refusals for unknown count names, repeated event ids, another working tree, a newer or merge-closed Yard Log and a batch kept in part. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The run is recorded as one turn of its session's main agent. A second recorder waits for the lock, and both paths check the page server's answer and name each request not kept. The number counted leaves out requests recorded before, and an untimed request keeps its first time. The command refuses unknown count names, repeated event ids, a session working in another tree, and a newer or merge-closed Yard Log, and keeps the store's error kinds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…n's tokens Each run sends its start, its end and its requests timed at its end, so that loft shows it as a closed turn and a repeat counts once. A failed Claude result's usage is read before it is judged, a failed task names its tokens, and only an unknown command falls back to the task's text. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every request names its time, a batch kept in part has the outcome partial, a recorder waits despite a stale server.json, fractional seconds count as their second, and unknown fields and a time outside the run's span are refused. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… answer The page server's answer now lists the events it held before, so loft yard usage counts the new requests from it on both paths and reads no event log of its own. Every request names its time. A batch kept in part has the outcome partial. A failed post waits for the lock again, the whole answer is checked, the task is checked again under the lock, and Yard Log is read settled. Turn ids name the run's requests, and unknown fields, a time outside the run's span, and a null time are refused. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ount, and ask for the exact diff A reviewer runs the exact diff even when it is large and reads its saved output, the docs say when the script exits 1 for a count, and they say when each task is assigned. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An older page server is refused, and recording adds no revision to Yard Log but for a settling. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
loft yard usage refuses a page server of an older loft, or an answer that does not name the events it held before. It waits 30 s for an answer, and never posts again what may have arrived. The page server lists a session file it could not write apart from the events it rejected. A rejected turn or an unwritten file is a warning, only requests make a run partial, and each skipped request is named. A time needs digits after its point, and the document is read before a settling. The network module's tests move to their own file to keep it within the line ceiling. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nts whole A Claude review that saved the exact diff to a file and read it counts as a review. A model with no count of its own is left out rather than emptying the document, a flag is no count, and a run that reports no tokens per model says so. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… the moved network tests Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…usage, and fit AGENTS.md to Codex's budget Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The browser test of a copied link's words found the paragraph in one round trip and selected it in another. The page draws its pane anew at each change, so a redraw between the two left a paragraph out of the page, whose selection holds nothing, and the test failed now and then. It now finds and selects the paragraph in one page call, polled until the page settles. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
swindler
left a comment
There was a problem hiding this comment.
Three important findings from a review of this PR, inline below. Minor nits are left out.
| // before anything is posted to it. Under the lock, Yard Log is read again, since its task | ||
| // may have changed while the command waited. | ||
| let check = |server: Option<&page::Running>| match server { | ||
| Some(running) if discovery::against_ours(&running.version) == Ordering::Less => { |
There was a problem hiding this comment.
A second loft yard usage can refuse when no page server is running at all, instead of waiting.
record() runs this older-version check on whatever page::quiet returns. While another recorder, a starting server or loft yard upgrade holds the lock, running() still reads a leftover ~/.yard/server.json. If that file names an older (or unreadable) version, check(Some(&running)) returns the refusal at once, without ever trying the port.
Scenario: loft is upgraded, and the last 2.4.x page server has stopped, leaving server.json at 2.4.4. Two reviewers in review.py finish together. Recorder A takes server.lock and writes. Recorder B gets the stale 2.4.4 entry, is told to restart a page server of an older loft, and exits 1. One reviewer's tokens are never counted and review.py exits 1. This breaks the criterion that a second loft yard usage waits where server.json names a page server that no longer runs.
Suggested fix: decide liveness first. If a post to that port is Unreached, keep waiting as the stale-server path already does, and refuse an older version only once a server actually answers on the port.
There was a problem hiding this comment.
Fixed in 2e242e6. Before refusing a page server of an older loft, the recorder posts an empty list of events, which records nothing, to the port server.json names. It checks the version only once a server answers there. An unreached port is waited out like a lock that names no page server, so the second recorder in your scenario records once the first frees the lock. New test: a_recorder_waits_where_server_json_names_a_stopped_page_server_of_an_older_loft. It fails without the fix.
| Some(running) if discovery::against_ours(&running.version) == Ordering::Less => { | ||
| Err(branch.refused(&held, vec![older(&running.version)])) | ||
| } | ||
| Some(_) => Ok(()), |
There was a problem hiding this comment.
With a page server running, the result can name a stage the requests were not counted toward, and still exit 0.
check(Some(_)) returns Ok without reading Yard Log again, unlike the None branch, which refuses with moved. The page server works out the stage from Yard Log as it is when the post arrives, while fields["stage"] still reports the stage read before the lock.
Scenario: task r1 is moved to stage B, or unassigned, between stage_of() and the post. The server counts the requests toward B (or toward no stage). The command prints "Recorded 1 request(s) … toward stage review" and exits 0.
Suggested fix: send the expected stage with the post and have the server confirm it. If that is not possible, read the task's stage again after the answer and refuse (or warn) when it differs, as the None branch does.
There was a problem hiding this comment.
Fixed in a01dbb4, with the spec change in eca7a55. The page server's events answer now gives stages: for each recorded event, the stage it counted toward. A repeated event gives the stage it counted toward the first time, which each receipt now keeps. The command's result names that stage, or null when there is none, and adds a warning when it differs from the stage read before the lock. It still exits 0, since the requests are counted. Where no page server runs, the command still refuses before writing (moved).
| if found is None: | ||
| return f"the branch's Yard Log holds no stage {stage}" | ||
| owner = found.get("owner") or {} | ||
| if (owner.get("host"), owner.get("session")) != (host, session): |
There was a problem hiding this comment.
--stage is refused as "not the author's own" for a stage the author does own, if their session continues an earlier one.
stage_refusal compares the stage owner's (host, session) exactly with CLAUDE_CODE_SESSION_ID / CODEX_THREAD_ID. Loft itself resolves continuations (Lineage from ~/.yard/continuations.json, Continuations::identity, log.lineage.same), so loft yard write --session <new> would accept the continuing session as the owner.
Scenario: the author creates the review stage, runs /clear (a new session id; the Loft hook records the continuation), then runs review.py --stage review. It exits 2 with "the stage review is not the author's own", and no review is recorded.
Suggested fix: compare through the lineage, for example by asking loft whether the session may write the stage, or by reading the continuations, rather than comparing strings.
There was a problem hiding this comment.
Fixed in fe8c2bc. The script now reads Yard Log with the author's briefing (loft yard read --context --host --session), in which Loft follows a continued session to the stages the earlier one owns. It accepts --stage when the stage's owner is the author's session or the briefing names it as the author's stage, and still refuses before any review runs. I checked it in a scratch repository: a session continuing the owner was accepted, and an unrelated one refused.
A recorder that found the lock held, and `~/.yard/server.json` still naming a stopped page server of an older `loft`, refused at once instead of waiting for the lock. The recorder now posts an empty list of events to the port the file names, which records nothing, and checks the page server only once it answers; one that does not is waited out as a lock that names no page server. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`--stage` was refused as not the author's own after `/clear`, since the script compared the stage owner's session with the author's as strings. It now reads Yard Log with the author's briefing, in which loft follows a session that continues another to the stages that one owns, and takes a stage whose owner is the author's session or that the briefing names the author's stage. A stage neither is still refused before any run. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The page server's events answer names the stage each recorded event counted toward, and the command's result names that stage, with a warning where the task moved before the page server counted its requests, or where they counted toward no stage. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The page server's events module holds what a session keeps and how a batch is kept; where each event of a batch arrives, its agent's working tree, that tree's open Yard Log and the stage it counts toward, moves to `events/arrival.rs`, which leaves room under the line ceiling for the stage the answer is to name. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With a page server running, the result named the stage the task held when the command read Yard Log, while the page server counted the requests toward the stage the task held when they arrived. The page server's events answer now names, for each event it recorded, the stage it counted toward, and a repeated event the stage it counted toward the first time, which each receipt now keeps. The command's result names that stage, or none, with a warning where it is not the stage read; it still exits 0, since the requests are counted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Summary
docs/contributing/review.mdandreview-checklist.mddescribe the review a change passes before a person is asked.scripts/agent-review/review.pyruns the two read-only reviewers in parallel (Claude/code-reviewand Codex) on the pinned diff, records each run as a Yard task, and probes that each reviewer really can't write. A PR template records the checks and the review rounds. CI and the release gate run the runner's 50 tests.loft yard usage(new command): records the tokens of a run that no Loft hook sees, such as a reviewer the script starts. It counts them toward the stage of the run's task, and the run shows on the page as one turn. The page server's events answer gainsrepeatedandunwritten.AGENTS.mdfits Codex's 32 KiB budget: the release steps moved todocs/contributing/releasing.md, and a guard test holds the limit.Specification
The Feature "Record an outside run's tokens" (
spec/products/yard-client/commands/loft-yard-usage.yaml), approved in four spec commits. Its criteria are linked inloft.trace.yaml. The agent-review process itself adds no behavior.Checks
loft fmt --check/check/reconcile: cleancargo nextest run --workspace: 4272 passed, on a tree identical to the merged head (the only later commit changes a browser test)npm test429 passed,npm run typescleanAgent review
/simplifyefbc1904efbc1904/code-review(round 1, process)efbc1904efbc19041bab8e1052f7a25floft yard usage, rounds 1–3)4e6fc5cb,a78cc45f,550e2c69Declined: splitting
2f517cecinto one commit per fix (that would rewrite history). Later page-server behaviors around late-posted events are left as follow-ups.🤖 Generated with Claude Code