Repository navigation
fix(runtime): settle session work before fresh preparation - #522
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 16, 2026, 5:13 AM ET / 09:13 UTC (Revision 4). ClawSweeper reviewWhat this changesSerializes runtime turns per session record and waits for cancellation and cleanup before recording fresh-session intent, with retry handling, regression tests, and updated documentation. Merge readiness✅ Ready for maintainer review Keep open as a focused, still-needed lifecycle repair. The earlier API and restart-fixture blockers are resolved, and the reviewed diff introduces no blocking correctness finding. Priority: P2 Review scores
Verification
How this fits togetherThe embedded acpx runtime manages ACP agent connections and persisted session records for host applications. Turn submission, cancellation, and fresh-session preparation pass through its session manager before reaching the adapter and session store. flowchart TD
A[Embedding host] --> B[Per-record task queue]
B --> C[Run or cancel turn]
C --> D[ACP agent connection]
D --> E[Finalize session work]
B --> F[Prepare fresh session]
E --> F
F --> G[Persist reset intent]
G --> H[Next ensure creates fresh session]
Before mergeNone. Agent review detailsSecurityNone. Review metrics
Technical reviewBest possible solution: Preserve the accepted API while making fresh preparation acknowledge only settled session work and successful local cleanup, without discarding native history. Do we have a high-confidence way to reproduce the issue? Yes, source establishes the race: main can acknowledge preparation before an active turn finishes writing its record. The supplied before-fix failures and focused regressions support that path; this read-only review did not execute it. Is this the best way to solve the issue? Yes. The patch repairs the existing manager's completion and cleanup boundaries while preserving the accepted public API, ordinary-close behavior, and persisted reset format. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 420157a762a7. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 earlier review cycles)
|
|
Maintainer triage: this remains a product/API decision because it introduces public
The meaningful control is identical launch identity in every process: create the original record through real ensure, prove restart without retirement keeps the backend identity, then prove retirement changes that identity while preserving the intended record identity. This is a source-supported assessment, not a claim that I executed the retirement scenario. Recommendation to the orchestrator: keep the decision with Peter until the retirement API, treatment of existing handles, and persistence guarantee are selected; the current proof should not be treated as satisfying that guarantee. No implementation or contributor changes are requested by this triage pass. |
Serialize per-record turns and settle prior work before durable reset. Keep failed owner cleanup retryable, preserve ordinary close behavior, and cover real runtime cancellation, restart, and recovery. Co-authored-by: Vincent Koc <[email protected]>
865a79e to
707a72b
Compare
|
Maintainer update: #596 already established the object-shaped fresh-session API. This rewrite keeps that accepted public contract and completes its cancellation, finalization, and cleanup-retry guarantees in the existing runtime manager. Same-record work is serialized; different records remain concurrent. Ordinary close retains its existing early-return/resume behavior. The former API-absence blocker is superseded. The earlier false-positive restart fixture is replaced by the identical-launch control already on main, plus active/queued-turn and cleanup-failure regressions. The updated body includes observed failures before the fix, passing isolated Linux checks, independent review, and source-blind real Codex cancellation/restart/native-history evidence. Thanks @vincentkoc for the original retirement and finalization work. |
|
Landed as 53177fc from reviewed head 707a72b. Validation: 117 focused runtime/manager/session-context tests; full isolated Linux Source-blind proof exercised real stdio/file-store cancellation, queued work, cleanup failure/retry, and restart. Real Codex preparation returned after explicit cancellation, and restart produced a new backend under the same acpx record with successful text output. Separate native-history proof reopened the retired backend and recalled its synthetic marker. All task-owned test processes and state were cleaned up; main is synchronized and clean. Thanks @vincentkoc for the original contribution. |
Fresh-session preparation could acknowledge a reset while an earlier turn was still writing the same record. That late write could erase the reset or restore the old backend identity. A failed cleanup could also leave an unusable owner available for reuse, or be forgotten when preparation was retried.
The public
prepareFreshSession({ handle })API already landed in #596. This PR now focuses on completing its lifecycle guarantee:The original contribution's completion and strict-finalization work informed this repair. It preserves the accepted object-shaped API and uses the valid identical-launch restart control already on main, replacing the earlier process fixture that could pass solely because launch identity changed. Thanks @vincentkoc.
Reproductions
The regression cases failed before their fixes for the intended reasons:
Validation
pnpm run checkandpnpm run check:docspassed on an isolated Linux runner.cancelled/cancelledin 1,268 ms, then a runtime restart produced a different backend under the same acpx record and delivered fresh synthetic text. A separate real native-history control successfully resumed the retired backend and recalled its synthetic marker; that unchanged-history proof was reused in the final focused rerun.This repair changes production by +70 net lines, tests by +210, and docs/changelog by +3. The added admission and retry state is confined to the existing runtime manager; the submitted tests are substantially smaller than the original PR's process harness.