d0rj commited on
Commit
6136b38
·
verified ·
1 Parent(s): 0d8f2b5

Publish mathematics RL 0.2.1: Docker validation and adapter fixes

Browse files
README.md CHANGED
@@ -152,6 +152,12 @@ and timeouts are recorded separately in traces.
152
 
153
  ## Verification and limitations
154
 
 
 
 
 
 
 
155
  Run the committed regression suite or bounded reference audit after installation:
156
 
157
  ```bash
 
152
 
153
  ## Verification and limitations
154
 
155
+ Version **0.2.1** includes a reproducible local Docker check for all five framework
156
+ integrations, using pinned SDKs, native clients/servers and actual Harbor agent
157
+ and separate-verifier containers. See [Docker instructions](rl/DOCKER.md) and
158
+ the [recorded container results](rl/DOCKER_VALIDATION.toml). The checks cover all
159
+ 70 modules in both languages with scripted answers; they do not measure model quality.
160
+
161
  Run the committed regression suite or bounded reference audit after installation:
162
 
163
  ```bash
rl/DOCKER.md ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Local Docker validation
2
+
3
+ Run all five integrations from this package directory on a machine with a Linux
4
+ Docker daemon and Python 3.11.4+ on the host:
5
+
6
+ ```bash
7
+ python integrations/docker/run.py --output /absolute/path/to/new-validation-directory
8
+ ```
9
+
10
+ The output directory must be new. The runner builds separate pinned SDK images,
11
+ runs the regression suite in each, then exercises native framework protocols.
12
+ It also builds the actual OpenEnv production Dockerfile and uses that image for
13
+ both English and Russian servers. The host needs only Python's standard library
14
+ and Docker CLI. Image builds need internet; scoring uses local committed fixtures.
15
+
16
+ For an individual integration, add `--framework harbor` (or `verifiers`, `openenv`,
17
+ `nemo`, `agentenv`). The flag is repeatable. Harbor's default covers 140 task
18
+ directories; `--harbor-limit 2` is a shorter development check. `--skip-build` is
19
+ for iterative development with existing images, not final release evidence.
20
+
21
+ ## What is exercised
22
+
23
+ | Integration | Docker execution |
24
+ | --- | --- |
25
+ | Verifiers | Native plugin discovery and `Task.score` for 70 modules × 2 languages; real `vf-eval` with six scripted model responses |
26
+ | Harbor | Real `harbor run`, agent containers, artifact collection, separate verifier containers, 140 oracle tasks, incorrect answers spanning all answer kinds, invalid-source and missing-output cases |
27
+ | OpenEnv | Production server image plus native `EnvClient` in a different container; correct/incorrect answers for every module/language pair, reset/state and rejection of repeated submissions |
28
+ | NeMo Gym | Real resource-server CLI, cross-container HTTP `/verify`, and supervisor-style entrypoint configuration; correct/incorrect answers for every module/language pair |
29
+ | AgentEnv | Native `EpisodeSpec.start`, solver turn, response submission, grading, result and local stores inside the container; correct/incorrect answers for every module/language pair |
30
+
31
+ The HTTP/episode matrices each cover 280 scripted submissions (140 correct, 140
32
+ incorrect). These are deterministic engineering checks, not evaluation of a real
33
+ model, model training or an independent audit of the entire published corpus.
34
+
35
+ ## Reproducibility and artifacts
36
+
37
+ The validation images pin Python 3.13.14, uv 0.11.23 and Docker CLI 29.7.2;
38
+ base-image manifest digests are in the Dockerfile. `uv sync --locked` preserves
39
+ the five SDK pins and their separate MCP dependency graphs. No API credentials
40
+ or host environment secrets are passed into the test containers.
41
+
42
+ `report.json` records image IDs, source hashes, Docker versions, pytest results,
43
+ case coverage and native protocol results. Per-phase logs and JUnit XML are
44
+ retained. Harbor's native trial JSON, verifier logs and artifacts are copied out
45
+ before its run volume is removed. Expected invalid-source errors are asserted
46
+ separately and do not count as model rewards.
47
+
48
+ The runner uses CPU limits, memory limits and a dedicated Docker network. It
49
+ removes its own named containers, networks and scratch volume, retaining the
50
+ built images and host reports. It never prunes Docker globally. Harbor alone
51
+ receives the Docker socket to launch sibling task containers. A named volume is
52
+ mounted at its daemon-side absolute path, so artifact mounts work on Docker
53
+ Desktop as well as a local Linux daemon.
54
+
55
+ ## Fixes verified by container execution
56
+
57
+ - Windows exports use LF for executable scripts. Earlier CRLF exports failed
58
+ inside Linux with `set: Illegal option -`; a native Windows export is also
59
+ executed directly in a Linux container as a regression check.
60
+ - Harbor verifiers use an explicit Compose `network_mode: none`. This works on
61
+ Docker Desktop kernels without `CONFIG_NFT_FIB_INET`, where Harbor's dynamic
62
+ egress-control `network_mode="no-network"` policy rejects startup. The native
63
+ trials verify that the verifier has no IPv4 routes and the agent cannot read
64
+ the verifier's reference/checker paths.
65
+ - Invalid Harbor references are checked before model artifacts. Source failures
66
+ leave no `reward.txt`; Harbor reports a verifier/source error. This prevents
67
+ malformed references and missing outputs from silently becoming zero model
68
+ rewards, and discards stale score files.
69
+ - The production OpenEnv image uses the same lockfile and pinned Python base as
70
+ validation, rather than resolving a separate transitive dependency set.
71
+ - Verifier inputs are snapshotted in a deterministic, content-addressed tar file,
72
+ with a unique source filename for Docker's `ADD`. A reference SHA-256 label
73
+ and build-time digest check supplement it. This replaces directory copying,
74
+ which mixed files between simultaneous task builds in the local Compose/BuildKit
75
+ run. Native tests also assert the task ID inside each verifier container.
76
+
77
+ See [VALIDATION.md](VALIDATION.md) and [DOCKER_VALIDATION.toml](DOCKER_VALIDATION.toml)
78
+ for release evidence. [FRAMEWORKS.md](FRAMEWORKS.md) describes normal use.
rl/DOCKER_VALIDATION.toml ADDED
@@ -0,0 +1,134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ date = 2026-10-19
2
+ package_version = "0.2.1"
3
+ status = "passed"
4
+ modules = 70
5
+ languages = ["en", "ru"]
6
+ fixtures = 1434
7
+ model_responses = "scripted/oracle"
8
+ training_run = false
9
+ gpu_used = false
10
+ real_model_benchmark = false
11
+ hosted_ci_run = false
12
+ verified_source_scope = "shared runtime plus each exercised framework adapter"
13
+
14
+ [runtime]
15
+ python = "3.13.14"
16
+ uv = "0.11.23"
17
+ docker_engine = "29.7.2"
18
+ docker_cli = "29.7.2"
19
+ docker_desktop = "4.89.0 (238018)"
20
+ platform = "linux/amd64"
21
+ python_base = "python:3.13.14-slim@sha256:9662417aace5ae7b8e2609cce472b72a8958e134ba372808abe9cc1a0c0125e6"
22
+ docker_cli_base = "docker:29.7.2-cli@sha256:3f4743208d2338c934d7b8bcfbe1bb54c0b2355c510ad5e0f31c0c4a54bd704e"
23
+
24
+ [windows_regression]
25
+ python = "3.13.13"
26
+ passed = 1506
27
+ skipped_sdk_modules = 5
28
+ includes_source_publication_tests = 7
29
+
30
+ [frameworks.verifiers]
31
+ sdk = "0.4.0"
32
+ passed = true
33
+ image_id = "sha256:4aae609e6aebf86960e0ada14e50f9e46d47b3ff8d98a737cd5855c5ab38ca53"
34
+ unit_passed = 1641
35
+ unit_skipped_sdk_modules = 4
36
+ unit_errors = 0
37
+ unit_failures = 0
38
+ module_language_pairs = 140
39
+ relevant_source_hashes_verified = true
40
+ native_task_score_cases = 140
41
+ vf_eval_scripted_episodes = 6
42
+
43
+ [frameworks.harbor]
44
+ sdk = "0.24.0"
45
+ passed = true
46
+ image_id = "sha256:0e52b73c8aee3032b12a1b76af75716d9ac77f274aae84273592fe6aeb572436"
47
+ unit_passed = 1500
48
+ unit_skipped_sdk_modules = 4
49
+ unit_errors = 0
50
+ unit_failures = 0
51
+ module_language_pairs = 140
52
+ relevant_source_hashes_verified = true
53
+ oracle_episodes = 140
54
+ incorrect_episodes = 24
55
+ negative_answer_kinds = 12
56
+ separate_verifier = true
57
+ agent_cannot_read_verifier_paths = true
58
+ verifier_ipv4_routes = 0
59
+ invalid_source_expected_errors = 1
60
+ source_error_leaves_no_reward = true
61
+ missing_output_episodes = 1
62
+ missing_output_reward = 0
63
+ private_payload = "content-addressed deterministic tar"
64
+ native_payload_identity_checked = true
65
+
66
+ [frameworks.openenv]
67
+ sdk = "0.9.0"
68
+ passed = true
69
+ image_id = "sha256:35bd6d5af450a823df37d046d8001ce74b52c9948820efbf66a47a5afad71a09"
70
+ unit_passed = 1502
71
+ unit_skipped_sdk_modules = 4
72
+ unit_errors = 0
73
+ unit_failures = 0
74
+ module_language_pairs = 140
75
+ relevant_source_hashes_verified = true
76
+ correct_submissions = 140
77
+ incorrect_submissions = 140
78
+ production_server_image_id = "sha256:ca6aabbb2e8fb8da16e8626af97366612fe425619a6d31d0cfc2365e78f26d20"
79
+ native_cross_container_client = true
80
+
81
+ [frameworks.nemo]
82
+ sdk = "0.7.0"
83
+ passed = true
84
+ image_id = "sha256:2b9744ccda3edeb1040a5b9e0f598be0995a0c29d5ee752a3687c489d40a7b30"
85
+ unit_passed = 1501
86
+ unit_skipped_sdk_modules = 4
87
+ unit_errors = 0
88
+ unit_failures = 0
89
+ module_language_pairs = 140
90
+ relevant_source_hashes_verified = true
91
+ correct_submissions = 140
92
+ incorrect_submissions = 140
93
+ supervisor_entrypoint_submissions = 280
94
+ native_cross_container_http = true
95
+
96
+ [frameworks.agentenv]
97
+ sdk = "0.9.1334"
98
+ passed = true
99
+ image_id = "sha256:48e7070d8491b13f2851edd5e33dba9d260c2b2cfa01c2b3d490605f4e789a85"
100
+ unit_passed = 1504
101
+ unit_skipped_sdk_modules = 4
102
+ unit_errors = 0
103
+ unit_failures = 0
104
+ module_language_pairs = 140
105
+ relevant_source_hashes_verified = true
106
+ correct_submissions = 140
107
+ incorrect_submissions = 140
108
+
109
+ [reports.run_1]
110
+ path = ".cache/docker-release-protocols-021/report.json"
111
+ run_id = "math-rl-9016b81692"
112
+ sha256 = "ff73021e9ea5cdc6d7c348797516e642ca5843123a3724860b3c9ad2cb196284"
113
+
114
+ [reports.run_2]
115
+ path = ".cache/docker-release-harbor-021/report.json"
116
+ run_id = "math-rl-4d94c6358e"
117
+ sha256 = "9c55f312587d1eded901c355ec42797651aa130b243789479479685d775dea31"
118
+
119
+ [release_source_python_sha256]
120
+ "src/mathematics_rl/__init__.py" = "6e9f28df95bc7145360ea46ac61d97c3cbbd3b3584e769077c125268574d7e1d"
121
+ "src/mathematics_rl/adapters/__init__.py" = "21029b465221f433a0c39cad0e613b30da4d6a8aaac2a6e35304f6675d47d898"
122
+ "src/mathematics_rl/adapters/agentenv.py" = "8cea8a64066fea29048aced1269ee1e819b188abca1557dc6b7e26744b2f4ec9"
123
+ "src/mathematics_rl/adapters/common.py" = "fb41ffb507dd6fe31370e6f3e96df1b25b540dd0203d1601207ad96ceac086db"
124
+ "src/mathematics_rl/adapters/harbor.py" = "b7114340963622441d8dda339152c342596bcd287a026606c8b6c5c2fbda842e"
125
+ "src/mathematics_rl/adapters/nemo.py" = "b3fb4c6e6dce2479d5676b6cb114a4f16db0599a3dea5d20c1382ef66397aaf5"
126
+ "src/mathematics_rl/adapters/openenv.py" = "442e275810ed8de6b8eacb78aa5026f6b57ec1612e94aa127f26e38f45548356"
127
+ "src/mathematics_rl/catalog.py" = "7f22e1fa95e818c08b8b605e632c954c3a10dc64b3a67a12d05c52a84fe39745"
128
+ "src/mathematics_rl/cli.py" = "b0d5b9565a53a947e60e01959680e8a34a6c2ff3510038bb92c1eab28ae82605"
129
+ "src/mathematics_rl/data.py" = "e3487755958973e903f4c33f87bec45d15f67edf3d51ffd3f3ae46e7215fbcc6"
130
+ "src/mathematics_rl/grading.py" = "ee1bd0a0b48832833ea1d13497024109f33ee5a3b759d87443d618bf56d64d6e"
131
+ "src/mathematics_rl/parsing.py" = "2d1bdfc68e3ca206422c4f45d076b5efe976d35898d4aefb206f7c44e6444699"
132
+ "src/mathematics_rl/taskset.py" = "1a5080cf4f344907c3103bbfd75df7fe3a9431b8b7587a17d4f3f18a551d0c2a"
133
+ "src/mathematics_rl/worker.py" = "0f96d77d294ab99f5f8cce114114e115143eb59e9ae6e55946e64d6e726a4fac"
134
+ "src/mathematics_rl/worker_entry.py" = "ef046fe8285b4d903b79f6b02ee4f5e525ac0e6c412cea8d2ae1c785e4c44839"
rl/FRAMEWORKS.md CHANGED
@@ -55,8 +55,13 @@ contains `task.toml` schema 1.4, `instruction.md`, the agent environment,
55
  container**; references and checker code are present only there. Missing, oversized,
56
  non-UTF-8 or non-regular answer files earn zero. Checker source is bundled with
57
  the task; the verifier image installs pinned SymPy. Image build needs internet.
58
- The base `python:3.13-slim` image is a mutable tag; archive the built image/digest
59
- when reproducing an experiment. Do not switch to shared verification for an
 
 
 
 
 
60
  untrusted shell agent: it could read references or alter the checker.
61
 
62
  ## OpenEnv
@@ -92,7 +97,7 @@ after termination is rejected. Native `/schema`, `/health`, `/reset`, `/step`,
92
 
93
  `integrations/openenv/openenv.yaml`, `app.py` and `Dockerfile` are also provided.
94
  Build from this package root with
95
- `docker build -f integrations/openenv/Dockerfile -t mathematics-openenv:0.2.0 .`.
96
  This creates a runnable image, not a published Hugging Face Space.
97
 
98
  ## NeMo Gym
@@ -181,6 +186,10 @@ The external-episode path above supplies model responses directly.
181
 
182
  ## Verification boundaries and sources
183
 
 
 
 
 
184
  See [VALIDATION.md](VALIDATION.md) for measured checks and outstanding deployment
185
  boundaries. SDK/protocol tests and oracle trials do not measure a real model or
186
  an RL training gain. The HF card tags identify adapter compatibility; use the
 
55
  container**; references and checker code are present only there. Missing, oversized,
56
  non-UTF-8 or non-regular answer files earn zero. Checker source is bundled with
57
  the task; the verifier image installs pinned SymPy. Image build needs internet.
58
+ Python 3.13.14 is pinned by its image manifest digest in the exporter.
59
+ `tests/docker-compose.yaml` disables verifier networking with `network_mode: none`,
60
+ including on Docker Desktop kernels without nftables FIB support. Exports use LF
61
+ on Windows too. Invalid source references leave no reward file and fail the trial.
62
+ The private checker/reference snapshot uses a content-addressed tar filename and
63
+ a build-time reference checksum, protecting parallel task builds from mixed files.
64
+ Do not switch to shared verification for an
65
  untrusted shell agent: it could read references or alter the checker.
66
 
67
  ## OpenEnv
 
97
 
98
  `integrations/openenv/openenv.yaml`, `app.py` and `Dockerfile` are also provided.
99
  Build from this package root with
100
+ `docker build -f integrations/openenv/Dockerfile -t mathematics-openenv:0.2.1 .`.
101
  This creates a runnable image, not a published Hugging Face Space.
102
 
103
  ## NeMo Gym
 
186
 
187
  ## Verification boundaries and sources
188
 
189
+ Use [DOCKER.md](DOCKER.md) to reproduce all five integrations locally with isolated
190
+ SDK images, native protocols and real Harbor sibling containers. The production
191
+ OpenEnv Dockerfile installs from the same lockfile used by these checks.
192
+
193
  See [VALIDATION.md](VALIDATION.md) for measured checks and outstanding deployment
194
  boundaries. SDK/protocol tests and oracle trials do not measure a real model or
195
  an RL training gain. The HF card tags identify adapter compatibility; use the
rl/README.md CHANGED
@@ -115,6 +115,10 @@ Keep both evaluation categories out of the training mixture.
115
 
116
  ## Tests and publication
117
 
 
 
 
 
118
  ```bash
119
  uv run pytest tests -q
120
  uv run ruff check src tests
 
115
 
116
  ## Tests and publication
117
 
118
+ To check every framework with its pinned SDK in local Linux containers, run
119
+ `python integrations/docker/run.py --output /absolute/path/to/new-results`.
120
+ See [DOCKER.md](DOCKER.md) for requirements, native protocol coverage and logs.
121
+
122
  ```bash
123
  uv run pytest tests -q
124
  uv run ruff check src tests
rl/VALIDATION.md CHANGED
@@ -3,6 +3,51 @@
3
  Implementation and checks: 2026-10-18/19. Source data revision:
4
  `d9f78d0665b3a13dad21c6830b9b358c8a25ae74`.
5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  ## Scope
7
 
8
  - 1,434 generated fixtures: 717 EN and 717 RU. Each language covers all 70 modules,
@@ -36,7 +81,7 @@ publication report and generated release manifest. CI is configured for
36
  Ubuntu Python 3.11/3.13 and Windows Python 3.13; configuring CI is not evidence that
37
  hosted CI has executed.
38
 
39
- ## Version 0.2.0: additional frameworks
40
 
41
  Checked on 2026-10-19 with actual installed SDKs, using the shared checker and
42
  the unchanged EN/RU regression fixtures:
@@ -50,7 +95,7 @@ the unchanged EN/RU regression fixtures:
50
  - Harbor 0.24.0's real `Task` loader validates exported task directories for all
51
  140 module/language pairs. Artifact checking covers correct, incorrect, missing
52
  and non-UTF-8 files. `environment_mode=separate` isolates references/checker code
53
- from the shell agent. **No Docker trial or image build was completed**: the
54
  installed Docker Desktop daemon was unavailable (`dockerDesktopLinuxEngine`
55
  pipe missing), including after its normal start command. Run the documented
56
  `harbor run --agent oracle` once a Docker daemon is available.
@@ -101,5 +146,6 @@ for RL. The environment itself uses modern dependencies pinned in `uv.lock`.
101
  These fixtures are engineering regression data, not held-out model benchmarks.
102
  Accepting an official generator's answer does not independently validate its math.
103
  The full 125,409,832-row corpus has not been audited, deduplicated or used for an
104
- RL experiment here. The release preparation changes only the card and adds `rl/`;
105
- it neither rewrites Parquet nor performs a hosted publication.
 
 
3
  Implementation and checks: 2026-10-18/19. Source data revision:
4
  `d9f78d0665b3a13dad21c6830b9b358c8a25ae74`.
5
 
6
+ ## Version 0.2.1: local Docker execution
7
+
8
+ The Docker runner builds separate SDK images on Docker Desktop 4.89.0,
9
+ Engine/CLI 29.7.2, Linux amd64, Python 3.13.14. The measured image IDs,
10
+ checksums and protocol results are recorded in [DOCKER_VALIDATION.toml](DOCKER_VALIDATION.toml).
11
+ Run it using [DOCKER.md](DOCKER.md).
12
+
13
+ | Pinned SDK in its own container | Package tests passed | Other SDK modules skipped |
14
+ | --- | ---: | ---: |
15
+ | Verifiers 0.4.0 | 1,641 | 4 |
16
+ | Harbor 0.24.0 | 1,500 | 4 |
17
+ | OpenEnv 0.9.0 | 1,502 | 4 |
18
+ | NeMo Gym 0.7.0 | 1,501 | 4 |
19
+ | AgentEnv 0.9.1334 | 1,504 | 4 |
20
+
21
+ Windows Python 3.13.13 separately passes 1,506 tests, with five optional SDK
22
+ modules skipped; this includes the seven source-repository publication checks.
23
+ The package suites include all 1,434 mathematical fixtures.
24
+
25
+ OpenEnv's actual production image and native cross-container client cover
26
+ 280 submissions across all 70 modules in both languages. NeMo Gym covers the
27
+ same 280 submissions both through the standalone launcher and through the
28
+ entrypoint receiving native supervisor configuration. AgentEnv completes 280
29
+ native episode/turn/result cycles with local stores. Verifiers covers native
30
+ `Task.score` for all 140 module/language pairs and six actual `vf-eval` episodes
31
+ against the local scripted endpoint.
32
+
33
+ Native Harbor trials exercise artifact collection and separate agent/verifier
34
+ containers, oracle reference acceptance for all 140 module/language pairs,
35
+ incorrect answers covering all 12 answer kinds in each language, a source error
36
+ with no model reward, and missing output earning zero. The trials assert
37
+ private reference/checker paths are absent from the agent and that the verifier
38
+ has no IPv4 routes.
39
+
40
+ Container execution found and corrected Windows CRLF shell exports, the
41
+ Docker Desktop kernel incompatibility of Harbor's egress sidecar policy,
42
+ invalid-source errors leaving a misleading reward, and mixed verifier build
43
+ payloads during parallel Compose/BuildKit execution. Content-addressed tar
44
+ snapshots and reference checksums now bind each verifier to its task's files.
45
+ The OpenEnv production image also uses the checked lockfile and pinned base.
46
+
47
+ All supplied model answers are scripted or oracle answers. No model training,
48
+ GPU use, hosted CI run or real-model quality benchmark is claimed. The older
49
+ Docker limitation below describes version 0.2.0 and is resolved in this release.
50
+
51
  ## Scope
52
 
53
  - 1,434 generated fixtures: 717 EN and 717 RU. Each language covers all 70 modules,
 
81
  Ubuntu Python 3.11/3.13 and Windows Python 3.13; configuring CI is not evidence that
82
  hosted CI has executed.
83
 
84
+ ## Version 0.2.0: historical SDK checks
85
 
86
  Checked on 2026-10-19 with actual installed SDKs, using the shared checker and
87
  the unchanged EN/RU regression fixtures:
 
95
  - Harbor 0.24.0's real `Task` loader validates exported task directories for all
96
  140 module/language pairs. Artifact checking covers correct, incorrect, missing
97
  and non-UTF-8 files. `environment_mode=separate` isolates references/checker code
98
+ from the shell agent. **Version 0.2.0 had no completed Docker trial or image build**: the
99
  installed Docker Desktop daemon was unavailable (`dockerDesktopLinuxEngine`
100
  pipe missing), including after its normal start command. Run the documented
101
  `harbor run --agent oracle` once a Docker daemon is available.
 
146
  These fixtures are engineering regression data, not held-out model benchmarks.
147
  Accepting an official generator's answer does not independently validate its math.
148
  The full 125,409,832-row corpus has not been audited, deduplicated or used for an
149
+ RL experiment here. Release preparation changes only the card and `rl/`;
150
+ it neither rewrites Parquet nor uploads files itself. The source repository's
151
+ publication report records the actual Hub commit and post-upload verification.
rl/integrations/docker/Dockerfile ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # syntax=docker/dockerfile:1
2
+ FROM docker:29.7.2-cli@sha256:3f4743208d2338c934d7b8bcfbe1bb54c0b2355c510ad5e0f31c0c4a54bd704e AS docker-cli
3
+ FROM python:3.13.14-slim@sha256:9662417aace5ae7b8e2609cce472b72a8958e134ba372808abe9cc1a0c0125e6
4
+ ARG FRAMEWORK
5
+ ENV PYTHONUNBUFFERED=1 PYTHONDONTWRITEBYTECODE=1 PYTHONUTF8=1
6
+ ENV PATH=/opt/math/.venv/bin:$PATH
7
+ ENV PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 CUDA_VISIBLE_DEVICES=""
8
+ RUN pip install --no-cache-dir uv==0.11.23
9
+ COPY --from=docker-cli /usr/local/bin/docker /usr/local/bin/docker
10
+ COPY --from=docker-cli /usr/local/libexec/docker/cli-plugins /usr/local/libexec/docker/cli-plugins
11
+ WORKDIR /opt/math
12
+ COPY pyproject.toml uv.lock ./
13
+ RUN --mount=type=cache,target=/root/.cache/uv uv sync --locked --extra "$FRAMEWORK" --no-install-project
14
+ COPY . .
15
+ RUN --mount=type=cache,target=/root/.cache/uv uv sync --locked --extra "$FRAMEWORK"
16
+ LABEL org.opencontainers.image.title="Mathematics RL local integration checks"
17
+ CMD ["python", "-m", "pytest", "-p", "pytest_asyncio.plugin", "tests", "-q"]
rl/integrations/docker/harbor_trials.py ADDED
@@ -0,0 +1,157 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Run real Harbor oracle and negative trials using sibling Docker containers."""
2
+
3
+ import argparse
4
+ import json
5
+ import shutil
6
+ import subprocess
7
+ from pathlib import Path
8
+
9
+ from scenarios import harbor_verify, representatives, rows, save
10
+
11
+ from mathematics_rl.adapters.harbor import build_verifier_payload, export_tasks
12
+
13
+
14
+ def prepare(tasks, path, prefix, negative=False):
15
+ manifest = export_tasks(tasks, path)
16
+ for item in manifest:
17
+ task_dir = path / item["directory"]
18
+ task_dir = task_dir.rename(task_dir.with_name(prefix + "-" + task_dir.name))
19
+ item["directory"] = task_dir.name
20
+ config_path = task_dir / "task.toml"
21
+ config = config_path.read_text().replace(
22
+ 'name = "mathematics/', f'name = "mathematics/{prefix}-'
23
+ )
24
+ config_path.write_text(config, encoding="utf-8", newline="\n")
25
+ solve = task_dir / "solution/solve.sh"
26
+ text = solve.read_text()
27
+ # These paths are mounted by the verifier only, not by the agent image.
28
+ text = text.replace(
29
+ "set -eu\n",
30
+ "set -eu\ntest ! -e /tests/reference.json\ntest ! -d /tests/mathematics_rl\n",
31
+ 1,
32
+ )
33
+ solve.write_text(text, encoding="utf-8", newline="\n")
34
+ check = task_dir / "tests/test.sh"
35
+ # Check the actual private build payload, not just the host export.
36
+ identity_check = (
37
+ "import json; from pathlib import Path; "
38
+ "r=json.loads(Path('/tests/reference.json').read_text()); "
39
+ f"assert r['id'] == {item['task_id']!r}, r; "
40
+ "print('Verifier task:', r['id'], 'reference:', repr(r['answer']))"
41
+ )
42
+ check.write_text(
43
+ check.read_text().replace(
44
+ "set -eu\n",
45
+ 'set -eu\npython -c "from pathlib import Path; '
46
+ "assert len(Path('/proc/net/route').read_text().splitlines()) == 1\"\n"
47
+ f'python -c "{identity_check}"\n',
48
+ 1,
49
+ ),
50
+ encoding="utf-8",
51
+ newline="\n",
52
+ )
53
+ build_verifier_payload(task_dir / "tests")
54
+ if negative:
55
+ save(task_dir / "solution/answer.json", "intentionally invalid mathematics answer")
56
+ return manifest
57
+
58
+
59
+ def run(tasks, root, prefix, label, expected, invalid_source=False, agent="oracle"):
60
+ task_dir = root / label / "tasks"
61
+ manifest = prepare(tasks, task_dir, prefix + "-" + label, negative=not expected)
62
+ if invalid_source:
63
+ for item in manifest:
64
+ reference = task_dir / item["directory"] / "tests/reference.json"
65
+ value = json.loads(reference.read_text())
66
+ value["answer"] = "invalid source reference"
67
+ save(reference, value)
68
+ build_verifier_payload(reference.parent)
69
+ job_name = prefix + "-" + label
70
+ jobs_dir = root / "jobs"
71
+ command = [
72
+ "harbor",
73
+ "run",
74
+ "--path",
75
+ str(task_dir),
76
+ "--agent",
77
+ agent,
78
+ "--jobs-dir",
79
+ str(jobs_dir),
80
+ "--job-name",
81
+ job_name,
82
+ "--n-concurrent",
83
+ "4",
84
+ "--max-retries",
85
+ "0",
86
+ "--no-export-push",
87
+ "--yes",
88
+ ]
89
+ with (root / f"{label}.log").open("w", encoding="utf-8") as log:
90
+ subprocess.run(command, stdout=log, stderr=subprocess.STDOUT, check=True, timeout=3000)
91
+ if invalid_source:
92
+ results = [json.loads(p.read_text()) for p in (jobs_dir / job_name).glob("*/result.json")]
93
+ assert len(results) == len(manifest)
94
+ for result in results:
95
+ assert result["exception_info"]["exception_type"] == "RewardFileNotFoundError", result
96
+ assert result["verifier_result"] is None, result
97
+ return {"episodes": len(results), "source_errors_have_no_reward": True}
98
+ result = harbor_verify(jobs_dir / job_name, expected)
99
+ assert result["episodes"] == len(manifest)
100
+ return result
101
+
102
+
103
+ def main():
104
+ parser = argparse.ArgumentParser(description=__doc__)
105
+ parser.add_argument("--work", type=Path, required=True)
106
+ parser.add_argument("--prefix", required=True)
107
+ parser.add_argument("--limit", type=int, default=0)
108
+ args = parser.parse_args()
109
+ root = args.work / "run"
110
+ root.mkdir(exist_ok=False)
111
+ results = Path("/results")
112
+ results.mkdir(exist_ok=True)
113
+ tasks = [task for lang in ("en", "ru") for _, task in representatives(lang)]
114
+ if args.limit:
115
+ tasks = tasks[: args.limit]
116
+ try:
117
+ positive = run(tasks, root, args.prefix, "positive", 1)
118
+ print(f"Harbor accepted {positive['episodes']} oracle answers", flush=True)
119
+ negatives = []
120
+ seen = set()
121
+ for lang in ("en", "ru"):
122
+ for task in rows(lang):
123
+ if (lang, task.kind) not in seen:
124
+ negatives.append(task)
125
+ seen.add((lang, task.kind))
126
+ if args.limit:
127
+ negatives = negatives[: args.limit]
128
+ negative = run(negatives, root, args.prefix, "negative", 0)
129
+ print(f"Harbor rejected {negative['episodes']} wrong answers", flush=True)
130
+ source_error = run(tasks[:1], root, args.prefix, "invalid-source", 0, invalid_source=True)
131
+ missing_output = run(tasks[:1], root, args.prefix, "missing-output", 0, agent="nop")
132
+ save(
133
+ results / "report.json",
134
+ {
135
+ "framework": "harbor",
136
+ "passed": True,
137
+ "oracle_episodes": positive["episodes"],
138
+ "incorrect_episodes": negative["episodes"],
139
+ "module_language_cases": [
140
+ {"module": t.module, "language": t.language} for t in tasks
141
+ ],
142
+ "negative_kinds": sorted({t.kind for t in negatives}),
143
+ "separate_verifier": True,
144
+ "agent_cannot_read_verifier_paths": True,
145
+ "source_error": source_error,
146
+ "missing_output": {"episodes": missing_output["episodes"], "reward": 0},
147
+ "positive": positive,
148
+ "negative": negative,
149
+ },
150
+ )
151
+ finally:
152
+ # Preserve native results even on error, before the runner removes its volume.
153
+ shutil.copytree(root, results / "native", dirs_exist_ok=True)
154
+
155
+
156
+ if __name__ == "__main__":
157
+ main()
rl/integrations/docker/run.py ADDED
@@ -0,0 +1,380 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Build and verify each framework in Docker. Only this run's resources are removed."""
2
+
3
+ import argparse
4
+ import hashlib
5
+ import json
6
+ import shutil
7
+ import subprocess
8
+ import time
9
+ import tomllib
10
+ import uuid
11
+ import xml.etree.ElementTree as ET
12
+ from pathlib import Path
13
+
14
+ PACKAGE = Path(__file__).absolute().parents[2]
15
+ FRAMEWORKS = ("verifiers", "harbor", "openenv", "nemo", "agentenv")
16
+
17
+
18
+ class DockerChecks:
19
+ def __init__(self, output, frameworks, skip_build=False, harbor_limit=0):
20
+ self.output = Path(output).absolute()
21
+ self.output.mkdir(parents=True, exist_ok=False)
22
+ self.frameworks = frameworks
23
+ self.version = tomllib.loads((PACKAGE / "pyproject.toml").read_text())["project"]["version"]
24
+ self.prefix = "math-rl-" + uuid.uuid4().hex[:10]
25
+ self.docker = (
26
+ shutil.which("docker") or r"C:\Program Files\Docker\Docker\resources\bin\docker.exe"
27
+ )
28
+ self.network = self.prefix + "-net"
29
+ self.volume = None
30
+ self.skip_build = skip_build
31
+ self.harbor_limit = harbor_limit
32
+ self.containers = []
33
+ self.production_openenv = None
34
+ self.report = {
35
+ "version": self.version,
36
+ "run_id": self.prefix,
37
+ "frameworks": {},
38
+ "model_responses": "scripted",
39
+ "training_run": False,
40
+ "gpu_used": False,
41
+ "source_python_sha256": {
42
+ p.relative_to(PACKAGE).as_posix(): hashlib.sha256(p.read_bytes()).hexdigest()
43
+ for p in sorted((PACKAGE / "src").rglob("*.py"))
44
+ },
45
+ }
46
+
47
+ def call(self, *args, timeout=60, check=True):
48
+ return subprocess.run(
49
+ [self.docker, *map(str, args)],
50
+ text=True,
51
+ encoding="utf-8",
52
+ errors="replace",
53
+ capture_output=True,
54
+ check=check,
55
+ timeout=timeout,
56
+ )
57
+
58
+ def image(self, framework):
59
+ return f"mathematics-rl-check-{framework}:{self.version}"
60
+
61
+ def build(self, framework):
62
+ if not self.skip_build:
63
+ with (self.output / f"build-{framework}.log").open("w", encoding="utf-8") as log:
64
+ result = subprocess.run(
65
+ [
66
+ self.docker,
67
+ "build",
68
+ "--progress",
69
+ "plain",
70
+ "--build-arg",
71
+ f"FRAMEWORK={framework}",
72
+ "-f",
73
+ str(PACKAGE / "integrations/docker/Dockerfile"),
74
+ "-t",
75
+ self.image(framework),
76
+ str(PACKAGE),
77
+ ],
78
+ stdout=log,
79
+ stderr=subprocess.STDOUT,
80
+ timeout=1200,
81
+ )
82
+ if result.returncode:
83
+ raise RuntimeError(f"Build failed: {framework}; see {log.name}")
84
+ info = json.loads(self.call("image", "inspect", self.image(framework)).stdout)[0]
85
+ self.report["frameworks"][framework] = {
86
+ "image_id": info["Id"],
87
+ "image": self.image(framework),
88
+ }
89
+ if framework == "openenv":
90
+ self.production_openenv = f"mathematics-openenv:{self.version}"
91
+ if not self.skip_build:
92
+ with (self.output / "build-openenv-production.log").open(
93
+ "w", encoding="utf-8"
94
+ ) as log:
95
+ subprocess.run(
96
+ [
97
+ self.docker,
98
+ "build",
99
+ "--progress",
100
+ "plain",
101
+ "-f",
102
+ str(PACKAGE / "integrations/openenv/Dockerfile"),
103
+ "-t",
104
+ self.production_openenv,
105
+ str(PACKAGE),
106
+ ],
107
+ stdout=log,
108
+ stderr=subprocess.STDOUT,
109
+ timeout=1200,
110
+ check=True,
111
+ )
112
+ info = json.loads(self.call("image", "inspect", self.production_openenv).stdout)[0]
113
+ self.report["frameworks"][framework]["production_server_image_id"] = info["Id"]
114
+
115
+ def create(self, framework, suffix, command, *, daemon=False, mounts=(), image=None):
116
+ name = self.prefix + "-" + suffix
117
+ self.containers.append(name)
118
+ args = [
119
+ "create",
120
+ "--name",
121
+ name,
122
+ "--label",
123
+ f"mathematics.rl.run={self.prefix}",
124
+ "--init",
125
+ "--cpus",
126
+ "2",
127
+ "--memory",
128
+ "4g",
129
+ "--network",
130
+ self.network,
131
+ ]
132
+ for mount in mounts:
133
+ args.extend(["--mount", mount])
134
+ args.extend([image or self.image(framework), *command])
135
+ self.call(*args)
136
+ if daemon:
137
+ self.call("start", name)
138
+ return name
139
+
140
+ def run(self, framework, suffix, command, *, timeout=600, mounts=()):
141
+ name = self.create(framework, suffix, command, mounts=mounts)
142
+ with (self.output / f"{suffix}.log").open("w", encoding="utf-8") as log:
143
+ proc = subprocess.run(
144
+ [self.docker, "start", "--attach", name],
145
+ stdout=log,
146
+ stderr=subprocess.STDOUT,
147
+ timeout=timeout,
148
+ )
149
+ exit_code = json.loads(self.call("inspect", name).stdout)[0]["State"]["ExitCode"]
150
+ target = self.output / suffix
151
+ target.mkdir(exist_ok=True)
152
+ self.call("cp", name + ":/results/.", target, check=False)
153
+ if proc.returncode or exit_code:
154
+ raise RuntimeError(f"{suffix} failed (exit {exit_code}); see {suffix}.log")
155
+ return target
156
+
157
+ def ready(self, name, port, endpoint):
158
+ deadline = time.monotonic() + 90
159
+ code = (
160
+ "from urllib.request import urlopen; "
161
+ f"urlopen('http://127.0.0.1:{port}{endpoint}', timeout=2).read()"
162
+ )
163
+ while time.monotonic() < deadline:
164
+ if (
165
+ self.call("exec", name, "python", "-c", code, timeout=5, check=False).returncode
166
+ == 0
167
+ ):
168
+ return
169
+ state = json.loads(self.call("inspect", name).stdout)[0]["State"]
170
+ if not state["Running"]:
171
+ break
172
+ time.sleep(0.5)
173
+ raise RuntimeError(f"Server {name} did not become ready")
174
+
175
+ def unit(self, framework):
176
+ target = self.run(
177
+ framework, framework + "-unit", ["python", "integrations/docker/scenarios.py", "unit"]
178
+ )
179
+ suite = ET.parse(target / "pytest.xml").getroot().find("testsuite")
180
+ assert int(suite.attrib["failures"]) == int(suite.attrib["errors"]) == 0
181
+ passed = int(suite.attrib["tests"]) - int(suite.attrib["skipped"])
182
+ assert passed > 1400
183
+ self.report["frameworks"][framework]["unit"] = dict(suite.attrib)
184
+
185
+ def protocols(self, framework):
186
+ if framework == "openenv":
187
+ results = []
188
+ for language in ("en", "ru"):
189
+ suffix = "openenv-" + language
190
+ name = self.create(
191
+ framework,
192
+ suffix,
193
+ [
194
+ "python",
195
+ "integrations/docker/scenarios.py",
196
+ "serve-openenv",
197
+ "--language",
198
+ language,
199
+ ],
200
+ daemon=True,
201
+ image=self.production_openenv,
202
+ )
203
+ self.ready(name, 8000, "/health")
204
+ target = self.run(
205
+ framework,
206
+ suffix + "-client",
207
+ [
208
+ "python",
209
+ "integrations/docker/scenarios.py",
210
+ "openenv",
211
+ "--url",
212
+ f"http://{name}:8000",
213
+ "--language",
214
+ language,
215
+ ],
216
+ )
217
+ results.append(json.loads((target / "report.json").read_text()))
218
+ self.call("stop", "-t", "10", name)
219
+ self.report["frameworks"][framework]["protocol"] = results
220
+ elif framework == "nemo":
221
+ name = self.create(
222
+ framework,
223
+ "nemo-server",
224
+ ["mathematics-nemo", "--host", "0.0.0.0", "--port", "8001"],
225
+ daemon=True,
226
+ )
227
+ self.ready(name, 8001, "/reverify_mode")
228
+ target = self.run(
229
+ framework,
230
+ "nemo-client",
231
+ [
232
+ "python",
233
+ "integrations/docker/scenarios.py",
234
+ "nemo",
235
+ "--url",
236
+ f"http://{name}:8001",
237
+ ],
238
+ )
239
+ self.report["frameworks"][framework]["protocol"] = json.loads(
240
+ (target / "report.json").read_text()
241
+ )
242
+ self.call("stop", "-t", "10", name)
243
+ name = self.create(
244
+ framework,
245
+ "nemo-native-server",
246
+ ["python", "integrations/docker/scenarios.py", "serve-nemo-native"],
247
+ daemon=True,
248
+ )
249
+ self.ready(name, 8001, "/reverify_mode")
250
+ target = self.run(
251
+ framework,
252
+ "nemo-native-client",
253
+ [
254
+ "python",
255
+ "integrations/docker/scenarios.py",
256
+ "nemo",
257
+ "--url",
258
+ f"http://{name}:8001",
259
+ ],
260
+ )
261
+ self.report["frameworks"][framework]["supervisor_entrypoint_protocol"] = json.loads(
262
+ (target / "report.json").read_text()
263
+ )
264
+ elif framework == "agentenv":
265
+ target = self.run(
266
+ framework,
267
+ "agentenv-episodes",
268
+ ["python", "integrations/docker/scenarios.py", "agentenv"],
269
+ timeout=900,
270
+ )
271
+ self.report["frameworks"][framework]["protocol"] = json.loads(
272
+ (target / "report.json").read_text()
273
+ )
274
+ elif framework == "verifiers":
275
+ target = self.run(
276
+ framework,
277
+ "verifiers-rollout",
278
+ [
279
+ "python",
280
+ "integrations/docker/verifiers_smoke.py",
281
+ "--output",
282
+ "/results/rollout",
283
+ ],
284
+ )
285
+ self.report["frameworks"][framework]["protocol"] = json.loads(
286
+ (target / "rollout/report.json").read_text()
287
+ )
288
+ else:
289
+ self.harbor()
290
+
291
+ def harbor(self):
292
+ self.volume = self.prefix + "-harbor-data"
293
+ self.call("volume", "create", "--label", f"mathematics.rl.run={self.prefix}", self.volume)
294
+ # Sibling containers must see the same absolute paths as the runner.
295
+ mountpoint = json.loads(self.call("volume", "inspect", self.volume).stdout)[0]["Mountpoint"]
296
+ target = self.run(
297
+ "harbor",
298
+ "harbor-trials",
299
+ [
300
+ "python",
301
+ "integrations/docker/harbor_trials.py",
302
+ "--work",
303
+ mountpoint,
304
+ "--prefix",
305
+ self.prefix,
306
+ "--limit",
307
+ str(self.harbor_limit),
308
+ ],
309
+ timeout=3600,
310
+ mounts=[
311
+ "type=bind,source=/var/run/docker.sock,target=/var/run/docker.sock",
312
+ f"type=volume,source={self.volume},target={mountpoint}",
313
+ ],
314
+ )
315
+ self.report["frameworks"]["harbor"]["protocol"] = json.loads(
316
+ (target / "report.json").read_text()
317
+ )
318
+
319
+ def cleanup(self):
320
+ for name in self.containers:
321
+ captured = self.call("logs", name, check=False)
322
+ log = captured.stdout + captured.stderr
323
+ if log:
324
+ (self.output / (name + "-container.log")).write_text(log, encoding="utf-8")
325
+ self.call("rm", "-f", name, check=False)
326
+ # Harbor tasks are prefixed with this run's random identifier before launch.
327
+ ids = self.call(
328
+ "ps", "-aq", "--filter", f"name=^/?{self.prefix}-", check=False
329
+ ).stdout.split()
330
+ if ids:
331
+ self.call("rm", "-f", *ids, check=False)
332
+ networks = self.call(
333
+ "network", "ls", "-q", "--filter", f"name=^{self.prefix}", check=False
334
+ ).stdout.split()
335
+ if networks:
336
+ self.call("network", "rm", *networks, check=False)
337
+ if self.volume:
338
+ self.call("volume", "rm", self.volume, check=False)
339
+
340
+ def execute(self):
341
+ self.report["docker"] = json.loads(self.call("version", "--format", "{{json .}}").stdout)
342
+ self.call("network", "create", "--label", f"mathematics.rl.run={self.prefix}", self.network)
343
+ try:
344
+ for framework in self.frameworks:
345
+ print(f"[{framework}] build, unit tests, native protocol", flush=True)
346
+ self.build(framework)
347
+ self.unit(framework)
348
+ self.protocols(framework)
349
+ self.report["frameworks"][framework]["passed"] = True
350
+ print(f"[{framework}] passed", flush=True)
351
+ self.report["passed"] = True
352
+ except Exception as error:
353
+ self.report["passed"] = False
354
+ self.report["error"] = str(error)
355
+ raise
356
+ finally:
357
+ self.cleanup()
358
+ (self.output / "report.json").write_text(
359
+ json.dumps(self.report, indent=2) + "\n", encoding="utf-8"
360
+ )
361
+
362
+
363
+ def main():
364
+ parser = argparse.ArgumentParser(description=__doc__)
365
+ parser.add_argument("--output", type=Path, required=True)
366
+ parser.add_argument("--framework", choices=FRAMEWORKS, action="append")
367
+ parser.add_argument(
368
+ "--skip-build", action="store_true", help="Development only: reuse already built images"
369
+ )
370
+ parser.add_argument(
371
+ "--harbor-limit", type=int, default=0, help="0 verifies all 140 module/language tasks"
372
+ )
373
+ args = parser.parse_args()
374
+ DockerChecks(
375
+ args.output, args.framework or FRAMEWORKS, args.skip_build, args.harbor_limit
376
+ ).execute()
377
+
378
+
379
+ if __name__ == "__main__":
380
+ main()
rl/integrations/docker/scenarios.py ADDED
@@ -0,0 +1,293 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Native framework checks for the Docker runner; all model responses are scripted."""
2
+
3
+ import argparse
4
+ import asyncio
5
+ import json
6
+ import os
7
+ import subprocess
8
+ import sys
9
+ import tempfile
10
+ import time
11
+ from dataclasses import asdict
12
+ from pathlib import Path
13
+ from urllib.request import Request, urlopen
14
+
15
+ PACKAGE = Path(__file__).absolute().parents[2]
16
+ FIXTURES = PACKAGE / "tests" / "fixtures"
17
+ WRONG = "intentionally invalid mathematics answer"
18
+
19
+
20
+ def rows(language):
21
+ from mathematics_rl.adapters.common import select_tasks
22
+
23
+ return select_tasks(
24
+ source=str(FIXTURES / f"generated_{language}.ndjson"),
25
+ language=language,
26
+ mode="all",
27
+ limit=10_000,
28
+ )
29
+
30
+
31
+ def representatives(language):
32
+ seen = set()
33
+ result = []
34
+ for index, task in enumerate(rows(language)):
35
+ if task.module not in seen:
36
+ seen.add(task.module)
37
+ result.append((index, task))
38
+ assert len(result) == 70
39
+ return result
40
+
41
+
42
+ def save(path, value):
43
+ path = Path(path)
44
+ path.parent.mkdir(parents=True, exist_ok=True)
45
+ path.write_text(json.dumps(value, ensure_ascii=False, indent=2) + "\n", encoding="utf-8")
46
+
47
+
48
+ def serve_openenv(language):
49
+ config = {
50
+ "source": str(FIXTURES / f"generated_{language}.ndjson"),
51
+ "language": language,
52
+ "mode": "all",
53
+ "limit": 10_000,
54
+ }
55
+ path = Path(tempfile.mkdtemp()) / "config.json"
56
+ save(path, config)
57
+ os.execvp(
58
+ "mathematics-openenv",
59
+ ["mathematics-openenv", "--config", str(path), "--host", "0.0.0.0", "--port", "8000"],
60
+ )
61
+
62
+
63
+ def serve_nemo_native():
64
+ # Match the config injected by Gym's supervisor; exercise the shipped shim.
65
+ os.environ["NEMO_GYM_CONFIG_PATH"] = "mathematics"
66
+ os.environ["NEMO_GYM_CONFIG_DICT"] = json.dumps(
67
+ {
68
+ "dry_run": False,
69
+ "head_server": {"host": "127.0.0.1", "port": 11000},
70
+ "mathematics": {
71
+ "resources_servers": {
72
+ "mathematics": {
73
+ "entrypoint": str(PACKAGE / "integrations/nemo/app.py"),
74
+ "host": "0.0.0.0",
75
+ "port": 8001,
76
+ "domain": "math",
77
+ }
78
+ }
79
+ },
80
+ }
81
+ )
82
+ os.execvp("mathematics-nemo", ["mathematics-nemo"])
83
+
84
+
85
+ def openenv_check(url, language):
86
+ from mathematics_rl.adapters.openenv import MathematicsAction, MathematicsClient
87
+
88
+ checks = []
89
+ with MathematicsClient(base_url=url, connect_timeout_s=10, message_timeout_s=30) as client:
90
+ for index, task in representatives(language):
91
+ for answer, expected in ((task.answer, 1), (WRONG, 0)):
92
+ initial = client.reset(task_index=index)
93
+ assert initial.observation.prompt == task.prompt, (task.module, index)
94
+ state = client.state().model_dump()
95
+ assert "answer" not in state and "content_hash" not in state
96
+ result = client.step(MathematicsAction(answer=answer))
97
+ assert result.done and result.reward == expected, (task.module, result)
98
+ assert client.state().step_count == 1
99
+ checks.append(
100
+ {"module": task.module, "language": language, "correct": 1, "incorrect": 0}
101
+ )
102
+ try:
103
+ client.step(MathematicsAction(answer=task.answer))
104
+ except Exception as error:
105
+ assert "terminal" in str(error).lower(), str(error)
106
+ else:
107
+ raise AssertionError("OpenEnv accepted a second submission")
108
+ return {
109
+ "framework": "openenv",
110
+ "cases": checks,
111
+ "episodes": 140,
112
+ "transport": "native EnvClient over Docker network",
113
+ "passed": True,
114
+ }
115
+
116
+
117
+ def response(text):
118
+ return {
119
+ "id": "scripted",
120
+ "object": "response",
121
+ "created_at": 0,
122
+ "model": "scripted",
123
+ "parallel_tool_calls": False,
124
+ "tool_choice": "auto",
125
+ "tools": [],
126
+ "output": [
127
+ {
128
+ "id": "msg",
129
+ "type": "message",
130
+ "role": "assistant",
131
+ "status": "completed",
132
+ "content": [{"type": "output_text", "text": text, "annotations": []}],
133
+ }
134
+ ],
135
+ }
136
+
137
+
138
+ def request(url, body=None):
139
+ data = json.dumps(body, ensure_ascii=False).encode() if body is not None else None
140
+ with urlopen(
141
+ Request(url, data=data, headers={"Content-Type": "application/json"}), timeout=30
142
+ ) as reply:
143
+ return json.load(reply)
144
+
145
+
146
+ def nemo_check(url):
147
+ checks = []
148
+ for language in ("en", "ru"):
149
+ for _, task in representatives(language):
150
+ row = {
151
+ "responses_create_params": {"input": [{"role": "user", "content": task.prompt}]},
152
+ "math_example": asdict(task),
153
+ }
154
+ for answer, expected in ((task.answer, 1), (WRONG, 0)):
155
+ result = request(url + "/verify", {**row, "response": response(answer)})
156
+ assert result["reward"] == expected and not result["mask_sample"], result
157
+ assert "math_example" not in result and result["task_id"] == task.id
158
+ checks.append(
159
+ {"module": task.module, "language": language, "correct": 1, "incorrect": 0}
160
+ )
161
+ assert request(url + "/reverify_mode") == "stateless"
162
+ return {
163
+ "framework": "nemo",
164
+ "cases": checks,
165
+ "episodes": 280,
166
+ "transport": "native resource server HTTP over Docker network",
167
+ "passed": True,
168
+ }
169
+
170
+
171
+ async def agentenv_check():
172
+ # The trainer supplies each answer through AgentEnv's real turn protocol.
173
+ from agent_env.config import configure
174
+ from agent_env.task import EpisodeSpec
175
+
176
+ from mathematics_rl.adapters.agentenv import make_task
177
+
178
+ state = tempfile.mkdtemp(prefix="mathematics-agentenv-")
179
+ os.environ["XDG_STATE_HOME"] = state
180
+ os.environ["AGENT_ENV_CONFIG"] = str(Path(state) / "config.toml")
181
+ Path(os.environ["AGENT_ENV_CONFIG"]).write_text("")
182
+ configure()
183
+ checks = []
184
+ for language in ("en", "ru"):
185
+ for _, task in representatives(language):
186
+ for answer, expected in ((task.answer, 1), (WRONG, 0)):
187
+ episode = await EpisodeSpec.from_task(make_task(task), turn_timeout=30).start()
188
+ try:
189
+ turn = await asyncio.wait_for(episode.next_turn(), 30)
190
+ assert turn.prompt == task.prompt
191
+ await turn.end(response=answer)
192
+ assert await asyncio.wait_for(episode.next_turn(), 30) is None
193
+ assert await asyncio.wait_for(episode.result(), 30) == {"grade": expected}
194
+ finally:
195
+ await episode.abandon("Docker check finished")
196
+ checks.append(
197
+ {"module": task.module, "language": language, "correct": 1, "incorrect": 0}
198
+ )
199
+ return {
200
+ "framework": "agentenv",
201
+ "cases": checks,
202
+ "episodes": 280,
203
+ "transport": "native EpisodeSpec, turn, result and local stores",
204
+ "passed": True,
205
+ }
206
+
207
+
208
+ def harbor_prepare(output, limit):
209
+ from mathematics_rl.adapters.harbor import export_tasks
210
+
211
+ tasks = [task for lang in ("en", "ru") for _, task in representatives(lang)]
212
+ return export_tasks(tasks[:limit] if limit else tasks, output)
213
+
214
+
215
+ def harbor_verify(job, expected=1):
216
+ trials = []
217
+ for path in Path(job).glob("*/result.json"):
218
+ result = json.loads(path.read_text())
219
+ assert not result["exception_info"], (path, result["exception_info"])
220
+ assert result["verifier_environment_mode"] == "separate", path
221
+ assert result["verifier_result"]["rewards"]["reward"] == expected, (path, result)
222
+ trials.append(
223
+ {"task_name": result["task_name"], "reward": expected, "separate_verifier": True}
224
+ )
225
+ assert trials, job
226
+ return {"framework": "harbor", "trials": trials, "episodes": len(trials), "passed": True}
227
+
228
+
229
+ def unit_tests(output):
230
+ command = [
231
+ sys.executable,
232
+ "-m",
233
+ "pytest",
234
+ "-p",
235
+ "pytest_asyncio.plugin",
236
+ "tests",
237
+ "-q",
238
+ "--junitxml",
239
+ str(Path(output) / "pytest.xml"),
240
+ ]
241
+ Path(output).mkdir(parents=True, exist_ok=True)
242
+ subprocess.run(command, check=True, timeout=300)
243
+
244
+
245
+ def main():
246
+ parser = argparse.ArgumentParser(description=__doc__)
247
+ parser.add_argument(
248
+ "scenario",
249
+ choices=(
250
+ "serve-openenv",
251
+ "serve-nemo-native",
252
+ "openenv",
253
+ "nemo",
254
+ "agentenv",
255
+ "harbor-prepare",
256
+ "harbor-verify",
257
+ "unit",
258
+ ),
259
+ )
260
+ parser.add_argument("--language", choices=("en", "ru"), default="en")
261
+ parser.add_argument("--url")
262
+ parser.add_argument("--output", type=Path, default=Path("/results"))
263
+ parser.add_argument("--limit", type=int, default=0)
264
+ parser.add_argument("--expected", type=int, default=1)
265
+ args = parser.parse_args()
266
+ started = time.monotonic()
267
+ if args.scenario == "serve-openenv":
268
+ serve_openenv(args.language)
269
+ elif args.scenario == "serve-nemo-native":
270
+ serve_nemo_native()
271
+ elif args.scenario == "unit":
272
+ unit_tests(args.output)
273
+ return
274
+ elif args.scenario == "openenv":
275
+ result = openenv_check(args.url, args.language)
276
+ elif args.scenario == "nemo":
277
+ result = nemo_check(args.url)
278
+ elif args.scenario == "agentenv":
279
+ result = asyncio.run(agentenv_check())
280
+ elif args.scenario == "harbor-prepare":
281
+ result = harbor_prepare(args.output, args.limit)
282
+ else:
283
+ result = harbor_verify(args.output, args.expected)
284
+ if isinstance(result, dict):
285
+ result["elapsed_seconds"] = round(time.monotonic() - started, 3)
286
+ save(args.output / "report.json", result)
287
+ print(json.dumps({k: v for k, v in result.items() if k not in ("cases", "trials")}))
288
+ else:
289
+ print(json.dumps({"exported": len(result), "output": str(args.output)}))
290
+
291
+
292
+ if __name__ == "__main__":
293
+ main()
rl/integrations/docker/verifiers_smoke.py ADDED
@@ -0,0 +1,213 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Run real vf-eval against a local scripted endpoint; this is not a model benchmark."""
2
+
3
+ import argparse
4
+ import json
5
+ import os
6
+ import signal
7
+ import subprocess
8
+ import sys
9
+ import threading
10
+ import time
11
+ from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
12
+ from pathlib import Path
13
+
14
+ CASES = [
15
+ ("arithmetic__add_or_sub", "Compute 1+1.", "2", "2", 1),
16
+ ("comparison__sort", "Sort 3, 1, 2.", "1, 2, 3", "3, 2, 1", 0),
17
+ ("algebra__polynomial_roots", "Factor x**2-1.", "(x-1)*(x+1)", "x**2-1", 0),
18
+ (
19
+ "polynomials__simplify_power",
20
+ "Simplify x**(2/4), assuming x is positive.",
21
+ "x**(1/2)",
22
+ r"\sqrt{x}",
23
+ 1,
24
+ ),
25
+ ("numbers__is_prime", "Is 7 prime?", "True", "False", 0),
26
+ ("arithmetic__simplify_surd", "Simplify sqrt(12).", "2*sqrt(3)", "sqrt(12)", 0),
27
+ ]
28
+
29
+
30
+ def verify_trace_files(output):
31
+ episodes = [
32
+ json.loads(line)
33
+ for path in (output / "runs").rglob("traces.jsonl")
34
+ for line in path.read_text().splitlines()
35
+ if line.strip()
36
+ ]
37
+ assert len(episodes) == len(CASES), f"Expected {len(CASES)} episodes, got {len(episodes)}"
38
+ expected = {case[1]: case[4] for case in CASES}
39
+ rewards = {}
40
+ for episode in episodes:
41
+ assert episode["ok"] and not episode["errors"], episode
42
+ assert len(episode["traces"]) == 1, episode
43
+ trace = episode["traces"][0]
44
+ question = episode["task"]["data"]["question"]
45
+ assert trace["task"]["data"]["question"] == question
46
+ reward = trace["rewards"]["correct"]
47
+ actual = reward["score"] * reward["weight"]
48
+ assert not trace["errors"] and trace["ok"] and len(trace["calls"]) == 1, trace
49
+ assert actual == expected[question], trace
50
+ rewards[question] = actual
51
+ assert set(rewards) == set(expected)
52
+ report = {
53
+ "type": "scripted_endpoint_real_verifiers_transport_smoke",
54
+ "not_a_model_benchmark": True,
55
+ "traces": len(episodes),
56
+ "rewards": rewards,
57
+ "no_remote_result_upload": True,
58
+ "gpu_used": False,
59
+ }
60
+ (output / "report.json").write_text(json.dumps(report, indent=2) + "\n")
61
+ return report
62
+
63
+
64
+ def main():
65
+ parser = argparse.ArgumentParser(description=__doc__)
66
+ parser.add_argument(
67
+ "--output",
68
+ type=Path,
69
+ required=True,
70
+ help="A new, empty output directory (never cleans existing runs)",
71
+ )
72
+ parser.add_argument(
73
+ "--verify-existing",
74
+ action="store_true",
75
+ help="Only verify traces already produced by this smoke test",
76
+ )
77
+ args = parser.parse_args()
78
+ if args.verify_existing:
79
+ print(json.dumps(verify_trace_files(args.output), indent=2))
80
+ return
81
+ args.output.mkdir(parents=True, exist_ok=False)
82
+ rows = [
83
+ {
84
+ "module": module,
85
+ "question": question,
86
+ "answer": answer,
87
+ "language": "en",
88
+ "category": "interpolate",
89
+ }
90
+ for module, question, answer, _, _ in CASES
91
+ ]
92
+ source = args.output / "source.ndjson"
93
+ source.write_text("".join(json.dumps(row) + "\n" for row in rows), encoding="utf-8")
94
+ received = []
95
+
96
+ class Handler(BaseHTTPRequestHandler):
97
+ def do_POST(self):
98
+ request = json.loads(self.rfile.read(int(self.headers["Content-Length"])))
99
+ content = str(request["messages"][-1]["content"])
100
+ case = next(case for case in CASES if content.endswith(case[1]))
101
+ received.append(case[1])
102
+ response = {
103
+ "id": "chatcmpl-local-smoke",
104
+ "object": "chat.completion",
105
+ "created": int(time.time()),
106
+ "model": "scripted-smoke",
107
+ "choices": [
108
+ {
109
+ "index": 0,
110
+ "message": {"role": "assistant", "content": case[3]},
111
+ "finish_reason": "stop",
112
+ }
113
+ ],
114
+ "usage": {
115
+ "prompt_tokens": 32,
116
+ "completion_tokens": 8,
117
+ "total_tokens": 40,
118
+ },
119
+ }
120
+ if request.get("stream"):
121
+ self.send_response(200)
122
+ self.send_header("Content-Type", "text/event-stream")
123
+ self.end_headers()
124
+ chunk = {
125
+ "id": response["id"],
126
+ "object": "chat.completion.chunk",
127
+ "created": response["created"],
128
+ "model": "scripted-smoke",
129
+ "choices": [
130
+ {
131
+ "index": 0,
132
+ "delta": {"role": "assistant", "content": case[3]},
133
+ "finish_reason": None,
134
+ }
135
+ ],
136
+ }
137
+ self.wfile.write(("data: " + json.dumps(chunk) + "\n\n").encode())
138
+ chunk["choices"] = [{"index": 0, "delta": {}, "finish_reason": "stop"}]
139
+ chunk["usage"] = response["usage"]
140
+ self.wfile.write(("data: " + json.dumps(chunk) + "\n\ndata: [DONE]\n\n").encode())
141
+ else:
142
+ payload = json.dumps(response).encode()
143
+ self.send_response(200)
144
+ self.send_header("Content-Type", "application/json")
145
+ self.send_header("Content-Length", str(len(payload)))
146
+ self.end_headers()
147
+ self.wfile.write(payload)
148
+
149
+ def log_message(self, *_):
150
+ pass
151
+
152
+ server = ThreadingHTTPServer(("127.0.0.1", 0), Handler)
153
+ thread = threading.Thread(target=server.serve_forever, daemon=True)
154
+ thread.start()
155
+ command = [
156
+ str(Path(sys.executable).parent / "vf-eval"),
157
+ "mathematics-rl",
158
+ "--env.taskset.language",
159
+ "en",
160
+ "--env.taskset.source",
161
+ str(source.absolute()),
162
+ "--client.base-url",
163
+ f"http://127.0.0.1:{server.server_port}/v1",
164
+ "--client.api-key-var",
165
+ "MATHEMATICS_UNUSED_SMOKE_KEY",
166
+ "--model",
167
+ "scripted-smoke",
168
+ "--env.agent.runtime.type",
169
+ "subprocess",
170
+ "--env.agent.harness.id",
171
+ "null",
172
+ "--env.agent.timeout.rollout",
173
+ "60",
174
+ "--client.timeout.read",
175
+ "30",
176
+ "--max-concurrent",
177
+ "2",
178
+ "-n",
179
+ str(len(CASES)),
180
+ "--no-push",
181
+ "--no-rich",
182
+ "--output-dir",
183
+ str((args.output / "runs").absolute()),
184
+ ]
185
+ try:
186
+ with (args.output / "vf-eval.log").open("w", encoding="utf-8") as log:
187
+ process = subprocess.Popen(
188
+ command, stdout=log, stderr=subprocess.STDOUT, start_new_session=True
189
+ )
190
+ try:
191
+ code = process.wait(timeout=300)
192
+ except (subprocess.TimeoutExpired, KeyboardInterrupt):
193
+ os.killpg(process.pid, signal.SIGTERM)
194
+ try:
195
+ process.wait(timeout=10)
196
+ except subprocess.TimeoutExpired:
197
+ os.killpg(process.pid, signal.SIGKILL)
198
+ process.wait(timeout=5)
199
+ raise
200
+ if code:
201
+ raise subprocess.CalledProcessError(code, command)
202
+ finally:
203
+ server.shutdown()
204
+ server.server_close()
205
+ thread.join(timeout=5)
206
+ expected = {case[1]: case[4] for case in CASES}
207
+ assert set(received) == set(expected)
208
+ report = verify_trace_files(args.output)
209
+ print(json.dumps(report, indent=2))
210
+
211
+
212
+ if __name__ == "__main__":
213
+ main()
rl/integrations/openenv/Dockerfile CHANGED
@@ -1,6 +1,11 @@
1
- FROM python:3.13-slim
 
 
2
  WORKDIR /opt/mathematics
 
 
 
3
  COPY . .
4
- RUN pip install --no-cache-dir '.[openenv]'
5
  EXPOSE 8000
6
  CMD ["mathematics-openenv", "--host", "0.0.0.0", "--port", "8000"]
 
1
+ FROM python:3.13.14-slim@sha256:9662417aace5ae7b8e2609cce472b72a8958e134ba372808abe9cc1a0c0125e6
2
+ ENV PATH=/opt/mathematics/.venv/bin:$PATH
3
+ ENV PYTHONUNBUFFERED=1 PYTHONUTF8=1
4
  WORKDIR /opt/mathematics
5
+ RUN pip install --no-cache-dir uv==0.11.23
6
+ COPY pyproject.toml uv.lock ./
7
+ RUN --mount=type=cache,target=/root/.cache/uv uv sync --locked --no-dev --extra openenv --no-install-project
8
  COPY . .
9
+ RUN --mount=type=cache,target=/root/.cache/uv uv sync --locked --no-dev --extra openenv
10
  EXPOSE 8000
11
  CMD ["mathematics-openenv", "--host", "0.0.0.0", "--port", "8000"]
rl/integrations/openenv/openenv.yaml CHANGED
@@ -1,6 +1,6 @@
1
  spec_version: 1
2
  name: mathematics
3
- version: 0.2.0
4
  type: space
5
  runtime: fastapi
6
  app: app:app
 
1
  spec_version: 1
2
  name: mathematics
3
+ version: 0.2.1
4
  type: space
5
  runtime: fastapi
6
  app: app:app
rl/pyproject.toml CHANGED
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
 
5
  [project]
6
  name = "mathematics-rl"
7
- version = "0.2.0"
8
  description = "Bilingual mathematics RL environments for Verifiers, Harbor, OpenEnv, NeMo Gym and AgentEnv"
9
  readme = "README.md"
10
  requires-python = ">=3.11.4,<3.15"
@@ -39,7 +39,7 @@ packages = ["src/mathematics_rl"]
39
  only-include = [
40
  "src", "tests", "integrations", "pyproject.toml", "uv.lock", "README.md",
41
  "FRAMEWORKS.md", "GRADING.md", "MODULES.md", "VALIDATION.md", "LICENSE", "NOTICE",
42
- ".dockerignore",
43
  ]
44
 
45
  [tool.hatch.build.targets.sdist.force-include]
 
4
 
5
  [project]
6
  name = "mathematics-rl"
7
+ version = "0.2.1"
8
  description = "Bilingual mathematics RL environments for Verifiers, Harbor, OpenEnv, NeMo Gym and AgentEnv"
9
  readme = "README.md"
10
  requires-python = ">=3.11.4,<3.15"
 
39
  only-include = [
40
  "src", "tests", "integrations", "pyproject.toml", "uv.lock", "README.md",
41
  "FRAMEWORKS.md", "GRADING.md", "MODULES.md", "VALIDATION.md", "LICENSE", "NOTICE",
42
+ ".dockerignore", "DOCKER.md", "DOCKER_VALIDATION.toml",
43
  ]
44
 
45
  [tool.hatch.build.targets.sdist.force-include]
rl/src/mathematics_rl/__init__.py CHANGED
@@ -1,7 +1,7 @@
1
  """Verifiers plugin entry point, loaded lazily so the checker also works on Windows."""
2
 
3
  __all__ = ["MathematicsTaskset", "MathematicsEnv"]
4
- __version__ = "0.2.0"
5
 
6
 
7
  def __getattr__(name):
 
1
  """Verifiers plugin entry point, loaded lazily so the checker also works on Windows."""
2
 
3
  __all__ = ["MathematicsTaskset", "MathematicsEnv"]
4
+ __version__ = "0.2.1"
5
 
6
 
7
  def __getattr__(name):
rl/src/mathematics_rl/adapters/common.py CHANGED
@@ -52,7 +52,9 @@ def checked_grade(grader, task, completion):
52
  def write_json(path, value):
53
  path = Path(path)
54
  path.parent.mkdir(parents=True, exist_ok=True)
55
- path.write_text(json.dumps(value, ensure_ascii=False, indent=2) + "\n", encoding="utf-8")
 
 
56
 
57
 
58
  def private_record(task):
 
52
  def write_json(path, value):
53
  path = Path(path)
54
  path.parent.mkdir(parents=True, exist_ok=True)
55
+ path.write_text(
56
+ json.dumps(value, ensure_ascii=False, indent=2) + "\n", encoding="utf-8", newline="\n"
57
+ )
58
 
59
 
60
  def private_record(task):
rl/src/mathematics_rl/adapters/harbor.py CHANGED
@@ -1,7 +1,9 @@
1
  """Harbor 0.24 task-directory export with a separate trusted verifier environment."""
2
 
 
3
  import json
4
  import stat
 
5
  from pathlib import Path
6
 
7
  from .. import __version__
@@ -10,6 +12,10 @@ from ..grading import MAX_COMPLETION
10
  from ..worker import Grader
11
  from .common import checked_grade, private_record, write_json
12
 
 
 
 
 
13
  TASK_TOML = """schema_version = "1.4"
14
  artifacts = ["/app/answer.txt"]
15
  [task]
@@ -35,10 +41,39 @@ cpus = 1
35
  memory_mb = 512
36
  storage_mb = 1024
37
  gpus = 0
38
- network_mode = "no-network"
39
  """
40
 
41
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
  def export_tasks(tasks, output):
43
  output = Path(output)
44
  output.mkdir(parents=True, exist_ok=False)
@@ -65,14 +100,16 @@ def export_tasks(tasks, output):
65
  (root / "task.toml").write_text(
66
  TASK_TOML.format(name=name, version=__version__, **private_record(task)),
67
  encoding="utf-8",
 
68
  )
69
  (root / "instruction.md").write_text(
70
  task.prompt + "\n\nWrite your final answer to /app/answer.txt (UTF-8).\n",
71
  encoding="utf-8",
 
72
  )
73
  (root / "environment").mkdir()
74
  (root / "environment" / "Dockerfile").write_text(
75
- "FROM python:3.13-slim\nWORKDIR /app\n", encoding="utf-8"
76
  )
77
  write_json(tests / "reference.json", private_record(task))
78
  # Package source is bundled only into the trusted verifier build context.
@@ -80,16 +117,18 @@ def export_tasks(tasks, output):
80
  target = tests / "mathematics_rl" / relative
81
  target.parent.mkdir(parents=True, exist_ok=True)
82
  target.write_bytes(content)
83
- (tests / "Dockerfile").write_text(
84
- "FROM python:3.13-slim\nRUN pip install --no-cache-dir sympy==1.14.0\n"
85
- "COPY . /tests\nENV PYTHONPATH=/tests\nWORKDIR /tests\n",
86
- encoding="utf-8",
87
  )
88
  (tests / "test.sh").write_text(
89
  "#!/bin/sh\nset -eu\nexport PYTHONPATH=/tests\n"
90
  "python -m mathematics_rl.adapters.harbor\n",
91
  encoding="utf-8",
 
92
  )
 
93
  solution = root / "solution"
94
  solution.mkdir()
95
  write_json(solution / "answer.json", task.answer)
@@ -99,6 +138,7 @@ def export_tasks(tasks, output):
99
  "Path('/app/answer.txt').write_text(json.loads("
100
  "Path('/solution/answer.json').read_text(encoding='utf-8')), encoding='utf-8')\nPY\n",
101
  encoding="utf-8",
 
102
  )
103
  manifest.append({"directory": root.name, "task_id": task.id, "module": task.module})
104
  write_json(output / "selection.json", {"framework": "harbor", "tasks": manifest})
@@ -110,21 +150,26 @@ def verify_task(reference, answer, log_dir):
110
  log_dir = Path(log_dir)
111
  log_dir.mkdir(parents=True, exist_ok=True)
112
  reward_file = log_dir / "reward.txt"
113
- reward_file.write_text("0\n", encoding="utf-8")
 
 
114
  task = Example(**json.loads(Path(reference).read_text(encoding="utf-8")))
115
  answer = Path(answer)
116
- try:
117
- info = answer.lstat()
118
- if not stat.S_ISREG(info.st_mode) or info.st_size > MAX_COMPLETION * 4:
119
- raise ValueError("Invalid answer artifact")
120
- completion = answer.read_bytes()[: MAX_COMPLETION * 4 + 1].decode("utf-8")
121
- except (OSError, ValueError):
122
- write_json(log_dir / "grading.json", {"reward": 0.0, "status": "invalid_artifact"})
123
- return 0.0
124
  with Grader() as grader:
 
 
 
 
 
 
 
 
 
 
 
125
  result = checked_grade(grader, task, completion)
126
  write_json(log_dir / "grading.json", result.to_dict())
127
- reward_file.write_text(f"{result.reward}\n", encoding="utf-8")
128
  return result.reward
129
 
130
 
 
1
  """Harbor 0.24 task-directory export with a separate trusted verifier environment."""
2
 
3
+ import hashlib
4
  import json
5
  import stat
6
+ import tarfile
7
  from pathlib import Path
8
 
9
  from .. import __version__
 
12
  from ..worker import Grader
13
  from .common import checked_grade, private_record, write_json
14
 
15
+ BASE_IMAGE = (
16
+ "python:3.13.14-slim@sha256:9662417aace5ae7b8e2609cce472b72a8958e134ba372808abe9cc1a0c0125e6"
17
+ )
18
+
19
  TASK_TOML = """schema_version = "1.4"
20
  artifacts = ["/app/answer.txt"]
21
  [task]
 
41
  memory_mb = 512
42
  storage_mb = 1024
43
  gpus = 0
44
+ # Docker network isolation is configured in tests/docker-compose.yaml.
45
  """
46
 
47
 
48
+ def build_verifier_payload(tests):
49
+ """Snapshot private inputs into one content-addressed build-context file."""
50
+ tests = Path(tests)
51
+ archive = tests / "payload.tar"
52
+ with tarfile.open(archive, "w", format=tarfile.PAX_FORMAT) as output:
53
+ paths = [tests / "reference.json", tests / "test.sh"]
54
+ paths.extend(sorted((tests / "mathematics_rl").rglob("*.py")))
55
+ for path in paths:
56
+ info = output.gettarinfo(str(path), arcname=path.relative_to(tests).as_posix())
57
+ info.mtime = info.uid = info.gid = 0
58
+ info.uname = info.gname = ""
59
+ info.pax_headers = {}
60
+ with path.open("rb") as source:
61
+ output.addfile(info, source)
62
+ digest = hashlib.sha256(archive.read_bytes()).hexdigest()
63
+ archive.replace(tests / f"payload-{digest}.tar")
64
+ reference_sha = hashlib.sha256((tests / "reference.json").read_bytes()).hexdigest()
65
+ (tests / "Dockerfile").write_text(
66
+ f"FROM {BASE_IMAGE}\nRUN pip install --no-cache-dir sympy==1.14.0\n"
67
+ f'LABEL mathematics.rl.reference.sha256="{reference_sha}"\n'
68
+ # Unique source names avoid cross-task directory transfer/cache reuse.
69
+ f"ADD payload-{digest}.tar /tests/\n"
70
+ f"RUN echo '{reference_sha} /tests/reference.json' | sha256sum -c -\n"
71
+ "ENV PYTHONPATH=/tests\nWORKDIR /tests\n",
72
+ encoding="utf-8",
73
+ newline="\n",
74
+ )
75
+
76
+
77
  def export_tasks(tasks, output):
78
  output = Path(output)
79
  output.mkdir(parents=True, exist_ok=False)
 
100
  (root / "task.toml").write_text(
101
  TASK_TOML.format(name=name, version=__version__, **private_record(task)),
102
  encoding="utf-8",
103
+ newline="\n",
104
  )
105
  (root / "instruction.md").write_text(
106
  task.prompt + "\n\nWrite your final answer to /app/answer.txt (UTF-8).\n",
107
  encoding="utf-8",
108
+ newline="\n",
109
  )
110
  (root / "environment").mkdir()
111
  (root / "environment" / "Dockerfile").write_text(
112
+ f"FROM {BASE_IMAGE}\nWORKDIR /app\n", encoding="utf-8", newline="\n"
113
  )
114
  write_json(tests / "reference.json", private_record(task))
115
  # Package source is bundled only into the trusted verifier build context.
 
117
  target = tests / "mathematics_rl" / relative
118
  target.parent.mkdir(parents=True, exist_ok=True)
119
  target.write_bytes(content)
120
+ # Docker Desktop kernels may lack nftables FIB_INET. Native Compose
121
+ # network_mode:none enforces isolation without Harbor's egress sidecar.
122
+ (tests / "docker-compose.yaml").write_text(
123
+ "services:\n main:\n network_mode: none\n", encoding="utf-8", newline="\n"
124
  )
125
  (tests / "test.sh").write_text(
126
  "#!/bin/sh\nset -eu\nexport PYTHONPATH=/tests\n"
127
  "python -m mathematics_rl.adapters.harbor\n",
128
  encoding="utf-8",
129
+ newline="\n",
130
  )
131
+ build_verifier_payload(tests)
132
  solution = root / "solution"
133
  solution.mkdir()
134
  write_json(solution / "answer.json", task.answer)
 
138
  "Path('/app/answer.txt').write_text(json.loads("
139
  "Path('/solution/answer.json').read_text(encoding='utf-8')), encoding='utf-8')\nPY\n",
140
  encoding="utf-8",
141
+ newline="\n",
142
  )
143
  manifest.append({"directory": root.name, "task_id": task.id, "module": task.module})
144
  write_json(output / "selection.json", {"framework": "harbor", "tasks": manifest})
 
150
  log_dir = Path(log_dir)
151
  log_dir.mkdir(parents=True, exist_ok=True)
152
  reward_file = log_dir / "reward.txt"
153
+ # Harbor consumes a reward file even when test.sh exits nonzero. Source and
154
+ # infrastructure failures must leave no score, including stale ones.
155
+ reward_file.unlink(missing_ok=True)
156
  task = Example(**json.loads(Path(reference).read_text(encoding="utf-8")))
157
  answer = Path(answer)
 
 
 
 
 
 
 
 
158
  with Grader() as grader:
159
+ # Validate the source even if the model produced no artifact.
160
+ checked_grade(grader, task, task.answer)
161
+ try:
162
+ info = answer.lstat()
163
+ if not stat.S_ISREG(info.st_mode) or info.st_size > MAX_COMPLETION * 4:
164
+ raise ValueError("Invalid answer artifact")
165
+ completion = answer.read_bytes()[: MAX_COMPLETION * 4 + 1].decode("utf-8")
166
+ except (OSError, ValueError):
167
+ write_json(log_dir / "grading.json", {"reward": 0.0, "status": "invalid_artifact"})
168
+ reward_file.write_text("0\n", encoding="utf-8", newline="\n")
169
+ return 0.0
170
  result = checked_grade(grader, task, completion)
171
  write_json(log_dir / "grading.json", result.to_dict())
172
+ reward_file.write_text(f"{result.reward}\n", encoding="utf-8", newline="\n")
173
  return result.reward
174
 
175
 
rl/tests/test_adapters.py CHANGED
@@ -1,6 +1,8 @@
1
  """Shared episode and artifact boundaries, independent of optional framework SDKs."""
2
 
 
3
  import json
 
4
  from dataclasses import replace
5
  from pathlib import Path
6
 
@@ -80,14 +82,27 @@ def test_harbor_export_and_artifact_verification(tmp_path, all_module_examples):
80
  output = tmp_path / "harbor"
81
  manifest = export_tasks([task], output)
82
  root = output / manifest[0]["directory"]
 
 
83
  with pytest.raises(FileExistsError):
84
  export_tasks([task], output)
85
  assert "separate" in (root / "task.toml").read_text()
 
86
  assert "reference" not in (root / "environment/Dockerfile").read_text()
87
  assert not list((root / "environment").glob("*.json"))
88
  answer = tmp_path / "answer.txt"
89
  logs = tmp_path / "logs"
90
  reference = root / "tests/reference.json"
 
 
 
 
 
 
 
 
 
 
91
  assert verify_task(reference, answer, logs) == 0
92
  answer.write_text(task.answer, encoding="utf-8")
93
  assert verify_task(reference, answer, logs) == 1
@@ -97,3 +112,18 @@ def test_harbor_export_and_artifact_verification(tmp_path, all_module_examples):
97
  answer.write_bytes(b"\xff")
98
  assert verify_task(reference, answer, logs) == 0
99
  assert json.loads((logs / "grading.json").read_text())["status"] == "invalid_artifact"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  """Shared episode and artifact boundaries, independent of optional framework SDKs."""
2
 
3
+ import hashlib
4
  import json
5
+ import tarfile
6
  from dataclasses import replace
7
  from pathlib import Path
8
 
 
82
  output = tmp_path / "harbor"
83
  manifest = export_tasks([task], output)
84
  root = output / manifest[0]["directory"]
85
+ for script in (root / "solution/solve.sh", root / "tests/test.sh"):
86
+ assert b"\r" not in script.read_bytes(), "Linux executable exports must use LF on Windows"
87
  with pytest.raises(FileExistsError):
88
  export_tasks([task], output)
89
  assert "separate" in (root / "task.toml").read_text()
90
+ assert "network_mode: none" in (root / "tests/docker-compose.yaml").read_text()
91
  assert "reference" not in (root / "environment/Dockerfile").read_text()
92
  assert not list((root / "environment").glob("*.json"))
93
  answer = tmp_path / "answer.txt"
94
  logs = tmp_path / "logs"
95
  reference = root / "tests/reference.json"
96
+ reference_sha = hashlib.sha256(reference.read_bytes()).hexdigest()
97
+ verifier_image = (root / "tests/Dockerfile").read_text()
98
+ assert f'mathematics.rl.reference.sha256="{reference_sha}"' in verifier_image
99
+ assert f"{reference_sha} /tests/reference.json" in verifier_image
100
+ archive = next((root / "tests").glob("payload-*.tar"))
101
+ assert archive.stem == "payload-" + hashlib.sha256(archive.read_bytes()).hexdigest()
102
+ assert f"ADD {archive.name} /tests/" in verifier_image
103
+ with tarfile.open(archive) as payload:
104
+ assert payload.extractfile("reference.json").read() == reference.read_bytes()
105
+ assert payload.extractfile("test.sh").read() == (root / "tests/test.sh").read_bytes()
106
  assert verify_task(reference, answer, logs) == 0
107
  answer.write_text(task.answer, encoding="utf-8")
108
  assert verify_task(reference, answer, logs) == 1
 
112
  answer.write_bytes(b"\xff")
113
  assert verify_task(reference, answer, logs) == 0
114
  assert json.loads((logs / "grading.json").read_text())["status"] == "invalid_artifact"
115
+
116
+
117
+ def test_harbor_source_errors_never_leave_a_model_reward(tmp_path, all_module_examples):
118
+ task = replace(all_module_examples[0], answer="invalid reference")
119
+ output = tmp_path / "export"
120
+ manifest = export_tasks([task], output)
121
+ reference = output / manifest[0]["directory"] / "tests/reference.json"
122
+ logs = tmp_path / "logs"
123
+ logs.mkdir()
124
+ reward = logs / "reward.txt"
125
+ reward.write_text("1\n")
126
+ # Missing model output must not hide an invalid source reference either.
127
+ with pytest.raises(ValueError, match="source"):
128
+ verify_task(reference, tmp_path / "missing-answer.txt", logs)
129
+ assert not reward.exists()
rl/uv.lock CHANGED
@@ -708,7 +708,7 @@ name = "cffi"
708
  version = "2.1.1"
709
  source = { registry = "https://pypi.org/simple" }
710
  dependencies = [
711
- { name = "pycparser", marker = "implementation_name != 'PyPy' or (extra == 'extra-14-mathematics-rl-agentenv' and extra == 'extra-14-mathematics-rl-verifiers') or (extra == 'extra-14-mathematics-rl-harbor' and extra == 'extra-14-mathematics-rl-verifiers') or (extra == 'extra-14-mathematics-rl-nemo' and extra == 'extra-14-mathematics-rl-verifiers') or (extra == 'extra-14-mathematics-rl-openenv' and extra == 'extra-14-mathematics-rl-verifiers')" },
712
  ]
713
  sdist = { url = "https://files.pythonhosted.org/packages/9e/ef/008a1939e372c06329a3fce4279c02f328488f3526744906eeec3da7ad5f/cffi-2.1.1.tar.gz", hash = "sha256:dd31f52ea1086513bb9df30f8fcee9b8918323ae067a3d5b78bc826a000712be", size = 530807, upload-time = "2026-08-03T21:21:18.939Z" }
714
  wheels = [
@@ -933,7 +933,7 @@ name = "connectrpc"
933
  version = "0.11.1"
934
  source = { registry = "https://pypi.org/simple" }
935
  dependencies = [
936
- { name = "protobuf-py", marker = "extra == 'extra-14-mathematics-rl-agentenv' or extra == 'extra-14-mathematics-rl-verifiers'" },
937
  { name = "pyqwest", version = "0.10.0", source = { registry = "https://pypi.org/simple" }, marker = "extra == 'extra-14-mathematics-rl-agentenv' or (extra == 'extra-14-mathematics-rl-harbor' and extra == 'extra-14-mathematics-rl-verifiers') or (extra == 'extra-14-mathematics-rl-nemo' and extra == 'extra-14-mathematics-rl-verifiers') or (extra == 'extra-14-mathematics-rl-openenv' and extra == 'extra-14-mathematics-rl-verifiers')" },
938
  { name = "pyqwest", version = "0.12.0", source = { registry = "https://pypi.org/simple" }, marker = "extra == 'extra-14-mathematics-rl-verifiers'" },
939
  ]
@@ -1004,7 +1004,7 @@ name = "cryptography"
1004
  version = "50.0.2"
1005
  source = { registry = "https://pypi.org/simple" }
1006
  dependencies = [
1007
- { name = "cffi", marker = "platform_python_implementation != 'PyPy' or (extra == 'extra-14-mathematics-rl-agentenv' and extra == 'extra-14-mathematics-rl-verifiers') or (extra == 'extra-14-mathematics-rl-harbor' and extra == 'extra-14-mathematics-rl-verifiers') or (extra == 'extra-14-mathematics-rl-nemo' and extra == 'extra-14-mathematics-rl-verifiers') or (extra == 'extra-14-mathematics-rl-openenv' and extra == 'extra-14-mathematics-rl-verifiers')" },
1008
  ]
1009
  sdist = { url = "https://files.pythonhosted.org/packages/9d/af/182eb91b0df3fe75c4d9f26fe70684569566745f6ba7e5c9c73a862c5252/cryptography-50.0.2.tar.gz", hash = "sha256:7b46165bb56eb4704e2eaaf86f3c940d19154535d9b0ca7d6d590b04060e00d5", size = 880623, upload-time = "2026-09-30T15:30:04.884Z" }
1010
  wheels = [
@@ -2778,7 +2778,7 @@ wheels = [
2778
 
2779
  [[package]]
2780
  name = "mathematics-rl"
2781
- version = "0.2.0"
2782
  source = { editable = "." }
2783
  dependencies = [
2784
  { name = "datasets" },
@@ -4381,7 +4381,7 @@ name = "protobuf-py"
4381
  version = "0.1.1"
4382
  source = { registry = "https://pypi.org/simple" }
4383
  dependencies = [
4384
- { name = "protobuf-py-ext", marker = "(platform_machine != 'aarch64' and platform_machine != 'x86_64' and sys_platform == 'linux' and extra == 'extra-14-mathematics-rl-agentenv' and extra == 'extra-14-mathematics-rl-verifiers') or (platform_machine != 'aarch64' and platform_machine != 'x86_64' and sys_platform == 'linux' and extra == 'extra-14-mathematics-rl-harbor' and extra == 'extra-14-mathematics-rl-verifiers') or (platform_machine != 'aarch64' and platform_machine != 'x86_64' and sys_platform == 'linux' and extra == 'extra-14-mathematics-rl-nemo' and extra == 'extra-14-mathematics-rl-verifiers') or (platform_machine != 'aarch64' and platform_machine != 'x86_64' and sys_platform == 'linux' and extra == 'extra-14-mathematics-rl-openenv' and extra == 'extra-14-mathematics-rl-verifiers') or (platform_machine != 'AMD64' and platform_machine != 'ARM64' and sys_platform == 'win32' and extra == 'extra-14-mathematics-rl-agentenv' and extra == 'extra-14-mathematics-rl-verifiers') or (platform_machine != 'AMD64' and platform_machine != 'ARM64' and sys_platform == 'win32' and extra == 'extra-14-mathematics-rl-harbor' and extra == 'extra-14-mathematics-rl-verifiers') or (platform_machine != 'AMD64' and platform_machine != 'ARM64' and sys_platform == 'win32' and extra == 'extra-14-mathematics-rl-nemo' and extra == 'extra-14-mathematics-rl-verifiers') or (platform_machine != 'AMD64' and platform_machine != 'ARM64' and sys_platform == 'win32' and extra == 'extra-14-mathematics-rl-openenv' and extra == 'extra-14-mathematics-rl-verifiers') or (platform_machine == 'arm64' and platform_python_implementation == 'CPython' and sys_platform == 'darwin' and extra == 'extra-14-mathematics-rl-agentenv') or (platform_machine == 'arm64' and platform_python_implementation == 'CPython' and sys_platform == 'darwin' and extra == 'extra-14-mathematics-rl-verifiers') or (platform_machine == 'aarch64' and platform_python_implementation == 'CPython' and sys_platform == 'linux' and extra == 'extra-14-mathematics-rl-agentenv') or (platform_machine == 'aarch64' and platform_python_implementation == 'CPython' and sys_platform == 'linux' and extra == 'extra-14-mathematics-rl-verifiers') or (platform_machine == 'x86_64' and platform_python_implementation == 'CPython' and sys_platform == 'linux' and extra == 'extra-14-mathematics-rl-agentenv') or (platform_machine == 'x86_64' and platform_python_implementation == 'CPython' and sys_platform == 'linux' and extra == 'extra-14-mathematics-rl-verifiers') or (platform_machine == 'AMD64' and platform_python_implementation == 'CPython' and sys_platform == 'win32' and extra == 'extra-14-mathematics-rl-agentenv') or (platform_machine == 'AMD64' and platform_python_implementation == 'CPython' and sys_platform == 'win32' and extra == 'extra-14-mathematics-rl-verifiers') or (platform_machine == 'ARM64' and platform_python_implementation == 'CPython' and sys_platform == 'win32' and extra == 'extra-14-mathematics-rl-agentenv') or (platform_machine == 'ARM64' and platform_python_implementation == 'CPython' and sys_platform == 'win32' and extra == 'extra-14-mathematics-rl-verifiers') or (platform_machine != 'arm64' and sys_platform == 'darwin' and extra == 'extra-14-mathematics-rl-agentenv' and extra == 'extra-14-mathematics-rl-verifiers') or (platform_machine != 'arm64' and sys_platform == 'darwin' and extra == 'extra-14-mathematics-rl-harbor' and extra == 'extra-14-mathematics-rl-verifiers') or (platform_machine != 'arm64' and sys_platform == 'darwin' and extra == 'extra-14-mathematics-rl-nemo' and extra == 'extra-14-mathematics-rl-verifiers') or (platform_machine != 'arm64' and sys_platform == 'darwin' and extra == 'extra-14-mathematics-rl-openenv' and extra == 'extra-14-mathematics-rl-verifiers') or (platform_machine == 'aarch64' and sys_platform == 'linux' and extra == 'extra-14-mathematics-rl-agentenv' and extra == 'extra-14-mathematics-rl-verifiers') or (platform_machine == 'aarch64' and sys_platform == 'linux' and extra == 'extra-14-mathematics-rl-harbor' and extra == 'extra-14-mathematics-rl-verifiers') or (platform_machine == 'aarch64' and sys_platform == 'linux' and extra == 'extra-14-mathematics-rl-nemo' and extra == 'extra-14-mathematics-rl-verifiers') or (platform_machine == 'aarch64' and sys_platform == 'linux' and extra == 'extra-14-mathematics-rl-openenv' and extra == 'extra-14-mathematics-rl-verifiers') or (platform_machine == 'x86_64' and sys_platform == 'linux' and extra == 'extra-14-mathematics-rl-agentenv' and extra == 'extra-14-mathematics-rl-verifiers') or (platform_machine == 'x86_64' and sys_platform == 'linux' and extra == 'extra-14-mathematics-rl-harbor' and extra == 'extra-14-mathematics-rl-verifiers') or (platform_machine == 'x86_64' and sys_platform == 'linux' and extra == 'extra-14-mathematics-rl-nemo' and extra == 'extra-14-mathematics-rl-verifiers') or (platform_machine == 'x86_64' and sys_platform == 'linux' and extra == 'extra-14-mathematics-rl-openenv' and extra == 'extra-14-mathematics-rl-verifiers') or (platform_machine == 'AMD64' and sys_platform == 'win32' and extra == 'extra-14-mathematics-rl-agentenv' and extra == 'extra-14-mathematics-rl-verifiers') or (platform_machine == 'AMD64' and sys_platform == 'win32' and extra == 'extra-14-mathematics-rl-harbor' and extra == 'extra-14-mathematics-rl-verifiers') or (platform_machine == 'AMD64' and sys_platform == 'win32' and extra == 'extra-14-mathematics-rl-nemo' and extra == 'extra-14-mathematics-rl-verifiers') or (platform_machine == 'AMD64' and sys_platform == 'win32' and extra == 'extra-14-mathematics-rl-openenv' and extra == 'extra-14-mathematics-rl-verifiers') or (platform_machine == 'ARM64' and sys_platform == 'win32' and extra == 'extra-14-mathematics-rl-agentenv' and extra == 'extra-14-mathematics-rl-verifiers') or (platform_machine == 'ARM64' and sys_platform == 'win32' and extra == 'extra-14-mathematics-rl-harbor' and extra == 'extra-14-mathematics-rl-verifiers') or (platform_machine == 'ARM64' and sys_platform == 'win32' and extra == 'extra-14-mathematics-rl-nemo' and extra == 'extra-14-mathematics-rl-verifiers') or (platform_machine == 'ARM64' and sys_platform == 'win32' and extra == 'extra-14-mathematics-rl-openenv' and extra == 'extra-14-mathematics-rl-verifiers') or (platform_python_implementation != 'CPython' and sys_platform == 'darwin' and extra == 'extra-14-mathematics-rl-agentenv' and extra == 'extra-14-mathematics-rl-verifiers') or (platform_python_implementation != 'CPython' and sys_platform == 'darwin' and extra == 'extra-14-mathematics-rl-harbor' and extra == 'extra-14-mathematics-rl-verifiers') or (platform_python_implementation != 'CPython' and sys_platform == 'darwin' and extra == 'extra-14-mathematics-rl-nemo' and extra == 'extra-14-mathematics-rl-verifiers') or (platform_python_implementation != 'CPython' and sys_platform == 'darwin' and extra == 'extra-14-mathematics-rl-openenv' and extra == 'extra-14-mathematics-rl-verifiers') or (sys_platform != 'darwin' and sys_platform != 'linux' and sys_platform != 'win32' and extra == 'extra-14-mathematics-rl-agentenv' and extra == 'extra-14-mathematics-rl-verifiers') or (sys_platform != 'darwin' and sys_platform != 'linux' and sys_platform != 'win32' and extra == 'extra-14-mathematics-rl-harbor' and extra == 'extra-14-mathematics-rl-verifiers') or (sys_platform != 'darwin' and sys_platform != 'linux' and sys_platform != 'win32' and extra == 'extra-14-mathematics-rl-nemo' and extra == 'extra-14-mathematics-rl-verifiers') or (sys_platform != 'darwin' and sys_platform != 'linux' and sys_platform != 'win32' and extra == 'extra-14-mathematics-rl-openenv' and extra == 'extra-14-mathematics-rl-verifiers')" },
4385
  ]
4386
  sdist = { url = "https://files.pythonhosted.org/packages/72/ed/02fd902d9c51b7ff53dfc9a745eb11490722edfd30073af889e171f07b8e/protobuf_py-0.1.1.tar.gz", hash = "sha256:6bd08ac4d8f1661965bbe2685429d79043704cdd1ee720a7a89617331742240b", size = 133525, upload-time = "2026-06-24T19:02:15.271Z" }
4387
  wheels = [
@@ -5334,7 +5334,7 @@ source = { registry = "https://pypi.org/simple" }
5334
  dependencies = [
5335
  { name = "attrs" },
5336
  { name = "rpds-py" },
5337
- { name = "typing-extensions", marker = "python_full_version < '3.13' or (extra == 'extra-14-mathematics-rl-agentenv' and extra == 'extra-14-mathematics-rl-verifiers') or (extra == 'extra-14-mathematics-rl-harbor' and extra == 'extra-14-mathematics-rl-verifiers') or (extra == 'extra-14-mathematics-rl-nemo' and extra == 'extra-14-mathematics-rl-verifiers') or (extra == 'extra-14-mathematics-rl-openenv' and extra == 'extra-14-mathematics-rl-verifiers')" },
5338
  ]
5339
  sdist = { url = "https://files.pythonhosted.org/packages/22/f5/df4e9027acead3ecc63e50fe1e36aca1523e1719559c499951bb4b53188f/referencing-0.37.0.tar.gz", hash = "sha256:44aefc3142c5b842538163acb373e24cce6632bd54bdb01b21ad5863489f50d8", size = 78036, upload-time = "2025-10-13T15:30:48.871Z" }
5340
  wheels = [
@@ -5964,7 +5964,7 @@ version = "1.9.0"
5964
  source = { registry = "https://pypi.org/simple" }
5965
  dependencies = [
5966
  { name = "anyio" },
5967
- { name = "typing-extensions", marker = "python_full_version < '3.13' or (extra == 'extra-14-mathematics-rl-agentenv' and extra == 'extra-14-mathematics-rl-verifiers') or (extra == 'extra-14-mathematics-rl-harbor' and extra == 'extra-14-mathematics-rl-verifiers') or (extra == 'extra-14-mathematics-rl-nemo' and extra == 'extra-14-mathematics-rl-verifiers') or (extra == 'extra-14-mathematics-rl-openenv' and extra == 'extra-14-mathematics-rl-verifiers')" },
5968
  ]
5969
  sdist = { url = "https://files.pythonhosted.org/packages/ad/eb/4e197bf26b023abafc5e9043ec8710d7de0fcb032d0969045236d72aa0b1/starlette-1.9.0.tar.gz", hash = "sha256:3d931de246ed870e35ce605974440816ef895e592f255d1396cfdf191d4c4318", size = 2732466, upload-time = "2026-10-18T15:50:33.189Z" }
5970
  wheels = [
@@ -6293,7 +6293,7 @@ version = "0.27.3"
6293
  source = { registry = "https://pypi.org/simple" }
6294
  dependencies = [
6295
  { name = "annotated-doc" },
6296
- { name = "colorama", marker = "sys_platform == 'win32' or (extra == 'extra-14-mathematics-rl-agentenv' and extra == 'extra-14-mathematics-rl-verifiers') or (extra == 'extra-14-mathematics-rl-harbor' and extra == 'extra-14-mathematics-rl-verifiers') or (extra == 'extra-14-mathematics-rl-nemo' and extra == 'extra-14-mathematics-rl-verifiers') or (extra == 'extra-14-mathematics-rl-openenv' and extra == 'extra-14-mathematics-rl-verifiers')" },
6297
  { name = "rich" },
6298
  { name = "shellingham" },
6299
  ]
 
708
  version = "2.1.1"
709
  source = { registry = "https://pypi.org/simple" }
710
  dependencies = [
711
+ { name = "pycparser", marker = "implementation_name != 'PyPy'" },
712
  ]
713
  sdist = { url = "https://files.pythonhosted.org/packages/9e/ef/008a1939e372c06329a3fce4279c02f328488f3526744906eeec3da7ad5f/cffi-2.1.1.tar.gz", hash = "sha256:dd31f52ea1086513bb9df30f8fcee9b8918323ae067a3d5b78bc826a000712be", size = 530807, upload-time = "2026-08-03T21:21:18.939Z" }
714
  wheels = [
 
933
  version = "0.11.1"
934
  source = { registry = "https://pypi.org/simple" }
935
  dependencies = [
936
+ { name = "protobuf-py" },
937
  { name = "pyqwest", version = "0.10.0", source = { registry = "https://pypi.org/simple" }, marker = "extra == 'extra-14-mathematics-rl-agentenv' or (extra == 'extra-14-mathematics-rl-harbor' and extra == 'extra-14-mathematics-rl-verifiers') or (extra == 'extra-14-mathematics-rl-nemo' and extra == 'extra-14-mathematics-rl-verifiers') or (extra == 'extra-14-mathematics-rl-openenv' and extra == 'extra-14-mathematics-rl-verifiers')" },
938
  { name = "pyqwest", version = "0.12.0", source = { registry = "https://pypi.org/simple" }, marker = "extra == 'extra-14-mathematics-rl-verifiers'" },
939
  ]
 
1004
  version = "50.0.2"
1005
  source = { registry = "https://pypi.org/simple" }
1006
  dependencies = [
1007
+ { name = "cffi", marker = "platform_python_implementation != 'PyPy'" },
1008
  ]
1009
  sdist = { url = "https://files.pythonhosted.org/packages/9d/af/182eb91b0df3fe75c4d9f26fe70684569566745f6ba7e5c9c73a862c5252/cryptography-50.0.2.tar.gz", hash = "sha256:7b46165bb56eb4704e2eaaf86f3c940d19154535d9b0ca7d6d590b04060e00d5", size = 880623, upload-time = "2026-09-30T15:30:04.884Z" }
1010
  wheels = [
 
2778
 
2779
  [[package]]
2780
  name = "mathematics-rl"
2781
+ version = "0.2.1"
2782
  source = { editable = "." }
2783
  dependencies = [
2784
  { name = "datasets" },
 
4381
  version = "0.1.1"
4382
  source = { registry = "https://pypi.org/simple" }
4383
  dependencies = [
4384
+ { name = "protobuf-py-ext", marker = "(platform_machine == 'arm64' and platform_python_implementation == 'CPython' and sys_platform == 'darwin') or (platform_machine == 'aarch64' and platform_python_implementation == 'CPython' and sys_platform == 'linux') or (platform_machine == 'x86_64' and platform_python_implementation == 'CPython' and sys_platform == 'linux') or (platform_machine == 'AMD64' and platform_python_implementation == 'CPython' and sys_platform == 'win32') or (platform_machine == 'ARM64' and platform_python_implementation == 'CPython' and sys_platform == 'win32')" },
4385
  ]
4386
  sdist = { url = "https://files.pythonhosted.org/packages/72/ed/02fd902d9c51b7ff53dfc9a745eb11490722edfd30073af889e171f07b8e/protobuf_py-0.1.1.tar.gz", hash = "sha256:6bd08ac4d8f1661965bbe2685429d79043704cdd1ee720a7a89617331742240b", size = 133525, upload-time = "2026-06-24T19:02:15.271Z" }
4387
  wheels = [
 
5334
  dependencies = [
5335
  { name = "attrs" },
5336
  { name = "rpds-py" },
5337
+ { name = "typing-extensions", marker = "python_full_version < '3.13'" },
5338
  ]
5339
  sdist = { url = "https://files.pythonhosted.org/packages/22/f5/df4e9027acead3ecc63e50fe1e36aca1523e1719559c499951bb4b53188f/referencing-0.37.0.tar.gz", hash = "sha256:44aefc3142c5b842538163acb373e24cce6632bd54bdb01b21ad5863489f50d8", size = 78036, upload-time = "2025-10-13T15:30:48.871Z" }
5340
  wheels = [
 
5964
  source = { registry = "https://pypi.org/simple" }
5965
  dependencies = [
5966
  { name = "anyio" },
5967
+ { name = "typing-extensions", marker = "python_full_version < '3.13'" },
5968
  ]
5969
  sdist = { url = "https://files.pythonhosted.org/packages/ad/eb/4e197bf26b023abafc5e9043ec8710d7de0fcb032d0969045236d72aa0b1/starlette-1.9.0.tar.gz", hash = "sha256:3d931de246ed870e35ce605974440816ef895e592f255d1396cfdf191d4c4318", size = 2732466, upload-time = "2026-10-18T15:50:33.189Z" }
5970
  wheels = [
 
6293
  source = { registry = "https://pypi.org/simple" }
6294
  dependencies = [
6295
  { name = "annotated-doc" },
6296
+ { name = "colorama", marker = "sys_platform == 'win32'" },
6297
  { name = "rich" },
6298
  { name = "shellingham" },
6299
  ]