Skip to content

fix(fork-kit): review kit follow-ups from the #955 reviews - #960

Merged
scuttletoby merged 1 commit into
mainfrom
review-kit-957-minors
Nov 22, 2026
Merged

scuttletoby merged 1 commit into
mainfrom
review-kit-957-minors

Conversation

@scuttletoby

Copy link
Copy Markdown
Owner

Fixes #957

Problem

The #955 lens reviews left six small points: in a few cases the review kit's advice did not match the gate, the eval's cost numbers were wrong, the general kit named fork facts, and one list was out of order. None of them changes what the gate passes or fails.

Change

  1. Base config git cannot read (review_kit.py base_file): plan --base first runs git ls-tree --full-tree <base> -- <config>. Only a tree with no such entry counts as "no queue config". If the tree or the blob cannot be read (a missing object, or a partial clone that is offline), plan now exits 2 with a plain message.
  2. The gate's repository check (changes_from): before it reads the paths, plan --base runs the gate's own head_check.Checkout.problem(). A repository holding info/grafts, shallow, alternates or info/attributes is refused, as the gate refuses it, and the message points to --changes or a full clone. git_dir now returns the common git folder (--git-common-dir). Without that, a linked worktree would be checked in its own private folder, which never holds those files. The docstring's "never fewer paths than the gate sees" is now true, so it stays.
  3. Eval cost (review_eval.py):
    • For a run that is the session, every transcript under <session>/subagents/ is counted, at any depth, workflows/wf_*/ included.
    • For a run that is itself a sub-agent, the cost now includes the sub-agents it started, at any depth. They are matched by parentAgentId in agent-<id>.meta.json. Its siblings are not counted.
    • Each message is priced at its own model. A sub-agent model with no price is named under "no price for".
    • model_seen comes from the run's own file and skips zero-usage <synthetic> messages.
    • The example config also globs subagents/workflows/*/.
  4. --settings: the copyable commands in COMMENTS.md and SKILL.md (plan, the lens prompt's check, the check block) now show [--settings <file>]. When plan or check reads no kit settings and finds no queue config, but .github/ holds a *review-kit*.json, the note now names that file: pass --settings <file>.
  5. Fork facts out of the general kit: the Fork test class is gone from plan.test.py. It is now a review-kit section in .github/scripts/fork-contracts.test.py, which also checks that the hint names .github/fork-review-kit.json on the real tree. The fork's file name is gone from REVIEW.md, and docs/fork/agent-rules.md now says to pass --settings .github/fork-review-kit.json here.
  6. .github/fork-pr-queue.json: .github/fork-review-kit.json now comes after .github/fork-removed-workflows.txt. Two other pairs in that list are out of plain sort order: */*/** before *.md, and *.yml before *.yaml. Those are older groupings, so I left them alone.

Scope

Fork-only tooling (fork-kit/review, the fork contract tests, fork docs and config). Issue #957.

Verification

  • python3 -I -B fork-kit/review/tests/plan.test.py: 36 OK. eval.test.py: 33 OK. comments.test.py: OK.
  • Failing first: I ran the new tests against origin/main's review_kit.py and review_eval.py, and 6 plan tests and 2 cost tests failed: the base blob deleted, grafts/alternates/shallow, the grafts in a linked worktree's common folder, the settings hint, nested and workflow sub-agents, and per-model pricing. New red-check mutations break each new rule and show that its test then fails.
  • python3 .github/scripts/fork-contracts.test.py: both new review-kit checks pass. 40 other checks fail on this machine only because jq is not installed (jq: command not found in the pr-guard and secret-scan shell steps). This change does not touch them.
  • vp run check:changed: format, typecheck and tests pass.

Claude Opus 5.5 in Claude Code.

🤖 Generated with Claude Code

…-agent cost, --settings hints (#957)

- plan: a base config git cannot read (missing object, partial clone offline)
  is a plain error with exit 2, not "no queue config"; only a base tree
  without the file falls back.
- plan --base: runs the gate's own Checkout.problem() on the repository's
  common git folder (linked worktrees too), so grafts, shallow, alternates or
  attributes are refused as the gate refuses them.
- eval cost: counts nested sub-agents of a sub-agent run (by parentAgentId)
  and workflow agents, prices each message at its own model, and takes
  model_seen from the run's own transcript.
- plan prints a --settings hint when it finds no settings and no queue
  config but a .github/*review-kit*.json; the copyable commands show
  [--settings <file>].
- The fork's settings test moves to the fork contract tests; the fork fact
  moves from REVIEW.md to docs/fork/agent-rules.md.
- fork-pr-queue.json: the gate rule's new path in alphabetical order.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@scuttletoby

Copy link
Copy Markdown
Owner Author

lens: merge-path · reviewer: Claude Opus 5.5 lens agent · read at: 7f0c8e7
verdict: safe to merge
covered: issue #957 (all six points), the PR body and the full diff against origin/main 8bff65c; the gate's path judging (review_judge.judge, review_glob.matches_any, review_config rule checks) and head_check.Checkout / changed_paths / pr_queue.UNTRUSTED_FILES / GIT_SAFE, to see what the kit now mirrors
checks: ran plan.test.py (36 OK), eval.test.py (33 OK), comments.test.py (42 OK); .github/scripts/fork-contracts.test.py: both new review-kit checks ok, 40 others fail here only because jq is not installed on this machine (pr-guard and secret-scan shell steps; not touched by this PR). Ran plan --base origin/main with and without --settings .github/fork-review-kit.json from a linked worktree: critical, merge-path + state (+ code for docs/fork), and the new hint without settings. Checked with the gate's own glob code that .github/scripts/fork-contracts.test.py matches .github/*/*/** (gate, critical) and fork-kit/review/tests/plan.test.py matches fork-kit/review/** (gate, critical). Tried a local replace ref on a config blob in a scratch repo: plain git show base:path reads the replacement, --no-replace-objects does not.
state: runs again: plan and check read everything afresh, same input gives the same output; stopped half-way: they write nothing; old or empty state: a base config git cannot read (missing tree or blob, offline partial clone) is now exit 2 instead of "no queue config, one lens", and a local repository with grafts, shallow, alternates or info/attributes is refused before paths are read; nothing of the gate's state or config semantics changes
blocker: none
major: none
minor: fork-kit/review/lib/review_kit.py:153 and :158 (base_file): the two git calls run without the gate's GIT_SAFE (--no-replace-objects) and git_env, while load_queue_config's docstring says the config is read "as the gate reads it". A local refs/replace/ entry for the base config blob makes plan judge with a different config than the gate (confirmed in a scratch repo); Checkout.problem() does not look at replace refs. Advisory only (the gate decides from its own bare fetch, so it cannot let a head through) and older than this PR (the old code used the same plain git show); passing *head_check.GIT_SAFE and env=pr_queue.git_env(os.environ) would close it.

Focus answers:

  • .github/fork-pr-queue.json:35-36: only two entries swap places inside the gate rule's paths. The set of globs is unchanged, and order inside one rule's list has no effect: review_judge.judge (review_judge.py:164) takes the first rule with any matching glob, via review_glob.matches_any (any(...)). The rule order, weights, lenses and min_lenses are untouched, so no path is judged differently. The gate reads this file from the base tip, so the PR cannot affect its own judgement either; it is a protected path and stays critical.
  • .github/scripts/fork-contracts.test.py:4891-4908: the moved fork check lands under .github/*/*/** (gate, critical), as the plan.test.py code it replaces was under fork-kit/review/** (gate, critical). No path moves out of the critical rule. The new checks only run review_kit.py plan with --changes; they read nothing of the gate and change no gate input.
  • plan --base and Checkout.problem() (review_kit.py:199-224): git_dir now returns --git-common-dir. Every file problem() looks for (info/grafts, shallow, objects/info/alternates, objects/info/http-alternates, info/attributes) lives in the common folder for a linked worktree too, so a normal clone and a linked worktree are checked against the same files. Before, a linked worktree's private folder never held them. With bare=(base, head) the later --git-dir <common> calls use only full shas (HEAD is resolved with -C root first), so the linked worktree's own HEAD cannot slip in. Where plan and the gate can still differ, plan refuses (exit 2) and never advises fewer lenses: a local repository with one of those files is refused although the gate's own fresh bare fetch would read it. That is fail-closed advice, not a path the gate treats differently.
  • base_file (review_kit.py:148-162) fixes a fail-open in the advice: an unreadable base config used to mean "no queue config, normal, one lens"; now only an absent tree entry means that (ls-tree paths are literal, not globs), and every other git failure is exit 2.
  • No token, secret or personal data in the diff; the eval changes only read transcript usage and print counts.

🤖 Generated with Claude Code

@scuttletoby

Copy link
Copy Markdown
Owner Author

lens: code · reviewer: Claude Opus 5.5 lens agent · read at: 7f0c8e7
verdict: safe to merge
covered: #957 (all six points; the issue has no comments), the PR body and the full diff of origin/main...7f0c8e7 (12 files): review_kit.py (base_file, other_settings, git_dir, changes_from, main), review_eval.py (_meta, _own_files, _usage_tokens, cost), plan/eval/comments tests, fork-contracts review-kit section, COMMENTS.md, SKILL.md, REVIEW.md, eval/README.md, eval.example.json, docs/fork/agent-rules.md, fork-pr-queue.json; read the gate's head_check.Checkout (problem, git, GIT_SAFE), changed_paths, base_config and pr_queue.UNTRUSTED_FILES that the kit now calls
checks: plan.test.py 36 OK, eval.test.py 33 OK, comments.test.py 42 OK on the head. With origin/main's review_kit.py and review_eval.py under the new tests: plan fails the base blob deleted, grafts/alternates/shallow, the linked worktree's common folder and the settings hint; eval fails nested + workflow sub-agents and per-model pricing / model_seen (plus the red-check rows, as expected). fork-contracts.test.py: both review-kit checks ok; 40 other checks fail here only because jq is not installed (all in secret-scan e2e and pr-guard fork_ci_result). Own mutation: the tree-unreadable branch of base_file turned back into return None leaves all 36 plan tests green (minor 1). No TS changed, so no vp run.
state: runs again: plan, check and cost read only files and git, write nothing but cost.json (rewritten whole, same input same output, the test runs cost twice); stopped half-way: nothing partial is left; old or empty state: a base without the config still falls back to one lens (tested), a base config git cannot read and a grafted, shallow or alternates repository now exit 2 with a plain message instead of a silent one-lens plan; transcripts without a meta file or parentAgentId count only for a session run, as before; an empty .github folder gives no hint.
blocker: none
major: none
minor: fork-kit/review/lib/review_kit.py:155 the tree-unreadable branch of base_file (#957 item 1, "missing tree") has no test: replacing its raise with return None (main's behaviour) keeps plan.test.py green; only the deleted-blob case is pinned (test_a_base_config_git_cannot_read_is_a_problem). A test that deletes the base's root tree object, plus a red-check row, would pin it.
minor: fork-kit/review/REVIEW.md:30 and :43 still show plan --root . --changes <file> and check --head <sha> without [--settings <file>]; :43 is the line a project copies into its lens prompt files, so those prompts lose --settings. REVIEW.md:71 says it in prose, but item 4 asked for the copyable commands.
minor: fork-kit/review/lib/review_kit.py:166 (docstring) and fork-kit/review/tests/plan.test.py:301-309 still name the fork's files (fork-review-kit.json, fork-pr-queue.json); the test uses them only as temp-dir fixtures, but a neutral name (acme-review-kit.json) would keep the general kit free of fork names, as #957 item 5 asks.
minor: fork-kit/review/lib/review_kit.py:154-158 (older than this PR) reads the base config with plain git -C root (replace refs and the user's global config apply), while the gate reads it through Checkout.git with GIT_SAFE (--no-replace-objects, no global config); with a refs/replace entry for the config blob the kit and the gate read different configs. Reading it through the same Checkout that changes_from now builds would close it.
minor: fork-kit/review/lib/review_eval.py:327 a transcript counts as a sub-agent when any parent folder is named subagents, so a transcripts glob under such a folder (/data/subagents/p/s.jsonl) treats a session as a sub-agent and drops its sub-agents; and :329 counts every *.jsonl under a session's subagents/ while the sub-agent branch counts only agent-*.jsonl. Checking only the folders right above the file (subagents/ or subagents/workflows/<wf>/) and globbing agent-*.jsonl in both branches would make the two agree.

Per #957 point: 1 base config read errors exit 2 (blob case tested, tree case untested: minor 1); 2 Checkout.problem() before the paths, common git folder for linked worktrees, both tested and mutation-pinned; 3 nested and workflow sub-agents, siblings excluded, per-message pricing, model_seen from the run's own file skipping zero-usage , example glob extended, all tested; 4 [--settings <file>] in COMMENTS.md:12 and SKILL.md:38/158/193 and the hint, tested in the kit and on the real tree (REVIEW.md commands: minor 2); 5 Fork class moved to fork-contracts and REVIEW.md:71 cleaned (fixture names: minor 3); 6 fork-pr-queue.json order fixed. Docs (eval README, SKILL.md, COMMENTS.md, REVIEW.md, agent-rules.md) agree with the code.

🤖 Generated with Claude Code

@scuttletoby

Copy link
Copy Markdown
Owner Author

lens: state · reviewer: lens agent (Claude Opus 5.5) · read at: 7f0c8e7
verdict: safe to merge
covered: issue #957 (all six points), the PR body and the full diff: review_kit.py (base_file, other_settings, git_dir, changes_from, main), review_eval.py (_meta, _own_files, _usage_tokens, cost), the new and changed tests in plan.test.py, eval.test.py and fork-contracts.test.py, the docs, the example config and .github/fork-pr-queue.json; also the gate code they call: head_check.Checkout.problem(), repo_path, and pr_queue.GIT_SAFE / UNTRUSTED_FILES.
checks: plan.test.py 36 OK, eval.test.py 33 OK, comments.test.py 42 OK. fork-contracts.test.py: both review-kit checks ok; the 40 other failures are all pr-guard / secret-scan steps, and the output says jq: command not found (jq is not installed on the review machine). Mutations (each restored after): skipping checkout.problem(), going back to --absolute-git-dir, dropping the hint, letting siblings in, no nested walk, a flat session glob, run-model pricing, and model_seen from any file or from synthetic messages each turn the tests red. Making a failed git show return None turns them red too. Ignoring the ls-tree exit code does NOT (finding 1). Scratch repos: a deleted .github tree object, and a refs/replace entry on the base's .github tree (finding 2).
state: Base config. A tree with no entry is "no queue config" (exit 0, one lens). A missing tree or blob, or an offline partial clone (blob or tree filter), exits 2 with a plain message. I checked this on a scratch repo with the .github tree object deleted. Shallow clones, grafts, alternates and info/attributes are refused by the gate's own problem(), run on the common git folder. In a linked worktree, --git-common-dir gives the folder that really holds those files, and the test proves it. One gap: replace refs are honoured by the kit's plain git but not by the gate (finding 2). Runs again: plan and check keep no state, so they give the same output. cost recomputes from the transcripts and writes cost.json by temp name and rename. Eval cost: no double counting inside a run, because files are deduplicated by path and usage by message id. A fork's copied context or the same file found by two globs therefore counts once. No sibling leakage: the nested walk only adds agents whose parentAgentId is in the run's own id set, and a test shows a sibling being kept out. Unchanged from main: a RUN-ID that appears in two sessions (a re-run) still sums both attempts. A session that is itself a run still counts any sub-agent runs below it. Fails open: never for the gate (plan is advice, and the gate counts the lenses itself). The kit's advice can still be too low in the replace-ref case (finding 2), and eval cost can be too low when a meta file is missing (finding 3).
blocker: none
major: none
minor: 1. fork-kit/review/lib/review_kit.py:154: no test covers the tree half of base_file. With the ls-tree exit-code check removed, all 36 plan tests still pass. On a scratch repo whose base .github tree object was deleted, that mutant prints "no queue config ... weight: normal, lenses: review" and exits 0, which is the #957 item 1 fail-open again. The PR code exits 2 ("git cannot read the tree of ..."). Add a test that deletes the .github tree object, beside the existing blob test.
minor: 2. fork-kit/review/lib/review_kit.py:153 and :158: base_file runs plain git -C root, without the gate's GIT_SAFE (--no-replace-objects, core.attributesFile=/dev/null) or its no-global-config env. Scratch repo: the base config is invalid JSON, so the PR code exits 2 ("the gate refuses the queue config"). After git replace <base .github tree> <empty tree>, plan --base main prints "no queue config ... weight: normal" and exits 0. The gate reads the real config, and Checkout.problem() does not see refs under refs/replace/. The old git show did the same, so this is not new. It needs a deliberate local replace ref, since replace refs are not fetched by default. Still, load_queue_config's docstring promises "as the gate reads it". Run both calls with head_check.GIT_SAFE and pr_queue.git_env (or through Checkout.git).
minor: 3. fork-kit/review/lib/review_eval.py:309-316 and :339: for a run that is a sub-agent, a nested agent counts only if its agent-<id>.meta.json exists, parses and holds parentAgentId. If not, _meta returns {}, and that agent and everything below it are dropped without a word, so usd/tokens come out low and no note says why. The one real meta file on the review machine is a depth-1 agent. It holds agentType and spawnDepth but, as expected, no parentAgentId, so the key's real shape at depth 2 or more is unverified here (the test fixture assumes it). Name the agents in the session tree that have no meta, or spawnDepth > 1 with no parentAgentId, in the cost output, the way "no price for" names unpriced models.

🤖 Generated with Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Review kit: small follow-ups from the #955 reviews

1 participant