Skip to content

Test selection finds tests for NodeNext .js imports and Rails specs - #4679

Merged
capy-ai[bot] merged 3 commits into
mainfrom
fix/test-selection-nodenext-js-and-rspec
Nov 22, 2026
Merged

capy-ai[bot] merged 3 commits into
mainfrom
fix/test-selection-nodenext-js-and-rspec

Conversation

@garrytan

@garrytan garrytan commented Nov 22, 2026 •

Copy link
Copy Markdown
Owner

In TypeScript repos that import ./x.js for x.ts (NodeNext) and in Rails repos, touched source files now get their tests instead of none.
Why: /verify and /ship found no tests for these files even though tests covered the files (#4398, #4211).
Nothing to do: a Rails file maps only when its spec exists at the conventional path.

What changed
  • lib/pregate/import-graph.ts: an import written as ./x.js (or .jsx, .mjs, .cjs) resolves to its TypeScript source first (x.ts, then x.tsx; .tsx, .mts, .cts), as tsc does, then to the path as written. Path string literals keep naming the file as written.
  • Same file: an RSpec spec at [<root>/]spec/<path>_spec.rb selects [<root>/]app/<path>.rb or [<root>/]<path>.rb when that file exists, at the repo root or under an engine's root.
  • Tests in test/pregate-import-graph-paths.test.ts and the new test/pregate-rspec-convention.test.ts; docs/pregate.md documents both rules.
Why

Test selection found no tests for these files, so the checks stopped or asked for hand-written mappings (#4398). Rebuilt on current main from #4401 by @mikhailsal and #4211 by @ikraamg, credited as co-authors.

Blast radius

Only test selection changes, and almost always more files map to tests. One narrow loss: when a committed x.js sits beside its x.ts source, a plain-JS file that imports ./x.js now maps to x.ts, so a test that reaches x.js only through that file is no longer selected locally for a change to x.js (CI still runs it). A repo whose declared runner cannot run Ruby treats a mapped spec as not run and not counted, as it does for Python today; with no remote check configured, nothing then runs that spec before CI. The docs' note that request and system specs are not mapped holds only because no app/requests/ or app/system/ source normally exists; the rule itself does not exclude them.

Documentation

Scope: the branch diff against c2b4f0d2. It changes the test selector in lib/pregate/import-graph.ts, adds two tests, and adds a changelog.d fragment. The working tree had no staged, unstaged or untracked changes. Result: docs/pregate.md (test selection) now lists RSpec's spec/_spec.rb to app/.rb or .rb convention, including engine roots, and says request and system specs are not mapped. It also documents that NodeNext emitted-extension imports (./x.js for x.ts or x.tsx, .jsx to .tsx, .mjs to .mts, .cjs to .cts) resolve to their TypeScript source first, before the path as written. The changelog.d fragment was already accurate. Debt: none found; no other doc describes selector resolution.

Agent notes

Plan: exempt: bug fix

Ruled note: lib/pregate/import-graph.ts:556:outside-voice at 549f94b ruled by GSTA-36 (relayed from GSTA-36:2026-11-22T06:36:45Z) at 2026-11-22T06:36:45.607Z: documented pass-with-note policy for runner-dropped files; below the blocking floor (approval a-6a010a528991)

Review notes (below the blocking floor, not fixed): a nested spec/lib/spec/ path loses its root mapping; TS-first resolution also applies when the importer is plain .js; vi.mock('../x.js') literals do not reach x.ts (no worse than main).

Fixes #4398
Refs #4211
Refs #4401
Refs p1v/adversarial-native#1
Refs p1v/adversarial-native#2
Refs p1v/adversarial-native#3
Refs p1v/outside-voice#2
Refs p1v/outside-voice#3
Related: #4401 (@mikhailsal)

Approvals

Approved: yes (record r-de9ed29ebdfc). The full approval record stays private.
Plan: exempt: bug fix
Plan check: exempt bug fix

{
  "schema_version": 1,
  "pr": 4679,
  "head": "32afbaa5c8b8ea402fc04eb5a6a418be8fcf61ab",
  "version": "1.102.2.0",
  "base": "main",
  "gate": {
    "pregate-focused": {
      "pass": 147,
      "fail": 0,
      "skip": 0
    },
    "free-suite": {
      "pass": 1744,
      "fail": 0,
      "skip": 0
    }
  },
  "ci_carried": [
    {
      "lane": "free-suite",
      "run": 45009721305,
      "attempt": 1,
      "tree": "9573af3567ee67ba54b1a7138bde045591106e1c"
    }
  ],
  "calls": 53,
  "session_kind": "unattended",
  "run": "ship-4679",
  "head_tree": "9573af3567ee67ba54b1a7138bde045591106e1c",
  "product_patch_id": "49b44333fba7408fd21bfb28c5e092695644a3c7",
  "gstack_version": "1.102.2.0",
  "review_depth": {
    "depth": "full",
    "class": "gate",
    "runtime_lines": 28,
    "rules": "630fd3101899e28e",
    "base": "7c0659a69fd731e20a9dd3833eb0a6a8aa165bdf",
    "registry": "7c0659a69fd731e20a9dd3833eb0a6a8aa165bdf",
    "gate_scan": {
      "tagged": 0,
      "head": "32afbaa5c8b8ea402fc04eb5a6a418be8fcf61ab"
    },
    "reasons": [
      "gate-class",
      "runtime=28"
    ],
    "risk": [],
    "mode": "panel"
  },
  "pregate": "requires-remote cleared @9573af3567ee (8 checks, current for 32afbaa5c8b8)",
  "requires_remote": [
    "free-tests.yml/macos-named-regressions: https://github.com/garrytan/gstack/actions/runs/45009721305/attempts/1",
    "windows-smoke.yml/windows-smoke: https://github.com/garrytan/gstack/actions/runs/45008710980/attempts/1",
    "pregate.json/remote_gate: remote-gate tree=9573af3567ee tests=38819 skipped=67 runs=45009721305/1 profiles=ci-reuse/free-tests heads=32afbaa5c8b8 verified=2026-11-22T10:08:33.030Z"
  ],
  "issues": {
    "fixes": [
      4398
    ],
    "refs": [
      4211,
      4401
    ],
    "flakes": [],
    "related": [
      {
        "pr": 4401,
        "author": "mikhailsal",
        "closes": [
          4398
        ]
      }
    ]
  },
  "docs": {
    "status": "updated",
    "scope": "docs/, README.md and CONTRIBUTING.md against the branch diff; docs/pregate.md updated"
  },
  "review_loop": {
    "passes": 2,
    "blocking_found": 6,
    "deferred": 0,
    "noted": 3,
    "fixed": 5,
    "scope": "frozen",
    "rounds": 2,
    "dispatches": {
      "specialist": 6,
      "red-team": 2
    }
  },
  "review_round_grants": [
    {
      "kind": "fix-check",
      "head": "549f94b2914d7655f05f1fd3ae96baa850eab3fd",
      "pr": 4679,
      "by": "GSTA-36",
      "reason": "one scoped fix-check so the five already-fixed Step 11 findings bind; no code change.",
      "at": "2026-11-22T07:14:39.288Z",
      "approval": "a-47752d589b41",
      "stop_run": "ship-4679",
      "findings": [
        "p1v/adversarial-native#1",
        "p1v/adversarial-native#2",
        "p1v/adversarial-native#3",
        "p1v/outside-voice#2",
        "p1v/outside-voice#3"
      ]
    }
  ],
  "ruled_notes": [
    {
      "finding": "lib/pregate/import-graph.ts:556:outside-voice",
      "head": "549f94b2914d7655f05f1fd3ae96baa850eab3fd",
      "by": "GSTA-36",
      "reason": "documented pass-with-note policy for runner-dropped files; below the blocking floor",
      "at": "2026-11-22T06:36:45.607Z",
      "approval": "a-6a010a528991",
      "relayed": "GSTA-36:2026-11-22T06:36:45Z"
    }
  ],
  "gate_dispositions": []
}

Test selection now follows a TypeScript import written with the emitted
extension (./x.js for x.ts) to its source, and maps a Rails file under app/
or lib/ to its RSpec spec by path, so these files no longer report no test
lane. Fixes #4398; rebuilt from #4401 and #4211.

Co-authored-by: mikhailsal <[email protected]>
Co-authored-by: Ikraam Ghoor <[email protected]>
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@trunk-io

trunk-io Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

😎 This pull request was merged.

garrytan and others added 2 commits November 22, 2026 06:06
…e specs

An import written as ./x.js now resolves to x.ts or x.tsx before a compiled x.js, as tsc does; filesystem literals keep their path as written, so a .js-named fixture directory keeps its edge; and an RSpec spec under an engine's own spec/ maps to that engine's app/ and lib/ files. The changelog fragment now says exactly which cases are covered.

Review-Finding: p1v/adversarial-native#1 reader=adversarial-native
Review-Finding: p1v/adversarial-native#2 reader=adversarial-native
Review-Finding: p1v/adversarial-native#3 reader=adversarial-native
Review-Finding: p1v/outside-voice#2 reader=outside-voice
Review-Finding: p1v/outside-voice#3 reader=outside-voice
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…uide

docs/pregate.md now lists the RSpec spec-to-source convention, including engine roots, and explains that NodeNext imports written with the .js extension resolve to their TypeScript source first.

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

pregate: NodeNext './x.js' imports of x.ts are not resolved, so every touched TS source is UNMAPPED / no test lane

1 participant