Skip to content

Make the plan-review test judge reject failed sessions and steady two flaky tests - #4849

Merged
capy-ai[bot] merged 1 commit into
mainfrom
flaky-tests-and-stricter-plan-review-judge
Nov 26, 2026
Merged

capy-ai[bot] merged 1 commit into
mainfrom
flaky-tests-and-stricter-plan-review-judge

Conversation

@garrytan

@garrytan garrytan commented Nov 26, 2026 •

Copy link
Copy Markdown
Owner

The plan-review test judge now fails a Claude Code session whose final result reports an error, even when the process exits 0, so a broken session can no longer pass a quality check. Two tests that failed at random are steadier, and one of them now says why when it fails. Nothing to do.

What changed

test/plan-floor-review.test.ts with the old judge helper (left) and this branch's (right): the three judge tests fail before and pass after

test/plan-floor-review.test.ts with the old judge helper and with this branch's: the three judge tests fail before and pass after.

Before/after as text: test/plan-floor-review.test.ts with the old judge helper (left) and this branch's (right): the three judge tests fail before and pass after
--- Before · before.txt · captured output
+++ After · after.txt · captured output
+ 84 pass
+ 0 fail
-(fail) replacement judge retains the original CLI model, a tool-free schema session, measured cap and absolute case deadline [5.98ms]
-(fail) an exit 0 whose result event reports an error is no assessment, even after an accepted call [1.88ms]
-(fail) a CLI notice line is skipped, but a broken JSON event still fails the assessment [0.19ms]
- 81 pass
- 3 fail
 

A second-model review of the plan-review judge found that it trusted an answer from a session that ended in an error: when Claude Code exits 0 but its last result event says is_error: true, the judge used the assessment it had seen earlier. The judge (test/helpers/plan-floor-review.ts) now rejects that session. It also runs Claude Code with slash commands and hooks turned off, like gstack's other Claude Code calls, and skips a plain notice line in the output while still failing on a broken JSON event.

The question-log Bun-config test (test/bun-config-shell-bins.test.ts) failed twice in CI with one leftover record written a few milliseconds before the failing test began. Each gstack-question-log write starts a background developer-profile update that keeps writing into the test's state folder after the test returns; the test now turns that update off with GSTACK_QUESTION_LOG_NO_DERIVE=1. This is the probable cause, not a reproduced one: 48 stress runs of the real test and 300 tight-loop trials never failed.

A brain-sync merge test (test/brain-sync.test.ts) failed once with push_failed and no message. Its assertion now prints the whole status, so the next failure names its cause.

Why

These are the daily repairs for tests that failed at random in CI. A random failure costs a rerun on every pull request it hits, and a quality judge that accepts a failed session can pass work it never assessed.

Blast radius

Only test code changes. The judge helper is used by the paid plan-review cases and their unit tests, and its new rejection path is covered by test/plan-floor-review.test.ts (script ran: 84 pass, and the two new tests fail on the old helper). One real judge run with the pinned Claude Code 2.1.326 and the new flags returned a valid assessment.

Tests

Tests ran: targeted 104
Tests ran: brainsync 11

bun run typecheck reports zero errors; bun run typecheck:test reports no new diagnostics. The full free suite ran in CI.

Pre-Landing Review

No issues found.

Documentation

Scope: this branch changes only tests: the plan-floor review judge helper and its test, the gstack-question-log Bun-config test and one brain-sync assertion. It also adds the changelog fragment changelog.d/flaky-tests-and-stricter-plan-review-judge.md. The audit checked docs/flaky.md, docs/TESTING_INTERNALS.md, docs/evals/detector-inventory.md and the GSTACK_QUESTION_LOG_NO_DERIVE comment in bin/gstack-question-log for statements the diff makes untrue.

Result: the docs are current and no docs needed edits. The changelog fragment matches the code changes: the judge now rejects a session whose final result has is_error: true, runs with hooks and slash commands turned off, and skips lines that are not JSON events. The question-log test turns off the background profile update.

Debt: docs/evals/detector-inventory.md cites test/helpers/plan-floor-review.ts:278-280 for pickPlanFloorProductType. That reference was already stale before this branch, and the function is now at line 327.

Agent notes
Agent notes

Issue GST-4001. Daily flaky-test pass, 2026-11-26.

Gate edits: none detected (8 listed, 6 read)

Approvals

Plan: exempt: bug fix to test helpers and flaky tests
Plan check: exempt bug fix

{
  "schema_version": 1,
  "pr": 4849,
  "head": "58c357e756dad4cb762b98be6e19dd58cb4a2a89",
  "version": "1.104.0.0",
  "base": "main",
  "calls": 15,
  "session_kind": "unattended",
  "run": "ship-f1126",
  "head_tree": "39536a552d9c1dda4734f8c21e729ac30dc0e35e",
  "product_patch_id": "none",
  "gstack_version": "1.104.0.0",
  "review_depth": {
    "depth": "light",
    "class": "tests",
    "runtime_lines": 0,
    "rules": "33831f8248a814fd",
    "base": "4ec576aaa57ea76be375d4259e6dca7966abfa86",
    "registry": "4ec576aaa57ea76be375d4259e6dca7966abfa86",
    "gate_scan": {
      "tagged": 0,
      "head": "58c357e756dad4cb762b98be6e19dd58cb4a2a89"
    },
    "reasons": [
      "runtime=0"
    ],
    "risk": [],
    "mode": "panel"
  },
  "pregate": "requires-remote cleared @39536a552d9c (8 checks, current for 58c357e756da)",
  "requires_remote": [
    "free-tests.yml/macos-named-regressions: https://github.com/garrytan/gstack/actions/runs/45851316052/attempts/1",
    "pregate.json/remote_gate: remote-gate tree=39536a552d9c tests=38470 skipped=88 runs=45851316052/1 profiles=ci-reuse/free-tests heads=58c357e756da base_moved=4ec576aaa57e verified=2026-11-26T15:46:39.228Z"
  ],
  "issues": {
    "fixes": [],
    "refs": [],
    "flakes": []
  },
  "docs": {
    "status": "current",
    "scope": "README.md, AGENTS.md, CLAUDE.md, CONTRIBUTING.md, ARCHITECTURE.md, ETHOS.md and docs/ (159 files hashed; flaky.md, TESTING_INTERNALS.md and evals/detector-inventory.md read in full)"
  },
  "review_loop": {
    "passes": 1,
    "blocking_found": 0,
    "deferred": 0,
    "noted": 0,
    "fixed": 0,
    "scope": "frozen",
    "rounds": 1,
    "ledgers_read": 2,
    "dispatches": {
      "specialist": 1
    }
  },
  "gate_dispositions": []
}

Open in Capy

… flaky tests

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

trunk-io Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

😎 This pull request was merged.

@capy-ai
capy-ai Bot merged commit 8982588 into main Nov 26, 2026
50 of 51 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