Skip to content

fix(devtools): expose live pytest verify progress (#2006) - #2074

Merged
Sinity merged 2 commits into
masterfrom
feature/test/query-descriptor-parity-2006
Jun 18, 2026
Merged

Sinity merged 2 commits into
masterfrom
feature/test/query-descriptor-parity-2006

Conversation

@Sinity

@Sinity Sinity commented Jun 18, 2026 •

Copy link
Copy Markdown
Owner

Summary

Adds a live progress artifact for pytest-backed devtools verify runs and turns MCP query descriptor parity into an enforced contract now that coverage is complete.

Problem

The final pytest JSON report is written only when pytest exits. During long pytest-testmon runs, that left no machine-readable progress artifact to inspect, so an active verify could look hung even when the subprocess was alive. Separately, the MCP query descriptor parity test had become a no-op even though current MCP query fields are fully represented by descriptor metadata.

Solution

devtools verify now writes .cache/verify/current-pytest-progress.json during pytest steps on start, output, heartbeat, timeout/stall termination, and finish. The artifact records elapsed time, pid, output byte counts, RSS/state when sampled, return code, and termination reason when applicable. Pytest step metadata now reports the progress path. The descriptor parity test now asserts that every query-bearing MCPSessionQueryRequest field is represented by QUERY_FIELD_DESCRIPTORS, excluding only control fields.

Verification

  • nix develop --command devtools test tests/unit/core/test_query_descriptor_parity.py tests/unit/devtools/test_verify.py -k 'descriptor_mcp_names_match_mcp_query_request_fields or pytest_run_writes_live_progress_artifact or pytest_run_streams_child_output_live or pytest_run_emits_heartbeat_for_long_silent_child or pytest_run_terminates_after_runtime_budget or pytest_run_terminates_after_output_stall or run_reads_structured_pytest_report' -> 7 passed, 41 deselected.
  • nix develop --command devtools verify --quick -> exit_code 0.
  • Pre-push devtools verify --quick reran on d8510ef1 -> exit_code 0.

Ref #2006

Summary by CodeRabbit

  • New Features

    • Long-running verification runs now emit live progress artifacts with real-time tracking of timing, output metrics, and process status.
  • Tests

    • Strengthened query descriptor parity validation to enforce strict alignment of descriptor fields.
    • Added test coverage for progress artifact generation during verification runs.

Problem: long pytest-testmon runs only wrote the structured pytest report at process completion, so an active default verify could look stalled even while pytest was still collecting or executing tests.

What changed: verify now maintains .cache/verify/current-pytest-progress.json during pytest steps, updating it on start, output, heartbeat, termination, and finish. The pytest step metadata reports that path, and the MCP query descriptor parity check now fails if a query-bearing MCP field lacks descriptor metadata.

Verification: nix develop --command devtools test tests/unit/core/test_query_descriptor_parity.py tests/unit/devtools/test_verify.py -k 'descriptor_mcp_names_match_mcp_query_request_fields or pytest_run_writes_live_progress_artifact or pytest_run_streams_child_output_live or pytest_run_emits_heartbeat_for_long_silent_child or pytest_run_terminates_after_runtime_budget or pytest_run_terminates_after_output_stall or run_reads_structured_pytest_report'; nix develop --command devtools verify --quick
@coderabbitai

coderabbitai Bot commented Jun 18, 2026 •

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@Sinity, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 42 minutes and 6 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 465d454c-655b-4ef7-9d35-0c228101b48d

📥 Commits

Reviewing files that changed from the base of the PR and between d8510ef and ed0f969.

📒 Files selected for processing (1)
  • tests/unit/devtools/test_verify.py
📝 Walkthrough

Walkthrough

devtools/verify.py gains a PYTEST_PROGRESS_PATH constant and _write_pytest_progress, which atomically writes JSON progress snapshots. The _run_pytest_with_heartbeat function is extended to emit started, output, heartbeat, terminated, and finished events, and step metadata now exposes progress_path. A new test validates the artifact. Separately, the MCP/descriptor parity test is changed from a soft check to a hard assertion.

Changes

Live pytest progress artifact

Layer / File(s) Summary
_write_pytest_progress helper and path constant
devtools/verify.py
Adds PYTEST_PROGRESS_PATH and _write_pytest_progress, which atomically writes structured JSON payloads (timing, pid, command, optional CPU/output/status/termination fields) via temp-file-then-replace.
Progress events wired into heartbeat loop and step metadata
devtools/verify.py
Initializes a started event and output_bytes counter before the selector loop; emits output events on stream chunks, heartbeat events on idle samples, and terminated (rc=124) or finished events at exit; adds progress_path to step metadata.
Test for live progress artifact
tests/unit/devtools/test_verify.py
Imports PYTEST_PROGRESS_PATH and adds test_pytest_run_writes_live_progress_artifact, which asserts the artifact exists with event=finished, returncode=0, non-zero stdout_bytes, and an updated_at field.

MCP/descriptor parity enforcement

Layer / File(s) Summary
Hard parity assertion
tests/unit/core/test_query_descriptor_parity.py
test_descriptor_mcp_names_match_mcp_query_request_fields now asserts (rather than merely computing) that every non-control MCPSessionQueryRequest field appears in QUERY_FIELD_DESCRIPTORS mcp_names.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • Sinity/polylogue#1803: Modifies devtools/verify.py's pytest step construction and metadata, overlapping with the progress_path addition in step metadata at the same code site.

Suggested labels

area:qa

🐇 A rabbit hops through logs with glee,
JSON artifacts bloom like a tree,
Each heartbeat ticks, each output lands,
Progress written by careful hands,
And parity tests now firmly stand! 🌿

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding live pytest progress exposure to devtools verify functionality.
Description check ✅ Passed The PR description covers all required template sections: Summary, Problem, Solution, Verification, and Changelog (appropriately skipped as internal). It provides concrete details about the implementation and testing.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/test/query-descriptor-parity-2006

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/unit/devtools/test_verify.py`:
- Around line 342-352: The test_pytest_run_writes_live_progress_artifact
function reads and writes to a shared path (PYTEST_PROGRESS_PATH) without
filesystem isolation, which can cause flaky behavior during parallel test
execution. Add monkeypatch and tmp_path as parameters to the function signature,
then call monkeypatch.chdir(tmp_path) at the start of the test to isolate the
working directory. This will ensure the test writes to an isolated temporary
directory instead of a shared .cache/verify location, following the pattern used
in test_testmon_preflight_* tests.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: efb2e22c-fc24-41a7-af68-7678b17fa067

📥 Commits

Reviewing files that changed from the base of the PR and between 43e088e and d8510ef.

📒 Files selected for processing (3)
  • devtools/verify.py
  • tests/unit/core/test_query_descriptor_parity.py
  • tests/unit/devtools/test_verify.py

Comment thread tests/unit/devtools/test_verify.py Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d8510ef192

ℹ️ 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".

Comment thread tests/unit/devtools/test_verify.py Resolved
The live progress artifact test now runs from a tmp_path cwd so xdist workers and sibling tests cannot race on the repo-level .cache/verify file.
@Sinity
Sinity merged commit 28f7903 into master Jun 18, 2026
11 checks passed
@Sinity
Sinity deleted the feature/test/query-descriptor-parity-2006 branch June 18, 2026 01:33
@Sinity

Sinity commented Oct 1, 2026

Copy link
Copy Markdown
Owner Author

Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.

  • 79.F061 / P2: stale at the checked revision: The local supervisor and the shared global-progress artifact assertion have been removed from the current verifier route. devtools/verify.py:847 binds reports to the active step, then lines 854-855 execute through the pytest slot and lines 867-870 consume its owned terminal outcome instead of the former ResourceSampler loop.

Only the rows listed above are dispositioned. Held findings remain open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant