Skip to content

test(offload): give the summary-wait test hooks a 30 s floor - #1376

Merged
amiddavid merged 1 commit into
mainfrom
test/seam-summary-floor
Nov 25, 2026
Merged

amiddavid merged 1 commit into
mainfrom
test/seam-summary-floor

Conversation

@amiddavid

Copy link
Copy Markdown
Collaborator

Production file changed, no behavior change: components/offload/summarize_testhook.go holds test hooks only.

Owner approval (David Amid, flaky-tests session, 2026-11-24): "read it all seams approved". He said it after this explanation of seam 2: "WaitForSummaryForTest and WaitForAllSummariesForTest get a 30 s floor; about 50 component tests pass 1-5 s today".

Summary

What changed

  • summarize_testhook.go: const summaryWaitFloorForTest (30 s) and summaryWaitLimit. WaitForSummaryForTest now calls the unexported waitForSummary, which has no floor.
  • 100 call sites checked (apply, components, proxy). Most pass 5 s or more and assert the wait returns true. They need no change.
  • Three call sites need a short limit on purpose. All are in cache_aware_after_stash_test.go. They now call waitForSummary (option c: a short-wait variant, no new export):
    1. TestWaitForSummaryCoversTheGapBetweenTakeAndStart: asserts the wait does NOT return in 50 ms.
    2. TestCacheAwareDetachedPrefixAskCommitsAfterTheTurnIsStashed: a 1 s wait that times out while a deferral is held, and a 100 ms poll step.
    3. TestAReplacedWarmDeferralIsDispatchedWithoutTheHook: a 100 ms poll step.
  • Without the change in 2 and 3, each test took 30 s instead of about 1 s. The first test run showed this.
  • Other ...ForTest hooks in components/offload that take a duration: none. These two are the only ones.

How tested

macOS, Go 1.27.4, load average 190 to 420.

  • CGO_ENABLED=1 go test -race -count=5 -run <the 91 tests in files that call the hooks> ./components/offload/: pass (330 s).
  • Same set, -count=1, back to back: before 11.3 s, after 11.5 s. (The first run showed 70 s: that was the two tests above. Fixed.)
  • Whole package in parts: ^TestCache, ^Test(Summar|Wait) and ^Test[A-D] pass. The TestV* and Test[E-Z] tests do not call the hooks. The whole package does not finish in 10 minutes on this loaded laptop, so those were not run.
  • go test -race ./apply/ ./components/all/: pass.
  • go test -race on the 28 proxy tests that call the hooks: pass. TestCacheAwareStalePrefixThroughARealOversizedTurn takes about 125 s with and without this change.
  • go vet (offload, apply, proxy, components/all), gofmt, go test ./internal/timingguard/: clean.
  • Mutation: a summary model that never returns (summarize timeout set to 10 m). The waiting test failed with "the background summary never finished" after about 30 s, not at the binary timeout. Reverted.

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 1 (glm, user of @amiddavid) GLM rits/zai-org/glm-5-3 via Claude Code 2.1.331 offload-review skill, @amiddavid's session fresh 1 of 2 1 of 2 8bab7b6898ee approve

Verdict: approve

Findings

None.

Non-blocking

  • components/offload/summarize_testhook.go:46 — waitForSummary lives in a non-_test.go file, so it ships in the production library build as dead code. The file already works this way for the exported hooks, so this follows the existing pattern. No action needed.
  • The floor makes a real hang cost 30 s per wait call. Tests that call a wait hook several times in sequence (for example apply/responses_test.go, which calls WaitForAllSummariesForTest up to 4 times per test) can take 2 minutes to report one hang. The PR states this tradeoff, and a passing test returns at once. Acceptable.
  • components/offload/cache_aware_after_stash_test.go:199 still passes 1 s to the floored WaitForSummaryForTest, with the result ignored. On the passing path it returns at once, so there is no cost today. If that commission ever hangs, the test takes 30 s to report, which is the intent of the floor.

What I checked

  • The full diff (2 files, 33 insertions, 7 deletions) and both files in full, plus the code around each change.
  • Every call site of WaitForSummaryForTest and WaitForAllSummariesForTest in apply/, components/ and proxy/ (about 100 sites). All sites that assert a result expect true (a summary lands), except the three converted in this PR. Those three are the only sites that need a short limit:
    • cache_aware_after_stash_test.go:80 — 1 s wait that times out while a deferral is held, on purpose.
    • cache_aware_after_stash_test.go:89 and :131 — 100 ms poll steps inside 5 s loops.
    • cache_aware_after_stash_test.go:228 — asserts the wait does NOT return in 50 ms. This is the only site that asserts false.
  • Drain-only sites (result ignored) where a deferral could stay held by design: summarize_thread_test.go, cache_aware_stale_replay_test.go, commitgate_summarize_test.go, cache_aware_trigger_test.go:277, components/all/reuse_test.go, proxy/summarytoken_test.go. All of them resolve the deferral or expect the summary to land before the wait, so the floor does not slow them. This matches the PR's measurement (11.3 s before, 11.5 s after for the offload set).
  • The gap the floor cannot hide: waitForSummary returns true at once when nothing is pending and nothing is in flight. The take-and-start gap is covered by the dispatching counter in deferralPending (summarize_testhook.go:108), so a wait during that gap still blocks. TestWaitForSummaryCoversTheGapBetweenTakeAndStart pins this, and the converted 50 ms call still tests it.
  • summaryWaitLimit and the two hooks are the only wait hooks in components/offload that take a duration. I listed every *ForTest function in the package. The PR's claim holds.
  • timingguard: the diff adds no time.Sleep, no new poll loop and no time.After. The loops at cache_aware_after_stash_test.go:84-91 and :126-133 keep their existing sleep counts, so the baseline does not change.
  • Behavior change and data dependence: none. The changed production file holds test hooks only, and the PR records the owner's approval for that. The hooks are called from tests only; I found no production caller.
  • Fail open: not affected. No production path changed.

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 2 (glm, user of @amiddavid) GLM rits/zai-org/glm-5-3 via Claude Code 2.1.331 offload-review skill, @amiddavid's session fresh 2 of 2 1 of 2 8bab7b6898ee approve

Verdict: approve

Findings

None.

Non-blocking

  • components/offload/summarize_testhook.go:15 — nothing pins the floor itself. If a later edit drops the summaryWaitLimit call from WaitForSummaryForTest or WaitForAllSummariesForTest, no test fails. A one-line test on summaryWaitLimit would pin it.
  • components/offload/cache_aware_after_stash_test.go:229 — the fatal message still says "WaitForSummaryForTest returned…", but the call above it is now waitForSummary. The code path is the same (the exported hook delegates), so this is wording only.
  • Failure diagnosis gets slower. A summary that never lands now costs 30 s per wait site instead of 1 to 5 s. With about 80 wait sites, a broadly broken build can push a package past go test's 10-minute default timeout, so it fails as a timeout panic and not as a clean t.Fatal. This is the tradeoff the change states, and a passing run is not slower.

What I checked

  • The full diff (one commit, two files) and both files in full, against the base version of summarize_testhook.go.
  • Every call site of WaitForSummaryForTest, WaitForAllSummariesForTest and the new waitForSummary across components, components/offload, components/all, apply and proxy (about 80 sites). For each, I checked whether it needs the wait to time out quickly, or uses it as a bounded poll step:
    • Three sites needed a short limit (a deliberately held deferral at cache_aware_after_stash_test.go:80, two 100 ms poll steps at lines 89 and 131, and the 50 ms must-time-out at line 228). The PR converts all of them to the unexported waitForSummary, so their behavior is unchanged.
    • All other sites either call ResolveDeferredCacheAwareSummary before the wait, drive a warm commission that lands, or assert nothing is pending. The floor cannot make a passing run slower there, because a summary that lands returns at once.
    • No remaining caller asserts a false return from the exported hooks. Every if !WaitFor… treats false as a test failure, so the floor only changes time-to-failure.
  • Name collision: waitForSummary does not collide with any identifier in package offload.
  • No production code calls the ForTest hooks (only comments reference them), so the floor cannot reach a non-test path.
  • The diff adds no time.Sleep or wall-clock assertion, so timingguard and the timing-test gating rules are not in play.
  • Data dependence: none. The change touches test hooks only; no feature row applies.
  • Hard boundaries: the hook file stays in the library package with its existing exported-and-test-only pattern, and the new unexported helper is same-package only.
  • I did not run builds or tests: this review is code-reading only, as instructed.

WaitForSummaryForTest and WaitForAllSummariesForTest now wait for
max(caller limit, 30 s). About 50 tests pass 1 to 5 s. On a loaded
machine a background summary can take longer, and the test failed
although the code was right.

A summary that lands returns at once, so a passing test is not slower.
Only a real hang takes 30 s to report.

Three places need the short limit on purpose. They prove a wait does
NOT return, or they poll in short steps while a deferral is held. They
now call the unexported waitForSummary, which has no floor. All three
are in cache_aware_after_stash_test.go.

No production behavior change. The file holds test hooks only.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: DAVID AMID <[email protected]>
@amiddavid
amiddavid force-pushed the test/seam-summary-floor branch from 8bab7b6 to 54e3b79 Compare November 25, 2026 08:54
@amiddavid

Copy link
Copy Markdown
Collaborator Author

Rebased onto main (e0a304e), after #1369. The approvals still count.

scripts/release/approval-still-valid.sh 1376 8bab7b6898eed8b0bed0ef4eca27ac7f77f86d5e:

SAME CHANGE: only the base moved. The approval of 8bab7b6898ee still counts. Say so on the PR.

Approved head: 8bab7b6898eed8b0bed0ef4eca27ac7f77f86d5e. New head: 54e3b799d145fa0ae70dc83a5bf335395d68f9e5. The change is the same: only the base moved.

@amiddavid
amiddavid merged commit 696ed60 into main Nov 25, 2026
8 checks passed
@github-project-automation github-project-automation Bot moved this from New/ToDo to Done in Rossoctl Issue Prioritization Nov 25, 2026
amiddavid added a commit that referenced this pull request Nov 25, 2026
#1371, #1372, #1373, #1376 and #1377 fixed them. Add 2 tests found
since: keepalive TestTheManualHoldTimerReleasesAndZeroisesWithoutASweep
and tooldefer TestHistorySetLoadedTwice. 118 tests remain.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: DAVID AMID <[email protected]>
amiddavid added a commit that referenced this pull request Nov 25, 2026
#1378)

test: gate the tests where time is the behavior behind CG_TIMING_TESTS

Gate 32 tests that assert a wall-clock limit, a rate, a watchdog or a
kill-at-the-limit. They run only with CG_TIMING_TESTS=1, so the
integrator's heavy checks run them and a loaded laptop does not.

- Go: testutil.RequireTiming(t) in 19 tests.
- OpenCode: the timingOnly option in 4 tests.
- pi-package and bob-plugin statusbar: a small timingOnly option in 6 tests.
- bob-plugin scripts: a small timing_only skip in 3 tests.

Test-only. No behavior change. No data dependence.

test: run the checks that do not depend on time in every run

A gated test that also checks something other than time hid that check
without the variable. Fix that.

- dash: move the query-plan check into TestSessionTokens_UsesTheIndexOnALargeWindow.
  It runs always. The time ratio stays gated.
- 13 tests assert their time bound only with CG_TIMING_TESTS=1. The rest
  of each test runs always: strategies read, testdb open, waitAll,
  OpenCode versions, pi (3), bob statusbar (3), bob scripts (3).

Test-only. No behavior change.

test: ungate 3 tests and teach the timing detector the new switches

- Ungate 3 silence tests whose result does not depend on time or load.
- WaitFor test: guard only the elapsed bound. The message checks run always.
- central rules test: RequireTiming after the CENTRAL_SLOW check, with a comment.
- OpenCode: export timingEnabled from helpers.mjs. Use it in versions and
  in the failopen missing-binary bound.
- timing-tests-needed.sh: match CG_TIMING_TESTS and timingEnabled, and look
  in *.py and *.test.ts files. Add cases to local-tests_test.sh.

Test-only. No behavior change.

test(bob): name CG_TIMING_TESTS in test_bob_control.py

Review round 2 (#1378): the file reads TIMING from test_bob_plugin but
never named the switch, so scripts/dev/timing-tests-needed.sh could not
see its timing gate. One comment line names it.

fix(dev): stop the timing detector losing to SIGPIPE

Review round 3 (#1378): with pipefail on, `grep -q` exits at the first
match, the writer (`git show` or `git diff`) then dies of SIGPIPE, and
the pipeline status becomes 141, so the `if` failed and the script
printed "skip" at random. On a large test file it said skip in 9 of 40
runs. Plain grep to /dev/null reads to the end. Two new self-tests, a
20,000-line file and a 20,000-line diff, each run 20 times: with
`grep -q` both say run 0 of 20, with this change 20 of 20.

docs(release): drop the 89 pending timing tests that merged PRs fixed

#1371, #1372, #1373, #1376 and #1377 fixed them. Add 2 tests found
since: keepalive TestTheManualHoldTimerReleasesAndZeroisesWithoutASweep
and tooldefer TestHistorySetLoadedTwice. 118 tests remain.


No behavior change (tests and test scripts only). Round 4 approved (owner granted rounds 3 and 4). Local tests waived (owner rule).

Assisted-By: Claude Opus 5.5
Signed-off-by: DAVID AMID <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant