fix(pi): preserve useful stderr diagnostics when Pi crashes#33344
Pi crashes left only an exit code in diagnostics because the RPC transport discarded stderr. Keep an 8,192-character tail and attach the last recognized error with up to three adjacent stack frames, redacted and capped at 240 characters per line, to the RPC failure and one warning.
Wait briefly for stderr to drain, preserving the existing 250 ms bound when extension children inherit the pipe. Log before waking callers so immediate scope cleanup cannot lose the warning. Explicit stops remain quiet. Credential assignments and flags share name coverage; incomplete lines and unsafe URI remainders are omitted conservatively. Safe local ESM stack locations remain useful.
Only rpc.ts and its focused subprocess tests change. The adapter's generic thread message and model ID parsing are unchanged. This improves diagnosis rather than repairing the external Pi/mitsupi race. Standard size: buffered transport state and lifecycle coordination.
Validation:
- 59 real-subprocess tests pass; restoring base RPC code makes 58 fail. Intentional-stop behavior is separately mutation-tested.
pnpm exec vp run check:changedpasses. No repository-wide checks were run.- Runtime transcript: request, events and the warning all contain
pi process exited with code 1,Error: This extension ctx is stale after session replacement (café) token=[redacted], andat Object.<anonymous> (/ext/mitsupi/extensions/prompt-editor.ts:1184:7). - Mutation proof covers warning-before-cleanup, quiet stop, ANSI/selection behavior and both eviction boundaries. Additional real-child proof covers stdout closing while the process remains alive, two pending requests, and one failure owner.
- Local cubic reported one P2 quoted-JSON redaction finding; fixed and covered. GitHub repository context was unavailable for that local run because origin is GitCafe.
- Rebased on current upstream main; range-diff confirms identical patches.
Limits: pattern-based redaction does not guarantee removal of arbitrary unlabeled secrets and can omit useful context. The original macOS Pi 1.4.0/mitsupi race, Windows process-tree termination and UI behavior were not verified. The second proof audit found no implementation defect; standalone TypeError selection, standalone Bearer/Basic and Slack token redaction, failed exit-code reads and non-finite exit codes remain unproven.
Deferred findings: shared sanitizer extraction exceeds this ticket's file ownership. Surrogate-safe truncation, Http2Error recognition, home-path normalization, C1/bidi controls, clean-exit warning policy, short tokens and malformed-holder fixture cleanup remain follow-ups. Additional prose-shaped API-key recognition and broader encoded file locations were left as nits.
Council review
Rounds: 5. Dispatcher explicitly authorized the fifth round.
| Delegate | Round 1 | Round 2 | Round 3 | Round 4 | Round 5 |
|---|---|---|---|---|---|
| GPT 6.1 Sol | 6/10 | 7/10 | 7/10 | 8/10 | 9/10 |
| Claude Opus 5.5 | 7/10 | 8/10 | 8/10 | 8/10 | 9/10 |
| Grok 4.7 | 8/10 | 8/10 | 7/10 | 9/10 | 9/10 |
No blocker or should findings remain in the final council round.
Created with GPT 6.1 Sol (lead, fixes, audit), Claude Opus 5.5 (build, trim, review), and Grok 4.7 (review, evidence) in T3 Code, using the Codex, Claude and Grok harnesses.
Closes #28653
Checks
Failing1
- CodeRabbitGitHubCancelled
Added 7 commits
- fix(pi): explain Pi crashes with its stderr error1cf099b
- fix(pi): redact crash credentials and preserve warnings33bdcd8
- fix(pi): close credential leaks in crash diagnostics404b88a
- fix(pi): conservatively redact crash diagnostics6a6904c
- test(pi): merge crash diagnosis cases and make held-stderr fixture real6c98d71
- fix(pi): redact credential flags and retain local stack locationsc207a37
- chore: credit the models that built this PRf7f53c9
Approvability
Verdict: Approved at f7f53c9
Macroscope's review found this PR approvable — Pi crashes now report a bounded, redacted stderr error excerpt rather than only an exit code. The change is limited to failure diagnostics, with capped output and bounded shutdown waits.
You can add or adjust custom eligibility rules. Learn more.
Thanks, @StiensWout, for the detailed fix and regression coverage. #28680 by @juliusmarminge addresses the same Pi crash stderr diagnostics, so I’m closing this as a duplicate. Please contribute any distinct cases to that PR.
Reopening: this focused fix is current, while #28680 is older than a week and main has changed its files. Thanks, @StiensWout, for the fix and regression coverage.