Skip to content

loopguard: a test run spelled the Windows way, or through py, is not counted as a verification #338

Backlog

Description

status_of_tests in tokeneconomizer/loopguard/turn.py does not read a test run named the Windows way: with backslashes, a drive letter or .exe (C:\repo\.venv\Scripts\python.exe -m pytest, .venv\Scripts\pytest.exe, python.exe -m pytest), or through the Windows py launcher (py -m pytest, py -3.12 -m pytest). That is how Claude Code's PowerShell tool records a command on Windows. A failing run after the last edit then leaves the turn counted as ended green, and it feeds the envelope.

The micro-skills observer already reads the backslash and .exe forms as test runs; test_a_windows_interpreter_path_is_the_interpreter (from #268) pins that for micro-skills. The py launcher is the default way to start Python on Windows per CPython's "Using Python on Windows" docs ("To launch your default runtime, run python or py", with a -V:<tag> or -3.x option to choose a version).

Reproduction (offline):

from tokeneconomizer.loopguard.turn import status_of_tests
from tokeneconomizer.microskills.observe import classify_command

for cmd in [r"C:\repo\.venv\Scripts\python.exe -m pytest", r".venv\Scripts\pytest.exe -q",
            "python.exe -m pytest", "py -3.12 -m pytest"]:
    print(cmd, "->", status_of_tests(cmd), [o.intent for o in classify_command(cmd)])

Expected: own from the loop guard for all four
Actual: None for all four, while the observer reads the first three as run_tests

Upstream main: 747b801
Python 3.13.18, Linux

Activity

  1. github-actions commented on Nov 26, 2026

    @github-actions

    Scout plan

    Issue: #338 — loopguard: a test run spelled the Windows way, or through py, is not counted as a verification

    Understanding

    status_of_tests (tokeneconomizer/loopguard/turn.py:222) matches VERIFY_RE (line 56), whose path prefixes only accept / and whose Python pattern _PYTHON (line 40) only accepts python[N[.M]]. So C:\repo\.venv\Scripts\python.exe -m pytest, .venv\Scripts\pytest.exe, python.exe -m pytest, and py -3.12 -m pytest return None, and a failing run after the last edit is counted as a green turn. The end state is "own" for all four, matching the micro-skills observer, which already strips the dir and .exe (microskills/observe.py:840). Note that PR #339 is already open against this issue; this plan is the same change, so reviewing or confirming it should not duplicate that work.

    Approach

    1. tokeneconomizer/loopguard/turn.py, _PYTHON: let the interpreter name be python\d?(?:\.\d+)? with an optional .exe, or the py launcher with an optional version option (-3, -3.12, -V:3.12, -V:Company/Tag), before the existing option group. Keep it case-insensitive (PY.EXE) and keep py from matching longer words (pytest and pyflakes must not read as the launcher; the existing (?![\w.\-/]) tail and the \s+-m requirement already guard this).
    2. Same file, VERIFY_RE: add a shared path-prefix fragment accepting / or \ separators and an optional drive ([A-Za-z]:), replacing the two (?:~?/)?(?:[\w.\-]+/)* prefixes, and an optional .exe after the bare runners (pytest, py.test, tox, nox, and ideally the other bare runners such as jest, vitest). Keep the final (?![\w.\-/]), extended with \\, so pytest.exe ends the word but pytest.ini and pytest-cov do not.
    3. Same file, _quiet (line 191) and _pieces (line 165): os.path.basename on Linux does not split backslashes, so C:\Windows\System32\grep.exe is not seen as quiet. Optional: reuse the basename helper from observe.py (line 840) without importing across mechanisms in a way that breaks the layout. If it is not shared cleanly, leave it out and say so in the PR.
    4. Tests: add tests/test_loopguard_windows_paths.py in the style of tests/test_loopguard_hatch_test.py. Parametrize the four commands from the issue plus py -V:3.12 -m pytest, PY.EXE -m pytest, and .venv\Scripts\pytest.exe -q against "own". Add negatives (pytest.ini, pyflakes x.py, py script.py, py -m pip install pytest, python.exe -m pytest --collect-only) against None. Add a ... | findstr FAIL case for "hidden". Add a parity test against classify_command for the non-py forms.
    5. No on-disk names, event kinds, or settings change, and no plugin text is touched.

    Verification

    • python -m pytest tests/test_loopguard_windows_paths.py tests/test_live_core.py tests/test_loopguard_python_runners.py tests/test_loopguard_productive_turns.py -q
    • python -m pytest tests experiments/tests
    • Run the reproduction from the issue and confirm own for all four.
    • Check recorded sessions: replay any stored Claude Code PowerShell sessions and Linux sessions through loopguard and confirm that turn verdicts are unchanged on Linux and that the Windows ones now count as verified.

    Open questions

    None


    Reply confirm to have scout implement this plan on a scout/issue-338 branch and link a one-click pull request (write access required). Reply /scout to plan again after editing the issue; text after the command is guidance for the new plan.

    Generated by Scout for #338 · claude · sonnet55 · ~16 AIC · ⌖ ~16 AIC · ⊞ 2.6K · ◷

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions