Repository navigation
Description
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, persistedsnapshot-manifest.v1contract, workspace export-path recording, Rust restore-manifest loading, explicitrestored_from_snapshotreplay, and not-ready partial-restore behavior. - 2026-04-23: local validation on current public
mainwas clean for the core acceptance bar:bun run --filter @evalops/contracts buildnpm test -- test/server/hosted-runner-drain.test.tscargo test --manifest-path packages/tui-rs/Cargo.toml hosted_runner --libMAESTRO_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), and6a3e9c3f/#120(retention-policy metadata on the manifest contract). - Remaining follow-through is cross-repo orchestration, not missing Maestro-core behavior:
evalops/platform#838for restore orchestration/state machine andevalops/deploy#1126for 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_snapshotsand 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
- Define Rust core runtime parity contract for hosted Maestro #84 — Rust core runtime parity decision for hosted Maestro.
- Add headless runtime conformance suite for Rust parity #85 — headless runtime conformance suite that should gate Rust-hosted runner parity.
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-secureprofile. - 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
haasonsaas commentedon Apr 22, 2026
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.
haasonsaas commentedon Apr 22, 2026
State machine + per-run resume flag from prior art — OpenHands V1 models this with
SandboxStatus ∈ {STARTING, RUNNING, PAUSED, ERROR, MISSING}whereMISSINGis distinct fromPAUSED— one means "gone forever, stop looking," the other means "resume on demand." E2B'sPausedSandboxResumeris feature-flagged per-sandbox (SandboxAutoResumeFlag) because they learned unconditional resume is wrong; some sessions should stay dead.Proposed shape for v1:
PAUSED, PVC retained for$RESUME_WINDOW(24h default).auto_resume: true→ new pod mounts PVC, replays events ≥ last checkpoint.MISSING, workspace deleted, attach returns 410 with "re-provision from run metadata" error.MISSING(no TTL-resume; scoped out of v1).This lets
auto_resumebecome a per-session policy knob later without refactoring the state machine.haasonsaas commentedon Apr 22, 2026
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.
haasonsaas commentedon Apr 22, 2026
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.
haasonsaas commentedon Apr 23, 2026
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.
haasonsaas commentedon Apr 23, 2026
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.
haasonsaas commentedon Apr 23, 2026
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.
haasonsaas commentedon Apr 23, 2026
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.
haasonsaas commentedon Apr 23, 2026
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.
haasonsaas commentedon Apr 23, 2026
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 buildnpm test -- test/server/hosted-runner-drain.test.tscargo test --manifest-path packages/tui-rs/Cargo.toml hosted_runner --libMAESTRO_RUST_HOSTED_CONFORMANCE=1 npm test -- test/headless/runtime-conformance.test.tsI'm closing this issue and leaving the remaining work in the cross-repo follow-ups:
evalops/platform#838for restore orchestration/state machine andevalops/deploy#1126for provider artifact hydration.