Skip to content

review kit: gate rules for state lines and changed paths, eval shape checks, doc follow-ups (#797, #914) - #955

Merged
scuttletoby merged 2 commits into
mainfrom
fork-kit-review-797-914
Nov 22, 2026
Merged

scuttletoby merged 2 commits into
mainfrom
fork-kit-review-797-914

Conversation

@scuttletoby

Copy link
Copy Markdown
Owner

Fixes #797, Fixes #914

Every point of both issues is done in this pull request. Each fix has a test that fails without it; see Verification.

#797 (K1 review kit lens minors)

  1. plan --base with a base config that is not UTF-8. The kit now hands the raw bytes from git show <base>:<config> to the gate's config.parse, which refuses them ("not UTF-8 text") exactly as the gate does. Before, it decoded with replace and printed a normal plan. Test: plan.test.py test_a_base_config_that_is_not_utf8_is_refused_as_the_gate_refuses_it.
  2. plan ran its own git diff. With --base, the kit now resolves the base and HEAD to full shas and calls the gate's head_check.changed_paths (every merge base, git's safe flags, no global config, --no-relative). Tests: test_base_reads_every_merge_base_as_the_gate_does (a criss-cross history: the old diff saw 2 paths, the gate 3) and test_base_reads_paths_whatever_the_repository_git_settings (diff.relative=true with --root in a subfolder).
  3. Run the kit at the pinned version. README.md has a new section "Which fork version". SKILL.md and REVIEW.md point to it. Test: comments.test.py test_the_docs_say_to_run_the_kit_at_the_pinned_release.
  4. The state: line rule lived only in the kit. The issue says to move it "when the gate starts enforcing it". This PR moves it now, because then nothing is left to do later: review_judge.has_state_line is gate code, and the kit imports it (review_kit.has_state_line is review_judge.has_state_line). The gate still parses state_line without enforcing it, so the gate's behaviour does not change (release note added). Tests: review_judge.test.py StateLine, comments.test.py test_the_state_rule_is_the_gates, and a new red check that breaks the rule inside the gate's review_judge.py and shows the kit's own tests then fail.
  5. A malformed scores.json crashed the eval. scores_of checks the shape that judge_prompt.txt asks for. A wrong shape is refused with a plain message naming the case and the file ("judge the case again"), not a traceback. Test: eval.test.py test_malformed_scores_are_a_plain_message (8 shapes; 4 of them crashed before and 4 passed silently).
  6. Sub-agent transcripts. A matched run's own <session>/subagents/*.jsonl count toward its cost, and each file counts once. The example config also globs ~/.claude/projects/*/*/subagents/*.jsonl, so a run that was itself started as a sub-agent is found. Tests: test_sub_agent_transcripts_count and test_the_example_config_finds_sub_agent_transcripts.
  7. Repo file or T3 settings. REVIEW.md now has a paragraph, "This file or T3's review rules setting". Nothing in T3 reads server.reviewRules yet (docs/fork/README.md says so), so today the repo file decides. Once T3 starts lenses itself, T3's setting decides the lenses T3 starts on that machine (the machine's half: which provider and model it has). The repo file decides lenses an agent starts by hand and what plan prints. Keep the two the same; the gate reads neither, so a difference can change cost and recall but never what passes. This follows docs/fork/README.md's split (the setting is "the machine's half"). It is not a new owner decision; if the owner wants it the other way, it is one paragraph. Test: test_review_md_says_which_decides_the_runner. It also fails once T3's docs stop saying "Nothing reads it yet", so the paragraph gets read again then.

#914 (#845 lens round 3 follow-ups)

  1. A fix past the last lens round that is not nit-only. SKILL.md "No round past the limit": the fix gets no new lens round. The orchestrator checks that fix diff itself and posts the override for the fix head, and a blocker or major left over counts as stuck (then one audit, then a person). Test: test_the_skill_says_what_happens_to_a_fix_past_the_last_round.
  2. Override author association wording. SKILL.md now uses COMMENTS.md's wording ("counts only from the configured author association", the queue config's override.author_association) and adds "never edited and not hidden". COMMENTS.md's table says the same. Test: test_the_docs_say_which_override_counts_as_the_gate_reads_it. It also checks the gate's lens.Review.override_sha refuses an edited, a hidden, and another association's override.
  3. Point the kit at the fork's real rules. Yes, through project config: a new .github/fork-review-kit.json (queue_config: .github/fork-pr-queue.json). It has the fork- prefix because the seam check treats other .github files as upstream files, so the fork passes --settings .github/fork-review-kit.json (REVIEW.md and SKILL.md say so). The file is added to the gate rule of .github/fork-pr-queue.json, as the ForkConfig test requires for every .github file. Test: plan.test.py Fork.test_the_fork_settings_point_the_kit_at_the_forks_queue_config. Run on this branch, plan --settings .github/fork-review-kit.json --base origin/main prints weight critical with lenses merge-path, state and code.

State question

What happens when this runs again, stops half-way, or meets existing, old or empty state?

  • Runs again: plan, check and the eval only read. They write nothing in the repository or the eval folder except the eval's own output, which is the same as before. A second run prints the same plan.
  • Stops half-way: plan --base runs git read-only (rev-parse, show, the gate's merge-base and diff from an empty temp folder, which head_check removes). Stopping leaves nothing behind.
  • Existing, old or empty state:
    • A base that is not a commit gets the same plain message as before (" is not a commit in ").
    • A base without the config gives the old "no queue config" note.
    • A base config that is not UTF-8 is now refused like the gate refuses it, instead of being planned.
    • A linked worktree works: the kit asks git for the absolute git dir, and plan was run from one.
    • Old scores.json files in the right shape read as before. A wrong shape is refused with a plain message, not a traceback.
    • A run with no subagents folder costs as before.
    • The gate itself only gains review_judge.has_state_line, which the gate does not call, so no pull request is judged differently.
    • The fork's .github/fork-pr-queue.json only adds a path to the critical gate rule. After merge, a change to the new kit settings file needs the critical lenses.

General vs project

  • General (kit and gate, any project): the base bytes, the gate's changed paths, has_state_line in the gate, the eval's shape check and sub-agent transcripts, and all doc points.
  • Project (the fork only): .github/fork-review-kit.json and its line in .github/fork-pr-queue.json. These are the fork's own facts in the fork's own config, like any project's --settings file. The kit has no code that knows about the fork.

Verification

  • All green on the branch:
    • fork-kit/review/tests/comments.test.py (42)
    • eval.test.py (31)
    • plan.test.py (31)
    • fork-ci/actions/head-check/review_guide.test.py (34)
    • fork-ci/actions/pr-queue/review_judge.test.py (55) and lens.test.py (80)
    • head_check.test.py (262, 1 skipped)
    • .github/scripts/fork-contracts.test.py (716 ok)
    • fork-head-gate-workflow.test.py (89 ok)
    • vp fmt --check
    • the seam check (--no-upstream HEAD^1 HEAD)
  • Red without the fixes: I copied the new test files over the base tree (main at the branch point, nothing else changed) and ran them. Every new test failed:
    • comments: 12 failures and 1 error, covering the state rule, the doc sentences for 797.3, 797.7, 914.1 and 914.2, and the gate red check.
    • eval: 8 failures and 4 errors (malformed scores, sub-agent transcripts).
    • plan: 5 failures and 1 error. On the base, the non-UTF-8 base config gives a normal plan with exit 0; the criss-cross history and diff.relative cases give "2" or fewer paths instead of the gate's count; and the fork settings file is missing.
    • review_judge: has_state_line is missing.
  • The in-suite red checks (RedCheck) break each new rule in a copy of the code: the base bytes, the gate's changed paths, sub-agent transcripts, the scores shape, and both state-line rules inside the gate's review_judge.py. Each shows its test then fails.

🤖 Generated with Claude Code

…checks, doc follow-ups (#797, #914)

- plan --base reads the base config as bytes (not UTF-8 is refused as the gate refuses it) and the
  changed paths through the gate's head_check.changed_paths (every merge base, no global git config).
- What counts as a state: line moves into gate code (review_judge.has_state_line); the kit imports it.
- The eval refuses a malformed scores.json with a plain message, counts a run's sub-agent
  transcripts, and the example transcripts globs find sub-agent sessions.
- Docs: run the kit at the pinned release; which of REVIEW.md's file or T3's reviewRules setting
  decides the runner; a fix past the last lens round; override author association, never edited
  and not hidden.
- The fork's own kit settings (.github/fork-review-kit.json) point the kit at .github/fork-pr-queue.json.

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

Copy link
Copy Markdown
Owner Author

lens: state · reviewer: state lens (Claude Opus 5.5) · read at: 984c853
verdict: safe to merge
covered: issues #797 (7 points) and #914 (3 points) with comments, the PR body, the full diff (review_kit.py, review_eval.py, review_judge.py, head_check imports, the docs, both .github configs, the four changed test files)
checks: ran comments.test.py (42), eval.test.py (31), plan.test.py (31), review_judge.test.py (55): all OK. Put main's review_kit.py under the PR's plan.test.py: 5 failures (non-UTF-8 base, criss-cross merge bases, diff.relative, both red checks), so the new tests fail on the old code. Ran plan by hand from a linked worktree: with --settings .github/fork-review-kit.json --base origin/main it says critical, merge-path + state + code; a missing --settings file, a base that is not a commit: plain message, exit 2. Built a repo whose base config blob is gone (finding 1).
state: runs again: plan, check and the eval only read; cost rebuilds cost.json from scratch each run and keys usage by message id, and a file found by two patterns is listed once, so a re-run gives the same numbers (the test checks it): no double count. Stops half-way: git runs read-only from a temp empty folder; nothing is left behind. Old or empty state: non-UTF-8 base config refused as the gate refuses it; invalid or empty config: exit 2; base without the config: the old fallback note; scores.json in a wrong shape: plain "judge the case again" message (8 shapes tested); an older kit release than the pin: an unknown config key is refused by the older parser (fails closed); a newer kit is doc-only (README "Which fork version"), and the kit is advisory, so it can never let a head through. The gate only gains has_state_line, which it does not call: no PR is judged differently.
blocker: none
major: none
minor: fork-kit/review/lib/review_kit.py:151: a base config that exists but cannot be read (a missing or corrupt blob, a partial clone offline) counts as "no queue config": plan prints weight normal, one lens, exit 0. Tried: git show fails with "bad object", plan still exits 0 with "no queue config". Same as before this PR and only advisory (the gate refuses such a base), but this block was rewritten here: tell "path not in the base tree" (git cat-file -e or ls-tree) apart from any other git failure, which should be a Problem.
minor: fork-kit/review/lib/review_eval.py:318: a run started as a sub-agent is now found, but its own sub-agents are not counted. Claude Code keeps a sub-agent's sub-agents flat in the top session's subagents/ folder (agent-.meta.json has spawnDepth 2 and parentAgentId), never under /subagents/, which is what this line globs. Workflow agents under /subagents/workflows/wf_*/ are not counted either. Cost is under-counted, never doubled; eval only. Fix: match a sub-agent run's children by parentAgentId in the meta files.
minor: fork-kit/review/SKILL.md:38: the fork's fix for #914.3 depends on remembering --settings. Without it, plan on this PR prints weight normal and one lens 'review', exit 0, while the gate holds the change as critical. The gate in enforce still fails the head, so it fails closed, but it costs a round. Add --settings to that code block, or make the fallback note say "if this project keeps its kit settings under another name, pass --settings".

@scuttletoby

Copy link
Copy Markdown
Owner Author

lens: merge-path · reviewer: Claude Opus 5.5 (independent read-only lens) · read at: 984c853
verdict: safe to merge
covered: issues #797 (7 points) and #914 (3 points) with comments, the PR body and the full diff (16 files); focus on .github/fork-pr-queue.json, the new .github/fork-review-kit.json, review_judge.has_state_line, and review_kit.py's use of head_check.changed_paths.
checks: ran the four changed test files on the head (review_judge 55, comments 42, eval 31, plan 31: all OK). Parsed the queue config at the base and at the head with the gate's config.parse (no warnings either side) and judged .github/fork-review-kit.json alone: base gives normal, lenses code, head gives critical, lenses merge-path, state. Ran plan --settings .github/fork-review-kit.json --base origin/main and compared it with the gate's own head_check.changed_paths plus review_judge.judge under the base config: both give 16 paths, critical, lenses merge-path, state, code, word for word the same. Checked that nothing in fork-ci calls has_state_line, and that state_line is still only parsed (review_config.py). Tried a local repository with info/grafts. Grepped the diff and the commit for personal data: none.
state: the gate change only adds a function and a regex that nothing in the gate calls, so a rerun on any open PR judges it the same. The queue config is read from the base tip, so the new rule line applies only after merge. It covers one new file that no open PR touches, so no open PR's required lenses change. plan, check and eval are read-only: a rerun prints the same thing, a stop leaves nothing behind (head_check removes its temp folder), and a base without the config or with a config that is not UTF-8 gives a plain message.
blocker: none
major: none
minor: fork-kit/review/lib/review_kit.py:183 builds a head_check.Checkout but never calls Checkout.problem(), which the gate runs first. In a local repository with info/grafts, git still follows the grafts under GIT_SAFE (I tried it: merge-base --all gave the grafted parent). So plan can see other paths than the gate, which reads a fresh bare fetch. The changes_from docstring says "never fewer paths than the gate sees", which overstates this. It is not a regression: the old git diff base...HEAD followed grafts too. It is advisory only, because the gate still judges with its own paths and blocks a head that lacks a lens. Fix: call problem() and raise Problem on an answer.
minor: plan without --settings on the fork still says normal, lenses review ("no path is critical"), because the default settings path is .github/review-kit.json. REVIEW.md:72 and SKILL.md:42 now say to pass --settings, and the gate is unaffected (it fails the head until the critical lenses read it). A one-line hint in the "no queue config" note, such as "pass --settings if your kit settings live elsewhere", would catch a missed flag.

Focus answers:

  • Gate rule entry (.github/fork-pr-queue.json:35): it only adds one literal path to the critical gate rule. Nothing it matched before changes weight, the lenses stay merge-path, state and min_lenses is the same, so it can only widen, and only for that file. The new file is read by nothing in the gate (only the kit's plan/check and plan.test.py), so changing it cannot change which lenses the gate requires. Only what plan advises can change, and the head would still fail at the gate. .github/fork-owned-paths.txt already matches it through .github/fork-*, so the workflows/kit_tests jobs keep running for it.
  • has_state_line move (fork-ci/actions/pr-queue/review_judge.py:374-380): the body is the same as the kit's old one (fold and lens.norm_line/lens.plain_lines are the same objects). Nothing in the gate calls it, and no module star-imports or walks review_judge's names. The gate's pass/fail results do not change today.
  • plan against the gate (fork-kit/review/lib/review_kit.py:177-187): it now uses the same function with the same flags and every merge base, the base config as bytes from the base tip, and full shas. It agrees with the gate when --base is the PR's base tip and HEAD is the PR head; the one case where it can disagree is the grafts minor above. The kit-from-a-newer-checkout drift is documented (README "Which fork version").

@scuttletoby

Copy link
Copy Markdown
Owner Author

lens: code · reviewer: Claude Opus 5.5 (code lens) · read at: 984c853
verdict: safe to merge
covered: the full diff (16 files) and what it calls into: review_kit.py (commit_of, load_queue_config, git_dir, changes_from, main), head_check.changed_paths and Checkout (bare mode, GIT_SAFE, git_env), config.parse on bytes, review_judge.has_state_line and lens.plain_lines/norm_line, review_eval.py cost and scores_of/analyze, lens.Review.override_sha, the four kit docs, eval README and example config, docs/fork/README.md reviewRules, .github/fork-ci-release.json paths, issues #797 (7 points) and #914 (3 points).
checks: ran the four changed test files on the head (comments 42, eval 31, plan 31, review_judge 55: all OK). Copied the four new test files over the parent commit and ran them: comments 12 failures + 1 error, eval 8 + 4, plan 5 + 1, review_judge 10 errors, matching the PR body; every new test fails on the old code. Ran plan --settings .github/fork-review-kit.json --base <parent> from a linked worktree: weight critical, lenses merge-path, state, code (the worktree git dir is found). Checked that git show <rev>:<file> applies no textconv, so the kit's config read is still byte-identical to the gate's. The release paths hold all of fork-ci and fork-kit, so a kit checked out at a ci/vN tag has head_check.py. Doc cross-check: SKILL.md, REVIEW.md, README.md and COMMENTS.md agree on the pinned-release rule, the override wording (it matches override_sha: association, never edited, not hidden), the past-the-limit rule and the state-line owner.
state: plan, check and the eval only read; a second run prints the same plan. plan --base runs git read-only (rev-parse, show, merge-base, diff from a temp folder head_check removes), so a stop leaves nothing. Old state: a base without the config gives the old note, a non-UTF-8 base config is now refused as the gate refuses it, a base that is not a commit gets the old message, old scores.json files in the right shape read as before, and a run without a subagents folder costs as before. The gate gains only has_state_line, which it does not call, so no PR is judged differently.
blocker: none
major: none
minor: fork-kit/review/lib/review_eval.py:316-360: a run's sub-agent transcripts are now added to its usage, but every token is priced at the run's model (c['prices'].get(runs[rid]['model'])), and model_seen is the last file's model, which can be a sub-agent's. A sub-agent on another model is priced wrong and can mask the run's own model in cost.json. Impact is low because eval/prompt.txt:7 forbids sub-agents in runs. Fix: price per message model, and take model_seen from the session file.
minor: fork-kit/review/COMMENTS.md:12, SKILL.md:38/158/192: the check and plan commands that lens and orchestrator agents copy have no --settings. Only SKILL.md:42 and REVIEW.md:71 say to add it. On the fork, plan --base without it still prints "weight: normal" with the one fallback lens (seen on this branch), which is #914.3's symptom. The gate still enforces the real rules, so nothing passes wrongly; it costs a wasted round. Fix: put [--settings <file>] in those command lines, or name the fork's file in the fork's lens prompts.
minor: fork-kit/review/tests/plan.test.py:333 (class Fork) and REVIEW.md:71 put fork facts (.github/fork-review-kit.json, the fork's queue config and its critical paths) in the general kit's tests and docs. The kit code stays general. The fork contract (.github/scripts/fork-contracts.test.py) is the usual home for that test.
minor: .github/fork-pr-queue.json:35: .github/fork-review-kit.json is listed before .github/fork-removed-workflows.txt; the rest of the list is sorted.

@scuttletoby
scuttletoby merged commit 8bff65c into main Nov 22, 2026
30 checks passed
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: follow-ups from the #845 lens round 3 K1 review kit: minor follow-ups from the #790 lens

1 participant