labs
한국어 hello@taklabs.dev

Moving review rules from the docs into a commit hook

I added a hook that blocks plan-less orch commits over 200 lines and requires a review PASS record for smaller ones. I also moved the reviewer pin to sonnet and made tests run less often.

What went wrong?

/orch is the skill chain I use for larger work. It sizes a task: a small S is implemented directly but reviewed before commit, while M or larger gets a written plan and a review gate on every slice. During the 2nd regression run of the "orch diet", my effort to trim that chain, one result didn't add up. The run went out with model: sonnet in settings (I pinned the model later in a separate PR), and eight of the nine orch runs committed without ever spawning a reviewer. ko-qmd-33 committed a +212/−8 change with no plan and no gate at all.

committed with no reviewer spawned a reviewer 0 1 2 3 4 5 6 7 8 9 runs 2nd regression run: 9 orch runs

The rules were only in the skill docs: "over 200 lines goes to the M chain" and "even an S change gets reviewed before commit". They held when the model followed the docs, and nothing stopped it when it didn't. This PR makes three changes: it enforces the chain rule in a hook, changes the reviewer model pin, and runs tests less often.

What does the gate look at?

The new module is claude/hooks/orch_gate.py. When an orch run tries to commit on a feature branch with no plan, it checks two things:

  • If the commit is over 200 lines (added plus removed), it blocks and points to the M chain.
  • If it is 200 lines or less, it looks for a review PASS record written by s-gate.sh record and blocks if there isn't one.
yes no yes no yes no orch commit, no plan plan points at branch? pass over 200 lines? block, go to M chain review PASS record, docs-only commit, or /team session? block

The scope is narrow. The gate only acts when the last human prompt in the transcript is /orch, or when a Skill(orch) call follows it, so typing some other prompt partway through takes the session out of scope. If a plan points at the branch, or the commit is on the default branch or a detached HEAD, the gate doesn't look at all. A docs-only commit or a /team ticket session skips only the review-record requirement; over 200 lines it is blocked like any other. ORCH_CHAIN_GATE=off switches the gate off.

I didn't add a new hook entry. The existing commit-convention.py imports the module, so settings.json stays untouched. The gate also fails open: a transcript or git error, or a timeout, lets the commit through, and an exception inside the module leaves just one line on stderr. I'd rather the gate miss something now and then than break and block every commit.

Why change the reviewer and the test cadence in the same PR?

I moved the reviewer pin from opus down to sonnet and flipped the cross-model finder in /review --full (a second reviewer on a different model) to opus, so the finish review still gets a second model's eyes. That was my call on cost: in the 2nd regression run, the opus reviewer spawn took $0.80 of the $1.63 the hwip-705 orch run cost. A sonnet reviewer may find less at the slice gate, and I haven't measured that yet.

For the test cadence, I rewrote one line in the Cadence section of 02-implement:

type check and test after every edit
→ test only after edits that change the result; type check in the same shell call

How did I check it?

test-orch-gate.sh passed all 51 tests, but a green run doesn't show the tests exercise the gate. So I broke the gate on purpose in ten different ways (disabling the line limit, ignoring the record, ignoring the scope check, and so on) and reran them. The tests failed all ten times. test-commit-convention.sh passed 169, and CI passed in all ten groups.

For session detection, I ran 54 real bench transcripts from the main run plus the 1st and 2nd regression runs. All 27 orch sessions came back true and all 27 vanilla sessions came back false.

What can it still not stop?

The limits are written into the PR:

  • The plan check reads only the Branch: header, so an empty plan passes.
  • Calling s-gate.sh record without running a review also passes.
  • Splitting a big job into several commits of 200 lines or less slips past the M rule, and once tasks stack up on one branch, later ones pass on the earlier task's record.
  • A small diff that should be M because of a security trigger or a public contract only gets the S rule.
  • The model can set ORCH_CHAIN_GATE=off too, though that leaves a trace in the commit command.

Cost will also move. The Sonnet orch runs in the 2nd regression run were cheap at $5.52 because they skipped the chain, so with the gate forcing the chain I expect that number to go up. I measured it in the next regression run with the model pinned; the results are in the next section.

What turned up after the merge?

Another session cross-checked the gate after the merge and found one Important issue: it was counting changes that never go into the commit. With 250 unstaged lines in a tracked file, committing a 1-line file still counted as 251 lines and hit the M rule. #317 fixed it to count only what is staged plus the files the command itself stages, and took the ORCH_CHAIN_GATE=off hint out of the block message.

The same day, in a regression run with the model pinned to Opus, the gate fired in headless runs too. It blocked commits once in gikae-91 and twice in dotfiles-43, and no commit got around it with ORCH_CHAIN_GATE=off. The nine orch runs came to $28.49. Diet rounds 2 and 3 were in that run as well, so the gate's share can't be separated out.

What did it cost?

Two sessions, about $5.20 mostly on Fable and around $0.09 on Sonnet. I used orch two times, and simplify and land 1 time each.

Build stats

ModelInputOutputCache readCache writeUSD
claude-fable-5-28834,6288,605,084130,581$5.20
claude-sonnet-5-561,87540,28328,738$0.09
Total9436,5038,645,367159,319$5.29
claude-fable-5-28,770,381claude-sonnet-5-570,902
Tokens by model
orch2land1simplify1
Skill calls

Counted from 2 session transcripts at 2026-11-15T01:31Z (PR #316, sessions 2026-11-14 to 2026-11-14). Tokens include subagents; USD is list price. Code: +567 / −25 lines.