You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
loopguard: pnpm --filter web test, npm -w web test, npm t and pnpm vitest run are not counted as test runs #335
The loop guard's test-run pattern (VERIFY_RE in tokeneconomizer/loopguard/turn.py) reads npm test, pnpm test and yarn test only right after the package manager. It misses:
a workspace or folder named first, as monorepos do: pnpm --filter web test, pnpm -r test, npm -w web test, npm --prefix web test, yarn --cwd web test, yarn workspace web test
npm's and pnpm's aliases of test: npm t, npm tst, pnpm t
pnpm and yarn running an installed runner by name: pnpm vitest run, pnpm jest, yarn jest, yarn vitest run
So when one of these fails after the last edit, the turn still counts as ended green and feeds the envelope.
I'd like to fix this: read each manager's own options (with the value of those that take one: npm's -w/--workspace and -C/--prefix, pnpm's -F/--filter and -C/--dir, yarn's --cwd), the aliases, and the runners, with tests for what should and should not count. I'll open a PR shortly.
Issue:#335 — loopguard: pnpm --filter web test, npm -w web test, npm t and pnpm vitest run are not counted as test runs
Understanding
VERIFY_RE in tokeneconomizer/loopguard/turn.py (line ~66) matches (?:npm|pnpm|yarn|bun)\s+(?:run\s+)?test only, so manager options before the script, the t/tst aliases, and pnpm|yarn <runner> are read as non-test commands. A failing run of those after the last edit then counts as a green turn end. The end state is that these forms count as test runs, while non-runs (installs, --help, wrong script names) still do not. The issue author says they will open the PR.
Approach
In tokeneconomizer/loopguard/turn.py, add a named sub-pattern (like _GRADLE_TASKS or _MAKE_VALUE) for each manager's options before the script, and use it in VERIFY_RE in place of the bare (?:npm|pnpm|yarn|bun)\s+(?:run\s+)?test:
npm: -w/--workspace and -C/--prefix take a value (= or space); other -x/--long flags do not. -ws, --workspaces take none.
pnpm: -F/--filter and -C/--dir take a value; -r/--recursive takes none.
yarn: --cwd takes a value; yarn workspace <name> test is its own form.
Aliases: npm t|tst|test, pnpm t|test (npm accepts run test/run-script; keep the existing run). Do not add yarn t.
Keep the option value tokens bounded (no nested unbounded (\S+\s*)*), as the make pattern's comment warns about backtracking. Keep the final (?![\w.\-/]) guard so npm test:unit-style and pnpm tsx stay judged as before.
Check the interaction with _PREFIX_RE (pnpm exec/yarn dlx prefixes) and _NOT_A_RUN_RE: pnpm --filter web test --help must still not count. -w/--prefix values that look like test (npm --prefix test install) must not match.
Tests: add a parametrized case in tests/test_loopguard_productive_turns.py (or a new tests/test_loopguard_node_runners.py) calling VERIFY_RE.match(_PREFIX_RE.sub("", cmd)) or going through TurnGuard.fold, with positives (every form listed in the issue) and negatives (npm install, pnpm --filter web build, npm --prefix test install, npm run testbed, pnpm --filter web test --help, yarn workspace web add x). Also add a TurnGuard case showing a failed pnpm --filter web test after an edit is not a green turn end.
No on-disk state, setting or event-kind names change, and no plugin user-visible text changes.
Replay a few recorded Node/pnpm sessions through TurnGuard before and after, and confirm only the turns that ran the newly matched forms change their verdict. Also time the regex on a long option line to rule out backtracking.
Open questions
None.
Reply confirm to have scout implement this plan on a scout/issue-335 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 #335 · claude · sonnet55 · ~17 AIC · ⌖ ~16 AIC · ⊞ 2.6K · ◷
Activity
github-actions commentedon Nov 26, 2026
Scout plan
Issue: #335 — loopguard: pnpm --filter web test, npm -w web test, npm t and pnpm vitest run are not counted as test runs
Understanding
VERIFY_REintokeneconomizer/loopguard/turn.py(line ~66) matches(?:npm|pnpm|yarn|bun)\s+(?:run\s+)?testonly, so manager options before the script, thet/tstaliases, andpnpm|yarn <runner>are read as non-test commands. A failing run of those after the last edit then counts as a green turn end. The end state is that these forms count as test runs, while non-runs (installs,--help, wrong script names) still do not. The issue author says they will open the PR.Approach
In
tokeneconomizer/loopguard/turn.py, add a named sub-pattern (like_GRADLE_TASKSor_MAKE_VALUE) for each manager's options before the script, and use it inVERIFY_REin place of the bare(?:npm|pnpm|yarn|bun)\s+(?:run\s+)?test:-w/--workspaceand-C/--prefixtake a value (=or space); other-x/--longflags do not.-ws,--workspacestake none.-F/--filterand-C/--dirtake a value;-r/--recursivetakes none.--cwdtakes a value;yarn workspace <name> testis its own form.npm t|tst|test,pnpm t|test(npm acceptsrun test/run-script; keep the existingrun). Do not addyarn t.pnpm|yarn (?:exec\s+)?(?:jest|vitest|mocha|ava|playwright test).Keep the option value tokens bounded (no nested unbounded
(\S+\s*)*), as themakepattern's comment warns about backtracking. Keep the final(?![\w.\-/])guard sonpm test:unit-style andpnpm tsxstay judged as before.Check the interaction with
_PREFIX_RE(pnpm exec/yarn dlxprefixes) and_NOT_A_RUN_RE:pnpm --filter web test --helpmust still not count.-w/--prefixvalues that look liketest(npm --prefix test install) must not match.Tests: add a parametrized case in
tests/test_loopguard_productive_turns.py(or a newtests/test_loopguard_node_runners.py) callingVERIFY_RE.match(_PREFIX_RE.sub("", cmd))or going throughTurnGuard.fold, with positives (every form listed in the issue) and negatives (npm install,pnpm --filter web build,npm --prefix test install,npm run testbed,pnpm --filter web test --help,yarn workspace web add x). Also add aTurnGuardcase showing a failedpnpm --filter web testafter an edit is not a green turn end.No on-disk state, setting or event-kind names change, and no plugin user-visible text changes.
Verification
python -m pytest tests/test_loopguard_productive_turns.py tests/test_loopguard_jvm_builds.py tests/test_live_core.py -qpython -m pytest tests experiments/tests -qTurnGuardbefore and after, and confirm only the turns that ran the newly matched forms change their verdict. Also time the regex on a long option line to rule out backtracking.Open questions
None.
Reply
confirmto have scout implement this plan on ascout/issue-335branch and link a one-click pull request (write access required). Reply/scoutto plan again after editing the issue; text after the command is guidance for the new plan.