Skip to content

test(offload): the warm-sweep tests wait on the condition, not on time - #1463

Merged
amiddavid merged 3 commits into
mainfrom
test/fix-warm-timing
Nov 26, 2026
Merged

amiddavid merged 3 commits into
mainfrom
test/fix-warm-timing

Conversation

@amiddavid

@amiddavid amiddavid commented Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator

Test-only. No user behavior change. No product code change, no seam 4.

Summary

What changed

Test Cause Fix
TestAWarmQuestionAndAPingQuestionNeverRunTogetherOnAThread two 5 s windows testutil.WaitFor on each condition
TestTheWarmQuestionIsJudgedByTheSharedCacheReadRule 5 s poll, then a wrong failure message new warmRig.waitIdle (uses WaitFor); forward uses it too
TestTheWarmSweepOuterTimeoutFitsSeveralBatches 40 ms bound against 30 ms batches always-on, no gate. One subtest checks that 3 batches run. The other sets one question's bound to 10 h, so the outer deadline is the earlier one. The asker records the time left on its context. The test checks that it is near the keeper's timeout, and that the keeper's timeout is at least 3 questions long
  • forward now waits up to the testutil bound (30 s), not 60 s.
  • internal/timingguard/baseline.txt is lowered for the file.

How it was tested

Tests ran on macOS, Go 1.27.4, GOMAXPROCS=4.

  • CGO_ENABLED=1 go test -race -count=20 -run '^(the 3 tests)$' ./components/offload/: pass.
  • CGO_ENABLED=1 go test -race ./components/...: pass.
  • go test ./components/all/ ./internal/timingguard/, go vet ./components/...: pass.
  • Vacuity:
    • Removed close(blk.out): fails at 30 s with "timed out after 30.001s waiting for the thread is released after the warm question". No hang.
    • Outer timeout passed as 0 (falls back to one question's bound): the new subtest fails, "batch 0 saw 9h59m57s left, want between 2m30s and 5m0s". Outer timeout set to 1 s: fails, "asked 1 of 3 batches".
    • Read threshold 1,000,000 changed to 1: fails at once with "want the answer refused for a read below the turn's".
  • Local tests: waived (owner rule).

Refs #1193

Three warm-sweep tests used fixed 5 s polls or a tiny real-time bound.
They fail on a loaded machine.

- The two-asker and shared-read-rule tests wait with testutil.WaitFor.
  The rig gets one waitIdle helper, which forward also uses.
- The outer-timeout test keeps an always-on check that all 3 batches
  run. Its 3-batches-over-one-bound check is time by design: it is
  gated with RequireTiming and uses 10x wider margins.
- Remove the 3 tests from the pending list and lower the timing
  baseline.
- Add #1193 to the decided_by line of extract_llm_sweep.

Signed-off-by: DAVID AMID <[email protected]>
Assisted-By: Claude Opus 5.5
Signed-off-by: DAVID AMID <[email protected]>

# Conflicts:
#	docs/data-dependence.md
The timing subtest of the outer-timeout test slept in the asker and
ignored its context, so it did not test the outer bound at all.

- The asker now records the time left on its context.
- With one question's bound set far above the outer one, the first
  deadline is the outer deadline. The test checks that it is the
  keeper's timeout, and that the keeper's timeout is at least 3
  questions long. No sleep, no gate.

Signed-off-by: DAVID AMID <[email protected]>
Assisted-By: Claude Opus 5.5
@amiddavid

Copy link
Copy Markdown
Collaborator Author

Local tests: waived (owner rule)

@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.332 offload-review skill, @amiddavid's session fresh 2 of 2 1 of 2 42a306e180ce approve

Verdict: approve

Findings

None. The PR is test-only, plus docs and baselines. No product code changed. No behavior change.

Non-blocking

  • components/offload/extract_sweep_warm_test.go:147 — waitIdle waits up to the testutil bound (30 s). The deleted comment in forward said 60 s for a slow -race build. The PR names this change, and each batch here is local token counting, not a network call. Watch heavy CI for a flake at this wait.
  • components/offload/extract_sweep_warm_test.go:255 — a fixed time.Sleep(150 * time.Millisecond) stays in TestTheQuestionRunsAfterTheForwardAndTheForwardedRequestIsUnchanged. It is baselined (sleep=1), so it is allowed. It is the same defect class this PR fixes. A follow-up PR could convert it.
  • components/offload/extract_sweep_warm_test.go:2112 — the subtest "all batches are asked" repeats what TestAWarmSweepOverManyOutputsAsksBatchesAndMakesOneGateDecisionAndOneCut already checks (3 batches of 30). Harmless: it keeps the outer-timeout test self-contained.

What I checked

  • Full diff dec2ef0e..HEAD (3 commits, 5 files) and the code around each change. The merge c62ada92 brings in origin/main only; the cumulative diff holds just the branch's own changes.
  • The new waits are sound. warmRig.waitIdle keeps the exact old busy condition (t.asking || t.warmPending(), extract_sweep_warm.go:1112). ResolveWarmQuestion sets asking = true under warmMu before it returns (extract_sweep_warm.go:1172), so forward cannot pass before the question starts. The non-blocking select on the closed blk.in channel is a correct poll of the old blocking receive.
  • The outer-deadline test tests the right thing. The warm path passes CacheAwareSummarizerCallTimeout() (300 s) as the outer bound (extract_sweep_warm.go:1283), and adjudicateWith wraps each batch with context.WithTimeout(c.Ctx, llmCallTimeout) (extract_sweep.go:794). With llmCallTimeout = 10 h, Go keeps the parent's earlier deadline, so each Ask sees the outer deadline. If the code used one question's bound as the outer one, d would be near 10 h and the check d > outer would fail. The precondition outer >= 3 × perQuestion (300 s ≥ 270 s) enforces the invariant the production comment names at extract_sweep_ping.go:624-630 ("if either constant moves, check the other").
  • No race in the probe. batchAsker.left is appended under a.mu and read under a.mu after waitIdle. No test in the package calls t.Parallel(), so the llmCallTimeout mutation has no concurrent reader; the restore is deferred right after the write, and the precondition Fatalf runs before the mutation.
  • timingguard baseline is exact. I counted the patterns in the file at the head: 1 unmarked time.Sleep (line 255), 0 polls, 0 time.After. The baseline entry sleep=1 matches. The base had 5 sleeps, 3 polls, 1 after; all removed ones are gone. No new //timing:ok markers were needed.
  • pending-timing-fixes.txt. The 3 removed tests no longer wait on wall-clock windows, so the waiver entries are correctly gone.
  • Data dependence. Only the decided_by line of extract_llm_sweep changes: it appends the #1193 approval record. No Kind, no level, no storage change. I compared the row file and the generated page field by field: they match, including the merge conflict result (main's tier_target text kept, the branch's approval line kept). The PR names the data-dependence state at the top, as the rules ask.
  • PR body claims match the code: test-only, the 30 s bound named, no gate on the outer-timeout test (it needs none: its margins are 150 s wide, not load-sensitive).
  • No host-package logic, no client rules, no fail-open path touched.

@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.332 offload-review skill, @amiddavid's session fresh 1 of 2 1 of 2 42a306e180ce approve

Verdict: approve

Findings

None.

Non-blocking

  • docs/data-dependence/components/extract_llm_sweep.md:8 — the decided_by line backfills the #1193 approval record. That record was missing from main (commit e2d4177 updated the row's where text but not decided_by). It is unrelated to this PR's test change, so by the owner's rule it would get its own PR. The PR body names it, it is one docs line, and the row and the generated page carry the same text. I accept it here.
  • components/offload/extract_sweep_warm_test.go:595-596 — r.asker = blk.labelAsker is overwritten by r.asker = nil on the next line. Pre-existing on main, not touched by this PR. Dead line; a later PR can remove it.
  • components/offload/extract_sweep_warm_test.go:2130 — the static guard outer >= 3 x llmCallTimeout (300 s vs 270 s with defaults) reads env-resolved values. An environment that raises CONTEXT_GURU_LLM_TIMEOUT above 100 s without raising the summarizer timeout fails this test. That failure is the guard doing its job, so I only note it.

What I checked

  • Full diff dec2ef0e..HEAD (5 files) and each of the two commits on their own.
  • warmRig.waitIdle (extract_sweep_warm_test.go:147): same busy test as the old loops (t.asking || t.warmPending() under warmMu), now through testutil.WaitFor (30 s bound, fails on timeout). The old inline loop in TestTheWarmQuestionIsJudgedByTheSharedCacheReadRule did not fail on timeout; the new one does. Stronger, not weaker.
  • TestAWarmQuestionAndAPingQuestionNeverRunTogetherOnAThread: both WaitFor conditions are sound. A PingPlain claim holds nothing (ping_claim.go:101-139 releases it inside ClaimPing), so the poll that returns false leaks no hold. While the warm question holds the thread, ClaimPing returns PingPlain (busy); after release it returns PingNone or PingSweep, so the second condition detects exactly the release.
  • TestTheWarmSweepOuterTimeoutFitsSeveralBatches: I traced the deadline chain. The warm path passes CacheAwareSummarizerCallTimeout() (300 s) as the outer bound (extract_sweep_warm.go:1283); ask wraps c.Ctx with it (extract_sweep_ping.go:631-639); adjudicateWith wraps that with llmCallTimeout per batch (extract_sweep.go:794). With llmCallTimeout = 10 h, the deadline the asker sees is the outer one, so d > outer catches a regression to one question's bound and d < outer/2 catches a too-short outer bound. No sleep, no wall-clock dependence, no RequireTiming gate needed. The static guard holds with the shipped defaults (300 s ≥ 3 x 90 s).
  • The llmCallTimeout = 10 h mutation is safe: no t.Parallel in the package's warm tests, the write happens before the question goroutine starts, and the defer restores the value.
  • Coverage lost with the old 40 ms/30 ms test: a batch that fails while the others continue is still covered by TestAFailedWarmBatchKeepsItsOutputsAndTheOthersAreGated (error path, same fail-open behavior).
  • internal/timingguard/baseline.txt: I counted the unmarked patterns in the file by hand. One time.Sleep remains (line 255, no //timing:ok marker); no poll loop and no time.After select remain. sleep=1 matches.
  • scripts/release/pending-timing-fixes.txt: the file's own rule says "a PR that fixes a listed test removes its line in the same PR". All three removed tests no longer use a fixed time window.
  • Data dependence: no component or feature behavior changes, so no row of its own is needed. The row edit and docs/data-dependence.md carry the identical decided_by text; #1193's commit message records the owner's approval, so the backfilled line states a real decision.
  • No host-package code, no client rules, no production code at all: the host-boundary and client-rule checks do not apply.
  • The PR body's test notes say where the runs happened (macOS, Go 1.27.4) and list vacuity checks. I did not run tests; live tests are not approved for this review.

@amiddavid
amiddavid merged commit 632d0ab into main Nov 26, 2026
12 checks passed
@github-project-automation github-project-automation Bot moved this from New/ToDo to Done in Rossoctl Issue Prioritization Nov 26, 2026
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