mirror of
https://github.com/kvcache-ai/AgentENV.git
synced 2026-11-05 01:17:36 +00:00
[PR #400] fix: restore paused state when resume races shutdown #407
Labels
No labels
bug
documentation
enhancement
enhancement
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
kvcache-ai/AgentENV#407
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/kvcache-ai/AgentENV/pull/400
Author: @mvanhorn
Created: 10/20/2026
Status: 🔄 Open
Base:
main← Head:fix/372-resume-shutdown-rollback📝 Commits (1)
de0b6adfix: restore paused state when resume races shutdown📊 Changes
2 files changed (+237 additions, -8 deletions)
View changed files
📝
src/orchestrator/service.rs(+19 -7)📝
src/orchestrator/tests.rs(+218 -1)📄 Description
What
A paused sandbox whose resume overlaps shutdown is left mid-resume. Later resume, pause, delete, and keep-alive calls wait on that sandbox until they time out, and the next startup discards its paused memory snapshot and writable layer. Resume commits the store and the persisted record from paused to resuming before launch checks whether the process is still accepting work. The shutdown rejection at the start of launch returns immediately and is the only failure there that does not restore the paused record. A resume with no paused runtime state used to fail only after that same commit, so it could leave the same transitional record behind.
Paused runtime state is now required before the paused-to-resuming update, so a missing snapshot returns an internal error and does not mark the record resuming. If launch is rejected because shutdown has started and the plan is a resume, the existing failed-launch rollback restores the paused state and the persisted record, then the original shutdown error is returned. A create rejected at that gate still writes nothing. New tests cover a missing paused state, shutdown during the resuming mark, and a resume launch that starts after shutdown is already set.
Why
Paused runtime state is now required before the paused-to-resuming update, so a missing snapshot returns an internal error and does not mark the record resuming. If launch is rejected because shutdown has started and the plan is a resume, the existing failed-launch rollback restores the paused state and the persisted record, then the original shutdown error is returned. A create rejected at that gate still writes nothing. New tests cover a missing paused state, shutdown during the resuming mark, and a resume launch that starts after shutdown is already set.
Related issue
Closes #372
Scope and non-goals
Covered in the summary above.
Design and behavior changes
Covered in the summary above.
Compatibility and operations
Not applicable to this change.
Validation
make fmtmake clippymake test-unitmake -C services test(required whenservices/changes)maketargetRan
make testlocally on macOS for the AgentENV change; it fails the same way on the base branch, so the failure predates this change (it fails the same way on upstream/main). Tests for the AgentENV change live insrc/orchestrator/tests.rs.Risks and reviewer notes
Scoped to the files listed above; no other caller or consumer changes.
Checklist
No test file is among the paths the AgentENV change changes (
src/orchestrator/service.rsandsrc/orchestrator/tests.rs).🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.