Skip to content

Add runner workspace snapshot, drain, and resume hooks #83

Closed

Description

@haasonsaas

Current progress for agents

  • 2026-04-23: Maestro-core drain/restore scope is already landed on public main. The current public tree has the hosted drain endpoint, persisted snapshot-manifest.v1 contract, workspace export-path recording, Rust restore-manifest loading, explicit restored_from_snapshot replay, and not-ready partial-restore behavior.
  • 2026-04-23: local validation on current public main was clean for the core acceptance bar:
    • bun run --filter @evalops/contracts build
    • npm test -- test/server/hosted-runner-drain.test.ts
    • cargo test --manifest-path packages/tui-rs/Cargo.toml hosted_runner --lib
    • MAESTRO_RUST_HOSTED_CONFORMANCE=1 npm test -- test/headless/runtime-conformance.test.ts
  • Public history already reflects the major Maestro-side slices for this issue, including 875aa964 (hosted drain snapshot hook), 513e0b7b (Rust hosted runner conformance adapter and restore-path coverage in the current tree), and 6a3e9c3f / #120 (retention-policy metadata on the manifest contract).
  • Remaining follow-through is cross-repo orchestration, not missing Maestro-core behavior: evalops/platform#838 for restore orchestration/state machine and evalops/deploy#1126 for provider artifact hydration before Maestro starts.

Related: #76, #77, #81, #82, evalops/platform#781, evalops/platform#782, evalops/platform#784, evalops/deploy#1025

Problem

Remote runner sessions need predictable teardown and, eventually, resume. The Platform controller can delete pods, but only Maestro understands the active session state, conversation/session files, pending tool requests, workspace context, and what should be flushed before a pod exits.

This issue tracks Maestro-side hooks for draining a hosted runner session and exporting enough state for artifacts or future resume.

Scope

  • Add a hosted-mode drain/shutdown endpoint or control message.
  • Flush active session JSONL, summaries, pending metadata, and runtime state before shutdown.
  • Emit a final session snapshot manifest with session id, runner session id, workspace root, git ref, model/provider, timestamps, and stop reason.
  • Provide optional workspace export hook: tar/zip/git diff bundle, or delegate upload to a sidecar/controller via a local path contract.
  • Provide import/resume hook that can restore a previously exported session/workspace snapshot when Platform allows resume.
  • Correlate exported artifacts with Platform runner_workspace_snapshots and AgentRun artifacts.

Design Notes

  • Keep this as a local/runtime hook inside Maestro; Platform/deploy should own object storage and retention.
  • Start with drain + manifest + local artifact path. GCS upload can be controller/sidecar-owned.
  • Resume after hard TTL can remain disabled initially; explicit stop/lost-worker recovery is enough for v1.
  • The workspace root restrictions from Bind headless remote sessions to explicit workspace sandboxes #77 are a prerequisite for safe exports.

Acceptance Criteria

  • Hosted runner mode can receive a stop/drain request and flush session/runtime state before process exit.
  • A snapshot manifest is written to a configured path with runner/session/workspace correlation ids.
  • Export refuses to include files outside the session workspace root.
  • Tests cover normal drain, interrupted drain, outside-root export rejection, and local/offline behavior remaining unchanged.
  • Docs describe the handoff contract between Maestro, Platform remote-runner, and deploy/GCS artifact storage.

Runtime Parity / Conformance Links

Use #85 as the protocol-level acceptance bar: lifecycle, subscribe/events/messages/heartbeat/disconnect, viewer/controller roles, permission request/response, utility operations, workspace-root enforcement, cursor replay/reset, and drain/resume behavior should match across the current TypeScript web/headless bridge and the target Rust runtime.


GCP Storage / Sandbox Note Added 2026-04-22

GCP substrate research added one important constraint for this snapshot/drain contract:

  • evalops/deploy#1028 tracks a GKE Sandbox/gVisor maestro-secure profile.
  • Cloud Storage FUSE CSI should not be assumed for that secure profile; the Maestro side should expose a local drain/export path and manifest, while Platform/deploy own GCS upload, lifecycle, and retention through evalops/deploy#1025.
  • evalops/platform#786 should carry the resolved profile and workspace persistence mode so Maestro knows whether it is running in standard, spot, secure, or future microVM mode without depending on Kubernetes-specific details.

Decision summary for agents: keep Maestro's contract local and runtime-native. Object storage is an external handoff, not something Maestro should require as a mounted live workspace.

Activity

  1. haasonsaas commented on Apr 22, 2026

    @haasonsaas
    ContributorAuthor

    Cross-linking #84: snapshot/drain/resume should be implemented as part of the Rust core runtime target, with TypeScript/web-headless parity maintained through the headless/session protocol. Do not make resume semantics TS-only.

  2. haasonsaas commented on Apr 22, 2026

    @haasonsaas
    ContributorAuthor

    State machine + per-run resume flag from prior art — OpenHands V1 models this with SandboxStatus ∈ {STARTING, RUNNING, PAUSED, ERROR, MISSING} where MISSING is distinct from PAUSED — one means "gone forever, stop looking," the other means "resume on demand." E2B's PausedSandboxResumer is feature-flagged per-sandbox (SandboxAutoResumeFlag) because they learned unconditional resume is wrong; some sessions should stay dead.

    Proposed shape for v1:

    • Idle-TTL hit → AgentRun state PAUSED, PVC retained for $RESUME_WINDOW (24h default).
    • Attach within window + auto_resume: true → new pod mounts PVC, replays events ≥ last checkpoint.
    • After window → state MISSING, workspace deleted, attach returns 410 with "re-provision from run metadata" error.
    • Hard-TTL hit → always MISSING (no TTL-resume; scoped out of v1).

    This lets auto_resume become a per-session policy knob later without refactoring the state machine.

  3. haasonsaas commented on Apr 22, 2026

    @haasonsaas
    ContributorAuthor

    Cross-link after Daytona/Modal research: evalops/platform#787 evaluates managed sandbox providers whose snapshot/filesystem semantics differ from the self-operated GKE path. This Maestro issue should stay provider-neutral: expose drain/export/import hooks and a local artifact/manifest contract, while Platform/deploy own whether the backing substrate is GKE/GCS, Daytona snapshots, Modal filesystem snapshots/Volumes, or a future microVM profile.

  4. haasonsaas commented on Apr 22, 2026

    @haasonsaas
    ContributorAuthor

    Review cross-link: #86 now tracks the provider-neutral hosted runner contract this drain/snapshot work should implement. evalops/platform#790 should decide which substrates become production or experimental profiles; evalops/platform#788/#789 may reveal provider-specific snapshot semantics, but Maestro should keep the drain/export/import surface local and substrate-neutral.

  5. haasonsaas commented on Apr 23, 2026

    @haasonsaas
    ContributorAuthor

    Follow-up implementation is now in review in #116. It tightens the hosted drain/snapshot contract by returning the manifest in the drain response, recording requested workspace export paths in the persisted manifest, making host-level draining state win over inner agent readiness in runtime snapshots, and adding shared Rust-hosted conformance for manifest shape plus post-drain mutation rejection.

    This does not complete the full resume/import side of this issue, but it makes the drain handoff much more concrete for Platform to consume.

  6. haasonsaas commented on Apr 23, 2026

    @haasonsaas
    ContributorAuthor

    Correction on the previous link: #116 was opened against the public mirror by mistake and has been closed. The actual review thread for this drain/conformance slice is evalops/maestro-internal#1394.

    That internal PR is the one adding manifest-in-response, workspace export-path recording, host-level draining readiness, and required Rust-hosted conformance coverage for post-drain mutation rejection.

  7. haasonsaas commented on Apr 23, 2026

    @haasonsaas
    ContributorAuthor

    Update: evalops/maestro-internal#1394 has merged at evalops/maestro-internal@3bba9635. Drain now returns the manifest inline, records workspace export paths, reports not-ready/Drained after host drain, and is covered by the required Rust-hosted conformance job. Remaining resume/import work is tracked in evalops/maestro-internal#1395.

  8. haasonsaas commented on Apr 23, 2026

    @haasonsaas
    ContributorAuthor

    Cross-linking evalops/platform#852 here. The new remote-runner security review explicitly treats snapshot/drain/restore behavior as part of the production security boundary, not just runtime ergonomics.

    It also surfaced #119 as a dedicated follow-up for hosted runner artifact, snapshot, and log retention/redaction policy so those requirements stop being implicit.

  9. haasonsaas commented on Apr 23, 2026

    @haasonsaas
    ContributorAuthor

    Related follow-through: #120 now adds hosted-runner manifest retention-policy metadata plus the retention/redaction protocol doc, so the drain/snapshot handoff carries explicit visibility classes instead of leaving them implicit in issue prose.

  10. haasonsaas commented on Apr 23, 2026

    @haasonsaas
    ContributorAuthor

    Closure note: after re-checking current public main, the Maestro-core drain/restore scope tracked here is already landed.

    Validated locally on 2026-04-23 with:

    • bun run --filter @evalops/contracts build
    • npm test -- test/server/hosted-runner-drain.test.ts
    • cargo test --manifest-path packages/tui-rs/Cargo.toml hosted_runner --lib
    • MAESTRO_RUST_HOSTED_CONFORMANCE=1 npm test -- test/headless/runtime-conformance.test.ts

    I'm closing this issue and leaving the remaining work in the cross-repo follow-ups: evalops/platform#838 for restore orchestration/state machine and evalops/deploy#1126 for provider artifact hydration.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions