fix(server): keep corrupt plan JSON in the typed read error#21969
Problem
Malformed stored plan JSON escapes the read service as a defect instead of returning ProjectionStoreReadError.
Change
Decode plan payloads with the existing JSON schema decoder, preserving single-plan, bulk, and table-transfer read behavior.
Rebuilt from @t3dotgg’s #15040, keeping this layer to one concern. Six original claims are already fixed on the pinned main, including configured-home session forking. Those implementations are preserved.
Stack: #21969 → #21970 → #21971 → #21972 → #21974 → #21975 → #21976
Scope and approval
Maintainer takeover authorized for batch scheduler-tasks-05. Layer 1 of seven; coordinator owns landing and approval decisions. This is a focused correction to existing behavior.
Verification
ProjectionStore suite: 46 passed, including malformed JSON through single and bulk reads.
Fresh post-fix verification: workflow/transcript 8, selected ACP 11, complete launch suite 87: 106 distinct passes, independently reproduced by Opus. Four previously failing regressions now pass. Earlier unaffected checks are reused; the historical 422 count is not a fresh run. Full server TS7 found zero errors and one fixture warning (exit 2); the warning was corrected and its scoped fixture/import check passed with zero warnings. Targeted lint and diff checks pass.
R5 Opus and Sol cleared all seven layers and the cumulative diff. Four completed parallel rounds: R1, R3, R4, R5; R2 was cancelled before verdict. Current head-specific before/after evidence and limits.
This layer: c00b86c, based on 54983e3. CI will receive one delayed check; unfinished checks are handed to the coordinator.
Headless Linux, Node 24. Native Windows, macOS, iOS, Android, packaged Electron, real account-based provider execution, and relay/tunnel connections were not verified. No UI behavior changed.
Implementation: Codex gpt-6.1-sol; tests: Codex gpt-6-astra; review: Claude claude-opus-5-5 and Codex gpt-6-sol, through T3 Code.
Checks
Added 5 commits
- fix(server): return typed errors for malformed stored plans4803058
- test(server): expose malformed plan read defects51c4ad3
- test(server): clean corrupt plan rows after failed reads6b2d0cc
- fix(server): preserve plan table decoder callback signature9e77df8
- Merge commit '54983e3f458871dffe755ea908ffe0d60cea101b' into scheduler-tasks-05/plan-readsc00b86c
Approvability
Verdict: Approved at c00b86c
Macroscope's review found this PR approvable — This is a narrowly scoped server bug fix that preserves normal plan decoding while converting malformed stored JSON into the existing typed read error. The accompanying test covers the corrupt-data case, with no product-default or static-analysis changes.
You can add or adjust custom eligibility rules. Learn more.
Thread transfer impact
✅ Thread transfer remains within every enforced ceiling.
| Provider | Metric | Main baseline | This PR | Impact | PR ceiling | |
|---|---|---|---|---|---|---|
| Codex | Total thread wire | 5.0 KiB | 5.0 KiB | +7 B (+0.1%) | 6.8 KiB | ✅ |
| Codex | Thread snapshot wire | 3.8 KiB | 3.8 KiB | 0 B (0.0%) | 4.9 KiB | ✅ |
| Codex | Live turn WebSocket wire | 1.2 KiB | 1.2 KiB | +7 B (+0.6%) | 2.0 KiB | ✅ |
| Codex | Live turn WebSocket decoded | 20.9 KiB | 20.9 KiB | 0 B (0.0%) | 29.3 KiB | ✅ |
| Codex | Live turn messages | 2 | 2 | 0 (0.0%) | 8 | ✅ |
| Claude | Total thread wire | 5.0 KiB | 5.0 KiB | −31 B (−0.6%) | 6.8 KiB | ✅ |
| Claude | Thread snapshot wire | 3.8 KiB | 3.8 KiB | 0 B (0.0%) | 4.9 KiB | ✅ |
| Claude | Live turn WebSocket wire | 1.2 KiB | 1.2 KiB | −31 B (−2.5%) | 2.0 KiB | ✅ |
| Claude | Live turn WebSocket decoded | 21.2 KiB | 21.2 KiB | −41 B (−0.2%) | 29.3 KiB | ✅ |
| Claude | Live turn messages | 2 | 1 | −1 (−50.0%) | 8 | ✅ |
Baseline: a71a6c3 · PR result: c00b86c · Source CI: success
Scenario and decoded snapshot size
10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
- Codex decoded thread snapshot: 108.5 KiB
- Claude decoded thread snapshot: 108.8 KiB
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
- Configuration used: Path: .coderabbit.config.ts
- Review profile: CHILL
- Plan: Team
- Run ID:
4a39305a-b448-449b-9156-68e6b352d7a8
📥 Commits
Reviewing files that changed from the base of the PR and between a71a6c37d14154c8cb355242d569e8a1dbeec706 and c00b86c85e38eb44bcc00c55df93ef8e8be0296e.
📒 Files selected for processing: 2
apps/server/src/orchestration-v2/ProjectionStore.test.tsapps/server/src/orchestration-v2/ProjectionStore.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
📝 Walkthrough
Plan payload decoding now validates stored JSON strings with the plan artifact schema. A SQL test verifies the error returned when a plan contains malformed JSON.
Changes: Plan payload decoding
Layer / File(s) Summary Decode plan payloads and test read errors
apps/server/src/orchestration-v2/ProjectionStore.ts,apps/server/src/orchestration-v2/ProjectionStore.test.tsThe decoder validates stored plan JSON strings before decoding the plan artifact. A SQL test verifies that malformed JSON produces a ProjectionStoreReadError.Priority: ⬇️ Low
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix
Suggested reviewers:
t3dotgg
Merge Risk: ⚪ Minimal · up to c00b8
Malformed plan data is handled through the established read-error and unreadable-thread paths; no concrete merge-blocking risk remains.
Pre-merge checks: Passed 4
Check name Status Explanation Title check Passed The title clearly and concisely describes the main change: malformed plan JSON now remains within the typed ProjectionStoreReadError path. Linked Issues check Passed Check skipped because no linked issues were found for this pull request. Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request. Description check Passed The pull request description includes complete Problem, Change, Scope and approval, and Verification sections. It explains the defect, the implementation, the approval context, test results, verificat… Full details: Description check
Explanation
The pull request description includes complete Problem, Change, Scope and approval, and Verification sections. It explains the defect, the implementation, the approval context, test results, verification limits, and unchanged UI scope.
✨ Finishing Touches
📝 Generate docstrings
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
- Commit to this branch
- Create a new PR
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Comment @coderabbitai help to get the list of available commands.