Skip to content

fix(pregate): root tests in two languages each get their own runner - #3600

Closed
vilano93 wants to merge 1 commit into
garrytan:mainfrom
vilano93:fix/pregate-mixed-rest-runner
Closed

vilano93 wants to merge 1 commit into
garrytan:mainfrom
vilano93:fix/pregate-mixed-rest-runner

Conversation

@vilano93

@vilano93 vilano93 commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Why (in your own words)

A repo whose root tests come in two languages never gets a lanes run. Root-owned tests are the ones in no Cargo crate, nested JS package or Dart package. They all go through one detectRunner call. That call returns pytest only when every file is .py, and node --test only when every file is .js/.mjs. So scripts/doku-gate.test.mjs + scripts/version-gate.test.mjs + scripts/local-targets/test_prepare_native_culling_assets.py get no runner at all. The lane is PREGATE_INCOMPLETE, and the receipt is never written. The fix line asks for one declared runner. One command can't run both languages without a hand-written dispatcher script.

With this change, when no single runner fits the whole root group, the group is split by language and each part is detected on its own. A root that already gets one runner (bun, vitest, jest, a single language) keeps today's plan. A file no runner claims stays unclaimed, so the lane is still incomplete for it, never a pass.

Live evidence

The real repo: a Cargo workspace in engine/, a pnpm+vitest package in app/, no root package.json, and root tests in scripts/ written in both .mjs and Python. The throwaway branch touches exactly those three root tests.

# installed 1.91.275.0
$ gstack-pregate run --stage tests --only lanes --base origin/main --allow-repo-commands
    lanes: requires-remote ci.yml/app (linux): 3 test(s) — scripts/doku-gate.test.mjs scripts/local-targets/test_prepare_native_culling_assets.py scripts/version-gate.test.mjs
    lanes: fix: declare `runner` (with {files}) in .gstack/pregate.json
PREGATE: incomplete … checks=1
gstack-pregate: lanes: no test runner detected for 3 of 3 selected file(s): scripts/doku-gate.test.mjs scripts/local-targets/test_prepare_native_culling_assets.py scripts/version-gate.test.mjs; fix: declare `runner` (with {files}) in .gstack/pregate.json (PREGATE_INCOMPLETE)

# this branch, same command
    lanes: ran: node --test 'scripts/doku-gate.test.mjs' 'scripts/version-gate.test.mjs' && python3 -m pytest 'scripts/local-targets/test_prepare_native_culling_assets.py'
    lanes:   /opt/homebrew/opt/[email protected]/bin/python3.15: No module named pytest
PREGATE: fail … checks=1

Both languages now run. This machine has no pytest, so the Python half exits 1. Pregate reports that as PREGATE_LANE_FAILED ("fix the in-branch failure") instead of PREGATE_ENVIRONMENT. That misattribution already exists on main for any .py selection and is not part of this change. It is filed with a main-only repro as #3598.

The new test was red first, then green:

# test/pregate-selection.test.ts on upstream main (94165fff3)
(fail) nested JS packages run their own runner from their own directory > root tests in two languages plan one group per language; a file no runner claims stays unclaimed
-   "groups": [ node --test …mjs, python3 -m pytest …py ]
+   "groups": [],
+   "unclaimed": [ "scripts/doku-gate.test.mjs", "scripts/test_assets.py", "scripts/version-gate.test.mjs" ]
# after
(pass)

Scope

  • Changed:
    • lib/pregate/checks/lanes.ts (planRuns): when detectRunner finds no single runner for the root group, the group is split by language (.py, .js/.mjs/.cjs, other JS/TS) and each part is detected separately. Any other file is its own part, so it stays unclaimed as before.
    • test/pregate-selection.test.ts: one plan-level case. It covers a .mjs + .py selection getting both runners, and a .mjs + .bats selection running the .mjs while the .bats stays unclaimed.
  • Verified live by:
    • the before/after runs on the real repo above;
    • bun run typecheck: clean;
    • bun run typecheck:test: "814 known diagnostics, none new".
  • Compared with a clean upstream/main worktree on macOS:
    • test/pregate-selection.test.ts fails the same 4 gstack-pregate (bin) tests on both (macOS host, as noted in fix(pregate): Rust crate lanes and nested JS package runners (#3344) #3346). The new case passes only on this branch.
    • bun run test on this branch fails tests in 12 files, none of them in pregate lane planning: capy wrapper, codex probe, cso, doctor, pregate remote, qa, ship-receipt carry, test-free-shards settlement, ubicloud, update-check. I ran those 12 files on both trees. Main fails 126 and this branch fails 125. No test fails only on this branch. The one extra failure on main is test-free-shards … endpoint-mix, which is flaky.
  • Did NOT test:
    • Windows;
    • a declared runner is unchanged by construction (planRuns returns before this code), and the existing negative control covers it.
  • Left alone: pregate: a missing pytest is PREGATE_LANE_FAILED (blames the diff), not PREGATE_ENVIRONMENT #3598 (a missing pytest blames the diff).

Liveness proof (required for external contributors)

SCR-20261029-ixel

Checklist

🤖 Generated with Claude Code

Root-owned tests (no Cargo crate, no nested JS package, no Dart package) went
through one detectRunner call. It returns pytest only when every file is .py
and node --test only when every file is .js/.mjs, so a selection holding
scripts/*.test.mjs and a test_*.py got no runner at all: PREGATE_INCOMPLETE,
with a fix line asking for one declared `runner` that cannot serve both.

When no single runner fits the whole root group, split it by language and
detect each part. A root that already gets one runner (bun, vitest, jest, one
language) keeps today's plan; a file no runner claims stays unclaimed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@trunk-io

trunk-io Bot commented Oct 29, 2026

Copy link
Copy Markdown

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

@capy-ai

capy-ai Bot commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

Thank you for this fix. A crew lane is picking it up, together with your related pregate PRs, to land on current main with Co-authored-by credit to you.

capy-ai Bot added a commit that referenced this pull request Nov 2, 2026
…s; literals stops flagging stray digits (#3598, #3492) (#3741)

* fix(pregate): runner detection for pytest, Playwright and mixed-language roots; literals binds one-character values

A missing pytest is PREGATE_ENVIRONMENT, not the diff's failure (#3598).
Playwright specs run under playwright test, with missing browsers reported
as the machine's gap (#3629). Root tests in two languages each get their
runner, and a repo's bun/vitest/jest claims only JS/TS (#3600). literals
counts a one-character old value only in a statement naming the constant,
and a call-site name also needs the module (#3492, gstack-evals#97).

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

* fix: pre-landing review fixes

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

* docs(pregate): name the import-type shapes the Playwright detection skips

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

* fix: escape Playwright file filters; skip type-only Playwright imports; pytest probe and summary read hardening

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

* fix(pregate): linear Playwright import scan; comments and no-space imports detected

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

* docs(pregate): Playwright missing-browsers exception and literals continuation rule

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

---------

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@capy-ai

capy-ai Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Thanks @vilano93. This landed in v1.93.15.0 as #3741: root tests in two languages now each get their own runner (.py gets pytest, .mjs gets node --test), and bun, vitest and jest claim only JS/TS files. The fix was rewritten on current main rather than merged from this branch (our policy for outside code), and the idea is credited in the changelog. Closing this PR in favor of that change.

@capy-ai capy-ai Bot closed this Nov 2, 2026
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