RFC: Environment snapshots for branching and regrading trials

Open
#4,526 3 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
docker, python
Domain
backend, devops

Research direction

Start by reading check_task_regradable in src/harbor/trial/regrade.py and the attached 40-page RFC based on commit cf4bd00. The proposal spans environment contracts, configuration and CLI flags, branching, regrading, provider snapshots, cleanup, and garbage collection. Done means implementing and validating the RFC across the listed providers; the issue does not specify a smaller first contribution.

Written by the indexing model from the issue text.

Description

Harbor can boot sandboxes from cached images, but it cannot capture a running trial's environment, and the environment is gone once stop() runs. That has three costs today:

  • harbor job regrade refuses shared-mode verifiers, because the agent environment no longer exists (check_task_regradable). 82 of the 83 adapter templates use shared mode.
  • Every rollout builds a fresh sandbox and reinstalls the agent, so RL groups and agent comparisons have no shared starting point.
  • Keeping a failed trial's state for debugging means --no-delete, which does five different things depending on the provider.

The attached RFC proposes runtime snapshots as an optional environment capability. It is based on cf4bd00.

Proposal

  1. Environment contract. await env.snapshot(...) returns a SnapshotRef, and a restore_from= constructor argument boots a new sandbox from one. Providers opt in with capability flags, and unsupported requests fail before any sandbox starts. start() and third-party environments do not change.
  2. Config. An environment.snapshots block and --snapshot flags, with three triggers: post_setup, post_agent and final. When unset, config.json, lock.json and result.json are byte-identical to today.
  3. Restores. A new branch action on source_trial re-runs an agent from a snapshot. regrade learns to restore a post_agent snapshot and run a shared-mode verifier in it.
  4. Cleanup. The trial writes a ledger line with the snapshot's name before it calls the provider, so a capture that times out or is killed can still be found and deleted. Snapshots expire after 7 days by default, and harbor snapshot gc removes them.

Docker, Modal, Daytona, E2B and Runloop come first. Every other provider gets a tar fallback over listed paths.

Related

  • #2675: hooks have no environment handle, so a plugin cannot do this.
  • #1767: scoring a completed trial without re-running the agent.
  • #571: container reuse, including snapshot-based reuse.
  • #2801: trial recovery by re-attaching to live environments.
  • #788 (closed): periodic workspace checkpoints with restore into a Daytona sandbox.

The full RFC is attached (PDF, 40 pages): harbor-environment-snapshots-rfc.pdf. I can also open it as a PR under rfcs/.

Dominant language
Python
Stars
5.6k
Forks
1.9k
Avg merge
1d 17h
Merged PRs (30d)
156

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from harbor-framework/harbor

All issues in harbor-framework/harbor

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.