Skip to content

The stale-test-value check matches tests by resolved import, not file name (GST-3563) - #4723

Merged
capy-ai[bot] merged 3 commits into
mainfrom
stale-test-value-check-resolves-imports
Nov 22, 2026
Merged

capy-ai[bot] merged 3 commits into
mainfrom
stale-test-value-check-resolves-imports

Conversation

@garrytan

@garrytan garrytan commented Nov 22, 2026 •

Copy link
Copy Markdown
Owner

The check that flags tests still holding a changed constant's old value now matches tests by the import that resolves to the changed file, not by file name.
Why: when two files share a name (two config.ts), it flagged tests of the wrong file and a JSON golden nobody could waive, and a list that only gained an item flagged every test still naming the kept item.
What you do: nothing.

What changed

gbrain changed DEFAULT_SESSION_TOKEN_BUDGET from 2000 to 8000 in src/core/skills/resolver/config.ts, and the check flagged 17 tests that import the other src/core/config.ts and contain an unrelated 2000 (since: '2000-01-01', lockWaitMs: 2000). It also flagged an exports golden where "2000" belongs to LONG_PAGE_DEADLINE_MS, and JSON can't hold a waiver comment. Separately, when GSTACK_RETIRED_SKILLS went from "investigate" to "investigate verify", every test line that creates an investigate folder needed a waiver (13 of them, in #4714).

Now:

  • Same-named files. When another file in the repository has the changed file's name, a test counts only if one of its imports or paths resolves to the changed file. That covers relative imports, tsconfig/jsconfig paths and baseUrl, quoted repository paths and join() segments, through the same resolver that picks which tests a change runs. An alias import also counts when the name is unique. Run as text over gbrain's main (5f989a1e) for that change, the old rule flags 17 files by file name alone (16 unrelated, plus test/skill-resolver.test.ts, matched only through an unrelated '../config' string); the new rule flags none.
  • JSON files. An old value counts only where the JSON ties it to the constant: the value of a key with the constant's name, or anything inside a record whose string value is the name ({ "name": "LIMIT_MS", "signature": ["2000"] }). A golden that pins the changed constant still fails. A JSON file that doesn't parse counts only on lines that name the constant. Call-site names (timeout, limit) still need the module named in the file, as they do for other files.
  • A one-item list that only gained items. Lines that use the kept item (paths, fixtures, toContain) no longer count. A line still counts when it asserts the whole old value: toBe/toEqual/===, an assert call, an assignment, or a statement using the constant or a binding from it, such as an alias modes. Multi-item lists and prose keep the old rule. The 13 waivers in test/retired-skills.test.ts are gone.

What this does not catch: a test that reaches the constant only through another module (a barrel or a caller), without naming the constant, isn't flagged. Such a stale value now shows up only when that test runs in CI, not as an early warning from this check. gbrain's one real consumer is like this: test/skill-resolver.test.ts imports resolver/index.ts, and the old check found it only through an unrelated '../config' string. Following every import transitively instead would make 6,606 gbrain files (6,284 of them tests) depend on that one config file.

Blast radius

Only the stale-value check in lib/pregate/checks/literals.ts changes; pathAliasResolver is now exported from lib/pregate/import-graph.ts and otherwise unchanged. When no other file shares the module's name and no alias is configured, matching for code and shell tests is the same as on main (JSON files and grown one-item lists follow the new rules above), and the existing 25 literals tests in test/pregate-selection.test.ts pass unchanged (CI run 45082536135).

Test Coverage

New test/pregate-literals-consumers.test.ts (4 tests) fails at main and passes here: two config.ts files with a test of each (only the real consumer flagged, through a relative import, a @/ alias and an exact alias), JSON goldens (tied, keyed, unrelated, sibling, unparseable, and a call-site key without the module), and the grown list (member uses, membership checks, whole-value assertions, alias and derived bindings, prose and multi-item lists).
Negative control: putting toBe('investigate') back into test/retired-skills.test.ts is flagged again at line 27.
Coverage audit: 9 of 12 paths at first; two of the three gaps (unparseable JSON, unique-name alias) got tests in the review fix. The third is that no test drives run() itself with a twin.

Pre-Landing Review

Two full review rounds plus a second-model review.

  • Fixed in this PR: JSON files had dropped the module requirement for call-site names, so an unrelated fixture with "attempts": 3 would have failed the check with no way to waive it. A folder sharing the module's name (config/README.md) no longer counts as a same-named file.
  • Open notes, ruled to ship as notes: a JSON golden that never names its source module isn't flagged when a call-site value changes (same as main). A same-named folder module (src/x/config/index.ts) isn't treated as a same-named file, so its importers can still be flagged by name (same as main, waivable; a one-line follow-up can add it).
Documentation

Status: current. The docs already describe the new stale-test-value check behavior, so no edits were needed.

Scope: the diff from 50cc296 to 61bf71f (3 commits, 7 files), plus staged, unstaged and new files (none). I read docs/pregate.md, docs/troubleshooting.md and the changelog.d fragment in full against lib/pregate/checks/literals.ts and lib/pregate/import-graph.ts.

Documentation health:

  • docs/pregate.md: current. It explains how name twins are resolved through imports, aliases and paths, how JSON values tied to a constant count, and how a one-item list that only gained items is handled.
  • docs/troubleshooting.md: current. The PREGATE_LITERALS fix text explains that a JSON file cannot hold a waiver marker.
  • changelog.d/stale-test-value-check-resolves-imports.md: current (reviewed, not edited).

Coverage debt: the PREGATE_LITERALS behavior has reference coverage in pregate.md and how-to coverage in troubleshooting.md, which is enough for an internal check. There are no gaps to fill.

Diagram drift: none.

Tests
  • bun run test (the full free suite, CI run 45082536135 at 61bf71f): 1773 test files passed, 0 failed.
  • macOS and Windows jobs at the same head passed: macos-named-regressions and windows-smoke.
  • bun test test/pregate-literals-consumers.test.ts test/pregate-selection.test.ts test/retired-skills.test.ts test/pregate-import-graph-paths.test.ts test/module-size-ratchet.test.ts, bun run typecheck, bun run typecheck:test: pass locally.
Agent notes

Agent notes

Refs GST-3563, GBRA-739, #4714, #4719
Refs #4714

Approvals

Approved: yes (record r-56d7bcc530b5). The full approval record stays private.
Plan: exempt: bug fix, no new functionality (GStack Minder brief)
Plan check: exempt bug fix

REVIEW_LOOP: passes=2 blocking_found=3 deferred=0 noted=3 fixed=5 scope=frozen open=2 unbound=5 dispatches=8
Gate edits: none detected (GATE_SCAN tagged=0)
Ruled note: lib/pregate/checks/literals.ts:222:outside-voice at 79a0e2b ruled by GSTA-36 (relayed from GSTA-36:2026-11-22T23:19Z) at 2026-11-22T23:19:04.955Z: Main also requires the module name for call-site values in every file; no change from main and no test fails. (approval a-8a949b0a4589)
Ruled note: lib/pregate/checks/literals.ts:204:outside-voice at 79a0e2b ruled by GSTA-36 (relayed from GSTA-36:2026-11-22T23:19Z) at 2026-11-22T23:19:05.125Z: Same false-positive behaviour as main for a same-named directory module; waivable, nothing breaks; index-module clause can follow. (approval a-aab4126098fa)

{
  "schema_version": 1,
  "pr": 4723,
  "head": "61bf71f8a3f601950b7d5778f3c7c2f3cd4417d5",
  "version": "1.102.2.0",
  "base": "main",
  "gate": {
    "tests": {
      "pass": 1773,
      "fail": 0,
      "skip": 0
    }
  },
  "ci_carried": [
    {
      "lane": "tests",
      "run": 45082536135,
      "attempt": 1,
      "tree": "2017fd2ca5f7ad7bc901c442f08ac424ed95012b"
    }
  ],
  "calls": 20,
  "session_kind": "unattended",
  "run": "/home/user/.capy/work/ship-gsta816",
  "head_tree": "2017fd2ca5f7ad7bc901c442f08ac424ed95012b",
  "product_patch_id": "53dcc78c8727f1fc2265400305ca5c41eb7aa9ed",
  "gstack_version": "1.102.2.0",
  "review_depth": {
    "depth": "full",
    "class": "gate",
    "runtime_lines": 143,
    "rules": "33831f8248a814fd",
    "base": "50cc296700977b64c8c37ac0dbcb7e6250d1f302",
    "registry": "50cc296700977b64c8c37ac0dbcb7e6250d1f302",
    "gate_scan": {
      "tagged": 0,
      "head": "61bf71f8a3f601950b7d5778f3c7c2f3cd4417d5"
    },
    "reasons": [
      "gate-class",
      "runtime=143"
    ],
    "risk": [],
    "mode": "panel"
  },
  "pregate": "requires-remote cleared @2017fd2ca5f7 (8 checks, current for 61bf71f8a3f6)",
  "requires_remote": [
    "free-tests.yml/macos-named-regressions: https://github.com/garrytan/gstack/actions/runs/45082536135/attempts/1",
    "windows-smoke.yml/windows-smoke: https://github.com/garrytan/gstack/actions/runs/45082536176/attempts/1",
    "pregate.json/remote_gate: remote-gate tree=2017fd2ca5f7 tests=39212 skipped=67 runs=45082536135/1 profiles=ci-reuse/free-tests heads=61bf71f8a3f6 verified=2026-11-22T23:28:20.821Z"
  ],
  "issues": {
    "fixes": [],
    "refs": [
      4714
    ],
    "flakes": []
  },
  "docs": {
    "status": "current",
    "scope": "docs/ and README.md against the diff 50cc2967..61bf71f8"
  },
  "review_loop": {
    "passes": 2,
    "blocking_found": 3,
    "deferred": 0,
    "noted": 3,
    "fixed": 5,
    "scope": "frozen",
    "rounds": 2,
    "unbound": 5,
    "dispatches": {
      "specialist": 6,
      "red-team": 2
    }
  },
  "ruled_notes": [
    {
      "finding": "lib/pregate/checks/literals.ts:222:outside-voice",
      "head": "79a0e2ba8df7d32d3b04a361aaca2d1bfdcc0351",
      "by": "GSTA-36",
      "reason": "Main also requires the module name for call-site values in every file; no change from main and no test fails.",
      "at": "2026-11-22T23:19:04.955Z",
      "approval": "a-8a949b0a4589",
      "relayed": "GSTA-36:2026-11-22T23:19Z"
    },
    {
      "finding": "lib/pregate/checks/literals.ts:204:outside-voice",
      "head": "79a0e2ba8df7d32d3b04a361aaca2d1bfdcc0351",
      "by": "GSTA-36",
      "reason": "Same false-positive behaviour as main for a same-named directory module; waivable, nothing breaks; index-module clause can follow.",
      "at": "2026-11-22T23:19:05.125Z",
      "approval": "a-aab4126098fa",
      "relayed": "GSTA-36:2026-11-22T23:19Z"
    }
  ],
  "gate_dispositions": []
}
{"head":"79a0e2ba8df7d32d3b04a361aaca2d1bfdcc0351","run":"ship-gsta816","status":"started","review_loop":{"passes":1,"blocking_found":1,"deferred":0,"noted":0,"fixed":2,"scope":"frozen","rounds":1,"unbound":8,"dispatches":{"specialist":3,"red-team":1}}}

Open in Capy

… name (GST-3563)

When two files share a name, a test counts as using the changed file only
through an import or path that resolves to it, tsconfig aliases included.
JSON goldens count only where a value sits under the constant's name. A
one-item list that only gained items no longer flags tests that still use
the kept item; a whole-value assertion, through an alias too, still fails.
Removes the 13 waiver markers #4714 needed in test/retired-skills.test.ts.

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 23:07
Review-Finding: p1/red-team#1 reader=red-team
Review-Finding: lib/pregate/checks/literals.ts:197:core reader=core
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 marked this pull request as ready for review November 22, 2026 23:30
@capy-ai
capy-ai Bot merged commit 79f3052 into main Nov 22, 2026
64 of 65 checks passed
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