Repository navigation
fix(tests): restore the run-image mock, tighten approx and the layout check - #252
Merged
Merged
Conversation
zhenhuang12
requested review from
RuibinCheung,
irvineoy,
jiejingzhangamd,
kyle-256 and
xiaobochen-amd
as code owners
November 18, 2026 02:25
There was a problem hiding this comment.
🟡 Changes recommended
The layout checker overlooks missing package markers in intermediate directories and incorrectly rejects valid imports of ordinary helper values.
3 open issues
What changed in this PR
Follow-up to #250 that strengthens the converted AgentX tests and test-layout checks. Changes are limited to tests and contributor documentation; runtime and AgentX production code are unchanged.
Changes:
- Restore recipe-test isolation from the real
stack.json. - Add explicit absolute tolerances to numerical assertions.
- Expand layout checks, add the benchmark package initializer, and clarify testing guidance.
| File | Description |
|---|---|
tests/check_layout.py |
Expands forbidden-import detection and checks package initializers. |
tests/benchmarks/test_agentx_plan.py |
Restores the fixture that mocks run-image lookup. |
tests/benchmarks/test_agentx_metrics.py |
Sets absolute tolerances for metric ratios. |
tests/benchmarks/test_agentx_comparisons.py |
Sets absolute tolerances for comparison results. |
tests/benchmarks/test_agentx_baselines.py |
Sets absolute tolerances for baseline ratios. |
tests/benchmarks/test_agentx_archives.py |
Sets an absolute tolerance for archived interactivity. |
tests/benchmarks/__init__.py |
Makes benchmark tests a Python package. |
tests/AGENTS.md |
Documents the AgentX test-layout exception. |
harness/README.md |
Lists the tdd skill and its scope. |
Review effort: Max
Comment on lines
+18
to
+19
| if not (path.parent / "__init__.py").is_file(): | ||
| errors.append(f"{path}: no __init__.py in {path.parent}/") |
| last = name.rpartition(".")[2] | ||
| if name.split(".")[0] == "tests" and (last.startswith("test_") or last == "conftest"): | ||
| # any spelling: `tests.x.test_y`, `.test_y`, bare `test_y` | ||
| if last.startswith("test_") or last == "conftest": |
| assert not validator.is_valid(run) | ||
|
|
||
|
|
||
| @pytest.mark.usefixtures("case") # build_run reads the run image: keep stack.json out of this test |
zhenhuang12
force-pushed
the
fix/agentx-tests-review
branch
from
November 18, 2026 03:33
d55d2ee to
e2e297a
Compare
… check Follow-up to #250, from its review. - test_repository_recipes_match_agentx_yaml lost the ci_image.run_image patch in the pytest conversion and read the real stack.json; it takes the case fixture again. - pytest.approx gets abs=5e-8, the bound assertAlmostEqual had. - tests/check_layout.py flags a test_*.py or conftest import in any spelling (relative, bare), not only tests.<...>, and a test directory without __init__.py; tests/benchmarks gets one. - tests/AGENTS.md names the AgentX tests as the exception to the aklr/ mirror; harness/README.md lists the tdd skill.
…modules only From the review of this PR. - test_agentx_environment.py: use_environ is a mock.patch.dict(os.environ, clear=True) context again, as before #250, so the environment is restored before the assertions. Held to the end of the test through monkeypatch, a process-wide change by execution_env went unseen. - tests/check_layout.py: a name imported with from is a module only if its file exists, so a helper function named test_* is allowed; every directory up to tests/ needs __init__.py, not only a test's own.
From the review of this PR: `from ....helpers import x` in tests/probe.py raised IndexError and stopped the scan. Such an import resolves nowhere, so it is skipped. The lookup's limit (the repository root and the file's own directory) is written down beside it.
zhenhuang12
force-pushed
the
fix/agentx-tests-review
branch
from
November 18, 2026 11:27
e2e297a to
dbe7e22
Compare
irvineoy
added a commit
that referenced
this pull request
Nov 18, 2026
Main moved from a65066c to 7e9cff8, ten commits, among them #253 (sglang 0.5.23, which bcf2f95 already declares), #257 (the GPU jobs run on the aklr-safe runner) and #252 (a tighter tests layout check). Nothing conflicts. CI run 44255030975 on bcf2f95 started on the old runner setup and its GPU prepare job is still queued, so this head's run is the branch's first on aklr-safe. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Why
Follow-up to #250, which merged before its review finished. The review found one test that lost a mock in the pytest conversion, and a few smaller gaps.
Scope
tests/benchmarks/test_agentx_plan.py:test_repository_recipes_match_agentx_yamltakes thecasefixture again, soci_image.run_imageis patched as it was before test(agentx): pytest style, tests/AGENTS.md rules and the tdd skill #250 and the test no longer reads the realstack.json.pytest.approx(..., abs=5e-8)in four modules: the boundassertAlmostEqualhad. test(agentx): pytest style, tests/AGENTS.md rules and the tdd skill #250 left the default relative 1e-6.tests/benchmarks/test_agentx_environment.py:use_environis amock.patch.dict(os.environ, clear=True)context again, scoped to the call as before test(agentx): pytest style, tests/AGENTS.md rules and the tdd skill #250. test(agentx): pytest style, tests/AGENTS.md rules and the tdd skill #250 held it to the end of the test throughmonkeypatch, which restores only the keys it set.tests/check_layout.py: flags an import statement whose module is atest_*orconftestmodule, relative or bare as well astests.<...>(from .test_b import x,from test_b import x,import conftest). A name imported withfromcounts as a module only if its file exists under the repository root or beside the importing file. It also flags a directory undertests/that holds Python files, or lies above one that does, without__init__.py.tests/benchmarks/__init__.pyis added: the eleven modules there are now imported astests.benchmarks.<name>instead of top-level modules, andtests/benchmarksis no longer put onsys.path. The collected test ids are unchanged.tests/AGENTS.mdrule 8 says. Not seen:importlib.import_module("..."); a module reached through anothersys.pathentry; a directory with no Python file below it. Any imported module whose own name starts withtest_is flagged, a third-party one too (sglang.test.test_utils,aiter.test_common; no test imports these today), as is a helper module of that name; so is a helper package of that name when imported asfrom ..test_support import x(but not asfrom .. import test_support).tests/AGENTS.mdrule 4 names the AgentX tests as the exception to "tests mirroraklr/";harness/README.mdlists thetddskill.Nothing under
aklr/orbenchmarks/agentx/changes.Verification
Environment: head e2e297a (rebased on main at b6dd38e, after #246),
lmsysorg/sglang:v0.5.22-rocm10-mi30x, no GPU usedGate overrides: none
Code
stack.jsonin a scratch copy,test_repository_recipes_match_agentx_yamlpasses on this head. test(agentx): pytest style, tests/AGENTS.md rules and the tdd skill #250's reviewer saw it fail on test(agentx): pytest style, tests/AGENTS.md rules and the tdd skill #250's head under the same change; that failing run was not repeated here.execution_envchanged in a scratch copy to clearos.environ, fill it and return it, main'stest_agentx_environment.pypasses with the rest (331) and 2 tests fail on this head. feat(agentx): gate PR and manual runs on a reviewer allowlist #246 restyled that file's patches aspytest.MonkeyPatch.context(); the call-scoped environment is reapplied on top of it.test_*andconftest), 5 allowed ones (three import a helper function namedtest_payload) and an intermediate directory without__init__.py, it reports the 9 and the directory and nothing else. test(agentx): pytest style, tests/AGENTS.md rules and the tdd skill #250's version reported 4 of the 9. For a relative import above the repository root (from ....helpers import x) the file lookup is skipped; it raisedIndexErrorbefore. Its module name is still checked.CI
code-lintran pre-commit on this head: ruff check, ruff format andtests-layoutpass.Not run
aiter-test,sglang-test,vllm-test: they need theci:gpulabel. They were skipped on test(agentx): pytest style, tests/AGENTS.md rules and the tdd skill #250 too, so the converted tests have not run in CI on a PR.Risk
Affects: tests and agent documents only
AgentX: none (no AgentX run needed)
If wrong: a CI failure in
tests/benchmarksor in thetests-layouthookUndo:
git revert