Repository navigation
fix(devtools): report active pytest node during verify - #2100
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughThe pytest progress plugin gains a ChangesLive pytest event ledger and heartbeat surfacing
Sequence Diagram(s)sequenceDiagram
participant pytest
participant pytest_progress_plugin
participant _write_event
participant JSONL_ledger as JSONL Ledger
participant _read_latest_pytest_event
participant verify_py as verify.py heartbeat
pytest->>pytest_progress_plugin: pytest_runtest_logstart(nodeid, location)
pytest_progress_plugin->>_write_event: {event: test_started, nodeid, location}
_write_event->>JSONL_ledger: append line + updated_at
pytest->>pytest_progress_plugin: pytest_runtest_logreport(report)
pytest_progress_plugin->>_write_event: {event: test_report, ...}
_write_event->>JSONL_ledger: append line + updated_at
verify_py->>_read_latest_pytest_event: read tail of JSONL ledger
_read_latest_pytest_event->>JSONL_ledger: scan backwards for last valid JSON
JSONL_ledger-->>_read_latest_pytest_event: last event dict
_read_latest_pytest_event-->>verify_py: {event, nodeid, ...}
verify_py->>verify_py: emit stderr "latest=test_started:<nodeid>"
verify_py->>verify_py: write progress JSON with latest_test_event + current_test_nodeid
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
## Summary Tighten the query descriptor parity tests around the now-shipped shared query metadata and fix stale daemon route wording for terminal query units. ## Problem The #2006 metadata split and terminal query-unit work have already landed, but the descriptor parity test still described itself as an informational #621 placeholder and carried a stale allowlist of fields that now have real MCP/API names. The daemon `/api/query-units` handler docstring also still named only message/action/block rows even though assertions are now part of the terminal query-unit surface. ## Solution - Reword descriptor parity coverage as shared query-substrate coverage. - Reduce the allowlist to true internal plan-only descriptors (`parent_id`, lineage booleans, branch/predicate internals). - Keep the test as positive metadata coverage: public selection filters must expose a surface name unless they are genuinely plan-only. - Update the daemon handler docstring to describe terminal query-unit rows generically. ## Verification - `nix develop --command devtools test tests/unit/core/test_query_descriptor_parity.py tests/unit/daemon/test_daemon_http.py -k 'descriptor or query_units'` -> 5 passed, 5 deselected. - `nix develop --command devtools verify --quick` -> exit_code 0. Default `devtools verify` selected a very broad testmon set for this two-file metadata/docstring change and was stopped after ~35 minutes at 97%; the run had already written roughly 40 GB and did not expose the active test node. PR #2100 fixes that harness observability gap so future long default verifies report the current node instead of only percentage/process state.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9ac5778c39
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if latest_event.get("event") == "test_started" and isinstance(latest_event.get("nodeid"), str): | ||
| payload["current_test_nodeid"] = latest_event["nodeid"] |
There was a problem hiding this comment.
Track active pytest nodes across workers
In the seeded/full verify lanes, pytest runs with xdist (build_verify_steps() defaults those lanes to -n 16), so multiple tests can be active at once. If worker A starts a long or hung test and worker B later finishes another test, the latest ledger row becomes test_finished, this branch omits current_test_nodeid, and the live progress artifact no longer identifies the stuck test even though its unmatched test_started event is still in the ledger. Track active nodeids from unmatched start/finish events rather than deriving current state from only the latest event.
Useful? React with 👍 / 👎.
## Summary Make the default `devtools verify` pytest-testmon path validate the seed stamp before it starts pytest. The preflight now rejects missing, unreadable, wrong-head, and fingerprint-drifted `.cache/testmon/seed.json` state instead of accepting any old `.testmondata` file. ## Problem A diagnostic default verify run accepted a seed from `a1a4f9f` recorded on 2026-06-06, while current master was `28e95ab` after 245 first-parent commits. That stale seed selected a very broad pseudo-full run: the bounded diagnostic reached 900s, emitted 1,406 test starts, and was still progressing through MCP archive-surface tests. The harness was observable after #2100, but the preflight still allowed stale affected-test metadata to waste the gate. ## Solution `_testmon_preflight` now reads `.cache/testmon/seed.json`, compares its `git_head` to the current checkout, and compares its recorded `.testmondata` fingerprint to the current file. If either check fails, default verify exits immediately with reseed instructions. `--seed-testmon`, `--all`, `--quick`, and commit/pre-push quick paths remain unaffected. ## Verification - `nix develop --command devtools test tests/unit/devtools/test_verify.py -k 'testmon_preflight'` → 6 passed, 42 deselected - `nix develop --command ruff check --fix devtools/verify.py tests/unit/devtools/test_verify.py` → fixed import order, 0 remaining - `nix develop --command ruff format --check devtools/verify.py tests/unit/devtools/test_verify.py` → 2 files already formatted - `nix develop --command devtools verify --quick` → exit_code 0 - `nix develop --command devtools verify` with stale local seed → exits in ~1s with: `pytest-testmon seed was recorded for a different git head`
Summary
Make
devtools verifyexpose the active pytest node while long testmon runs are in flight. The pytest progress plugin now writes start/finish events for each node, and verify heartbeats/progress JSON include the latest event/current node when available.Problem
A default
devtools verifyrun for a two-file metadata/docstring branch selected a very broad testmon set, ran for over 35 minutes, wrote roughly 40 GB according to/proc/<pid>/io, and reported only percentage/process state. The live progress artifact did not name the active test node, and the advertised events ledger was missing because the plugin did not emit runtime events under real pytest.Solution
current-pytest-progress.jsonand heartbeat output.Verification
nix develop --command devtools test tests/unit/devtools/test_pytest_progress_plugin.py tests/unit/devtools/test_verify.py -k 'pytest_progress_plugin or heartbeat_reports_latest_test_node or emits_heartbeat_for_long_silent_child or writes_live_progress_artifact or forces_subprocesses'-> 7 passed, 42 deselected.POLYLOGUE_PYTEST_EVENTS_PATH=/tmp/polylogue-pytest-events-smoke.jsonl nix develop --command pytest -q -p devtools.pytest_progress_plugin tests/unit/core/test_query_descriptor_parity.py-> 5 passed and emitted 10 start/finish events.nix develop --command devtools verify --quick-> exit_code 0.Summary by CodeRabbit
New Features
Improvements