Skip to content

Fix three flaky test causes found in the 2026-11-08 harvest (GST-1912) - #4167

Merged
capy-ai[bot] merged 6 commits into
mainfrom
fix-flaky-tests-2026-11-08
Nov 8, 2026
Merged

capy-ai[bot] merged 6 commits into
mainfrom
fix-flaky-tests-2026-11-08

Conversation

@garrytan

@garrytan garrytan commented Nov 8, 2026 •

Copy link
Copy Markdown
Owner

Three flaky-test causes are fixed, and ./setup no longer tells people their healthy hooks are broken when Bun crashes during the hook check. This serves gstack's goal of a test suite and setup you can trust: a red run or a setup error should mean something is really wrong.

What changed

A Bun crash during the hook check no longer reports healthy hooks as broken

A Bun crash during the hook check no longer reports healthy hooks as broken.

Before/after as text: A Bun crash during the hook check no longer reports healthy hooks as broken
--- Before · before.txt · captured output
+++ After · after.txt · captured output
+$ GSTACK_HOOK_CHECK_BUN=<bun killed by SIGSEGV> bin/gstack-hook-check .   # this branch
+gstack-hook-check: bun was killed by signal 11 while bundling the TypeScript hook entries, so they cannot be checked
-$ GSTACK_HOOK_CHECK_BUN=<bun killed by SIGSEGV> bin/gstack-hook-check .   # main
 ok bin/gstack-session-update
+ok careful/bin/check-careful.sh
+ok freeze/bin/check-freeze.sh
+exit 3
-fail hosts/claude/hooks/question-log-hook /workspace/gstack/hosts/claude/hooks/question-log-hook.ts:1: bun could not bundle the TypeScript entry
-fail hosts/claude/hooks/question-preference-hook /workspace/gstack/hosts/claude/hooks/question-preference-hook.ts:1: bun could not bundle the TypeScript entry
-fail hosts/claude/hooks/auq-error-fallback-hook /workspace/gstack/hosts/claude/hooks/auq-error-fallback-hook.ts:1: bun could not bundle the TypeScript entry
-fail hosts/claude/hooks/timeline-stop-hook /workspace/gstack/hosts/claude/hooks/timeline-stop-hook.ts:1: bun could not bundle the TypeScript entry
-fail hosts/claude/hooks/skill-route-hook /workspace/gstack/hosts/claude/hooks/skill-route-hook.ts:1: bun could not bundle the TypeScript entry
-...
-exit 1
 

Hook check when Bun crashes (Free Tests 42327570347 shard 8). Bun segfaulted in the one-process bundle probe, and the check reported four healthy hooks as "does not parse", so setup exited 1 with "this is a gstack bug". Now the rows Bun printed before the crash still count: a reported failure still fails its hook, an ok row still feeds the merge-marker scan, and the shell parse checks still run. Only an entry Bun never reported is unchecked, and the check exits 3 (unavailable, the same as a missing Bun) only when such an entry exists and nothing else failed. A Bun that exits normally without a report still fails every entry it left out.

gbrain prune test (Free Tests 42448270551 shard 3). test/gbrain-prune-gone-worktrees.test.ts saw a parallel shard's live gbrain autopilot process through pgrep -f, so the removal refused. The fixture now stubs pgrep to "no match", as test/gstack-gbrain-sync.test.ts already does.

plan-ceo-finding-floor overwrite binding (census 42252633016 slice 7). The floor actor did not recognize Claude Code's cropped "Do you want to overwrite …?" diff for its own working plan, so the menu waited out PERMISSION_UNANSWERED_MS. The binding now handles an overwrite like a cropped Create: it binds to the sole pending owned Write and checks every visible row against the current file bytes and the pending content. The cases live in test/plan-count-file-permission.test.ts, the owner test the test-of-test ratchet names.

The third-party-actions defer change this PR first carried is gone: review found it counted "I will not mark this step as blocked on you" as a defer option, so those two files are back to main and that flake gets its own fix.

Why

These were open entries in the crew's flaky ledger. Each one failed a PR or census check on a correct run, or (setup) told users healthy hooks were broken. Now those runs pass, and setup refuses only hooks that really fail.

Blast radius

bin/gstack-hook-check changes behavior only when its Bun process dies by a signal, and its three consumers stay fail-closed. Setup refuses every hook with a fail line, and bin/gstack-session-update holds the update on exit 3 or an incomplete report (walked in hook_report, and the signal cases run in test/setup-hook-syntax-gate.test.ts). Everything else is test helpers and fixtures.

Summary

Flaky reds on correct runs cost every lane a rerun and hide real failures. This branch removes three causes with a failing-first test each, moves the new overwrite cases into their owner test so the ratchet stays green, and makes the hook check keep what Bun already reported when Bun crashes.

Test Coverage

Coverage: deterministic (each changed runtime file has a changed test naming it).
Regression proof: "a failure bun reported before it was killed still fails its hook" fails at d174289 (expected 1, received 3) and passes at 38ef0ad; the crash-plus-broken-shell assertion fails on the original script (expected 1, received 3) and passes after the fix.
Tests ran: targeted 257
Tests ran: tests (bun run test) carried from CI at the final head

Pre-Landing Review

Pass 1 fixed one finding (a crash skipped the shell checks), pass 2 found nothing to fix, and Step 11's outside voice found two blockers: a pre-crash fail row was discarded (fixed in 38ef0ad under a granted fix-check) and the widened defer rule accepted a negated mark (reverted to main in 17edf5b under a second grant). Both fix-checks were clean. The last outside voice at 17edf5b: CLEAN.
Gate edits: none detected (13 listed, 4 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 (advisory, informational, test-gap or wording items); recorded here and not fixed in this PR.

  • INFORMATIONAL bin/gstack-doctor:202 still words exit 3 as "bun not found", which misdiagnoses a Bun crash.
  • INFORMATIONAL bin/gstack-session-update:104 after a Bun crash with a broken shell hook, the hold names hook-check-unavailable instead of the broken file (the update still holds).
  • INFORMATIONAL setup:4364 in the crash-plus-real-failure case, setup's lists leave out the TypeScript hooks it registers unchecked, and the "registered unchecked" warning does not print.
  • INFORMATIONAL bin/gstack-hook-check:205 after a late crash the check can exit 0 while stderr still says the entries cannot be checked.
  • INFORMATIONAL bin/gstack-hook-check:262 a signal landing between two ok rows of one entry leaves its later imports unscanned for merge markers.
  • Low: on native Windows a Bun crash may exit at or below 128, so the crash path may never fire there (unverified; that falls back to main's fail-closed behavior).
  • Low: on the first auto-update after this lands, a crash under the old installed checker can hold the update with a misleading reason.

Exploratory QA

Functional smoke on bin/gstack-hook-check at b0336fb (3 probes, all pass): the real checkout exits 0 with an ok per hook; a Bun killed by SIGSEGV exits 3 with no fail lines; a Bun that exits 0 with no report exits 1 with a fail line per TypeScript hook. After the fix, a Bun that prints a fail row and then crashes exits 1 with that fail line (scripted repro and test).

Eval Results

Test-harness files changed. The focused paid runs at 429777e: tpa-present PASS 1/1 ($0.08) and plan-ceo-finding-floor PASS 1/1 (cost not printed). tpa-present's harness change was later reverted to main. The 54-test PR profile was not run (over the $10 focused cap); this is a known gap for a --no-screen READY.

Review bot comments

No review bot comments.

Scope Drift

Scope Check: CLEAN

Plan Completion

Plan completion audit: not run (no plan is bound to this branch and no docs/designs/ file matches). Daily flaky pass, exempt from planning.

TODOS

No TODO items completed in this PR.

Documentation

Status: current. No documentation edits were needed.

Scope: 6 commits from 6042f6a to a1e7432 on fix-flaky-tests-2026-11-08, 8 committed files and no working-tree changes. The only user-facing change is in bin/gstack-hook-check: when Bun is killed by a signal during bundling, the rows it already reported still count, the shell checks still run, and the check exits 3 only when a hook went unreported and nothing else failed. The rest is test fixes plus the changelog.d fragment.

Documentation health:

  • docs/troubleshooting.md: current. The auto-update-hook-check-unavailable entry already counts a crash as an unavailable reason, and the setup refusal entry still describes real parse failures correctly.
  • bin/gstack-hook-check header comment: current. It documents the new exit-3 crash case.
  • AGENTS.md, README.md, CONTRIBUTING.md: current. No surface they describe changed.

Coverage debt: setup's existing warning, "the hook parse check could not run (exit N); hooks are registered unchecked", has no troubleshooting entry. Only reference coverage exists, in the script header and the changelog fragment. This gap predates the branch, and the change now makes the warning reachable after a Bun crash.

Diagram drift: none.

Test plan

  • bun test (targeted: prune, plan-count-file-permission, setup-hook-syntax-gate, third-party-actions, test-of-test ratchet, free-fixtures, session-update hook hold): 257 tests, exit 0
  • bun run test: carried from Free Tests at the final head

🤖 Generated with Claude Code

Agent notes

Refs GST-1912

Approvals

Approved: yes (record r-ce7fab9a6a7b). The full approval record stays private: this repository is public or its visibility is unknown.
Plan: exempt: flaky

REVIEW_LOOP: passes=2 blocking_found=2 deferred=0 noted=6 fixed=2 scope=frozen unrecorded=1 ledgers_read=8 fix_checks=2 dispatches=8
Gate edits: none detected (13 listed, 4 read; patterns: RH-1,RH-3,RH-4,RH-12,RH-13,RH-14,RH-15,RH-16; unlisted idioms: none)
Review-loop grants: a-357b0f3ee235 (fix-check at d174289), a-1a987d0e4fd4 (fix-check at 38ef0ad, split).

{
  "schema_version": 1,
  "pr": 4167,
  "head": "a1e743245d9b15db0a91f73bf229c57b6e4832e1",
  "version": "1.98.0.0",
  "base": "main",
  "gate": {
    "tests": {
      "pass": 1643,
      "fail": 0,
      "skip": 0
    },
    "targeted": {
      "pass": 257,
      "fail": 0,
      "skip": 0
    }
  },
  "ci_carried": [
    {
      "lane": "tests",
      "run": 42494190452,
      "attempt": 1,
      "tree": "a23b4ab125c911925178a2b64853c0ccf7496113"
    }
  ],
  "session_kind": "unattended",
  "head_tree": "a23b4ab125c911925178a2b64853c0ccf7496113",
  "product_patch_id": "adff9d6c30a1e7f54a87b82b20446944ee69c04f",
  "gstack_version": "1.98.0.0",
  "review_depth": {
    "depth": "full",
    "class": "gate",
    "runtime_lines": 21,
    "rules": "c6a079fdf812f479",
    "base": "6042f6ad48774504f918ab1391908c1ccdb11fe0",
    "registry": "6042f6ad48774504f918ab1391908c1ccdb11fe0",
    "gate_scan": {
      "tagged": 0,
      "head": "a1e743245d9b15db0a91f73bf229c57b6e4832e1"
    },
    "reasons": [
      "gate-class",
      "runtime=21"
    ],
    "risk": [],
    "mode": "panel"
  },
  "pregate": "requires-remote cleared @a23b4ab125c9 (8 checks, current for a1e743245d9b)",
  "requires_remote": [
    "free-tests.yml/macos-named-regressions: https://github.com/garrytan/gstack/actions/runs/42494190452/attempts/1",
    "pregate.json/remote_gate: remote-gate tree=a23b4ab125c9 tests=36501 skipped=90 runs=42494190452/1 profiles=ci-reuse/free-tests heads=a1e743245d9b verified=2026-11-08T15:29:22.122Z"
  ],
  "issues": {
    "fixes": [],
    "refs": [],
    "flakes": []
  },
  "docs": {
    "status": "current",
    "scope": "AGENTS.md, CONTRIBUTING.md, README.md and docs/ (troubleshooting.md checked against the hook-check change)"
  },
  "review_loop": {
    "passes": 2,
    "blocking_found": 2,
    "deferred": 0,
    "noted": 6,
    "fixed": 2,
    "scope": "frozen",
    "fix_checks": 2,
    "rounds": 4,
    "unrecorded": 1,
    "ledgers_read": 8,
    "dispatches": {
      "specialist": 6,
      "red-team": 2
    }
  }
}

Open in Capy

- gbrain prune test: stub pgrep so a parallel test's 'gbrain autopilot' process cannot refuse the removal (Free Tests 42448270551 shard 3).
- third-party-actions: a lettered option that marks the step blocked or waiting on the user is the defer option (gate 42431616220, tpa-present).
- gstack-hook-check: a Bun killed by a signal makes the check unavailable (exit 3) instead of failing every hook (Free Tests 42327570347 shard 8).
- floor actor: bind a cropped Write overwrite to the sole pending owned Write, checking every visible diff row (census 42252633016, plan-ceo-finding-floor).

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.

garrytan and others added 5 commits November 8, 2026 14:31
The test-of-test ratchet fails a new file that imports only test code. The cases now live in test/plan-count-file-permission.test.ts, the ratchet's suggested owner, and the fixture map points there.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
A Bun killed by a signal used to end the check before the shell parse and merge-marker scan. Those checks now still run: a shell failure exits 1 and setup refuses that hook, and otherwise the check exits 3 as before with TypeScript hooks left unverified.

Review-Finding: p1/red-team#1 reader=red-team
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
When Bun printed a fail row for one entry and was then killed by a signal, the check dropped that row and exited 3, so setup registered a hook it knew was broken. Rows Bun printed now count: a fail row fails its hook, an ok row adds its imports to the marker scan, and only entries with no row are unchecked. Exit 3 applies only when an entry has no row and nothing else failed.

Review-Finding: v2/outside-voice#1 reader=outside-voice
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
The widened defer rule counted a refusal such as "I will not mark this step as blocked on you" as a defer option, which loosens the paid consent gate. This change returns test/helpers/third-party-actions.ts and its test to origin/main; that flaky case moves to a separate fix.

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

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@capy-ai capy-ai Bot changed the title Fix four flaky test causes found in the 2026-11-08 harvest (GST-1912) Fix three flaky test causes found in the 2026-11-08 harvest (GST-1912) Nov 8, 2026
@capy-ai
capy-ai Bot merged commit 15a35ff into main Nov 8, 2026
75 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