fix(pi): preserve useful stderr diagnostics when Pi crashes#33344

open7
main
GitHub fork: t3/pi-stderr-diagnostics
opened2d agobyWWout Stiens
View on GitHubTwo-way sync enabledPR last imported 1d ago

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:changed passes. 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], and at 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.

DelegateRound 1Round 2Round 3Round 4Round 5
GPT 6.1 Sol6/107/107/108/109/10
Claude Opus 5.57/108/108/108/109/10
Grok 4.78/108/107/109/109/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

1 failing · 24 successful · 15 skipped
Some checks failed

Failing1

f7f53c9

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
Synced from GitHub

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.