Skip to content

Run store-owned turns on remote compute targets - #445

Open
Kevin Kitts (kittskevin) wants to merge 3 commits into
waldemort/m1-pr2-opaque-archive-storefrom
waldemort/m1-pr3-store-owned-mode1
Open

Kevin Kitts (kittskevin) wants to merge 3 commits into
waldemort/m1-pr2-opaque-archive-storefrom
waldemort/m1-pr3-store-owned-mode1

Conversation

@kittskevin

Copy link
Copy Markdown

Agent assessment

Self-reported assessment, not an independent review.

Assessed revision: 857c18101ff8c5516f53fffde0f8af1471c3a863

Dimension Assessment Rationale
Change confidence 8.5/10 ↑ remote-store-owned.test.js and compute-integration.test.mjs cover startup validation, cold/warm lease binding, hydrate mismatch recovery, per-phase deadlines, transport-loss and cancellation non-commit, and idempotent turn-key replay.
↓ Hosted PR checks on this branch run once the pull request is opened, and end-to-end qualification against a live external sandbox platform remains provider-specific.

Summary

Wires opt-in store-owned remote execution (statePolicy: "store-owned") into the ComputeTarget / ComputeProvider abstraction from #443 and the opaque-archive store contract from #444, and adds the developer guide for writing a compute provider.

Under store-owned, the session store owns durable state and the remote sandbox is a disposable warm cache. On each turn the worker probes the opaque archive head, answers an already-committed turnKey directly from the trusted turn record without contacting a sandbox, or opens a lease via provider.openStoreOwned(), verifies hydratedHead, runs the turn behind the worker's model credential broker, packs one opaque archive, and commits it with conditional store-wins CAS.

Design record: docs/proposals/remote-compute-targets.md §8–§11.
Provider guide: docs/developer/building/compute-providers.md.

Stack

  1. Add a provider-neutral remote compute abstraction #443: compute abstraction (base main)
  2. Add an opaque-archive store contract for remote session state #444: opaque-archive store contract (base waldemort/m1-pr1-compute-abstraction)
  3. This PR: store-owned turns (base waldemort/m1-pr2-opaque-archive-store)

What changes

  • Provider contract (compute-target.ts, remote-store-owned.ts): extends ComputeProvider with openStoreOwned(request) -> Promise<RemoteStoreOwnedLease> and adds storeOwned target settings (maxArchiveBytes up to 16 MiB, deadlinesMs for open, read, dehydrate, and commit).
  • Startup validation (worker.ts): worker.start() fails closed unless every enabled store-owned target has a registered provider declaring "store-owned", implementing openStoreOwned, and a session store supporting opaque archives.
  • Turn lifecycle (remote-store-owned.ts, session-lifecycle.ts, session-proxy.ts):
    • Short-circuits already-committed turnKey retries from readTrustedTurnCommit with zero sandbox contact.
    • Passes expectedHead and a single-use readArchive callback to openStoreOwned; verifies hydratedHead matches expectedHead (STORE_OWNED_HYDRATE_MISMATCH invalidates the warm cache and retries).
    • Binds the lease's CopilotClient with resume: true iff the store holds a head in the current epoch, and creates a fresh per-turn model broker handler while the session holds no binding.
    • Enforces separate phase deadlines (default 60 s open, 60 s read, 120 s dehydrate, 60 s commit, and 60 s native create/resume).
  • Unpublished turns: conflicts (SnapshotConflictError), user stops, cancelled attempts (lost activity lock, cancel, delete), and lost runtime connections (transport_loss or connection-closed errors) commit nothing, invalidate the warm cache, close the lease, and emit session.snapshot_unpublished.
  • Docs: adds docs/developer/building/compute-providers.md, documents storeOwned target configuration in docs/developer/reference/configuration.md, and documents the stop-deploy-start rollout and rollback procedure in docs/developer/deploy/aks.md.

Compatibility

  • No compute target configured or selected: worker and session behavior is unchanged.
  • No CMS migration and no orchestration version change.
  • Rollout: the release that first enables compute targets requires a stop, deploy, start deployment so an older worker in a mixed fleet cannot pick up a target session's turn and run it locally (docs/developer/deploy/aks.md).

Tests

Adds packages/sdk/test/local/remote-store-owned.test.js and extends packages/sdk/test/unit/compute-integration.test.mjs:

  • Cold creation, warm sandbox reuse (reusedWarm: true), cold restore on sandbox replacement, and epoch reset across FilesystemSessionStore and SessionBlobStore.
  • Hydrate mismatch detection, readArchive head-movement refusal, and invalidateWarmCache handling.
  • Idempotent turnKey recovery after a crash between archive commit and activity completion, with zero sandbox contact.
  • Unpublished turn handling for CAS conflict, stop, cancel/lost lock, and runtime transport loss.
  • Per-phase deadline expiry (STORE_OWNED_DEADLINE) and abort signal propagation.

Not in this PR

Session workspaces on a compute target, snapshot-owned (platform-managed) state policies, worker-side token usage metering for brokered requests, and orchestration-version fencing across mixed fleets (see docs/proposals/remote-compute-targets.md §12).

Waldemort Agent and others added 3 commits December 2, 2026 07:04
…omputeProvider

Wires store-owned (`statePolicy: "store-owned"`) turn execution into the unified
ComputeTarget / ComputeProvider / ComputeRegistry abstraction:

- Extends ComputeProvider with optional `openStoreOwned(request) -> RemoteStoreOwnedLease`.
- Validates fail-closed at `worker.start()` that every enabled `store-owned` target has a
  registered provider implementing `openStoreOwned` and a session store supporting opaque
  archives.
- Per durable turn, probes the opaque store head, answers an already-committed turn key
  from the worker-owned trusted record with zero sandbox contact, opens a lease through
  the target's provider (`expectedHead` + lazy `readArchive`), verifies `hydratedHead`
  matches the stored head, runs the turn on the bound remote runtime behind the worker
  model credential broker, takes one opaque archive and commits it with conditional
  store-wins CAS.
- Each turn binds its lease's client for the target with resume: true exactly when the
  store holds a head in the epoch (the sandbox kept it warm or hydrated it from the
  archive), so no later turn is bound as one whose remote lost the conversation; turn 0
  and an epoch's first turn create it. The turn's model handler is its own, made while
  the session holds no binding, so it serves that turn's binding only. A binding the
  turn did not make, or a lease client still bound to another session, is refused for
  a retry: a client serves one session at a time.
- The provider's open has a 60 s default deadline, the same as the session manager's
  deadline for the native create or resume that follows it on the lease's client. The
  two run one after the other, neither covers the other, and each holds the session
  lock at most half of what a caller waits for it. A native create or resume past its
  deadline fails the turn for a retry and drops the sandbox cache.
- A conflict invalidates the warm cache and reports unpublished (reason "conflict")
  without bricking the session. Unset, worker behavior is unchanged.
- A cancelled attempt (a lost activity lock, a cancel or a delete) commits nothing,
  as a local session's does since #382: the warm cache is invalidated and the turn
  reported unpublished (reason "cancelled"), so no cancelled result is stored under
  the turn key and its retry runs the turn from the stored head. A cancelled
  attempt's result settles nothing for good (no store-owned refusal is raised).
- Documents the rollout: the release that first lets workers enable a compute target
  is deployed by stop, deploy, start, because during a rolling update a worker without
  compute-target support can run a target session's turn locally. Targets are enabled
  only after every worker runs it; a rollback first ends or deletes every session
  placed on a compute target.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
A local turn that lost its Copilot runtime connection skips its snapshot
commit (transport_loss) because the runtime may have torn its files. The
same holds for a remote sandbox: a store-owned turn with a transport-loss
result, or an error result in the connection-closed words without the
flag (the inactivity watchdog, a session error; the same check the remote
guard of runTurn uses), now invalidates the warm cache, closes the lease
and reports the turn unpublished with reason "transport_loss". The retry
starts from the stored head.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add docs/developer/building/compute-providers.md: who does what, the
ComputeProvider and RemoteStoreOwnedLease interface with a TypeScript
skeleton, the store-owned target settings (storeOwned.maxArchiveBytes and
storeOwned.deadlinesMs), what happens every turn, the rules a provider
must keep, error handling, testing and rollout. List it in the developer
guide. In the configuration reference, describe the store-owned start
checks and the storeOwned block, and link the guide. The design record's
link to the guide no longer says it is to be added.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@waldemort-auto
waldemort-auto Bot force-pushed the waldemort/m1-pr2-opaque-archive-store branch from 02bb72b to 7851de6 Compare December 2, 2026 07:21
@waldemort-auto
waldemort-auto Bot force-pushed the waldemort/m1-pr3-store-owned-mode1 branch from 857c181 to 9d2bc3c Compare December 2, 2026 07:21

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant