Skip to content

feat(runtime): persist complete thread continuation state (YEF-1061) - #564

Merged
Yevanchen merged 3 commits into
mainfrom
feat/runtime-thread-checkpoints
Aug 21, 2026
Merged

feat(runtime): persist complete thread continuation state (YEF-1061)#564
Yevanchen merged 3 commits into
mainfrom
feat/runtime-thread-checkpoints

Conversation

@Yevanchen

@Yevanchen Yevanchen commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Define warm/cold continuation equivalence for Task Agent Threads in the PRD and architecture.
  • Commit the complete Cattle Thread workspace through the existing Cloudflare Sandbox Backup path after a successful turn and before lease release.
  • Atomically bind the ready checkpoint to its Run and promote the provider-native resume cursor; block follow-up admission and idle recycle until that boundary is ready.
  • Grandfather pre-rollout Threads, restoring their recorded artifacts on cold continuation, then enable strict Run-bound checkpoints after their first successful post-rollout turn.
  • Return a typed SESSION_RUN_CHECKPOINT_PENDING / Public API readiness_blocked 409 for follow-ups that arrive while checkpointing is incomplete.
  • Restore the exact Thread checkpoint on cold activation, exclude attachment mounts and transient credentials, and return actionable missing/corrupt-state errors.

Why

  • Cattle continuation previously restored only recorded artifacts and bounded message history, so a recycled Sandbox lost files outside outputs/, Git state, installed workspace dependencies, and provider-local resume state.
  • A user's next message should observe equivalent Thread state whether the Sandbox remained warm for ten minutes or was completely recycled for twenty days.
  • Existing Threads must remain usable across rollout even though their completed Runs predate Run-bound checkpoint metadata.

Verification

  • Commands:
    • CI=1 bun run check (passed: formatting, docs, lint, type checks, all package tests, and Public API contract checks)
    • bun run --filter @mosoo/api test (1240 passed)
    • bun run commit:check (passed)
  • Manual steps: N/A; cold restore, 20-day retention, rollout compatibility, failure, retry, admission, idle sweep, and idempotency are exercised with deterministic fixtures.
  • Not run: A live production Cloudflare Backup/Restore cycle.

Impact

  • User/API/contract changes: Task Agents now promise Thread-scoped workspace and native-resume durability. A follow-up during checkpointing returns a retryable 409 instead of an internal 500; no new public endpoint is added.
  • Generated files / GraphQL / DB / lockfile: Extends D1 migration 0011_cattle-terminal-checkpoints.sql with the additive session.workspace_checkpoint_required rollout marker and updates its generated snapshot; no GraphQL or lockfile change.
  • Env or config changes: None.
  • Risk and rollback: Pre-rollout Threads default to compatibility mode and retain artifact recovery. A new successful Cattle turn enables strict checkpoint enforcement; checkpoint failure intentionally blocks the next turn. Rolling back application behavior leaves additive columns and the partial index inert.

Review

  • Closest review areas: rollout-marker transition, terminal event/checkpoint/lease ordering, D1 batch atomicity and concurrent retry cleanup, exact-Thread restore selection, admission/idle guards, and credential-safe checkpoint preparation.
  • Known trade-offs: Live processes, sockets, kernels, attachment mounts, and short-lived credentials are intentionally excluded. Background self-healing after terminal checkpoint retry exhaustion is tracked in YEF-1067.

Closes YEF-1061

@Yevanchen Yevanchen changed the title feat(runtime): persist complete thread continuation state feat(runtime): persist complete thread continuation state (YEF-1061) Aug 20, 2026
@Yevanchen
Yevanchen merged commit 63270a0 into main Aug 21, 2026
9 checks passed
@Yevanchen
Yevanchen deleted the feat/runtime-thread-checkpoints branch August 21, 2026 10:15
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