Skip to content

feat(devtools): add devtools test focused runner so agents avoid raw pytest - #1786

Merged
Sinity merged 1 commit into
masterfrom
feature/feat/devtools-test-runner
Jun 5, 2026
Merged

Sinity merged 1 commit into
masterfrom
feature/feat/devtools-test-runner

Conversation

@Sinity

@Sinity Sinity commented Jun 5, 2026

Copy link
Copy Markdown
Owner

Summary

Adds devtools test <pytest args> — a focused inner-loop runner that routes a
selection through the managed harness, so agents and humans never hand-roll raw
pytest. Complements devtools verify (the full gate); it is not a substitute.

Problem

devtools owned the full verification gate (verify) but had no comfortable
entrypoint for "run this file / -k expr / directory." The result: agents reach
for raw pytest, hand-rolling worker counts, env, and tmpfs handling — exactly
the ad-hoc path that, in a recent session, led to launching overlapping suites
that raced on shared test state and produced false failures.

Solution

devtools/run_tests.py (devtools test):

  • Forwards any selection (paths, -k/-m, -x, …) to pytest via the
    control-plane dispatch's existing passthrough (allow_extra_args /
    ignore_unknown_options).
  • Managed environment parity with verify (POLYLOGUE_ROOT,
    POLYLOGUE_REPO_ROOT, repo-local PYTHONPYCACHEPREFIX).
  • Single-process default (-n 0) for fast focused runs; override with an
    explicit -n or POLYLOGUE_PYTEST_WORKERS.
  • Live, streamed output (unlike verify, which captures for aggregation).
  • A checkout-scoped flock serializes overlapping devtools test runs so two
    suites from one checkout don't burn CPU racing. Correctness under concurrency
    is already guaranteed by the per-run tmpfs basetemp (fix(tests): isolate concurrent pytest runs with per-run tmpfs basetemp #1785); this lock is the
    throughput guard. POLYLOGUE_TEST_NO_LOCK=1 bypasses it.
  • Empty selection prints guidance and exits 2 (does not silently run the whole
    suite — that's devtools verify).

Registered as a featured catalog command; docs/devtools.md + AGENTS.md
regenerated; TESTING.md steers the inner loop to devtools test.

Verification

devtools test tests/unit/devtools/test_run_tests.py   -> 7 passed (dogfooded, -n 0)
# two concurrent runs, same selection:
  -> exactly one printed "waiting for in-flight run"; both passed (lock works)
devtools verify --quick   -> EXIT 0 (ruff/mypy/render-all/verify-doc-commands + all gates)

New unit tests in tests/unit/devtools/test_run_tests.py cover worker-default
and override, --json stripping, the no-selection guard, exit-code
passthrough, and managed-env contents.

…w pytest

Problem: devtools exposes `verify` (the full gate) but no comfortable way to
run a focused selection, so agents reach for raw pytest and hand-roll worker
flags, env, and tmpfs handling. That ad-hoc path is how a recent session ended
up launching overlapping suites that raced on shared test state.

What changed:
- New `devtools test <pytest args>` command (devtools/run_tests.py). Forwards
  any selection (paths, -k/-m, -x, …) to pytest with the managed environment
  (POLYLOGUE_ROOT + repo-local pycache), a single-process worker default
  (-n 0; override via -n or POLYLOGUE_PYTEST_WORKERS), and live streamed output.
- Checkout-scoped flock serializes overlapping `devtools test` runs so two
  suites from the same checkout don't burn CPU racing. Concurrency is already
  correctness-safe at the conftest level (#1785 per-run basetemp); this lock is
  the throughput guard. POLYLOGUE_TEST_NO_LOCK=1 bypasses it.
- Registered in the command catalog (featured); regenerated docs/devtools.md
  and AGENTS.md. TESTING.md now steers the inner loop to `devtools test`.

Verification:
- nix develop -c devtools test tests/unit/devtools/test_run_tests.py -> 7 passed
  (dogfooded; single-process).
- Two concurrent `devtools test` on the same selection: exactly one printed
  "waiting for in-flight run", both passed (lock serializes).
- nix develop -c devtools verify --quick -> EXIT 0 (ruff/mypy/render-all/
  verify-doc-commands and all gates green).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Copilot AI review requested due to automatic review settings June 5, 2026 08:15
@coderabbitai

coderabbitai Bot commented Jun 5, 2026

Copy link
Copy Markdown

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 36 minutes and 17 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ 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.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

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: 9bbdd45d-5fb1-45ca-b8c8-fb5b86644c3b

📥 Commits

Reviewing files that changed from the base of the PR and between e789ca5 and 92ba04c.

📒 Files selected for processing (6)
  • AGENTS.md
  • TESTING.md
  • devtools/command_catalog.py
  • devtools/run_tests.py
  • docs/devtools.md
  • tests/unit/devtools/test_run_tests.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/feat/devtools-test-runner

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.

Copilot AI 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.

Pull request overview

This PR introduces a new focused test runner, devtools test, to route inner-loop pytest selections through Polylogue’s managed devtools harness (parity env setup, single-process default, and checkout-scoped serialization), reducing ad-hoc raw pytest usage and preventing overlapping runs from the same checkout.

Changes:

  • Added devtools test implementation (devtools/run_tests.py) with managed environment, default -n 0, optional worker override, and a checkout-scoped flock.
  • Registered devtools test in the devtools command catalog and updated developer documentation to steer inner-loop testing to it.
  • Added unit tests covering command construction, selection guardrails, dispatch --json stripping, exit-code passthrough, and managed env contents.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
devtools/run_tests.py Implements the new devtools test runner (env parity, worker defaulting, lock, pytest invocation).
devtools/command_catalog.py Registers devtools test as a featured verification command.
tests/unit/devtools/test_run_tests.py Adds unit coverage for devtools test behavior and guardrails.
TESTING.md Updates testing guidance to prefer devtools test for focused runs.
docs/devtools.md Documents devtools test among recommended devtools commands.
AGENTS.md Regenerates agent guidance to prefer devtools test for focused runs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread devtools/run_tests.py
with _LOCK_PATH.open("a+") as handle:
try:
fcntl.flock(handle.fileno(), fcntl.LOCK_EX | fcntl.LOCK_NB)
except OSError:
@Sinity
Sinity merged commit 15af28c into master Jun 5, 2026
6 checks passed
@Sinity
Sinity deleted the feature/feat/devtools-test-runner branch June 5, 2026 08:25
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.

2 participants