Recover interrupted runs and commit terminal state once #53

Merged
weichen merged 1 commits from feature/pi-durable-borrow into main 2026-10-03 14:44:38 +00:00
Owner

Why: A hard kill left runs in pending, running, or waiting_hitl. A busy send stored a message before the 409. finishRun could mark a run completed without an assistant message. A full SSE buffer dropped events without closing the stream.

Evidence: GOWORK=off go vet ./... and GOWORK=off go test -count=1 ./... passed. Migration v14, ReconcileInterrupted, request-id admission, SettleRun, and the SSE replay tests are in this branch. AGENT_PG_TEST_DSN was not set, so the PostgreSQL other-instance case was skipped.

Impact: Startup reconciliation and shutdown share one seal. Turn and workflow sends claim a slot before writing. Duplicate request ids return the existing message. SettleRun updates the run and appends the assistant message in one transaction. A full subscriber buffer closes the channel. No Core contract change.

Refs: Dev feature/pi-durable-borrow

Why: A hard kill left runs in pending, running, or waiting_hitl. A busy send stored a message before the 409. finishRun could mark a run completed without an assistant message. A full SSE buffer dropped events without closing the stream. Evidence: GOWORK=off go vet ./... and GOWORK=off go test -count=1 ./... passed. Migration v14, ReconcileInterrupted, request-id admission, SettleRun, and the SSE replay tests are in this branch. AGENT_PG_TEST_DSN was not set, so the PostgreSQL other-instance case was skipped. Impact: Startup reconciliation and shutdown share one seal. Turn and workflow sends claim a slot before writing. Duplicate request ids return the existing message. SettleRun updates the run and appends the assistant message in one transaction. A full subscriber buffer closes the channel. No Core contract change. Refs: Dev feature/pi-durable-borrow
weichen added 1 commit 2026-10-03 14:41:16 +00:00
Recover interrupted runs and commit terminal state once
ci / vet-and-test (pull_request) Successful in 43s
44aa764b56
Why: A hard kill left runs in pending, running, or waiting_hitl, a busy send stored a message before the 409, finishRun could mark a run completed without an assistant message, and a full SSE buffer dropped events without closing the stream.
Evidence: GOWORK=off go vet ./... and GOWORK=off go test -count=1 ./... passed, including store, runmgr, bus, and server recovery tests.
Impact: Migration v14 adds runs.instance_id and messages.request_id. Startup reconciliation and shutdown share one seal. Turn and workflow sends claim a slot before writing. Duplicate request ids return the existing message. SettleRun updates the run and appends the assistant message in one transaction. A full subscriber buffer closes the channel so SSE can replay from the cursor.
Refs: Dev feature/pi-durable-borrow
Co-authored-by: Cursor <cursoragent@cursor.com>
weichen merged commit 5d59ee9d4f into main 2026-10-03 14:44:38 +00:00
weichen deleted branch feature/pi-durable-borrow 2026-10-03 14:44:38 +00:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: weichen/Agent-System-Backend#53