Verified. The --agent path gates on cfg.IsZero() (which ignores Role), while the bare-reviewers path reads s.Review[name] directly (cmd.go:391) — so a role-configured, skill-less generic reviewer works one way but is rejected the other. All three concrete findings hold up. Here's the consolidated review.
Code Review: entire review redesign + live-token emission
Overview
This branch reworks entire review into a role-first flow and restores iterative (live) token counts during agent runs. Five committed commits (~4,400 lines vs merge-base 73db6f8c) plus ~1,000 lines of uncommitted work. The major pieces:
- Roles (
roles.go, flags.go, settings/migration.go): per-agent reviewer/fixer/both/skip with a 5-step resolution fork, --reviewers/--fixer one-off overrides, and in-memory legacy-role migration.
- Setup (
setup.go): two-step role+skills picker replacing the removed first-run auto-picker; non-interactive invoker fallback.
- Live tokens (
codex/review_tokens.go, codex/reviewer.go, claudecode/reviewer.go): codex now tails the rollout file for per-turn token totals so the TUI updates during the run, not just at the end.
- Discovery refactor (
skilldiscovery/scan.go): shared three-roots walk + PickLatestVersion dedupe extracted out of claudecode/discovery.go (which shrank ~280 lines) and reused by codex.
Overall this is solid, well-tested work. The token double-counting concern is genuinely well-defended, migration is idempotent and tested, the discovery dedupe survived the refactor, and none of the documented anti-features were reintroduced. The findings below are mostly edge-cases and one ordering hazard worth fixing before merge.
★ Insight ─────────────────────────────────────
- The codex live-token design is interesting: codex's
--json stdout only carries usage on the terminal turn.completed, so to get per-turn updates the parser tails the rollout file (the same source codex's own interactive UI reads), located by thread_id. This is a "two producers, one channel" concurrency pattern where the consumer treats Tokens as cumulative/last-write-wins rather than additive.
- That last-write-wins contract is exactly why event ordering relative to
Finished matters (Finding 1) — there's no summation to smooth over a stale late value.
─────────────────────────────────────────────────
Findings
1. ⚠️ Medium-High — Rollout tailer can emit Tokens after Finished, overwriting the final tally
cmd/entire/cli/agent/codex/reviewer.go:130-237 (with review_tokens.go, consumer review/run.go:65-69)
The tailer goroutine and the scan loop both send Tokens on out. The tailer is only stopped in the deferred block (close(stop) → tailWG.Wait()), which by LIFO runs after the scan loop has already pushed the authoritative turn.completed Tokens (line 193) and Finished{Success:true} (line 233) onto the buffered channel.
I confirmed the consumer (run.go:65) ranges over all events until channel close and applies tokens = e last-write-wins (run.go:69). So if the tailer's ticker fires between the final Finished emission and close(stop), a stale rollout-file total lands after Finished and overwrites the correct final count. The Claude parser has a test (TestParseClaudeOutput_EmitsInputOnlyDuringRun) asserting no Tokens after Finished; the codex path has no such guard and is structurally able to violate it.
Impact is a possibly-stale final TOKENS display (not a crash) — but that's precisely the symptom the PR set out to fix ("final tally only appears at end"), so it's worth closing.
Fix: drain the tailer (close(stop) + tailWG.Wait()) before emitting the final turn.completed/backstop Tokens and Finished, instead of relying on the LIFO defer that fires after Finished is queued.
2. Medium — Codex install hint never suppressed (slash-form vs dollar-form mismatch)
cmd/entire/cli/agent/skilldiscovery/registry.go:72
The codex hint declares ProvidesAny: []string{"/codex:adversarial-review"} (slash form), but codex discovery now emits dollar-form names via skilldiscovery.DollarForm (discovery.go:39; test asserts $github:gh-review). isSuppressed (registry.go:111-121) does exact-string membership, so /codex:adversarial-review is never found in a discovered set containing $codex:adversarial-review. Result: the "Install codex-review-pack" hint shows even when the plugin is installed and discovered — the exact regression ProvidesAny exists to prevent.
Fix: change the codex fingerprint to dollar form: ProvidesAny: []string{"$codex:adversarial-review"}. (Claude hints are unaffected — claudecode discovery emits slash form.)
3. Medium — --agent <name> rejects a valid role-configured, skill-less reviewer
cmd/entire/cli/review/cmd.go:379-385
The --agent branch gates on !ok || cfg.IsZero(), but ReviewConfig.IsZero() deliberately ignores Role (only checks Skills/Prompt/Model/ReasoningEffort). A reviewer configured with a role but no skills/prompt is explicitly supported — setup.go has a "(no skills — generic review)" branch and VerifyConfiguredSkillsInstalled short-circuits to nil for empty skills. The bare-reviewers path reads s.Review[name] directly (cmd.go:391) with no IsZero check, so entire review works for such an agent but entire review --agent <that-agent> falsely reports "not configured as a reviewer."
Fix: gate on the role instead: if !ok || !cfg.Role.IsReviewer().
4. Low — Tailer absolute totals can oscillate / go backwards
cmd/entire/cli/agent/codex/review_tokens.go:77-80
The dedupe only suppresses exact-equal pairs (in == lastIn && outTok == lastOut). Two independent cumulative sources (stdout turn.completed vs rollout file) written at different instants can disagree mid-run, and a non-monotonic rollout rewrite (compaction/torn line) would be emitted as a decrease, making the live counter jump backwards. A skip when in < lastIn && outTok < lastOut guard would make the counter monotonic.
5. Low — mergeFlagOverrideWithSavedSkills drops saved Model/ReasoningEffort
cmd/entire/cli/review/flags.go:84-91
The flag-override merge copies Skills and Prompt from saved config but not Model/ReasoningEffort, so --reviewers <agent> silently loses a user's saved per-agent model/effort tuning. Likely fine for a one-off, but if those are meant to be sticky per agent, copy them alongside.
6. Low — Dead exported helpers + CLAUDE.md doc drift
picker.go:53,105,144: MergePickerResults, ComputeEligibleConfigured, SelectReviewAgent now have only test callers after the dispatch-fork rewrite (exported, so golangci-lint unused won't flag them). Consider removing them and their tests, or confirm they're intentional public API.
- CLAUDE.md references
PromptForAgent in picker.go (doesn't exist) and pickLatestVersion (now exported as skilldiscovery.PickLatestVersion). Worth a doc touch-up while this is fresh.
Test coverage gaps
Coverage for parsers, token accounting, role helpers, and migration is strong. The notable gaps:
- 🔴 Highest value — the 5-step resolution fork in
runReview (cmd.go:325-357) has its inputs tested but none of its outcomes. Untested branches: (a) non-interactive + invoker-detected → synthesized RoleBoth run, and the "do NOT persist" contract (no test asserts .entire/settings.json is unchanged after an invoker-only run — contrast the careful migration non-persistence test); (b) non-interactive + no config + no invoker → hard error; (c) interactive + unconfigured → "Run: entire review setup" pointer (guards against reintroducing the removed auto-picker). Plus invokerOnlyReviewConfig's not-installed / no-launcher error returns.
- Codex zero-usage backstop branch unproven (reviewer.go:221-225). The happy path is locked by exact-count tests (2 turns → exactly 2
Tokens), but the backstop's reason for existing — turn.completed with no usage block → emit once post-loop — is dead under all current fixtures. A fixture with {"type":"turn.completed"} and no usage asserting exactly one Tokens would close it.
mergeFlagOverrideWithSavedSkills curated-builtin fallback (flags.go:92-96) untested for the override-agent-not-in-saved-config path.
Verified correct (no action)
- Token double-counting avoided: neither parser sums subset fields (codex
cached_input/reasoning_output; claude sums genuinely-disjoint input/cache_read/cache_creation). emittedTokens gating cannot duplicate or skip the final tally.
MigrateLegacyRoles idempotency, anyEmpty short-circuit, at-most-one-fixer — thoroughly tested.
PickLatestVersion semver-vs-lexicographic dedupe preserved across the discovery refactor (covered end-to-end by both agents' discovery tests).
- Parser robustness (garbled lines →
RunError+continue, scanner-cap regression guard, missing terminal envelope → Finished{false}) — well covered.
- No anti-features reintroduced (no spawn-time multi-select,
PickAgents, first-run auto-picker, ConfirmFirstRunSetup). t.Parallel() usage and its t.Chdir/t.Setenv exceptions are correct. SilentError, settings-package access, and accessibility forms follow CLAUDE.md.
Recommendation: Address Finding 1 (ordering hazard on the final tally) and the two Medium correctness bugs (2, 3) before merge — all are small, localized fixes. The Lows and the resolution-fork test gaps can be follow-ups, though gap (a)'s non-persistence assertion is cheap insurance against a nasty hidden-state class of bug.
This review session will be recorded against the checkpoint on your next git commit. Want me to apply the fixes for Findings 1–3?