Skip to content

Stop the pre-push check flagging real files whose names start with tmp or scratch (GST-1944) - #4177

Merged
capy-ai[bot] merged 3 commits into
mainfrom
stop-pregate-flagging-tmp-prefixed-files
Nov 8, 2026
Merged

capy-ai[bot] merged 3 commits into
mainfrom
stop-pregate-flagging-tmp-prefixed-files

Conversation

@garrytan

@garrytan garrytan commented Nov 8, 2026 •

Copy link
Copy Markdown
Owner

The pre-push check's stray-file rule stops flagging real files whose names merely start with tmp or scratch, and still catches every real scratch name.

  • What works: tmp and scratch now match only as the whole name stem, optionally numbered. tmp-watch.js, tmpfs-mount.js, tmpl.ts, tmp_cleanup.py, scratchpad.ts and scratch-card.tsx pass; tmp, tmp.js, tmp2.js, tmp_1.txt, tmp-1.js, TMP.js, scratch.md, scratch2.ts, every zz-* name and every editor leftover are still flagged.
  • What didn't: on main, one real module (lib/server/disk-space/tmp-watch.js in alphaclaw, ALPH-74) failed with PREGATE_STRAYS, and no branch could clear it, because strays.allow is read from the base branch on purpose. That base-branch rule is unchanged. The narrower rule also stops catching a stem followed by a word, such as tmp-repro.ts or scratch_notes.md; the changelog says so and suggests zz-* for scratch files.

What changed

STRAY_NAME in lib/pregate/checks/strays.ts goes from ^(?:zz-|tmp|scratch) to ^(?:zz-|(?:tmp|scratch)\d*(?:[-_]\d+)?(?:\.|$)). The zz- prefix stays a prefix. The match is still case-insensitive and still runs on the file's base name. docs/pregate.md, the PREGATE_STRAYS entry in docs/troubleshooting.md and the check's header comment describe the new rule.

Text before/after
before: /^(?:zz-|tmp|scratch)|\.(?:orig|rej|swp|swo|bak|tmp)$|~$|^\.DS_Store$|^Thumbs\.db$/i
after:  /^(?:zz-|(?:tmp|scratch)\d*(?:[-_]\d+)?(?:\.|$))|\.(?:orig|rej|swp|swo|bak|tmp)$|~$|^\.DS_Store$|^Thumbs\.db$/i

Why

"A real module named tmp-watch.js fails the pre-push check and nothing on the branch can clear it" (ALPH-74). The check fails closed and the allowlist is read only from the base branch, so a false positive blocks a branch with no escape. Treating tmp as a bare prefix caught module names like tmp-watch and tmpfs-mount, and scratch had the same problem (scratchpad). Now those names pass, and real scratch names still fail.

Summary

A branch that adds a real module whose name starts with tmp or scratch used to fail the pre-push check with no way out. The stray-name rule now matches tmp and scratch only as the whole stem, so those modules pass while tmp.js, tmp2.js and scratch.md still fail. Review added a case-safe fixture and wrote the tradeoff into the changelog and both docs.

Blast radius

Only the strays check's name rule changes. STRAY_NAME is used only by lib/pregate/checks/strays.ts and its tests (red-team read every consumer). Fewer files get flagged, and no file flagged today as tmp, tmp<n>, tmp_<n>, scratch (with an optional extension) or zz-* stops being flagged (script ran: the GST-1944 table and fixture). Names with a word after the stem (tmp-repro.ts) are no longer caught, by design.

Test Coverage

  • New GST-1944 test in test/pregate-selection.test.ts, written first and failing on main (tmp-watch.js matched). It checks the regex on the names above and runs gstack-pregate --only strays on a fixture: tmp-watch.js, tmpfs-mount.js and scratchpad.js pass, and eight bypass names fail. Review moved the uppercase case to docs/TMP.js so no two fixture paths differ only by case, and added tmp-repro.ts and scratch-probe.sh to the must-not-match list.
  • The existing GST-1211 test used lib/tmp-x.ts as its tmp stray. That name has the same shape as tmp-watch.js, so it now passes by design; the fixture uses lib/tmp.ts and keeps the same count of four strays.

Coverage: deterministic (each of 2 changed runtime files has a changed test naming it; no audit reader).
Tests ran: test 1645 (files; carried from CI run 42522445413/1 at tree a255f136479a)

Pre-Landing Review

Pre-Landing Review: 5 issues — 2 auto-fixed, 0 asked, 0 deferred, 3 noted

  • [AUTO-FIXED] test/pregate-selection.test.ts:559 (testing, CRITICAL): the fixture wrote both lib/tmp.js and lib/TMP.js, which collide on case-insensitive disks (macOS, Windows) → uppercase case moved to docs/TMP.js.
  • [AUTO-FIXED] lib/pregate/checks/strays.ts:16 (red-team, informational): the dropped tmp-<word> class was not written down → stated in the changelog fragment and docs/pregate.md, and pinned in the test's must-not-match list.
  • The docs/troubleshooting.md:4244 drift (red-team and the docs audit) was fixed after review in a docs-only commit; the docs re-audit is current.
  • Outside review (openai/gpt-6.1-sol): VERDICT: CLEAN.

Gate edits: none detected (2 listed, 1 read; patterns: RH-1,RH-3,RH-4,RH-12,RH-13,RH-14,RH-15,RH-16; unlisted idioms: none)

Review notes

Below the blocking floor; recorded here and not fixed in this PR. Follow-ups:

  • INFORMATIONAL lib/pregate/checks/strays.ts:16 Root-level tmp-*.md and scratch-*.md files now pass strays silently: STRAY_NAME misses them and ROOT_OK allows any root *.md. The old prefix rule caught them; root tmp-debug.js is still caught as a new root file. A root-only prefix check in run() would close it.
  • INFORMATIONAL test/pregate-selection.test.ts:552 Subdirectory scratch names with a word after the stem (tmp_test.py, tmp-debug.js, scratch-notes.ts) are no longer caught, and the must-not-match list pins tmp-repro.ts and scratch-probe.sh. Restoring them (a word list, or a warning instead of a pass) is a policy call.

Exploratory QA

Smoke only: the focused GST-1944 and GST-1211 tests passed (4 pass, 0 fail) at the fix commit. QA's method files were not read; no other probe ran.

Design Review

No frontend files changed — design review skipped.

Eval Results

No prompt-related files changed — evals skipped.

Review bot comments

No review bot comments.

Plan Completion

Plan completion audit: not run (no plan is bound to this branch and no docs/designs/ file matches). Bug fix, exempt from plan review.

TODOS

No TODO items completed in this PR.

Documentation

Status: current. The docs on this branch already match the new pregate strays naming rule, so nothing needed editing.

Scope: committed diff from base 1999310 to head 3247e41 on stop-pregate-flagging-tmp-prefixed-files. Nothing was staged, unstaged or new. Changed files: lib/pregate/checks/strays.ts, docs/pregate.md, docs/troubleshooting.md and changelog.d/stop-pregate-flagging-tmp-prefixed-files.md. I checked the new STRAY_NAME regex against 13 example names, and its results match every example the docs give.

Documentation health:

  • docs/pregate.md: current. The strays entry gives the whole-stem rule with correct examples.
  • docs/troubleshooting.md: current. The PREGATE_STRAYS meaning matches the code.
  • changelog.d/stop-pregate-flagging-tmp-prefixed-files.md: current. It is accurate and states the tradeoff.
  • CHANGELOG.md, docs/designs/MULTI_AGENT_WAVE_2026_10_10.md: left as they are. Their tmp* and scratch* wording records past behavior.

Coverage debt: none found. Diagram drift: none, because no diagrams cover this check.

Test plan

  • bun run test: carried from CI run 42522445413/1 at tree a255f136479a (1645 files, exit 0)
  • bun test test/pregate-selection.test.ts -t 'GST-1944|GST-1211': 4 pass, 0 fail
Agent notes

GST-1944, for Alphaclaw's ALPH-74. A tmp/ directory was never caught by the name rule: the check matches the file's base name, so lib/tmp/x.js passes on main and on this branch, and a new top-level tmp/ only warns as a new directory. This PR doesn't change that.

Approvals

No approvals recorded for branch stop-pregate-flagging-tmp-prefixed-files.
Plan: exempt: bug fix
Plan check: exempt bug fix

REVIEW_LOOP: passes=2 blocking_found=0 deferred=0 noted=1 fixed=2 scope=frozen unbound=2 ledgers_read=5 dispatches=8
Gate edits: none detected (2 listed, 1 read; patterns: RH-1,RH-3,RH-4,RH-12,RH-13,RH-14,RH-15,RH-16; unlisted idioms: none)

Refs GST-1944

{
  "schema_version": 1,
  "pr": 4177,
  "head": "3247e41979cea7bdc78a6f8489d2ef22569bc204",
  "version": "1.98.0.0",
  "base": "main",
  "gate": {
    "test": {
      "pass": 1645,
      "fail": 0,
      "skip": 0
    }
  },
  "ci_carried": [
    {
      "lane": "test",
      "run": 42522445413,
      "attempt": 1,
      "tree": "a255f136479a9ba9ee13fa5840cbbc327740d21f"
    }
  ],
  "session_kind": "unattended",
  "head_tree": "a255f136479a9ba9ee13fa5840cbbc327740d21f",
  "product_patch_id": "9723d0b674a29ea3f58f55dcc08ac0865553c451",
  "gstack_version": "1.98.0.0",
  "review_depth": {
    "depth": "full",
    "class": "gate",
    "runtime_lines": 11,
    "rules": "66e5174161eecc2c",
    "base": "199931029e9fe9808554a4863c960d4b9b663a60",
    "registry": "199931029e9fe9808554a4863c960d4b9b663a60",
    "gate_scan": {
      "tagged": 0,
      "head": "3247e41979cea7bdc78a6f8489d2ef22569bc204"
    },
    "reasons": [
      "gate-class",
      "runtime=11"
    ],
    "risk": [],
    "mode": "panel"
  },
  "pregate": "requires-remote cleared @a255f136479a (8 checks, current for 3247e41979ce)",
  "requires_remote": [
    "free-tests.yml/macos-named-regressions: https://github.com/garrytan/gstack/actions/runs/42522445413/attempts/1",
    "pregate.json/remote_gate: remote-gate tree=a255f136479a tests=36584 skipped=68 runs=42522445413/1 profiles=ci-reuse/free-tests heads=3247e41979ce verified=2026-11-08T21:02:22.102Z"
  ],
  "issues": {
    "fixes": [],
    "refs": [],
    "flakes": []
  },
  "docs": {
    "status": "current",
    "scope": "docs/ (139 files) against base 199931029e9f; the strays rule in docs/pregate.md and docs/troubleshooting.md checked against STRAY_NAME"
  },
  "review_loop": {
    "passes": 2,
    "blocking_found": 0,
    "deferred": 0,
    "noted": 1,
    "fixed": 2,
    "scope": "frozen",
    "rounds": 2,
    "ledgers_read": 5,
    "unbound": 2,
    "dispatches": {
      "specialist": 6,
      "red-team": 2
    }
  }
}

Open in Capy

…h (GST-1944)

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

trunk-io Bot commented Nov 8, 2026 •

Copy link
Copy Markdown

😎 This pull request was merged.

@capy-ai capy-ai Bot changed the title Stop pregate flagging real files whose names start with tmp or scratch (GST-1944) Stop the pre-push check flagging real files whose names start with tmp or scratch (GST-1944) Nov 8, 2026
garrytan and others added 2 commits November 8, 2026 20:43
…e tmp-word tradeoff

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>
…ing entry

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@capy-ai
capy-ai Bot merged commit b615592 into main Nov 8, 2026
54 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