fix(harness): preserve regenerated session configuration during resume - #812
Conversation
Review — PR #812 (
|
Follow-up review — PR #812 (delta since
|
|
The failed-resume finding was valid. Preparation now follows the existing exit path, so a builder or adapter failure removes generated configuration. Simplified the guard in 9f7ecee: the removal promise itself prevents duplicate cleanup and is cleared after the next configuration build awaits it. The extra Set and reset callbacks are gone. All 202 lifecycle and retention tests pass, including preparation failure, retry, and metadata broadcasts after deletion completes. The description also notes the visible change from the follow-up review: failed preparation clears the old exit code and tail while preserving the previous activity timestamp. |
c9b535b to
c9768a8
Compare
9f7ecee to
fd9fe9d
Compare
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (5)
🚧 Files skipped from review as they are similar to previous changes (1)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe harness now persists the starting session state before resume preparation, tracks generated-directory cleanup across exit notifications, protects regenerated configuration during resume, and cleans up after failed preparation. Tests cover restart, history adoption, repeated broadcasts, and retry behavior. ChangesSession configuration retention
Priority: ⬇️ Low Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to Resume now coordinates generated-configuration cleanup with regeneration and cleans up failed preparation attempts. The covered lifecycle paths show no remaining merge-blocking risk. Sequence Diagram(s)sequenceDiagram
participant SessionManager
participant Server
participant GeneratedDirectory
SessionManager->>Server: emit exited status
Server->>GeneratedDirectory: schedule removal once per lifetime
SessionManager->>Server: resume session
Server->>GeneratedDirectory: await removal before rebuilding configuration
Server->>SessionManager: return prepared launch options
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. A rabbit hops where sessions start, Comment |
7d6fc4b to
ebe263d
Compare
ebe263d to
f108b1e
Compare
Problem and motivation
After a session ends, Studio can still send updates that say “ended.” Each update can start another deletion. An old deletion can then remove new configuration files that Resume just wrote.
Summary and scope
Delete once per run, and wait for that deletion to finish before Resume writes new files. Repeated status updates no longer start extra deletions. This applies to Claude, Codex, and other harnesses.
If resume setup fails after writing files but before the agent starts, normal exit cleanup removes those files too.
Also repairs a missing credential-path mock and removes fixed timing assumptions from two CI tests.
Before
flowchart LR B1["Repeated ended updates<br/>start extra deletions"] --> B2["Resume writes new files<br/>before deletion finishes"] B2 --> B3["Old deletion removes<br/>the new files"] style B3 fill:#fff1f2,stroke:#be123c,color:#881337With this fix
flowchart LR F1["Delete once<br/>when the run ends"] --> F2["Wait for deletion<br/>to finish"] F2 --> F3["Resume writes<br/>new files"] style F2 fill:#ecfdf5,stroke:#047857,color:#064e3b style F3 fill:#ecfdf5,stroke:#047857,color:#064e3bRelated work
Independent cleanup fix. The Codex MCP connection fix (#810) and its tests (#879) are already merged.
Validation
main.Diff, checklist, and release details
Primary change type
Tests and documentation
Extended the generated-configuration retention tests. README update is N/A: this restores existing cleanup behavior; the changeset records the fix.
Compatibility and release impact
@sapiom/harnesspatch changeset.Security
AI assistance
Codex implemented the cleanup guard and regressions, then isolated this change from #810. Verified with diff review, lifecycle tests, build, typecheck, and lint on this branch.
Checklist
CONTRIBUTING.mdand followed the contribution policy.Summary by CodeRabbit