Skip to content

[RFC 005] 1/4: split openenv.core.harness into a package - #1097

Open
splusq wants to merge 2 commits into
huggingface:mainfrom
splusq:rfc-005/pr1-harness-package-split
Open

[RFC 005] 1/4: split openenv.core.harness into a package#1097
splusq wants to merge 2 commits into
huggingface:mainfrom
splusq:rfc-005/pr1-harness-package-split

Conversation

@splusq

@splusq splusq commented Aug 28, 2026

Copy link
Copy Markdown

Stack for RFC 005: Agentic Harness Integration — this is 1 of 4. Each PR is one commit; later PRs target main (cross-fork PRs cannot chain bases), so review them in order and read the top commit of each.

  1. 1/4 — this PR: package split (refactor only)
  2. 2/4 — foundation types
  3. 3/4 — HarnessEnvironment + subprocess + tool bridge
  4. 4/4 — production /harness route + mode wiring

What

Moves the trainer-side rollout API out of the package __init__ and into openenv.core.harness.rollout, leaving __init__ as a re-export shim.

No behavior change. Every name previously importable from openenv.core.harness still is, and is the identical object.

Why now

openenv/core/harness/__init__.py is ~730 lines of implementation living directly in the package __init__, with a docstring saying it sits outside the stable surface "while RFC 005 is still under review". The rest of RFC 005 adds a second, differently-shaped layer to the same package. Splitting first means that layer lands in sibling modules instead of growing the __init__ to ~2000 lines, and it keeps the refactor reviewable on its own instead of buried inside a feature diff.

Two details worth a look

  • _resolve_env_reward is re-exported too, with a noqa and a comment. It is private, but tests/scripts/test_browsergym_harness_eval_examples.py imports it from the package root. I found this by running the consumer tests, not by reading — worth knowing it is load-bearing.
  • collect.py now imports from .rollout rather than from . import ..., removing a self-referential package import.

Verification

tests/core/test_harness_rollout_backcompat.py is added as the contract: every name in the old __all__ resolves from the package root and is the same object as on rollout.

All in-repo consumers pass unchanged — openenv collect, pi_env, opencode_env, browsergym_env, reasoning_gym_env, openspiel_env:

82 passed

(test_harness_runtime, test_harness_collect, test_opencode_factory_lifecycle, test_openspiel_collect, test_browsergym_harness, test_browsergym_harness_eval_examples, plus the new back-compat file.) Lint clean.

Question for reviewers

Longer term the naming is muddled: HarnessAdapter here drives rollouts, while RFC 005's adapter adapts an external process, and both want the plain name. A rationalization would be RolloutDriver / MCPRolloutDriver / BlackBoxRolloutDriver / RolloutResult / RolloutLimits for this layer, freeing HarnessAdapter for the RFC 005 meaning. Not done here — it would break the "no behavior change" property of this PR — but this is the natural moment to decide, before the names calcify. Happy to do it as a follow-up with deprecation aliases.


Note

Low Risk
Mechanical module move with explicit re-exports and back-compat tests; no rollout or reward logic changes.

Overview
Refactor-only split of openenv.core.harness: the trainer-side rollout implementation (~730 lines) moves from the package __init__ into a new rollout module. __init__.py is now a thin re-export shim so from openenv.core.harness import ... still resolves to the same objects as before.

collect.py imports rollout types from .rollout instead of from . import ..., avoiding a circular package self-import. The private helper _resolve_env_reward is deliberately re-exported from the package root for existing test/script consumers.

Adds tests/core/test_harness_rollout_backcompat.py to lock the contract: public __all__ names and _resolve_env_reward identity-match between openenv.core.harness and rollout.

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

Moves the trainer-side rollout API out of the package __init__ and into
`openenv.core.harness.rollout`, leaving __init__ as a re-export shim. No
behavior change: every name previously importable from
`openenv.core.harness` still is, and is the same object.

The module was ~730 lines living directly in __init__ with a docstring
noting it sat outside the stable surface "while RFC 005 is still under
review". Splitting it now makes room for the RFC 005 turn-based agentic
harness layer to land in sibling modules instead of growing the __init__
further.

Also re-exports the private `_resolve_env_reward`, which
tests/scripts/test_browsergym_harness_eval_examples.py imports from the
package root, and points `collect.py` at `.rollout` directly rather than
importing from its own package.

Consumers left untouched and verified: `openenv collect`, pi_env,
opencode_env, browsergym_env, reasoning_gym_env, openspiel_env.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
from openenv.core.harness import rollout

ROLLOUT_PUBLIC_NAMES = [
"CLIHarnessAdapter",

@splusq splusq Aug 28, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

these can be rationalized in a separate PR - there are lots of conflated names here.

@splusq
splusq marked this pull request as ready for review August 31, 2026 21:15
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.

1 participant