Skip to content

Commit 7b1e7a7

Browse files
committed
feat(agents): recover ended Sandbox sessions explicitly
An ended session is resumed only when the desktop sends provider_config.sandbox.recovery for one click: {"mode":"checkpoint"} restores the tombstone's verified checkpoint, {"mode":"fresh"} starts with an empty workspace. Recovery is refused on anything that is not an Ended, Suspended tombstone, so a live workspace is never discarded, and checkpoint mode is refused when the tombstone has no checkpoint key. Every refusal carries a typed code (session_active, session_ending, no_ended_session, no_checkpoint, recovery_interrupted, recovery_mode_conflict) that the desktop branches on. Before it deletes the tombstone, the provider preserves it in an immutable <sandbox>-recovery journal Secret without an owner reference. Journal validation checks object identity and ownership. A retry resumes from the journal after an interrupted delete/create; an ordinary deploy refuses an unfinished recovery. A retry reuses a replacement that was already created only for the same mode and checkpoint key; a retry in the other mode is refused and the journal is kept. Deletion uses uid and resourceVersion preconditions. Recovery then waits up to one drain grace (the shared 300-second termination grace) for the old owned Pod to disappear, so that with the binding and startup waits it ends inside the 600-second operation deadline, and creates the replacement under a new generation with recovered-from. The journal is removed once the replacement is bound; a failed removal is reported on stderr and retried by the next deploy. Signed-off-by: Tee8z <[email protected]>
1 parent 4d98c30 commit 7b1e7a7

12 files changed

Lines changed: 1290 additions & 28 deletions

‎crates/buzz-backend-kubernetes/src/config.rs‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,15 @@ pub fn config_schema() -> serde_json::Value {
429429
"format": "uuid",
430430
"pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
431431
},
432-
"thread_root": {"type": "string", "pattern": "^[0-9a-f]{64}$"}
432+
"thread_root": {"type": "string", "pattern": "^[0-9a-f]{64}$"},
433+
"recovery": {
434+
"type": "object",
435+
"additionalProperties": false,
436+
"required": ["mode"],
437+
"properties": {
438+
"mode": {"type": "string", "enum": ["checkpoint", "fresh"]}
439+
}
440+
}
433441
}
434442
}
435443
],

0 commit comments

Comments
 (0)