Skip to content

Run Harbor Compose tasks on local Docker - #2547

Open
xeophon wants to merge 8 commits into
mainfrom
harbor-compose
Open

xeophon wants to merge 8 commits into
mainfrom
harbor-compose

Conversation

@xeophon

@xeophon xeophon commented Sep 6, 2026

Copy link
Copy Markdown
Member

Harbor runs each task's authored Docker Compose project on local Docker. The Harbor environment uses an async compose_services() context manager for startup, readiness, and cleanup; the agent borrows an ordinary DockerRuntime attached to the project's main container.

Local execution requires --env.trust-compose, since authored Compose definitions can access host files and Docker privileges. Compose receives only Docker connection settings and infrastructure variables, with task-local .env files and declared task environment available. Separate graders requesting a fresh copy inherit the main container's resolved image and working directory.

DockerRuntime.attach() inspects an existing container and provides the shared command, process, file, and callback interfaces without taking ownership of container removal. Compose preserves authored images, working directories, entrypoints, dependencies, health checks, networks, and volumes, with explicit task/runtime overrides applied to main.

Projects are removed on completion, startup failure, or cancellation. Whole-episode retries create fresh projects through env.retries. This supports public-network CPU tasks on local Docker; separate grading retains its ordinary fresh verifier runtime.

Note

Add Harbor Compose task support on local Docker

  • Adds a compose_services lifecycle context manager in compose.py that starts a temporary, isolated Compose project and yields a borrowed DockerRuntime for its main container. It requires explicit Compose trust, rejects restricted networking, GPU usage, static host ports, unscoped resources, explicit container names, and unsupported host networking.
  • Adds DockerRuntime.attach in __init__.py to borrow an existing local container without owning its lifecycle, with an ownership guard in cleanup so borrowed containers are not removed.
  • Updates HarborEnv.run in env.py to detect Compose definitions, require local Docker runtime and trust_compose config (default false), and route through the Compose lifecycle while preserving the separate verifier flow for non-Compose tasks.
  • Adds optional environment forwarding to _communicate and cli in container.py so host commands can run with an explicit environment. Updates resolve_image in taskset.py so Compose tasks with an authored main image or build no longer need a separately resolved pullable image.
  • Risk: HarborEnvConfig.trust_compose defaults to false; Compose tasks will fail until operators opt in. Borrowed-container cleanup path in DockerRuntime.cleanup must not remove containers created outside the runtime.

Macroscope summarized 00452a0.


Note

High Risk
Compose runs trusted task infrastructure with host file mounts and Docker privileges (--env.trust-compose), and project teardown uses compose down --volumes, which can destroy project data; grading paths depend on borrowed-container resolution.

Overview
Adds local Docker Compose execution for Harbor tasks when environment/docker-compose.yaml is present and runtime.type = "docker". A new compose_services() context manager rolls out the authored topology (with Harbor base/env overlays), validates CPU/public-network constraints, publishes a callback port on the network owner, and lends the main container to the agent via DockerRuntime.attach()—which inspects an existing container, marks it borrowed, and skips docker rm on cleanup.

Harbor env gains trust_compose (--env.trust-compose); without it, Compose tasks fail fast. Compose subprocesses use a filtered host env (Docker connection vars + infra), not the full evaluator environment. Non-Compose agent flow is refactored so separate-verifier tasks still defer scoring/collect artifacts; when grading requests a fresh copy from a borrowed Compose box, the verifier task inherits the resolved image and workdir from the agent runtime.

Supporting changes: container.cli / _communicate accept an explicit env dict; resolve_image returns None when Compose main declares image or build so the harness does not pre-pull the wrong ref. Docs describe Compose behavior, retries at the project level, and narrow the entrypoint/sidecar shortcomings to non-Compose runs.

Reviewed by Cursor Bugbot for commit 00452a0. Bugbot is set up for automated code reviews on this repo. Configure here.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 6, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-20T17:22:33.079385Z 475c4de New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Comment thread verifiers/v1/tasksets/harbor/runtime.py Outdated
Comment thread verifiers/v1/tasksets/harbor/runtime.py Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 28dffe7255

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread verifiers/v1/tasksets/harbor/runtime.py Outdated
Comment thread verifiers/v1/tasksets/harbor/runtime.py Outdated

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread verifiers/v1/tasksets/harbor/compose.py Outdated
Comment thread verifiers/v1/tasksets/harbor/compose.py Outdated
@macroscopeapp

macroscopeapp Bot commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Not approved

Macroscope's review found this PR not approvable — This adds a substantial local Docker Compose execution path with borrowed-container lifecycle management, callback proxying, image-resolution changes, and trusted access to host files and Docker privileges. The breadth and security-sensitive runtime effects require human review.

You can add or adjust custom eligibility rules. Learn more.

@xeophon
xeophon changed the base branch from main to feat/local-container-runtimes September 6, 2026 18:10
Comment thread verifiers/v1/tasksets/harbor/compose.py Outdated
Comment thread verifiers/v1/tasksets/harbor/runtime.py Outdated
Comment thread verifiers/v1/tasksets/harbor/runtime.py Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6bff76b193

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread verifiers/v1/tasksets/harbor/runtime.py Outdated
Comment thread verifiers/v1/tasksets/harbor/env.py Outdated

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread verifiers/v1/tasksets/harbor/runtime.py Outdated
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

1 similar comment
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread verifiers/v1/tasksets/harbor/runtime.py Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 141d878fba

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread verifiers/v1/tasksets/harbor/env.py Outdated
Comment thread verifiers/v1/tasksets/harbor/runtime.py Outdated
Comment thread verifiers/v1/tasksets/harbor/runtime.py Outdated

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread verifiers/v1/tasksets/harbor/compose.py Outdated
Comment thread verifiers/v1/tasksets/harbor/runtime.py Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d66e109f55

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread verifiers/v1/tasksets/harbor/compose.py Outdated
Comment thread verifiers/v1/tasksets/harbor/compose.py Outdated

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread verifiers/v1/tasksets/harbor/runtime.py Outdated
Comment thread verifiers/v1/tasksets/harbor/runtime.py Outdated
Base automatically changed from feat/local-container-runtimes to main September 17, 2026 20:04
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

Comment thread verifiers/v1/tasksets/harbor/compose.py Outdated
Comment thread verifiers/v1/tasksets/harbor/compose.py Outdated
Comment thread verifiers/v1/tasksets/harbor/runtime.py Outdated
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

Comment thread verifiers/v1/tasksets/harbor/env.py Outdated
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

Comment thread verifiers/v1/tasksets/harbor/compose.py Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6952c894b2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread verifiers/v1/tasksets/harbor/compose.py Outdated

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread verifiers/v1/tasksets/harbor/compose.py Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0cee43655b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread verifiers/v1/tasksets/harbor/compose.py Outdated
Comment thread verifiers/v1/tasksets/harbor/compose.py Outdated
Comment thread verifiers/v1/tasksets/harbor/taskset.py

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 0cee436. Configure here.

Comment thread verifiers/v1/tasksets/harbor/compose.py Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ed08794e05

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread verifiers/v1/tasksets/harbor/taskset.py
Comment thread verifiers/v1/tasksets/harbor/compose.py
Comment thread verifiers/v1/tasksets/harbor/compose.py
Comment thread verifiers/v1/tasksets/harbor/compose.py

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 386e882239

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread verifiers/v1/tasksets/harbor/compose.py Outdated
Comment thread verifiers/v1/tasksets/harbor/taskset.py Outdated
Comment thread verifiers/v1/tasksets/harbor/taskset.py Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 475c4de352

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread verifiers/v1/runtimes/docker/__init__.py

@mikasenghaas mikasenghaas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we have an example of a harbor taskset which uses compose which we can use to prove that things work?

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