Repository navigation
The stale-test-value check matches tests by resolved import, not file name (GST-3563) - #4723
Merged
Merged
Conversation
… 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>
|
😎 This pull request was merged. |
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>
This was referenced Nov 23, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_BUDGETfrom 2000 to 8000 insrc/core/skills/resolver/config.ts, and the check flagged 17 tests that import the othersrc/core/config.tsand contain an unrelated2000(since: '2000-01-01',lockWaitMs: 2000). It also flagged an exports golden where"2000"belongs toLONG_PAGE_DEADLINE_MS, and JSON can't hold a waiver comment. Separately, whenGSTACK_RETIRED_SKILLSwent from"investigate"to"investigate verify", every test line that creates aninvestigatefolder needed a waiver (13 of them, in #4714).Now:
pathsandbaseUrl, quoted repository paths andjoin()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, plustest/skill-resolver.test.ts, matched only through an unrelated'../config'string); the new rule flags none.{ "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.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 aliasmodes. Multi-item lists and prose keep the old rule. The 13 waivers intest/retired-skills.test.tsare 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.tsimportsresolver/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.tschanges;pathAliasResolveris now exported fromlib/pregate/import-graph.tsand 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 intest/pregate-selection.test.tspass unchanged (CI run 45082536135).Test Coverage
New
test/pregate-literals-consumers.test.ts(4 tests) fails at main and passes here: twoconfig.tsfiles 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 intotest/retired-skills.test.tsis 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.
"attempts": 3would 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.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:
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.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)