Skip to content

[4/6][rollout] feat: harbor execution backend v2 - #286

Merged
mathewjhan merged 1 commit into
mainfrom
mathew/harbor-backend-v2
Aug 6, 2026
Merged

[4/6][rollout] feat: harbor execution backend v2#286
mathewjhan merged 1 commit into
mainfrom
mathew/harbor-backend-v2

Conversation

@mathewjhan

@mathewjhan mathewjhan commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Part of splitting #272 into reviewable pieces (4/6). Builds on #284 (container contract) and #285 (packaging).

What this adds

HarborBackendV2: runs each rollout as a Harbor trial. The agent can be either a user workflow (packaged into a wheel and installed in the container at trial start) or a registered native Harbor agent (terminus-2, mini-swe-agent, oracle) with the rollout endpoint injected into its environment.

How a rollout flows through it:

  1. Task selection (tasks.py): template mode uses one task directory for every rollout; dataset mode routes by metadata["harbor_task_id"] to a folder under tasks_dir (path escapes rejected); metadata["harbor_task"] fetches a task from a local path, git checkout, or registry package, with per-ref locks so concurrent rollouts download once.
  2. Materialization: the task is copied into a per-rollout directory; the rollout's input file is staged; if the task has no tests/ and a grader exists, a test.sh is generated that installs and runs the grader. The ground-truth label is staged only into tests/, which Harbor uploads at verification time — the agent phase cannot read it.
  3. Image preparation: patch_dockerfile_with_sdk appends a block to the task's Dockerfile that installs a static uv binary and creates /opt/osmosis/venv with the bundle's dependencies pre-installed. Per-trial installs then only add the user's own code (--no-deps), which cuts container startup from minutes to seconds. The patch is deterministic, so identical tasks keep identical image content hashes and share builds.
  4. Execution (harness_agent.py): the installed agent uploads the wheel, installs it into the venv, backfills an empty prompt from the task's instruction.md, runs the agent script, and returns the result through the trial's agent metadata.
  5. Callbacks: the workflow-complete callback fires when verification starts (agent phase over); the grader-complete callback fires at trial end with the reward parsed from Harbor's verifier result. Callback delivery failures are logged and never abort trial archival.
  6. Observability and lifecycle: per-phase timings and failure phases in every result (diagnostics.py), native-agent ATIF parsing with secret redaction, artifact relocation, prewarm() / prewarm_lifespan() to build task images before serving traffic, cancel_rollouts(ids | prefix | all), rollout_status() with terminal outcomes retained in a TtlCache ([1/6][rollout] feat: add TtlCache utility #283), and admission control via max_queue_depth.

Example

backend = HarborBackendV2(
    orchestrator=TrialQueue(n_concurrent=100),
    tasks_dir=Path("tasks"),           # 300 task folders
    task_mode="dataset",
    agent=MyWorkflow,                  # or agent="mini-swe-agent"
    workflow_config=my_config,
    environment_config=EnvironmentConfig(type=EnvironmentType.SKYPILOT),
)
app = create_rollout_server(
    backend=backend,
    lifespan=backend.prewarm_lifespan(task_ids=["task-0000"]),
)

A trainer then POSTs rollouts with metadata={"harbor_task_id": "task-0042"}; each one runs in its own sandbox and reports back through the callbacks.

@mathewjhan mathewjhan changed the title [rollout] feat: harbor execution backend v2 [4/6][rollout] feat: harbor execution backend v2 Aug 6, 2026
@mathewjhan
mathewjhan force-pushed the mathew/harbor-backend-v2 branch from 7598f86 to e62f900 Compare August 6, 2026 22:29
@mathewjhan
mathewjhan force-pushed the mathew/harbor-backend-v2 branch from e62f900 to 9ce689b Compare August 6, 2026 22:31
Base automatically changed from mathew/packaging to main August 6, 2026 22:31
Co-authored-by: Cursor <cursoragent@cursor.com>
@mathewjhan
mathewjhan force-pushed the mathew/harbor-backend-v2 branch from 9ce689b to 16307d5 Compare August 6, 2026 22:31
@mathewjhan
mathewjhan merged commit bdc679a into main Aug 6, 2026
1 check passed
@mathewjhan
mathewjhan deleted the mathew/harbor-backend-v2 branch August 6, 2026 22:33
mathewjhan added a commit that referenced this pull request Aug 6, 2026
…ncel endpoints (#287)

Part of splitting #272 into reviewable pieces (5/6). Builds on #286
(backend capabilities).

## What this adds

Three server-level behaviors that let a trainer manage load and track
rollouts over plain HTTP:

- **Admission control on `POST /rollout`**: when the backend's queue is
at `max_queue_depth`, the server answers `429` with a `Retry-After`
header instead of accepting work it cannot start. Accepted rollouts
return `202`, which states what actually happens: the rollout is queued
and runs after the response is sent.
- **`GET /rollout/{id}/status`**: reports `queued`, `running`, or
`grading` for live rollouts, and `success` / `failure` / `cancelled`
(with reward and error message) for recently finished ones, retained for
a fixed window. Anything else returns `unknown`. A trainer polls this as
a liveness signal instead of trusting a blind timeout.
- **`POST /rollout/cancel`**: takes exactly one selector — `{"ids":
[...]}`, `{"prefix": "tenant-a::"}`, or `{"all": true}` — and returns a
disposition per rollout (`cancelled_queued`, `cancelled_running`,
`not_found`). Prefix cancellation is what a controller uses to stop
everything belonging to one adapter when it is deregistered. Cancelling
an already-finished rollout returns `not_found`, so the call is safe to
repeat.

## Example

```bash
curl -X POST $SERVER/rollout -d '{"rollout_id": "tenant-a::r1", ...}'
# -> 202 (or 429 + Retry-After: 5 when the queue is full)

curl $SERVER/rollout/tenant-a::r1/status
# -> {"rollout_id": "tenant-a::r1", "status": "running"}

curl -X POST $SERVER/rollout/cancel -d '{"prefix": "tenant-a::"}'
# -> {"dispositions": {"tenant-a::r1": "cancelled_running"}}
```

Co-authored-by: Cursor <cursoragent@cursor.com>
@mintlify

mintlify Bot commented Aug 6, 2026

Copy link
Copy Markdown

Docs PR opened: https://github.com/osmosis-ai/docs/pull/68

Documented the new HarborBackendV2 execution backend, covering task modes, native agents, prewarming, cancellation, status, and admission control.

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.

2 participants