Skip to content

[skip-tag:sdk] feat(sdk/engine): optional Resumer + LoadAndResume helper (3/4)#76

Merged
lIang70 merged 2 commits into
mainfrom
feat/sdk-engine-resume
May 8, 2026
Merged

[skip-tag:sdk] feat(sdk/engine): optional Resumer + LoadAndResume helper (3/4)#76
lIang70 merged 2 commits into
mainfrom
feat/sdk-engine-resume

Conversation

@lIang70

@lIang70 lIang70 commented May 8, 2026

Copy link
Copy Markdown
Collaborator

Summary

Part 3 of 4 in the v0.2.x additive SDK batch. Tagging suppressed via
[skip-tag:sdk]; cumulative sdk/v0.2.9 tag will be cut on PR 4/4.

Adds a host-side helper to drive durable resume against any engine, and an
optional capability interface engines can implement to participate.

Surface

  • Resumer optional interface — CanResume(Checkpoint) error. Engines that
    implement it get a chance to reject incompatible checkpoints (schema drift,
    expired runs, mismatched topology) before the resume is dispatched.
  • IsResumable(Engine) bool / AsResumer(Engine) (Resumer, bool) — capability
    probes for callers that need to branch.
  • ResumeContext (value-type) — per-attempt metadata: ExecID, AttemptID,
    StartedAt, Reason. Plumbed via WithResumeContext /
    ResumeContextFromContext using the standard context-key idiom.
  • LoadAndResume(ctx, eng, host, store, run, board, opts...) — orchestrates
    the canonical host-side flow:
    1. Load checkpoint (if any) from CheckpointStore.
    2. Validate via Resumer.CanResume when the engine opts in.
    3. Hydrate Board from checkpoint state.
    4. Dispatch into Engine.Run with ResumeContext attached.
    • AllowFreshStart(bool) / OnMissing(handler) options control behaviour
      when no checkpoint is found.

Out of scope (deliberately)

  • Engine.Engine / Run contracts are unchanged. Engines that don't implement
    Resumer still work — they simply get fresh-start semantics.
  • Persistence backends are not touched.

sdk/engine/doc.go adds a worked example of the resume flow.

Test plan

  • go vet ./engine/...
  • go test ./engine/... -count=1
  • New test file sdk/engine/resume_test.go covers:
    • Fresh start when no checkpoint and AllowFreshStart=true.
    • Disallowed fresh start returns the expected error.
    • Resume path hydrates board and propagates ResumeContext.
    • ExecID mismatch is rejected.
    • Resumer.CanResume rejection short-circuits before dispatch.

Release notes

Additive only; tag deferred to PR 4/4.

Made with Cursor

- Resumer optional interface with CanResume(Checkpoint) error — engines
  opt in to early validation of resumed checkpoints.
- IsResumable / AsResumer helpers for capability detection.
- ResumeContext value-type carrying per-attempt metadata (ExecID, AttemptID,
  StartedAt, Reason). WithResumeContext / ResumeContextFromContext follow
  the standard context-key idiom.
- LoadAndResume orchestrates the host-side resume flow: load checkpoint,
  invoke CanResume, hydrate Board, dispatch into Engine.Run with the
  resume context attached. AllowFreshStart / OnMissing options control
  behavior when no checkpoint exists.

The core engine.Engine and engine.Run contracts are unchanged; this is
purely additive.

Co-authored-by: Cursor <cursoragent@cursor.com>
@lIang70
lIang70 merged commit 4949512 into main May 8, 2026
17 checks passed
@lIang70
lIang70 deleted the feat/sdk-engine-resume branch May 8, 2026 05:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant