Repository navigation
fix(qed): keep spawned verifier imports lightweight - #1491
Conversation
There was a problem hiding this comment.
Alignment Review Report
Automated Checks
- Lint: FAIL (minor) —
usortwantsfrom typing import Any, TYPE_CHECKING(alphabetical) in both touched__init__.pyfiles; they currently readTYPE_CHECKING, Any.ruff format/ruff checkare clean. Note CI's lint job (test.yml) only runs oversrc/andtests/, so this won't fail CI, but it's a one-line fix for consistency with the rest of the repo (e.g.atari_env/client.py,openspiel_env/client.py,sync_client.pyall sortAnybeforeTYPE_CHECKING). - Debug code: CLEAN — no prints/breakpoints/TODOs introduced by this diff.
Open RFCs Context
Scanned rfcs/000–012. None reference QED-Math, math_verify, process pools, or lazy imports, so there's no overlap with any open RFC (several are Draft/In Review, e.g. 010 echo-env-token-world-model and 011 ard-catalog-discovery, but they're unrelated to this change).
Tier 1: Fixes Required
-
envs/qed_math_env/__init__.py:10—usortimport-order:from typing import TYPE_CHECKING, Any→from typing import Any, TYPE_CHECKING. -
envs/qed_math_env/server/__init__.py:9— sameusortimport-order fix.
Tier 2: Alignment Discussion
Principle Conflicts
None identified. The __getattr__/TYPE_CHECKING lazy-export pattern this PR adds to qed_math_env/__init__.py and qed_math_env/server/__init__.py matches the existing convention already used in browsergym_env/__init__.py, thinkingbox_env/__init__.py, calendar_env/__init__.py, and finqa_env/server/__init__.py (same globals() caching + __dir__ shape), so it's consistent with prior art rather than introducing a new pattern. It doesn't touch the client/server boundary, reward computation, or the Gym-like/MCP dual API, so no invariant is at risk.
RFC Conflicts
None identified.
Verification
- New tests pass:
tests/envs/test_qed_math_worker_imports.py::test_spawned_verifier_does_not_import_applicationand::test_public_package_exports_keep_their_identity(2/2 passed). - Existing suite:
tests/envs/test_qed_math_environment.py— 147 passed; the 5 failures are the pre-existing@pytest.mark.integrationtests that need a live server onlocalhost:8000(excluded by CI's-m "not integration and not network and not docker"), unrelated to this change.
Summary
- 2 mechanical issues to fix (import-sort order, non-blocking for CI but easy to clean up)
- 0 alignment points for human review
- 0 RFC conflicts to discuss
Nice, well-scoped fix — the lazy-export pattern is well-tested and matches the convention already used elsewhere in the repo.
Sent by Cursor Automation: Pre-review
|
Addressed review 5656435359 in 04d3172: reordered typing imports in the two QED init.py files. Installed usort check, ruff format --check, and ruff check all pass (no formatter disagreement). QED tests: 149 passed, 5 integration tests deselected, including spawned-worker isolation and public-export identity regressions. No main merge needed. |


Summary
Spawned QED verifier workers eagerly imported the client and complete server, including Gradio and datasets, inside the five-second request deadline. Cold startup can exhaust both attempts and turn correct answers or wrong-answer penalties into neutral timeout rewards (seen in CI on #1469 and #1270).
Only the two QED package initializers change. Request deadlines, retries, grading, and existing fixtures are unchanged.
Evidence
Before: Python 3.11 cold worker import: 13.907s. Injecting an 11s delay into
datasetsimport reproducestest_correct_gives_max_reward: score 0 instead of 7, with two 5s timeouts; workers subsequently finish. The new subprocess regression fails because the worker importsopenenv.After: worker import: 0.216s. All three originally failing tests pass with that same delay; 149 QED tests pass (5 integration tests deselected). Regression verifies isolated imports, real spawned correct/wrong grading, and public export identity.
Relevant dependency versions match failing CI: math-verify 0.9.0, SymPy 1.14.0, latex2sympy2-extended 1.11.0, ANTLR 4.13.2. Reproduction is local macOS Python 3.11; CI itself has not been instrumented.
Changed-file formatting/import sorting and repository
ruff check src/ tests/pass. Global formatting hook reports existing issues (including grid-world/Julia import ordering and 47 unrelated formatting files). The test hook requires unavailable GNUtimeout; its pytest command was run directly.Full Python 3.11 suite: 3,882 passed, 135 skipped, 66 deselected; 1 unrelated failure. Harbor port-binding test expects "already in use" but gets a startup timeout on macOS; the identical failure reproduces independently on unchanged main (
cad76b7a).Merge Danger
Door: two-way
Blast Radius: QED
Public imports remain available, but application dependencies now load when their exported classes are requested. No API signatures or architecture change; no RFC needed. Independent review and CI required before merge.