Repository navigation
Changed-constant check stops flagging unrelated tests for one- and two-digit numbers - #4683
Merged
Merged
Conversation
When a one- or two-digit constant changes, a test file found only through the constant's module now counts as a consumer only on a line that uses a name it took from that module, or names the constant. A comment naming the module beside an unrelated 10 no longer blocks a push, while a test that imports the module and asserts the old value still does. Fixes #4312; rebuilt from #4354, with the narrower rule from the review on it. Co-authored-by: Mahmoud ElNeMR <[email protected]> Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
|
😎 This pull request was merged. |
…lease note's numbers The narrower rule for one- and two-digit values now also follows a variable declared or assigned from an imported name or from the module (const items = listItems(), out = run(...) inside a hook, or a declaration whose module path sits on a continuation line), so those tests still count as consumers. The release note's before/after numbers now come from a recount over gstack's own test tree with the check's real inputs. Review-Finding: p1/red-team#1 reader=red-team Review-Finding: p1/specialist-batched#1 reader=testing Review-Finding: p1/red-team#2 reader=red-team Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
… guard passes Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
This was referenced Nov 22, 2026
Merged
3 tasks done
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.
Changing a small constant such as
MAX_ITEMS = 10no longer flags every test that mentions its module and holds a10somewhere; only lines that use something taken from the module, or name the constant, count.Why: one-line raises of two-digit constants were blocked by dozens of false matches (#4312); on gstack itself, changing
RECEIPT_RUNS_KEPT(30) flagged 20 test files and now flags 4.Nothing to do. Three-digit and longer values keep the old rule, and a test that imports the module and asserts the old value is still caught.
What changed
Raising a one- or two-digit constant used to trip the changed-constant check on every test file that mentioned the constant's module and happened to hold the same small number anywhere, even in a comment or an unrelated timestamp. Now a one- or two-digit old value found through the module counts only on a statement that names the constant or a binding the test takes from the module.
lib/pregate/checks/literals.ts: for a one- or two-digit integer old value (sign not counted, so-10is included), a test file found only through the module counts a line only when its statement names the constant or a binding the file takes from the module: a JS/TS import of it (named, aliased, default, namespace or multi-line; type-only imports excluded) or a variable that a line naming the module declares (const out = run('scripts/arms.ts'),const { a } = require(...)). One-character values keep needing the constant's name.-10, and a three-digit control. Both tests fail on main and pass here.docs/pregate.mdstates the new rule in theliteralsentry.Known trade-off: some tests that really do use a changed one- or two-digit value are no longer reported early. That covers a test that runs the module without taking a binding from it, a typed or array-destructured declaration, and a test that imports the module but asserts through another module's function. Three-digit values still use the old rule, and the full test run still runs every such test.
Rebuilt on current main from #4354 by @ElNeMeR70 (co-author), using the narrower rule @Davmunrey proposed in review so GST-820's two-digit importer case stays covered. Closes #4312.
Security read
Pure text matching over test files the check already reads. Nothing new spawns a process, reads new files, touches the network, auth, CI, install scripts or dependencies. The outside diff was read as text only; no outside branch was fetched or run.
Blast radius
Only the changed-constant check's choice of which test files to warn about moves; it reads the same files as before and starts no process. A warning it no longer gives is still caught when the test itself runs, locally and in the full CI run (confirmed by reading
consumersOfinlib/pregate/checks/literals.tsand by base-vs-head probes over gstack's own test tree).Pre-Landing Review
One read-only full review of the final head by four readers: a batched specialist, a red team, a same-family adversarial reader and a second-model review. None found a defect that fails a test, breaks production or loses data. The second-model review marked two early-warning gaps as blocking (listed below); they were ruled notes because the stale assertion still fails when the test runs.
Review notes
lib/pregate/checks/literals.ts:149(testing): a one- or two-digit value asserted on a statement that names the module inline, with no binding in the file, is no longer reported early.lib/pregate/checks/literals.ts:203(adversarial): typed, array-destructured, defaulted and multi-variable declarations are not followed as bindings, and the look-back stays at three lines.lib/pregate/checks/literals.ts:149(adversarial): a code line naming both the module and the old value no longer counts without a binding.lib/pregate/checks/literals.ts:196(adversarial): binding chains stop after four rounds, and statements are built from text with comment lines removed.lib/pregate/checks/literals.ts:181(second-model review, ruled note): a test that imports the module but asserts through another module's function (for exampletest/design-lint-fifth-cycle.test.ts:112forWAIVER_MIN_REASON) is no longer reported early.lib/pregate/checks/literals.ts:203(second-model review, ruled note):const items: string[] = listItems()is not followed as a binding.Exploratory QA
Smoke: the targeted tests (
test/pregate-selection.test.ts,test/spawnsync-timeout-tripwire.test.ts) passed, 60 tests, and the readers ran base-vs-headconsumersOfprobes on synthetic files and on gstack's own test tree; the probe forWAIVER_MIN_REASON24 -> 25 was rerun independently (base flagstest/design-lint-fifth-cycle.test.ts:112, head does not). No plan checks apply (bug fix). No separate browser or QA charter ran.Documentation
Status: current. No documentation edits were needed in this read-only audit.
Scope: branch
fix/constant-check-short-numbersated2dd06against basec2b4f0d2: 4 committed files (lib/pregate/checks/literals.ts,test/pregate-selection.test.ts,docs/pregate.md,changelog.d/pregate-literals-short-numbers.md). Nothing was staged, unstaged or untracked.Documentation health:
docs/pregate.md: current. Theliteralssection already describes the new rule for one- and two-digit integers: they count only in statements that name the constant or a binding taken from the module, type-only imports are excluded, and local helpers are not followed. This matches the code.docs/troubleshooting.md(PREGATE_LITERALS): current. Its general wording is unaffected.changelog.d/pregate-literals-short-numbers.md: reviewed only, since the release owner owns changelog content. Its file counts were not re-measured.Coverage debt: none found. Diagram drift: none, because no diagrams cover this check.
Issues
Fixes #4312
Refs #4354
Refs p1/red-team#1
Refs p1/red-team#2
Refs p1/specialist-batched#1
Related: #4354 (@ElNeMeR70)
Tests
bun test test/pregate-selection.test.ts test/spawnsync-timeout-tripwire.test.ts: 60 pass, 0 failAgent notes
Agent notes
Lane GSTA-805, issue GST-3487. Repro: ~/.capy/work/gsta-805/zz-gsta805-repro.test.ts on the lane machine. Final read-only review run ship-4683-r2 at ed2dd06.
Approvals
Approved: yes (record r-09272b9fd20d). The full approval record stays private.
Plan: exempt: bug fix
Plan check: exempt bug fix
REVIEW_LOOP: passes=1 blocking_found=2 deferred=0 noted=5 fixed=0 scope=frozen open=2 dispatches=4
Gate edits: none detected (1 listed, 1 read; patterns: RH-1,RH-3,RH-4,RH-12,RH-13,RH-14,RH-15,RH-16; unlisted idioms: none)
Ruled note: lib/pregate/checks/literals.ts:181:outside-voice at ed2dd06 ruled by GSTA-36 (relayed from GSTA-805:2026-11-22T07:14:20Z) at 2026-11-22T07:14:21.157Z: Captain ruled ship with note: pregate early-warning gap, CI and the import-graph tests stage still run the stale assertion (approval a-73a9248ba861)
Ruled note: lib/pregate/checks/literals.ts:203:outside-voice at ed2dd06 ruled by GSTA-36 (relayed from GSTA-805:2026-11-22T07:14:20Z) at 2026-11-22T07:14:21.369Z: Captain ruled ship with note: pregate early-warning gap, CI and the import-graph tests stage still run the stale assertion (approval a-6216073c9fc4)
Refs GST-3487