Skip to content

ResumeActor can require an expected snapshot - #2957

Open
Tom Gamble (gambtho) wants to merge 8 commits into
agent-substrate:mainfrom
gambtho:resume-expected-snapshot-current
Open

Tom Gamble (gambtho) wants to merge 8 commits into
agent-substrate:mainfrom
gambtho:resume-expected-snapshot-current

Conversation

@gambtho

@gambtho Tom Gamble (gambtho) commented Oct 20, 2026 •

Copy link
Copy Markdown

Sessions needs resume to refuse a checkpoint that changed after its GetActor check.

Adds optional ResumeActorRequest.expected (actor_uid, snapshot_uuid, generation). Stale actor/checkpoint returns FAILED_PRECONDITION; a matching pending upload returns UNAVAILABLE. Matching RUNNING retries return resumed=false. Concurrent template changes return ABORTED.

Without expected, behavior is unchanged. This does not select older snapshots or enforce restore fidelity. New clients must wait until every API server supports the field.

Local race tests, verifiers and fake-atelet tests passed. Runtime E2E and root-only tests weren't run locally.

Fixes #2832. Related: agent-primitives/sessions#192.

@aramase Anish Ramasekar (aramase) left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The check holds up for a SUSPENDED actor: validation runs under the lease, every later write is a CAS on the validated version, and in-flight transitions come back ABORTED. Two retry semantics look off, both confirmed with probes: a retry of a conditioned resume that already succeeded gets FAILED_PRECONDITION, and a concurrent template repoint gets FAILED_PRECONDITION although the same request succeeds when retried. Details inline, plus a few nits.

Two things sessions will need to handle (not blockers): after the default async suspend, a conditioned resume returns UNAVAILABLE until the upload completes; and a local-first actor with an older local copy can't satisfy expected.

Also, AGENTS.md asks for a rebase onto main rather than merging main into the branch.

Comment thread pkg/proto/ateapipb/ateapi.proto Resolved
Comment thread docs/api-guide.md Resolved
@gambtho

Copy link
Copy Markdown
Author

Rebased onto #2967; expected now checks snapshotToResume.

@gambtho
Tom Gamble (gambtho) force-pushed the resume-expected-snapshot-current branch from f3b431d to e73054d Compare October 21, 2026 19:37
@gambtho

Copy link
Copy Markdown
Author

Rebased onto #2967 and #3057; expected now checks snapshotToResume; ready for another look.

@gambtho
Tom Gamble (gambtho) force-pushed the resume-expected-snapshot-current branch from 4ec7a6d to a180bf0 Compare October 23, 2026 14:18
}
switch latest.GetDurableSnapshot().GetStatus() {
case ateapi.SnapshotStorageStatus_SNAPSHOT_STORAGE_STATUS_PENDING:
return apierror.Unavailable("expected snapshot is not yet complete in durable storage")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the actor's node was deleted before atelet reported this upload, nothing will mark it COMPLETED, so a conditioned resume returns UNAVAILABLE on every retry while an unconditioned one restores it via #3094. Could this path check NodeGone and either follow the gone-node restore or return FAILED_PRECONDITION so callers stop retrying?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 0cc025f: conditioned resumes restore the matching upload after its node is deleted, or return FAILED_PRECONDITION with the held and expected snapshot identities if the upload is missing.

@gambtho
Tom Gamble (gambtho) force-pushed the resume-expected-snapshot-current branch from a180bf0 to dfa7f1b Compare October 23, 2026 19:36
@bowei Bowei Du (bowei) added area/api User-facing API changes area/api-machinery area/storage kind/feature An enhancement / feature request or implementation labels Oct 27, 2026
@gambtho
Tom Gamble (gambtho) force-pushed the resume-expected-snapshot-current branch from 0cc025f to 1b4e89e Compare October 28, 2026 14:23
Let callers bind resume to an actor incarnation and snapshot generation. Validate the condition under the lifecycle lease before restore work, and recheck it after assignment conflicts. Requests without a condition retain the existing behavior.

Signed-off-by: gambtho <Thomas.Gamble@microsoft.com>
Signed-off-by: gambtho <Thomas.Gamble@microsoft.com>
Signed-off-by: gambtho <Thomas.Gamble@microsoft.com>
Signed-off-by: gambtho <Thomas.Gamble@microsoft.com>
Signed-off-by: gambtho <Thomas.Gamble@microsoft.com>
Signed-off-by: gambtho <Thomas.Gamble@microsoft.com>
Signed-off-by: gambtho <Thomas.Gamble@microsoft.com>
Signed-off-by: gambtho <Thomas.Gamble@microsoft.com>
@gambtho
Tom Gamble (gambtho) force-pushed the resume-expected-snapshot-current branch from 1b4e89e to 7efdb04 Compare November 8, 2026 04:27

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/api User-facing API changes area/api-machinery area/storage kind/feature An enhancement / feature request or implementation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ResumeActor: optional expected-snapshot precondition

3 participants