please review pr 963 and use /pr-review-toolkit:review-pr, /codex:review and /codex:adversarial-review
Assistant
I'll review PR 963 using all three requested skills. Let me start by invoking them in sequence.
★ Insight ─────────────────────────────────────
This repo has three distinct review skills that complement each other: pr-review-toolkit:review-pr runs a bundle of specialized reviewers (type design, silent failures, tests, comments), codex:review gets a second-opinion review from Codex/GPT-5, and codex:adversarial-review specifically challenges design choices rather than just checking correctness.
Running all three gives defense-in-depth: different models and different framings catch different issues.
─────────────────────────────────────────────────
Assistant
Now I have a good overview of PR 963. It's a 527-line change that adds typed error classification for Claude CLI failures. Let me launch the review agents in parallel.
Assistant
★ Insight ─────────────────────────────────────
The five pr-review-toolkit agents already converged on a clear top issue: SummaryTimeoutSeconds is wired into settings but no production code reads it, while the timeout error message tells users to set it. Multiple independent reviewers landing on the same finding is strong signal.
Now I'll run the Codex reviews — these use a different model (GPT-5) and bring an outside perspective. The adversarial one specifically challenges design choices rather than just correctness, so it should pressure-test things the in-family reviewers may have agreed with.
─────────────────────────────────────────────────
Assistant
Codex review started in the background. Now launching the adversarial review in parallel.
Assistant
The plain /codex:review rejected the focus text — it's now built-in only. I'll retry it without focus text after launching the adversarial review.
Assistant
Both Codex reviews are running in the background. I'll wait for them to complete.
★ Insight ─────────────────────────────────────
The codex:review skill recently changed: it no longer accepts focus text — that's now exclusively /codex:adversarial-review's domain. Good signal that the project is steering people to the right tool: plain review for general second-opinion, adversarial for targeted design challenges.
Running both in parallel since they're independent.
─────────────────────────────────────────────────
Assistant
Codex review complete and confirms the timeout-setting issue. Waiting for the adversarial review.
Assistant
All three reviews are complete. Here's the consolidated summary.
★ Insight ─────────────────────────────────────
All three independent review systems (pr-review-toolkit's 5 specialist agents, Codex GPT-5 standard review, Codex GPT-5 adversarial review) converged on the same top-priority issue: summary_timeout_seconds is parsed and advertised in error text but never read at runtime. When 8 distinct review passes from 2 different model families all flag the same thing, treat it as a hard blocker — the chance of a false positive is near-zero.
The adversarial review found the most architecturally interesting issue: manual_commit_condensation.go still drops typed errors as opaque log noise, which means the typed-error machinery only helps the explicit entire explain --generate path. None of the in-family reviewers spotted this because they all focused on the diff scope rather than upstream callers. That's the value of an adversarial framing — it questions whether the architecture is right, not just whether the code is right.
─────────────────────────────────────────────────
PR #963 Consolidated Review
Critical (must fix before merge)
1. summary_timeout_seconds is dead code — flagged by all three reviews
cmd/entire/cli/explain.go:520-535 — uses hard-coded defaultCheckpointSummaryTimeout = 30s; never calls settings.SummaryTimeoutValue()
cmd/entire/cli/explain.go:566 — error message tells users to set summary_timeout_seconds: 600 to fix the timeout, but doing so has zero effect
Fix: wire settings.Load().SummaryTimeoutValue() into generateCheckpointAISummary, OR remove the setting + the remediation text from this PR
2. Typed errors only help the explain path; auto-condensation drops them silently(adversarial finding)
cmd/entire/cli/strategy/manual_commit_condensation.go:459-464 — summary failures become logging.Warn and disappear
When Claude auth expires or quota runs out at commit time, the user sees nothing — exactly the observability gap this PR is trying to close
Fix: move classification/formatting to a shared boundary, or propagate typed errors so command-level code can warn the user once
High
3. Context-deadline path can mask real *ClaudeError () — if is , the typed returned is discarded; rate-limit failures around the deadline boundary get reported as timeouts. Check the err for first.
User
yes go ahead with all these
Assistant
Before diving in, I need to confirm which branch to apply fixes on — we're on checkout-963 but PR 963's branch is feat/explain-summary-observability, and the current branch has more changes than the PR.
Assistant
We're actually on the PR branch itself (feat/explain-summary-observability). But the local branch has 13 commits and 1607 line diff vs main, while PR 963 shows only 13 files / 527 additions. Something's off. Let me check.
Assistant
Important: the local branch has 13 commits but the remote PR only has 4. The extras include things like "TTY-gated deadline", "stream-json", and "map typed Claude errors to actionable user messages" — which may already address several review findings. I need to check before duplicating work.
Assistant
Before I start, I need to flag an important context shift and confirm the plan with you. Three things changed the situation:
You're on the PR branch (feat/explain-summary-observability), not just looking at it — the working tree is the live PR.
There are 9 unpushed commits beyond what reviewers see on PR 963. The remote PR has 4 commits / 13 files. Local has 13 commits / 18 files including big unpushed work: feat(claudecode): switch GenerateText to stream-json, feat(explain): TTY-gated deadline, idle watchdog, summaryProgressWriter, etc. So all the review findings need re-verification against the current local state — some may already be partially handled, others may have moved.
Even with all the unpushed work, SummaryTimeoutValue() is still dead code — confirmed via grep. So Critical #1 is real.
Two things I'd like to confirm before going:
Assistant
Quick answer to your question on the unpushed commits, then I'll start:
Unpushed local commits (10 total beyond the 4 on remote PR):
96ea1f2ffrefactor(claudecode): replace single-envelope parser with streaming reader
Big refactor
3
961c7458afeat(claudecode): switch GenerateText to stream-json with typed errors
Major change
4
566e7e9c4feat(summarize): forward progress callback and drop duplicate error wrap
Replaces remote 92449c4b1
5
facf4cb8efeat(explain): show transcript size in pre-flight summary message
UX
6
ca5d79fdbfeat(explain): add summaryProgressWriter for stream-driven progress
Streaming UX
7
ee5a17907feat(explain): wire progress writer and TTY-gated deadline
TTY deadline
8
d575a9cfffeat(explain): resolve TTY-gated deadline and add idle watchdog
Watchdog
9
b4b1e97a0fix(explain): eliminate data race in idle watchdog via atomic timestamp
Race fix
10
2965e2469feat(explain): map typed Claude errors to actionable user messages
Error mapping
So the local branch has substantial extra work — particularly the streaming and TTY-deadline machinery. I'll re-verify each finding against current state before fixing, since #3, #5, #8, #10 from the review touch code that's been heavily reworked.
Let me set up the task list and start.
Assistant
Re-verifying findings against current local state.
User
[Request interrupted by user]
User
do we need all these extra ones, were they forgotten? or i guess for more context, we split up 964 and 963
Assistant
Useful context. Let me check if those extras live in a sibling PR (e.g. 964).
Assistant
Confirmed — PR 964 (feat/explain-stream-progress) is stacked on top of 963. Let me check whether the unpushed commits live on 964's branch.
Assistant
That's the picture: the 10 unpushed commits on your local feat/explain-summary-observability branch are actually PR 964's work, split into finer-grained atomic commits. They don't belong on 963's branch — they should be on feat/explain-stream-progress.
Looking at PR 964's remote history, it currently has those changes as 2 fat commits (4d5c5afec feat: stream-driven progress... and c0e696173 fix: address PR review findings...). Your local branch has them as 10 well-separated atomic commits — clearly the same content, just better split.
They were forgotten on the wrong branch. If you push 963 from here, all 10 PR-964 commits would land on PR 963.
★ Insight ─────────────────────────────────────
This is a classic stacked-PR slippage: PR 964 is stacked on 963, you split 964's commits locally for cleaner history, but did the splitting on the base branch (963) instead of the dependent branch (964). When 963 merges, those commits would arrive in main as part of 963's diff — confusing reviewers and inflating 963's scope.
The fix is structural before code: get the 10 commits off this branch and onto feat/explain-stream-progress, reset this branch to origin/feat/explain-summary-observability, then apply review fixes only to the actual 963 scope.
─────────────────────────────────────────────────
Recommended sequence before any review fixes:
Save the 10 split commits by creating/updating a worktree or branch off origin/feat/explain-stream-progress, cherry-picking them on top
Reset local 963 to origin/feat/explain-summary-observability
Re-verify the 14 review findings against the actual PR 963 scope (much smaller — the streaming/TTY work won't be there)
Apply fixes one commit per finding as you wanted
Before I do anything destructive, two questions:
Assistant
I want to make sure I understand before doing anything destructive — your answer was a bit ambiguous to me. Let me confirm.
Assistant
Got it — just PR 963, scope it down. Let me preserve a backup pointer first (safety net), then reset, then verify and fix.
Assistant
Backup at 2965e2469. Now reset.
Assistant
Now matches PR 963 exactly: 13 files, 527/22. Re-verifying findings against this trimmed scope.
Assistant
All 14 findings confirmed against the trimmed PR 963 scope. Ready to start fixing. I'll do them in dependency order — #11 constructor first since later fixes will use it, then easier ones, then the architectural ones.
One note before I start: Finding #2 (condensation drops typed errors) is in manual_commit_condensation.go which is not currently in PR 963's diff. Fixing it properly expands PR 963's scope by 1 file. I'll defer that one and ask you at the end.
Assistant
Fix #11: ClaudeError constructor
★ Insight ─────────────────────────────────────
I'm doing this first because subsequent fixes (#4, #5, #10) will create new ClaudeError instances. If I add the constructor first, those fixes use it immediately and the codebase doesn't drift.
I'll keep ClaudeErrorKind as a string alias (less churn than int constants) but add a valid() check + central constructor that defaults invalid kinds to ClaudeErrorUnknown. This closes the practical gap without forcing a big rename.
─────────────────────────────────────────────────
User
[Request interrupted by user]
User
reverify fixes after narrowed scope, are all these actually needed
Assistant
Good check. Let me re-walk each finding against the actual trimmed PR 963 code rather than the original review (which was partly against local extras).
Assistant
Here's the honest assessment per finding against the trimmed PR 963 scope:
#
Finding
Status
Worth doing?
1
SummaryTimeoutValue() is dead code; error message tells users to set the setting
✅ Real, HIGH impact (the message lies to users)
Yes — required
2
Condensation drops typed errors as opaque log noise
✅ Real but in manual_commit_condensation.go, NOT in PR 963
No — out of scope; defer to follow-up
3
Context-deadline check can mask real *ClaudeError
⚠️ Real but extremely narrow race (CLI returns ClaudeError and timeoutCtx happens to fire). Normal cases work because GenerateText returns sentinel errors directly when ctx is done.
Marginal — small fix, edge case
4
isExecNotFound uses os.ErrNotExist (too broad)
⚠️ The code comment shows it's intentional defensive coding for absolute-path failures. claudePath := "claude" is PATH-based so the broad check never triggers anyway.
No — stylistic; current code is correct
5
ClaudeError.Error() empty Message lacks ExitCode
✅ Real diagnostic gap on segfault/SIGKILL
Yes — small win
6
Stderr fallback: only 2 phrases, 500-byte truncation
⚠️ Comment says it's intentionally minimal because envelope is the primary path. Adversarial review wanted fixtures for future-proofing.
No — current design is documented as intentional
7
No errors.As preservation tests in summarize
✅ Real — the //nolint:wrapcheck annotations are the entire contract; nothing tests them
Yes — important regression guard
8
Envelope with result:null + is_error:true falls through to "missing result item"
✅ Real edge case; loses signal
Assistant
What would you like to clarify? I can explain any of the trade-offs in more detail, or revise the scope based on your priorities.
User
okay and you're clear on what this pr does?
Assistant
Yes — let me state it back to make sure we're aligned:
PR 963 — what it does:
Before this PR, when entire explain --generate failed because the Claude CLI hit auth/rate-limit/invalid-model errors, users saw opaque garbage:
failed to generate summary: failed to generate summary: claude CLI failed (exit -1): (double-wrapped)
failed to parse summary JSON: ... (response: There's an issue with the selected model...) (the CLI returned an error envelope; the old code tried to parse the human-readable error text as a Summary struct)
Root cause: Claude CLI returns most operational errors at exit 0 with is_error: true in the JSON envelope. The old code only checked exit codes, not is_error.
What the PR changes:
Extends the response envelope parser to capture is_error, subtype, api_error_status
GenerateText now checks is_error on every response and returns a typed *ClaudeError with a Kind (auth / rate_limit / config / cli_missing / unknown) classified from HTTP status code
Stderr fallback for the rare case the CLI dies non-zero before producing an envelope
Drops duplicate error-wrapping in the summarize layer so *ClaudeError survives errors.As up to explain
New formatCheckpointSummaryError in explain.go maps each Kind to actionable user wording (auth → "run claude login", rate_limit → "wait and retry", etc.)
Adds SummaryTimeoutSeconds setting — but the PR body says this is groundwork: "used by the timeout message, and by a follow-up PR for TTY-gated deadline strategy"
Scope clarification this triggers for finding #1: The setting being unwired in this PR is intentional per the body — it's groundwork for PR 964. The actual bug isn't "wire it up in 963"; it's that the timeout error message at explain.go:566 advertises a setting that won't actually do anything until 964 lands. Two ways to fix:
(a) wire it up here — slight scope expansion, makes the message honest immediately
(b) remove the misleading advice from the error message — stays in stated PR scope; PR 964 puts the advice back when wiring lands
Same logic for finding #12 (the doc says "no deadline interactive, 5 min in CI" which is also aspirational for PR 964).
So the real question is: for #1+#12, do you want to push the wiring into PR 963 (option a), or keep PR 963 honest about being just the typed-error classification and pull the misleading advice out (option b)?
User
okay good, now proceed with fixes
Assistant
Going with option (b) for #1+#12 (keeping PR 963 honest — trim the misleading advice; PR 964 puts it back when wiring lands). Cleaning up tasks first.
Assistant
Commit 1/6 — Fix #5: Surface ExitCode in Error() fallback
Writing failing test first.
Assistant
Now the fix:
Assistant
Commit 2/6 — Fix #8: Surface envelope is_error when result is null
Assistant
Add failing test for null-result + is_error case:
Assistant
Now fix the parser:
Assistant· <synthetic>
API Error: Stream idle timeout - partial response received
User
prcoceed
Assistant
Commit 3/6 — Fix #10: Apply auth phrase check to envelope text when apiStatus nil
Assistant
Add new table rows for envelope auth fallback:
Assistant
Now the fix. I'll extract the phrase scan to a tiny helper so both classifiers share it:
Assistant
Commit 4/6 — Fix #7: errors.As preservation tests in summarize
Assistant
Now add the companion test in summarize_test.go:
Assistant
★ Insight ─────────────────────────────────────
I deliberately wrapped the error in an outer fmt.Errorf("...: %w", err) before the errors.As check. If the production code did a bare return err, errors.As(err, &ce) trivially passes. But the real threat is future code adding any wrapping — so testing through at least one wrap is what validates the contract the //nolint:wrapcheck comment actually defends.
To make this a genuine regression guard, if someone "fixes" the nolint by writing fmt.Errorf("foo: %v", err) (note: %v, not %w), the test fails. If they use %w, it passes — which is correct; %w preserves the chain.
─────────────────────────────────────────────────
Now trim the misleading advice in the timeout error message:
Assistant
Now I need to check if any test asserts the removed line:
Assistant
Update the test to match the trimmed message:
Assistant
Good question. Let me check what 964 currently does with the timeout to answer you properly.
Assistant
Let me answer your question with the full picture:
What's actually going on with timeout infrastructure:
main already has the 30s hardcoded timeout (defaultCheckpointSummaryTimeout = 30 * time.Second). It predates PR 963.
PR 963 inherits main's 30s timeout unchanged. The PR itself only added:
The SummaryTimeoutSeconds setting + SummaryTimeoutValue() accessor (unwired, groundwork for 964)
The advice line "Try: set summary_timeout_seconds: 600..." in the timeout error message
PR 964 replaces the 30s hardcoded timeout with a three-mode deadline system (deadlineModeNone / deadlineModeIdle / deadlineModeHardClock) and wires up SummaryTimeoutValue().
What my commit just did:
Trimmed the misleading advice from the error message (that line was 963's addition)
Trimmed the aspirational "no deadline interactive, 5 min in CI" from the setting's doc comment
Kept the 30s timeout (inherited from main) and kept the setting/accessor unchanged
So: I'm not removing the timeout itself. The 30s hardcoded timeout is main's, not 963's. PR 964 removes it.
Your call on scope:
Assistant
Good — commit stands as-is. Moving to the last fix.
Assistant
Commit 6/6 — Fix #13 + #14: Comment trims
Assistant
Final verification — mise run check
Assistant
All green. Final summary:
Assistant
6 commits landed, full check passes. Summary of changes to PR 963:
#
Finding
Commit
#5
ExitCode in empty-Message fallback
ea2128845
#8
Null-result + is_error envelope handling
071b08991
#10
Auth heuristic applied to envelope text
59ffbee3f
#7
*ClaudeError preservation tests in summarize
4ad8c1be6
#1 + #12
Trim misleading timeout-setting advice + aspirational docs
a07871c36
#13 + #14
Drop rot-prone comments on formatter + ClaudeError fields
16369dad1
Skipped (with rationale):
#2 — out of scope (touches manual_commit_condensation.go, not in PR 963)
#3 — extreme edge case (race: ClaudeError + timeout simultaneously)
#4 — current isExecNotFound is intentional defensive coding
#6 — stderr fallback is intentionally minimal per the existing comment
#9 — %w-wrap has no downstream consumer today (PR 964 will add one)
#11 — open ClaudeErrorKind set works by convention today
Want me to push these to origin/feat/explain-summary-observability?
User
yes go ahead
Assistant
Remote hasn't moved. Clean fast-forward push — no force needed.
Assistant
Pushed — PR 963 now at 16369dad1.
Assistant
Updated: https://github.com/entireio/cli/pull/963 — now +684/-23 across 14 files (was +527/-22 across 13; new file is summarize/summarize_test.go edit which was already listed, so 14 vs 13 reflects the added test coverage).
Also preserved the pre-reset local state in branch backup-963-with-964-splits-pre-reset (pointing at 2965e2469) in case you ever need the 10 atomic split commits of PR 964.
User
okay now run full user simulation so we see fix from user persepctive now. pull latest from main and
this branch
Assistant
Plan: pull latest, build the CLI, then exercise each failure mode by stubbing claude on PATH and running entire explain --generate against a real checkpoint. I'll compare pre-fix vs post-fix behavior where possible.
Assistant
Step 1: Pull latest
Assistant
Main hasn't moved and our remote PR branch is in sync with HEAD. No rebase needed.
Assistant
Step 2: Build
Assistant
Built with our latest fix commit (16369dad1). Moving on.
Assistant
Step 3: Set up a test repo with a real checkpoint
The IDE-opened log file at /Users/peytonmontei/demo-repository/.entire/logs/entire.log suggests you already have a demo repo. Let me check if it has a usable checkpoint.
Assistant
Demo repo has a settings compatibility issue. Let me create a clean minimal test repo instead.
Assistant
Rather than wrestle with entire enable's UX, let me write a focused simulator that exercises the exact error path users hit: GenerateText → GenerateFromTranscript → formatCheckpointSummaryError, printing the final rendered user message per scenario. That's what the user actually sees.
Assistant
NewClaudeCodeAgent returns an agent.Agent interface. Let me check how the existing claudecode tests set up a CommandRunner:
Assistant
Construct the struct directly, not via NewClaudeCodeAgent. Also need to work around the TextGenerator interface expectation:
Assistant
Working. Let me capture the full output.
Assistant
Sim ran successfully. But it exposed a real issue: two scenarios now render an empty message ("Claude failed to generate the summary: " with nothing after the colon):
null-result-envelope-500 — Fix #8 saved the envelope, but it has result:null so Message="", and formatCheckpointSummaryError reads .Message directly (not Error()), bypassing Fix #5's exit-code fallback.
stderr-empty-oom-137 — Same root cause. Exit 137 with empty stderr → Message="", same empty rendering.
This is ironic: Fix #5 and Fix #8 both fix part of the problem (respectively, the type's self-rendering and the parser preservation), but the formatCheckpointSummaryError default branch still reads .Message directly, so users get the whitespace-only output.
Let me update the task list and check if this is a regression vs main:
Assistant
Pre-fix state restored. Running sim with PRE-FIX code:
Assistant
Now I have the side-by-side. Let me restore my fixes and then look at what needs a 7th commit.
Assistant
Side-by-side comparison — pre-fix vs post-fix user output
Here's what an entire explain --generate user sees for each failure mode:
Scenario
Pre-fix
Post-fix
Verdict
auth-401-envelope
Claude authentication failed: Invalid API key · Please run /loginRun \claude login` and retry`
same
✅ already good
rate-limit-429
Claude rejected the summary request due to rate limits or quota: ...Wait and retry
same
✅ already good
config-invalid-model
Claude rejected the summary request: Model "haiku-nonsense" not foundCheck your Claude CLI config and selected model
same
✅ already good
stderr-auth-nonzero-exit
Claude authentication failed: error: Invalid API keyRun \claude login` and retry`
same
✅ already good
cli-missing
Claude CLI is not installed or not on PATH
same
✅ already good
envelope-auth-no-status
Claude failed to generate the summary: Invalid API key — please run /login ← missing auth guidance
Claude authentication failed: Invalid API key — please run /loginRun \claude login` and retry`
✅ Fix #10 improves
deadline-exceeded
...sonnet is taking longer...Try: set summary_timeout_seconds: 600 in .entire/settings.local.json (or 0 to disable) ← misleading (setting doesn't work)
(line removed)
✅ Fix #1 improves
null-result-envelope-500
Claude failed to generate the summary: failed to parse claude CLI response: unsupported Claude CLI JSON response: json: cannot unmarshal object into Go value of type []claudecode.responseEnvelope
Claude failed to generate the summary: ← empty!
⚠️ Fix #8 regressed UX
stderr-empty-oom-137
Claude failed to generate the summary: ← empty
★ Insight ─────────────────────────────────────
Two issues the simulation revealed that the unit tests missed: Fix #8 and Fix #5 both work at the typed-error layer (classifier and .Error()), but formatCheckpointSummaryError's default branch reads claudeErr.Message directly — bypassing both. Users see whitespace-only output in the null-result + OOM cases.
This is exactly why user-perspective simulation matters. The unit tests verified the pieces; the sim verified the assembled experience.
─────────────────────────────────────────────────
Clear fix path — one more commit: make formatCheckpointSummaryError's default branch fall back to exit code and/or API status when Message is empty. Small, targeted, fixes both gaps.
Now rerun the user sim to confirm the two empty-message scenarios are fixed:
Assistant
Both empty scenarios now render useful info:
Claude failed to generate the summary (Anthropic API returned HTTP 500) ✅
Claude failed to generate the summary (claude CLI exited with code 137) ✅
Final check — remove the sim test file (it's dev-only, shouldn't ship), then commit:
Assistant
Clean. Commit & push:
User
[Request interrupted by user for tool use]
User
but is right response from failed cluade, - Claude failed to generate the summary (claude CLI exited with code 137) ✅ - prior was empty error?
Assistant
Good question. Let me verify directly and show you:
Yes, the prior output was truly empty. Re-running the pre-fix sim earlier showed literally:
code
SCENARIO: stderr-empty-oom-137
| Claude failed to generate the summary:
(the trailing space after : is real — nothing renders after it).
But is my new message right? Honestly, it's "better than empty" but not ideal:
Claude failed to generate the summary (claude CLI exited with code 137)
✅ Non-empty
✅ Technically accurate
⚠️ Cryptic to a non-dev: most users don't know exit 137 = SIGKILL = usually OOM
⚠️ Doesn't tell them what to do
A real-world exit 137 with no stderr almost always means:
OOM killer (most common — large transcript + small RAM)
Manual SIGKILL
Container memory limit hit
Three options for what to put in the message:
Assistant
Keeping it as-is then. Proceeding with the commit.
User
[Request interrupted by user for tool use]
User
run user flow again where you uncovered this again to cover all user scnearios to test fix again
Assistant
All 9 scenarios pass. Here's the complete post-fix user view — what a user of entire explain --generate sees for every failure mode:
#
Scenario
User sees
1
auth-401-envelope
Claude authentication failed: Invalid API key · Please run /loginRun \claude login` and retry`
2
rate-limit-429
Claude rejected the summary request due to rate limits or quota: Rate limit reached. Please try again in 1 hour.Wait and retry
3
config-invalid-model
Claude rejected the summary request: Model "haiku-nonsense" not foundCheck your Claude CLI config and selected model
4
null-result-envelope-500
Claude failed to generate the summary (Anthropic API returned HTTP 500)
5
envelope-auth-no-status
Claude authentication failed: Invalid API key — please run /loginRun \claude login` and retry`
6
stderr-auth-nonzero-exit
Claude authentication failed: error: Invalid API keyRun \claude login` and retry`
7
stderr-empty-oom-137
Claude failed to generate the summary (claude CLI exited with code 137)
8
cli-missing
Claude CLI is not installed or not on PATH
9
deadline-exceeded
Claude did not return a summary within the 500ms safety deadline. This usually means one of: - sonnet is taking longer than expected on a large transcript - the Claude CLI cannot reach Anthropic's API (network, VPN, firewall) Try: run \claude --print "hi"` from a shell to confirm the CLI works<br> - Anthropic's API is degraded<br> Check: https://status.anthropic.com`
Verified:
✅ No bare colons / empty messages
✅ Auth paths correctly route to the Run \claude login`` guidance (including #5 — envelope with no status code, which Fix #10 added)
✅ Timeout message no longer advertises the unwired summary_timeout_seconds setting (Fix #1)
✅ Null-result envelope shows API status instead of the ugly json: cannot unmarshal... internal error (Fix #8 + the new fallback)
✅ OOM-style crashes show exit code instead of empty (the new fallback on top of Fix #5)
Ready to commit the 7th fix + push. Shall I proceed?
All mise run check passes (fmt, lint, unit, integration, E2E canary)
Sim-verified user experience for every failure mode: no empty messages, auth paths get the claude login guidance, rate-limits and invalid-model errors get appropriate wording, null-result envelopes render the API status, OOM-style crashes show the exit code, timeout no longer advertises an unwired setting.
User
do you need to upate pr description w results and or in general
Assistant
Yes, worth updating. The PR now has 11 commits and the description doesn't reflect the review-feedback round or the user-sim results. Here's what I'd propose adding — let me show you before I modify GitHub:
Proposed addition to the PR description (appended after the existing "Test plan"):
markdown
Assistant
Let me check for conflicts first, then come back to the PR description question.
Assistant
Good points on both. Let me handle the conflict first.
Assistant
Let me see what main did to each conflicting file before rebasing.
Assistant
Attempting rebase onto main:
Assistant
Resolving the first conflict in settings.go — both sides added different fields in the same struct:
Assistant
This is a structural conflict — main refactored GenerateText to use a shared helper agent.RunIsolatedTextGeneratorCLI. Let me check its signature.
Assistant
This conflict has design implications — let me stop and report before going further. I'll abort the rebase and preserve the current (pre-rebase) state so we can discuss.
Assistant
Rebase aborted. Back at ac6c85105. Here's the situation:
Conflict summary
Easy conflicts (already saw how to resolve):
settings.go — main added SummaryGeneration provider + Vercel fields; ours added SummaryTimeoutSeconds. Just stack both. ✅ trivial
Hard conflict (structural):
claudecode/generate.go — main refactored the whole function to use a new shared helper agent.RunIsolatedTextGeneratorCLI that unifies all 6 text-gen agents (codex, copilot, cursor, gemini, etc.) behind one runner. That helper returns (string, error) only — it collapses stderr + exit code into a formatted error string.
The design tension: PR 963's typed-error classification needs:
stdout (for envelope is_error check)
stderr (for auth-phrase fallback)
exit code (for Fix #5 diagnostics)
Main's helper deliberately hides all three behind a single string error. You can't add PR 963's classification on top of it without either:
★ Insight ─────────────────────────────────────
This is a classic "stack at the wrong height" conflict: main unified all agents at the "run CLI + simple error" layer, but PR 963 wants typed errors specifically for Claude, which needs raw access to stderr + exit code. The helper's API is too narrow for the richer contract 963 needs.
Resolution options range from cheap/local (bypass the helper) to principled/structural (extend the helper's return type).
─────────────────────────────────────────────────
Three resolution paths
Assistant
Going with a merge commit approach instead of rebase — resolves conflicts once instead of 11× and avoids force-push.
Assistant
3 conflicts. Let me resolve each.
Assistant
Starting with the easy one — summarize_test.go:
Assistant
Now settings.go:
Assistant
Now generate.go — the structural one. Approach: keep PR 963's direct cmd.Run() pattern (since it needs stderr/exit/envelope), add a comment explaining why it doesn't use the shared helper.
Assistant
StripGitEnv is exported. I can reuse it. Let me rewrite the whole file:
Assistant
Clean. Running tests:
Assistant
All pass. Let me also re-run the user simulation to confirm behavior survived the merge, and do the full check:
Assistant
Those go.mod/go.sum diffs come from main's merge — they'll land in the merge commit automatically. Finishing the merge now:
Assistant
Lint passed (transient network blip on schema validation is unrelated). Running full check:
Assistant· <synthetic>
API Error: Unable to connect to API (ConnectionRefused)
User
proceed
Assistant
All three test tiers pass. The earlier check failure was the transient lint-schema network blip. Pushing merge:
Assistant
SSH port 22 is blocked. Using SSH over 443:
Assistant
Merge pushed. Verify PR no longer conflicts:
Assistant
mergeable: MERGEABLE — conflicts resolved. BLOCKED is likely just the "needs review approval" gate, not a conflict.
Assistant
PR description — rewrite as branch-level summary
Your feedback: a PR summary should describe what the entire branch does from a product perspective, not list commits. Here's the proposed new body:
Commits: 4 original + 7 review fixes + 1 merge commit = 12 on branch
Diff: +789 / -24 across 14 files
Description: rewritten as a product-level summary (no commit-by-commit log)
All tests: unit + integration + E2E canary all pass
Sim-verified: 9 failure modes, all produce non-empty actionable user messages
Notable design decision in the merge:claudecode.GenerateText deliberately doesn't use main's new agent.RunIsolatedTextGeneratorCLI shared helper, because the helper collapses stderr + exit code into a formatted string, and Claude's envelope-based is_error semantics need structured access to stdout + stderr + exit code to produce typed errors. Added a comment explaining why. If code-review pushes back on the divergence, the principled fix is extending the helper's return type — but that's scope creep for this PR.
User
why did the rebase cause an insertion of 200 lines
Assistant
Good catch — let me investigate. PR was +684/-23 before the merge, now +789/-24. That's +105 insertions delta. Let me find out where they came from.
Assistant
Good catch. Let me quantify precisely where those lines came from.
Assistant
Actual numbers (not 200 — 36):
Before merge: +753 insertions across 14 files
After merge: +789 insertions across 14 files
Delta:+36 lines, entirely in cmd/entire/cli/agent/claudecode/generate.go (went from +44 to +81)
Why: Main recently landed a refactor that moved CLI-running boilerplate into a shared helper agent.RunIsolatedTextGeneratorCLI:
stdoutText, err := agent.RunIsolatedTextGeneratorCLI(ctx, ...)1 line
So main's generate.go is ~30 lines shorter now. When we merged, our PR needs to keep the structured cmd.Run pattern (we need stderr + exit code for envelope classification), which means restoring those ~30 lines — but they look like "insertions" in the PR diff because main no longer has them.
Breakdown of the 36 new insertion lines in generate.go:
~18 lines: inline cmd setup (cmd.Dir, cmd.Env, cmd.Stdin, stdout/stderr buffers) — restored because the shared helper hides these
~8 lines: new doc comment explaining why Claude doesn't use the shared helper (envelope-based error semantics need access to stderr + exit code)
~10 lines: the isExecNotFound helper we kept (stripGitEnv got removed since we now use agent.StripGitEnv from the shared package — actually a small subtraction)
★ Insight ─────────────────────────────────────
The diff-size delta from the merge is a fair signal that PR 963 is now inconsistent with the rest of the codebase (everyone else uses the helper, we don't). If reviewers push back, the principled answer is to extend the helper's return type to optionally expose stderr + exit code — but that touches 5 other agents and is genuine scope creep.
The comment in generate.go is the load-bearing thing: it tells the next reader "this divergence is deliberate, here's why." Without that, the next refactor would quietly re-introduce the helper and silently kill the error classification.
─────────────────────────────────────────────────
Net: the merge cost us 36 lines in one file, all structurally justified, all explained by a single design-decision comment.
User
find where we went from ~500 diffs to ~700
Assistant
Let me trace the +527 → +684 jump through our 7 review-fix commits.
Assistant
Tracked down. The PR grew from 527 → 753 lines (+226) through the 7 review fixes, then +36 in the merge. Here's the exact attribution:
Commit
Per-commit Δ
Cumulative PR
What drove the growth
92449c4b1 baseline
—
527
original PR
ea2128845 Fix #5 ExitCode
+23
550
2 new tests + 3 lines in Error()
071b08991 Fix #8 null result
+35 -2
584
1 new test + 10 lines in parser
59ffbee3f Fix #10 auth-on-envelope
+19 -5
598
2 new test table rows + hasAuthPhrase helper
4ad8c1be6 Preservation tests (#7)
+88
686
2 new test functions + errorGenerator stub + claudecode imports
a07871c36 Fix #1 trim advice
+5 -5
686
pure swap, net zero
16369dad1 Docs cleanup
+4 -6
684
shrinks slightly
ac6c85105 Empty-msg fallback
+70 -1
753
formatClaudeErrorSuffix helper + 3 new tests
merge with main
+36 -1
789
restored inline cmd.Run setup in generate.go
The two big contributors — both tests:
4ad8c1be6 (+88): preservation regression tests pinning the //nolint:wrapcheck contract (the whole point of that commit was tests; zero production lines)
ac6c85105 (+70): new formatClaudeErrorSuffix (~25 lines production) + 3 test cases guarding it (~45 lines tests)
~60% of the growth is test coverage, not production code. Rough production vs test split across the 7 fixes:
Production code added: ~70 lines
Tests added: ~155 lines
★ Insight ─────────────────────────────────────
The *ClaudeError preservation tests (4ad8c1be6) cost 88 lines but prevent the entire PR's value from being silently reverted by a future refactor — the two //nolint:wrapcheck annotations are the only thing between typed errors and flat string errors, and nothing else pins that contract. High line count for high structural value.
Two-thirds of the PR growth being tests is a healthy signal for a PR like this. Error-handling code that's under-tested is exactly how regressions slip in silently.
─────────────────────────────────────────────────
User
why do we need those tests and review all tests using /test-auditor, you tend to write a lot of tests compared to production code, and we don't want to overload code base on assumption of merging this, and want to add the fix, but not with so many tests, make hard to review PR and also many additions
Assistant
Fair pushback. Let me audit them.
Assistant
Test Audit Summary
Branch: feat/explain-summary-observability (7 review-fix commits touching 4 test files)
Existing Test Ratings
Test
File
Lines
Rating
Reason
TestClaudeError_ErrorEmptyMessageIncludesExitCode
error_test.go
10
KEEP
Tests the main branch of the new fallback — real regression guard
TestClaudeError_ErrorEmptyMessageNegativeExitCode
error_test.go
10
REMOVE
Duplicate: same ExitCode != 0 branch. Language guarantees cover -1 vs 137
Only guard for the null-result envelope fix — non-negotiable
AuthFromResultWhenStatusNil (table row)
error_test.go
1
KEEP
Tests the new envelope-auth path
AuthFromResultCaseInsensitive (table row)
error_test.go
1
REMOVE
Case-insensitivity already tested via stderr path; both paths share hasAuthPhrase — redundant
TestClaudeGenerator_PreservesClaudeError
summarize/claude_test.go
41
REMOVE
Consolidate into one end-to-end test through the real chain
TestGenerateFromTranscript_PreservesClaudeError
summarize/summarize_test.go
41
REWRITE
Use real ClaudeGenerator + stubTextGenerator to cover both//nolint:wrapcheck sites in one test
errorGenerator stub
summarize/summarize_test.go
6
User
sure go ahead
Assistant
1. Remove duplicate negative-ExitCode test + redundant auth row
Assistant
2. Consolidate preservation tests
Remove standalone TestClaudeGenerator_PreservesClaudeError in claude_test.go:
Assistant
Both imports are now unused. Remove them:
Assistant
Now rewrite the remaining preservation test to go through the real ClaudeGenerator + stubTextGenerator chain (covers both//nolint:wrapcheck sites in one test):
Assistant
3. Collapse 3 UnknownEmptyMessage tests into table-driven
Assistant
Now verify everything builds and passes:
Assistant
All green. Check diff size:
Assistant
Saved 81 lines. Committing:
Assistant
Pushed. Final state:
PR size: 789 → 708 insertions (−81 lines)
Test functions in our commits: 11 → 6
Coverage: unchanged — all 4 consolidated areas still have regression protection, just through fewer + better-targeted tests
AuthFromResultCaseInsensitive row — redundant with stderr-path test
TestClaudeGenerator_PreservesClaudeError — absorbed into end-to-end test
errorGenerator stub — no longer needed
2 of 3 UnknownEmptyMessage* tests — collapsed into table rows
User
now run /pr-review-toolkit:review-pr /codex:review and /codex:adversarial-review on entire branch changes and run through fix for 963 only
Assistant
Running pr-review-toolkit first; I'll launch the two Codex reviews in parallel after.
Assistant
Launching all 5 specialist reviewers in parallel, plus the two Codex reviews (adversarial in background, standard uses working-tree).
Assistant
Excellent comprehensive review. Now launching the two Codex reviews in parallel:
Assistant
Both Codex reviews running in background. While they work, here's the pr-review-toolkit summary (5 agents already done):
Round 2 Review — pr-review-toolkit findings
Critical (blocking)
Silent-failure-hunter #1 — explain.go:570-575: If err is *ClaudeError AND timeoutCtx.Err() fired (race), the typed error is LOST because fmt.Errorf("...: %w", context.Canceled) wraps the sentinel not the err. At explain, errors.As fails → user sees bare "canceled"/"timed out" instead of real auth/rate-limit message. Same issue my own review flagged earlier as #3. Fix: fmt.Errorf("...: %w", err) so the ClaudeError survives, since formatCheckpointSummaryError already checks typed-error first.
High
Silent-failure-hunter #2 — response.go:38-44: Array-response path still requires Result != nil. If Claude emits an array ending in {is_error:true, result:null, api_error_status:500}, we fall through to "missing result item" and discard the signal. Mirror the object-path fix.
Silent-failure-hunter #3 — generate.go:86-89: Parse-error on exit 0 drops raw stdout. User sees "failed to parse claude CLI response: " but never what was actually printed.
Silent-failure-hunter #4 — generate.go:76-81: Non-zero exit with empty stderr but non-empty stdout discards stdout. Shared helper falls back to stdout; this path doesn't.
Silent-failure-hunter #5 — explain.go:623-635: ClaudeErrorUnknown with all-zero fields renders empty suffix — "Claude failed to generate the summary" with NO diagnostic. Reachable via classifyEnvelopeError("", nil, 0). The all-zero branch isn't tested.
Medium (should fix)
isExecNotFound may false-positive on any wrapped os.ErrNotExist — narrow with filepath.IsAbs(claudePath) or drop the os.ErrNotExist arm
500-byte stderr truncation runs BEFORE hasAuthPhrase check — a long panic trace ending in "Invalid API key" misses auth classification. Also can split UTF-8
Exit code -1 renders as "exited with code -1" in user output — misleading
TestFormatCheckpointSummaryError_DeadlineExceeded doesn't negative-assert that summary_timeout_seconds is absent — Fix #1 has no regression guard
Assistant
Codex found the same array-form envelope issue AND a new one: formatCheckpointSummaryError hardcodes "Claude" and "sonnet" in messaging, but entire explain --generate now supports multiple summary providers (codex, gemini) per PR 887. If a non-Claude provider hits a deadline, user gets Claude-specific guidance. That's a real bug from the interaction between PR 887 (provider selection) and PR 963 (Claude-specific wording).
Waiting for the adversarial review.
Assistant
All reviews done. Aggregating:
Round-2 Review Aggregate
Confirmed by 2+ independent reviewers (high confidence)
#
Issue
Reviewers
Fix size
A
Array-form envelope still drops is_error:true + result:null (response.go:38)
Parse-error drops stdout (generate.go:86) — real but niche
Non-zero exit + stdout-only discards stdout — real but niche
500-byte UTF-8 boundary split — real but rare
isExecNotFound too broad — false-positive surface is small
responseEnvelope.Subtype dead weight — cosmetic
ClaudeErrorKind zero value — cosmetic
Recommended fix set (economical, in-scope)
Only A, B, D, E, F, G — all are real user-visible bugs or load-bearing design issues. Total: ~20 production lines, ~4 test rows (not new test functions).
Assistant
Starting with Fix A — array-form null-result envelope:
Assistant
Add test row for array-form null-result envelope:
Assistant
Convert the null-result test to cover both object and array shapes via table:
Assistant
Fix D — Context cancel/deadline path preserves typed error
Assistant
Add a regression test for the race scenario:
Assistant
Add a regression test for the typed-error-vs-sentinel race:
Assistant
Fix E — All-zero ClaudeError fallback in formatClaudeErrorSuffix
Assistant
Also apply Fix B (treat ExitCode < 0 as "abnormal termination" rather than "exit -1") together with Fix E (all-zero fallback):
Assistant
Extend the existing table to cover all-zero and negative-exit rows:
Assistant
Fix F — Provider-neutral timeout messaging
Assistant
Update the deadline test to drop status.anthropic.com assertion and add the negative assertion for summary_timeout_seconds (Fix G):
7d189d738 — Fix D: typed *ClaudeError no longer lost when ctx is done independently (+ regression test)
6401dca62 — Fix B + E: negative ExitCode renders as "abnormal termination"; all-zero ClaudeError gets diagnostic sentinel instead of empty suffix
a28fbbefe — Fix F + G: timeout message is provider-neutral (no more hardcoded "Claude/sonnet/Anthropic" breaking non-Claude providers); test negative-asserts against regressions
PR state:
15 commits total on branch (+4 from round 1, +1 merge, +1 test audit, +4 round 2)
+799 / -29 across 14 files (up from +708 / -24 — added ~91 lines for 4 fixes incl. regression tests)
MERGEABLE — no conflicts
User-visible improvements:
Event-stream null-result errors now route to actionable classification instead of generic parse error
Auth/rate-limit failures that race with ctx-done no longer get rewritten as timeouts
OOM/abnormal-termination cases no longer confuse users with "-1" exit codes
Non-Claude providers (codex, gemini) get accurate timeout guidance instead of Claude-specific advice
All-zero ClaudeError produces a truthful "no diagnostic detail" message instead of a bare colon
Explicitly skipped (per the user's "just the real bugs" scoping): the low-priority items (stdout fallback in parse-error path, UTF-8 truncation, isExecNotFound narrowing, Subtype dead field, ClaudeErrorKind zero value). Those can be follow-ups if they matter; today none produce user-visible bugs.
User
run /pr-review-toolkit:review-pr /codex:review and /codex:adversarial-review again on 963
Assistant
Launching all 7 reviews in parallel — 5 specialist agents + 2 Codex (background):
Assistant
5 pr-review-toolkit agents done. Key finding I need to verify right now before Codex finishes:
silent-failure-hunter flagged a real regression I missed — formatClaudeErrorSuffix fixed the bare-colon case only for the default branch, but the typed Auth/RateLimit/Config branches still do unconditional %s interpolation. An empty Message + 401 envelope would produce "Claude authentication failed: \nRun \claude login` and retry"` — exactly the bare-colon regression we thought we fixed.
Let me verify this is a real reachable path:
Assistant
Confirmed real bug. Now waiting for the 2 Codex reviews to finish, then I'll propose a tight fix set.
Assistant
Both Codex reviews done. Aggregating:
Round-3 Review Aggregate
Confirmed by 2+ independent reviewers
#
Issue
Reviewers
Severity
A
Empty Message in Auth/RateLimit/Config branches still produces bare colon — formatCheckpointSummaryError fixed the default branch in round 2 but missed the typed branches (explain.go:593-598). Reachable: null-result envelope with status 401 → "Claude authentication failed: \nRun \claude login` and retry"`. Same class of bug as Fix E but at 3 different call sites.
silent-failure-hunter
HIGH
B
generateCheckpointSummary always passes checkpointSummaryTimeout (default 30s) to formatCheckpointSummaryError instead of the actual applied deadline — generateCheckpointAISummary computes timeoutDuration (may be shorter if parent ctx is tighter) but discards it. User sees wrong deadline in error.
codex-review, codex-adversarial
HIGH
C
GenerateText checks ctx.Err() before parsing envelope (generate.go:52-58) — same class as the explain-layer race we fixed in round 2, just one layer deeper. If Claude emits an is_error envelope AND ctx fires simultaneously, typed error is discarded for bare sentinel.
codex-adversarial
HIGH
D
isExecNotFound matches any *exec.Error — perm-denied/broken-exec misclassified as "CLI not installed".
codex-review, codex-adversarial, earlier rounds
MEDIUM
Single-reviewer but real
#
Issue
Severity
E
Production path uses TextGeneratorAdapter, not ClaudeGenerator. Preservation test (TestGenerateFromTranscript_PreservesClaudeError) uses ClaudeGenerator, so a %w→%v refactor in the adapter silently breaks production while tests pass.
MEDIUM
F
ClaudeError.ExitCode tri-state (>0 / <0 / 0) not documented at the type — struct comment says "0 means N/A" which is misleading now that <0 means "abnormal".
LOW
G
Comment nits: "concurrently" wording too narrow, ExitCode<0 example too narrow (also covers signal-terminated exit)
LOW
Recommended fix set
All 4 blockers (A/B/C/D) are real reachable user bugs. Total ~25 production lines, ~3 test rows (not new tests).
Assistant
Fix A — Bare colon in typed branches
Route Auth/RateLimit/Config through a helper that drops the : %s when Message is empty:
Assistant
Add a test row to pin the bare-colon negative contract for each typed branch:
Assistant
Fix B — Thread actual timeoutDuration out to the user-facing formatter
Assistant
Now update callers in tests (there are 4 existing test invocations):
Assistant
Add a test that shorter parent deadline is reported correctly:
Assistant
Fix C — GenerateText envelope/stderr classification before ctx.Err() check
Assistant
Reorder: parse envelope first, only fall back to sentinels when no typed classification is possible. Also apply Fix D (narrow isExecNotFound) here:
Assistant
Fix D — Narrow isExecNotFound
Assistant
Verify all tests still pass:
Assistant
All green. Commit all 4 fixes:
Assistant
Flaky test in strategy (passes in isolation, unrelated to PR 963). My changes pass:
Assistant
Round-3 review → fixes complete
Seven reviews run (5 pr-review-toolkit agents + 2 Codex), converged on 4 real blockers, all fixed in one commit (0bc148e0a).
What was fixed
#
Bug
Root cause
Fix
A
Bare colon in Auth/RateLimit/Config user messages when Message is empty
Round-2 only guarded the default branch's suffix — typed branches still did unconditional : %s
New formatMessageSuffix helper; drops colon when Message empty; test guard for all 3 typed kinds
B
Wrong timeout value reported to user (always checkpointSummaryTimeout, not the applied deadline)
generateCheckpointAISummary computed the real duration but discarded it; caller passed the default
Thread appliedDeadline as a third return value; caller passes it to the formatter; test asserts the returned deadline matches the shorter parent-ctx deadline
C
GenerateText dropped typed errors under ctx race
Checked ctx.Err() BEFORE parsing envelope; if both fired, bare sentinel won
Reorder: parse envelope first; ctx sentinels only surface when no structured signal is captured
D
Permission-denied / broken-executable misclassified as "Claude CLI not installed"
errors.As(err, &execErr) matched any *exec.Error
Narrow to errors.Is(execErr.Err, exec.ErrNotFound)
Current PR state
15 commits total on branch (originals + round-1 + merge + test-audit + round-2 + round-3)
+866 / -37 across 14 files
MERGEABLE — no conflicts
3 files touched in this commit: generate.go, explain.go, explain_test.go
+90 / -31 diff in this commit (roughly 60 prod / 30 test)
What was explicitly skipped
Per your "just the blockers" choice:
Adapter test coverage gap (silent-failure-hunter) — real concern but production path works today
Each round the number of new findings dropped: round 1 = 14, round 2 = 11, round 3 = 4 (all fixed). Running round 4 would likely find only cosmetic comment nits.
4. isExecNotFound is too broad (generate.go:89-95) — errors.Is(err, os.ErrNotExist) can misclassify unrelated subprocess failures as "binary missing." Prefer errors.Is(err, exec.ErrNotFound) + *exec.Error.
5. classifyStderrError produces empty messages (error.go:88-101) — segfault/OOM/SIGKILL with no stderr yields claude CLI error (kind=unknown) with no exit code. Surface ExitCode when Message is empty.
6. Stderr fallback is brittle to Claude CLI version skew(adversarial finding) — only two auth phrases, 500-byte head-truncation, no fixtures from real CLI output. Future CLI releases that change error wording will degrade to generic messages.
Medium
7. End-to-end errors.As preservation through summarize layer is untested — the //nolint:wrapcheck annotations are the entire contract; nothing enforces them. Add tests asserting errors.As(err, &*ClaudeError) after ClaudeGenerator.Generate and GenerateFromTranscript.
8. Envelope with result: null + is_error: true falls through to "missing result item" (response.go:22) — discards is_error / api_error_status. Return envelope when IsError is true regardless of Result.
9. formatCheckpointSummaryError doesn't %w-wrap typed errors back (explain.go:545-578) — downstream errors.As finds nothing. Either wrap with %w or document the deliberate termination.
10. Envelope with nil apiStatus + auth text classifies as Unknown (error.go:63-79) — apply authStderrPhrases to envelope result text too.
Type-Design Issues
11. ClaudeErrorKind is an open string set — ClaudeErrorKind("banana") compiles; zero value "" is legal; no constructor enforces invariants. Two inline constructions in generate.go already bypass the classifier factories. Consider a single newClaudeError constructor, or iota ints to close the set and remove //nolint:exhaustive.
Comment / Doc Issues
12. SummaryTimeoutSeconds doc is aspirational — claims "no deadline interactive, 5 min in CI" but reality is fixed 30s with no caller. Tied to issue #1.
13. formatCheckpointSummaryError comment claims "single point where final CLI wording is decided" — not enforced; rots if a second caller appears.
14. Field-level comments on APIStatus/ExitCode restate the type with little WHY value.
Strengths
Correct t.Parallel() usage everywhere
TestClaudeError_ErrorsAsIntegration is the right shape — verifies errors.As through wrap
No user content (prompts, file contents) is logged
//nolint annotations carry rationale
Good five-bucket taxonomy for user-facing UX
authStderrPhrases comment correctly explains why the list is small
Recommended fix order
Wire SummaryTimeoutValue() into generateCheckpointAISummary (or rip out the setting)
Centralize typed-error → user-message mapping so condensation also benefits
Re-order *ClaudeError check before context-sentinel branches in generateCheckpointAISummary
Narrow isExecNotFound; surface exit code when Message empty
Add the missing errors.As preservation tests in summarize
Address envelope-with-null-result and nil-apiStatus auth classification gaps
(Optional polish) Close the ClaudeErrorKind set; tighten doc comments
is_error
Yes — small fix, real bug
9
formatCheckpointSummaryError doesn't %w-wrap
⚠️ Future footgun — function is the final consumer today, no downstream errors.As exists
Marginal — only matters if #2 lands
10
Auth phrase check skipped for envelope result text when apiStatus nil
✅ Real consistency gap
Yes — small fix
11
ClaudeErrorKind open string set, no constructor
⚠️ Design improvement; current invariants hold by convention
Marginal — convention works today
12
SummaryTimeoutSeconds doc claims aspirational behavior ("no deadline interactive, 5 min in CI")
✅ Real — bundles with #1
Yes — fix with #1
13
"single point where final CLI wording is decided" comment
⚠️ Will rot when PR 964/condensation grows callers
Trim the line
14
Field comments restate types
⚠️ Minor
Trim
My recommendation: do 6 commits, skip the marginal ones:
#5 — ExitCode in Error() fallback
#7 — errors.As preservation tests in summarize
#8 — null-result envelope handling in response.go
#10 — auth phrase on envelope text when apiStatus nil
Skip: #2 (out of scope), #3 (extreme edge case), #4 (current code is intentional), #6 (intentionally minimal), #9 (no downstream consumer yet), #11 (design polish, convention works).
Claude failed to generate the summary: ← still empty
⚠️ Fix #5 didn't reach users
---
## Review feedback addressed (post-initial-review commits)
Seven follow-up commits addressing findings from `/pr-review-toolkit:review-pr`,
`/codex:review`, and `/codex:adversarial-review`:
| Commit | Fix |
|---|---|
| `ea2128845` | `ClaudeError.Error()` surfaces `ExitCode` when `Message` is empty |
| `071b08991` | Parser preserves envelope when `is_error:true` with `result:null` (previously fell through to "missing result item" and lost the API status) |
| `59ffbee3f` | `classifyEnvelopeError` applies auth-phrase heuristic when `api_error_status` is absent (matches the stderr fallback) |
| `4ad8c1be6` | Regression tests pinning `*ClaudeError` preservation through `ClaudeGenerator.Generate` and `GenerateFromTranscript` (the `//nolint:wrapcheck` contract was untested) |
| `a07871c36` | Trim misleading advice to "set `summary_timeout_seconds: 600`" from the timeout error message — the setting is groundwork for #964 and doesn't yet change behavior |
| `16369dad1` | Drop rot-prone comments (the "single point where final CLI wording is decided" claim; redundant per-field type comments) |
| `ac6c85105` | `formatCheckpointSummaryError` falls back to HTTP status / exit code when `Message` is empty (uncovered by user simulation — previously rendered `"Claude failed to generate the summary: "` with nothing after the colon) |
## User-facing output (sim-verified)
End-to-end simulation of 9 failure modes (stub `claude` → `GenerateText` →
`summarize.Generate` → `formatCheckpointSummaryError`). Every mode now
produces actionable output:
| Scenario | Rendered to user |
|---|---|
| Auth 401 envelope | `Claude authentication failed: Invalid API key · Please run /login` + `Run \`claude login\` and retry` |
| Rate limit 429 | `Claude rejected the summary request due to rate limits or quota: ...` + `Wait and retry` |
| Config 404 (invalid model) | `Claude rejected the summary request: Model "..." not found` + `Check your Claude CLI config and selected model` |
| Null-result envelope (500) | `Claude failed to generate the summary (Anthropic API returned HTTP 500)` |
| Envelope with auth text, no status | `Claude authentication failed: ...` + `Run \`claude login\` and retry` |
| Stderr-only auth (non-zero exit) | `Claude authentication failed: ...` + `Run \`claude login\` and retry` |
| OOM / SIGKILL (exit 137, empty stderr) | `Claude failed to generate the summary (claude CLI exited with code 137)` |
| `claude` binary not on PATH | `Claude CLI is not installed or not on PATH` |
| Context deadline exceeded | 3-cause guidance without the misleading setting-advice line |
## Test plan
- [x] `mise run check` (fmt + lint + unit + integration + e2e canary) passes
- [x] User-perspective simulation (9 failure modes) — all paths produce non-empty, actionable messages
- [ ] Manual: `entire explain -c <id> --generate` with an invalid model configured
- [ ] Manual: `entire explain -c <id> --generate` with claude not logged in
## Summary
Makes `entire explain --generate` surface actionable error messages when the
Claude CLI fails, instead of generic "failed to parse summary JSON" output
or silent empty errors.
## Problem
The Claude CLI returns most operational errors (auth, rate limit, invalid
model) at **exit 0** with `is_error: true` in its JSON envelope. The prior
implementation didn't check `is_error`, tried to JSON-parse the error text
as a `Summary`, and exposed users to messages like:
- `failed to parse summary JSON: ... (response: There's an issue with the
selected model...)`
- `failed to generate summary: failed to generate summary: claude CLI
failed (exit -1):` (double-wrapped)
For CLI crashes with no output (OOM, SIGKILL) users saw literally
`Claude failed to generate the summary:` — nothing after the colon.
## What changed
**Typed error classification.** Introduces `*claudecode.ClaudeError` with a
`Kind` discriminator (`auth` / `rate_limit` / `config` / `cli_missing` /
`unknown`) populated from HTTP status or stderr fallback:
- 401/403 → auth, 429 → rate limit, other 4xx → config
- Envelope with auth phrasing but no status → also classified as auth
(handles older CLI builds that omit `api_error_status`)
- Envelope with `is_error:true` + `result:null` → preserved with its HTTP
status instead of discarded as a parse error
- Binary not on PATH → `cli_missing`
- Structured errors survive `errors.As` all the way from
`claudecode.GenerateText` → `summarize.Generate` → explain
**User-facing message mapping.** `formatCheckpointSummaryError` turns each
Kind into an actionable message with remediation:
| Kind | User sees |
|---|---|
| Auth | `Claude authentication failed: <detail>` + `Run \`claude login\` and retry` |
| Rate limit | `Claude rejected the summary request due to rate limits or quota: <detail>` + `Wait and retry` |
| Config | `Claude rejected the summary request: <detail>` + `Check your Claude CLI config and selected model` |
| CLI missing | `Claude CLI is not installed or not on PATH` |
| Timeout | 3-cause diagnostic (transcript size / network / API status) |
| Unknown with no message | Falls back to HTTP status or exit code so output is never empty |
**Settings groundwork.** Adds `summary_timeout_seconds` field and
`SummaryTimeoutValue()` accessor. The field is not yet consumed by the
generate path; the stacked follow-up PR wires it into TTY-gated deadline
selection.
## Scope
All behavior changes are contained to:
- `cmd/entire/cli/agent/claudecode/` — typed error + classifier +
envelope parser enrichment
- `cmd/entire/cli/summarize/` — drops duplicate `fmt.Errorf` wrapping so
`errors.As` survives the layer boundary (pinned by regression tests)
- `cmd/entire/cli/explain.go` — typed-error mapping for user output
- `cmd/entire/cli/settings/` — new field + accessor
Merged with main to resolve conflicts with PR 887 (summary provider) and
PR 953 (remote metadata fetch). `GenerateText` intentionally runs the
subprocess directly instead of through `agent.RunIsolatedTextGeneratorCLI`
— the shared helper collapses stderr/exit into a string, but Claude's
envelope-based semantics need structured access to all three.
## Test plan
- [x] `mise run check` (fmt + lint + unit + integration + e2e canary)
- [x] End-to-end simulation of 9 failure modes (auth / rate-limit / config
/ null-result envelope / no-status auth / stderr-only auth / OOM /
CLI-missing / deadline) — every path produces a non-empty,
actionable message
- [ ] Manual: `entire explain -c <id> --generate` with invalid model
- [ ] Manual: `entire explain -c <id> --generate` with claude logged out
None identified. Every new production code path in the 7 fix commits has at least one meaningful regression test, and the consolidated versions preserve the same coverage at lower line cost.
RemoveAuthFromResultCaseInsensitive row (1 line — redundant with stderr-path test)
Consolidate the two preservation tests into one end-to-end test that uses ClaudeGenerator{TextGenerator: stubTextGenerator} → GenerateFromTranscript. This pins BOTH //nolint:wrapcheck sites via the real production chain in a single ~20-line test. Drop the errorGenerator stub. (saves ~62 lines)
Collapse the 3 UnknownEmptyMessage* tests into one table-driven test with 3 rows (withAPIStatus, withExitCode, withMessage). Same coverage, ~25 lines instead of 48. (saves ~23 lines)
Net effect
PR insertions: 789 → ~713 (-76 lines)
Tests: 11 → 6 functions (+3 table rows)
Coverage: unchanged — every production behavior still has a guarding test, still exercises the real code path
Want me to proceed with all of these, or would you like to adjust the plan?
Low / informational
Comment-analyzer: isExecNotFound doc overstates narrowness (says it covers "not-found" but errors.As(err, &execErr) matches any *exec.Error)
Type-analyzer: responseEnvelope.Subtype is parsed but never read — dead weight
Type-analyzer: ClaudeErrorKind zero value is "", not ClaudeErrorUnknown (3-line fix)
Adapter path summarize/text_generator.go:30 wraps error — verify the errors.As chain survives this too
Waiting for the Codex reviews to come back, then I'll aggregate and propose a fix set.