fix(tests): stop tests/ shadowing real packages on sys.path; de-flake LSP wait - #550
Merged
Merged
Conversation
… LSP wait
Two unrelated reds that survived every CI run because the per-file runner
reported them as "1 file where no tests ran" and "1 test failed".
1. tests/agent/test_endpoint_blackhole.py inserted os.path.join(dirname(
__file__), "..") == tests/ onto sys.path. tests/ contains packages whose
names shadow real top-level ones -- measured: agent, cron, docker, gateway,
hermes_cli, plugins, providers, tools, tui_gateway, website (10 collisions).
So `from hermes_cli import __version__`, reached from
agent/auxiliary_client.py:1016, resolved to tests/hermes_cli and raised
ImportError. Surfaced as 22 collection ERRORs that look nothing like a
sys.path bug. 22 errors -> 22 passed. Now resolves the repo ROOT from
__file__ so worktrees and second clones behave identically.
Added tests/agent/test_no_tests_dir_on_syspath.py: an AST lint that
statically evaluates every literal sys.path insert/append in tests/ and
fails if one resolves to tests/ itself. It asserts the PROPERTY, not one
spelling, so a novel phrasing of the same mistake is still caught. Ships
with a positive control (the evaluator must resolve the known-bad idiom --
a lint that evaluates nothing would pass forever) and a premise guard that
fails if tests/ ever stops shadowing a real package.
RED-proven: restoring the old one-liner fails the lint by name.
2. tests/agent/lsp/test_stale_diagnostics.py::test_slow_push_is_waited_for
asserted a 2.0s ceiling against an 0.8s server-side delay -- 1.2s of slack
while spawning a real subprocess, i.e. a timing assertion (2.5x ratio), not
a hang guard. Passed 5/5 in isolation, failed under 12-way parallel CI.
Raised to 15.0s.
The invariant is preserved, not widened away: the inverse case ("an
out-of-budget push must NOT satisfy the wait") is owned by
test_service_reports_no_data_not_stale_errors, which pins its own
wait_timeout=1.0 against a server that never re-publishes. This test only
ever proved the positive direction.
Load-immunity proven, not just idle re-runs: 3/3 green with 2x ncpu CPU
burners at load 11.13.
Test-only change; no production files touched.
Collaborator
Author
FleetReviewConfidence: 1/5 Findings
FleetReview provenance · models: B=gpt-5.6-sol, C=claude-code-opus-4-8, F=gpt-5.6-sol, G=grok-4.5 · cost: $7.59 · duration: 16m 10s · rounds: 1 · files examined: 3 |
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.
Two reds that survived every CI run
Both were invisible because the per-file runner reports them as
1 file where no tests ranand1 test failed— neither reads as a defect.1.
tests/was shadowing real packages onsys.path(22 collection errors)tests/agent/test_endpoint_blackhole.pydid:tests/contains packages whose names shadow real top-level ones — measured 10 collisions:So
from hermes_cli import __version__(reached fromagent/auxiliary_client.py:1016) resolved totests/hermes_cliand raisedImportError. The failure surfaced 22 collection ERRORs pointing deep intoagent/auxiliary_client.py— nothing that looks like a path bug.22 errors → 22 passed. Now resolves the repo ROOT from
__file__, so worktrees and second clones behave identically.The lint
tests/agent/test_no_tests_dir_on_syspath.pyAST-walks every literalsys.pathinsert/append undertests/, statically evaluates theos.path.*expression, and fails if one resolves totests/itself.It asserts the property, not one spelling — a novel phrasing of the same mistake is still caught. Ships with:
tests/. A lint that silently evaluates nothing would pass forever.tests/ever stops shadowing a real package, so it can't outlive its reason.RED-proven: restoring the old one-liner fails the lint by name.
2. LSP wall-clock flake
test_slow_push_is_waited_forasserted a 2.0s ceiling against an 0.8s server-side delay — 1.2s of slack while spawning a real subprocess. That is a timing assertion (2.5× ratio), not a hang guard. Passed 5/5 in isolation, failed under 12-way parallel CI. Raised to 15.0s.The invariant is preserved, not widened away. The inverse case — "an out-of-budget push must NOT satisfy the wait" — is owned by
test_service_reports_no_data_not_stale_errors, which pins its ownwait_timeout=1.0against a server that never re-publishes. This test only ever proved the positive direction.Load-immunity proven, not just idle re-runs: 3/3 green with
2× ncpuCPU burners at load 11.13.Scope
Test-only. No production files touched.