Skip to content

test(proxyapp): boot helpers read the child's output, not the clock or the shell env - #1371

Merged
amiddavid merged 2 commits into
mainfrom
test/proxyapp-boot
Nov 24, 2026
Merged

amiddavid merged 2 commits into
mainfrom
test/proxyapp-boot

Conversation

@amiddavid

Copy link
Copy Markdown
Collaborator

Summary

Batch 1 of the owner's timing task: "tests that are based on time will go into the pool that runs on integrator, and tests that can be fixed since time is a by product of poor design are fixed."

Test-only, no behavior change. Data dependence: none.

What we found

  • TestNoHooksKeepsTheBinaryDefaults is not a timing test. The child process copied the shell env. DASHBOARD_CONTENT=1 turned content_capture on, and the test rejects that.
  • TestHooksRunInOrderAndTakeEffect probed a port it had freed. Another process could take the port, and the test read a foreign server. It also had a 20 s probe limit and a 30 s context.
  • TestHostedModeRefusesCaptureEnv counted a 15 s timeout as "booted". Under load, a late refusal looked like a boot.
  • TestSingleTenantKeepsCaptureEnv passed at its 4 s deadline, even if the proxy never booted.
  • TestGracefulShutdownWithSSEClient polled 200 x 10 ms for the SSE client.

What changed

  • New proxyapp/hostedenv_helpers_test.go with childEnv, startChild and waitListening.
  • childEnv is an allow list (PATH, TMPDIR, TZ, LANG, LC_*, SYSTEMROOT, GOCOVERDIR) plus a private HOME. The proxy reads dozens of env vars (DASHBOARD_*, CG_*, CONTEXT_GURU_*, UPSTREAMS, CONTROL_DB, API keys). A block list goes stale. An allow list does not.
  • bootAndGet and runMain wait for the child's context-guru-proxy listening line or its exit. The safety bound is 90 s. No clock decides the verdict.
  • bootAndGet waits for addr=<its addr> in that line, then probes. It keeps the retry on "address already in use".
  • "Booted" means only that the line appeared. A refusal is an exit with no line.
  • TestGracefulShutdownWithSSEClient uses testutil.WaitFor. Its 2 s shutdown check is a real deadline, so it stays.
  • runMain lost its unused wait argument.
  • TestNoHooksKeepsTheBinaryDefaults left known-laptop-failures.txt. baseline.txt dropped 2 entries.

How it was tested

macOS, Go 1.27.4, laptop under heavy load.

  • Before: DASHBOARD_CONTENT=1 go test -run '^TestNoHooksKeepsTheBinaryDefaults$' ./proxyapp/ fails (content_capture=true) on the base.
  • After: it passes with DASHBOARD_CONTENT=1, DASHBOARD_DB, DASHBOARD_QUEUE, UPSTREAMS, CONTROL_DB exported.
  • CGO_ENABLED=1 go test -race -count=10 -run '^(TestNoHooksKeepsTheBinaryDefaults|TestHooksRunInOrderAndTakeEffect|TestHostedModeRefusesCaptureEnv|TestSingleTenantKeepsCaptureEnv|TestGracefulShutdownWithSSEClient)$' ./proxyapp/ passes (515 s).
  • Mutation 1: os.Environ() back in childEnv. TestNoHooks... fails with content_capture=true.
  • Mutation 2: 3 s delay before the refusal.
    • Real code: the test says "refused" and passes.
    • Real code with a 1 s bound: fails with "neither listened nor exited". It does not pass as "booted".
    • Old rule (timeout means booted): fails with "BOOTED". That is the old flaw.
  • Both mutations reverted.
  • go test -race ./proxyapp/... passes in 3 parts. gofmt, go vet and go test ./internal/timingguard/ pass.

Open questions

  • The proxy logs the configured addr, not the bound port. LISTEN_ADDR=:0 with a reported port does not work today. Product code would be needed (product=y). This PR keeps the bind, close and retry step.

@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 7025dac56a6d approve

Verdict: approve

Test-only change. The subprocess boot helpers now wait on the child's own
"listening" line, and the child gets an allow-listed env with a private HOME.
I found no defect I can prove.

Findings

None.

Non-blocking

  • proxyapp/hostedenv_helpers_test.go:120 — the goroutine checks the attr
    match only once, at the moment the generic watch fires. If the pipe ever
    splits the line between "context-guru-proxy listening" and "addr=...", the
    goroutine returns without closing ready, and waitListening reports a
    false childTimedOut after 90 s. Probability is very low: slog writes one
    record per Write, and both parts sit in that record. The exit branch
    re-checks the buffer; the split-write case has no such backstop. A loop that
    re-checks on every later write would close it.
  • proxyapp/hostedenv_test.go:44 — runMain returns a made-up exit code 0
    in the listening case. No caller reads code when exited is false today.
    A comment or a named constant would stop a future caller from trusting it.
  • scripts/release/known-laptop-failures.txt — the removal of
    TestNoHooksKeepsTheBinaryDefaults is sound by reading: the shell's
    DASHBOARD_CONTENT can no longer reach the child, and that var was the
    documented cause. The local-tests run at this head is the live proof; I could
    not run it (live tests not approved).

What I checked

  • The full diff, and every file it touches, in full.
  • All call sites of runMain, bootAndGet and bootAndGetOnce
    (hostedenv_test.go, hooks_test.go, importhistory_test.go,
    lifecycleflag_test.go). All updated to the new signature. No stale caller.
  • TestMain (hostedenv_test.go:16): the child path needs only
    CG_TEST_RUN_MAIN, CG_TEST_MAIN_ARGS, CG_TEST_HOOKS and LISTEN_ADDR.
    childEnv sets the first, startChild the last, and each test passes the
    rest. Nothing the child needs is missing from the allow list.
  • Env duplicate order: Go's Getenv scans the env list in reverse, so the last
    entry wins. childEnv appends the test's extra last, so a test var such as
    DASHBOARD=true overrides an earlier DASHBOARD=false from hostedEnv.
    Same semantics as the old append(os.Environ(), ...).
  • The waited-on line exists and is unique: listenAndAnnounce
    (proxyapp/main_run.go:61) is the only non-test caller, it logs after the
    bind succeeds, and the text and JSON handlers both put the msg and addr=
    on one line. attr="" matches any line, which is what runMain wants.
  • The exit races: a listening line written just before an exit is re-checked in
    the <-c.exited branch of waitListening, so it still counts as listening.
  • Refusal tests keep their meaning: the hosted refusal runs before the listen,
    so exited=true with a non-zero code, as before. -h and import-history
    children never print the listening line, so they take the exit path.
  • TestSingleTenantKeepsTheBinaryDefaults→ TestSingleTenantKeepsCaptureEnv:
    the new rule ("reached the listening line") is stricter than the old one
    ("still alive at 4 s"), and the verdict no longer depends on a clock.
  • timingguard: the new helper uses time.NewTimer + select, which the
    guard does not flag, so no new baseline entry is needed. The two removed
    entries match the removed time.Sleep and deadline loop; the baseline only
    shrinks, which is the required direction.
  • testutil.WaitFor fatals on timeout (internal/testutil/testutil.go:38),
    so the shutdown test still fails loudly if the SSE client never registers.
  • local-tests.sh handles an empty known-failures list: the comm filter
    then treats every failing test as unknown, which is the intent.
  • Compile shape: the moved syncBuffer has one definition, the removed imports
    (bytes, context, os, os/exec, sync, time in hooks_test.go) match
    the remaining usage in each edited file, and no symbol in the new file
    collides with one elsewhere in package proxyapp.
  • Commit message: DCO sign-off present, Assisted-By: used, no behavior
    change claimed, and the claim matches the diff.

@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 7025dac56a6d approve

Verdict: approve

The PR is test-only. It replaces clock-based waits and os.Environ() inheritance in the
proxyapp boot helpers with output-driven waits and a scrubbed child environment. I found no
real defect. Three robustness notes are below, none blocking.

Findings

None.

Non-blocking

  1. proxyapp/hostedenv_helpers_test.go:120-133 — the watcher checks the addr= part only once.

    • What could fail: the goroutine scans the lines when the message substring first appears. If that
      one pipe write ever lands split between context-guru-proxy listening and addr=…, the goroutine
      returns without closing ready, and the wait falls to the 90 s bound or the exit.
    • Why I do not believe it today: listenAndAnnounce writes the whole line in one slog record
      (main_run.go:66), far below the pipe buffer, so both substrings arrive in the same Write. I could
      not construct a failing input.
    • Fix if wanted: when the scan finds no matching line, re-arm the watch instead of returning.
  2. proxyapp/hooks_test.go:151-159 — the third port collision returns got=nil.

    • Callers then read a zero-value probe (status 0) and the failure names the route, not the lost
      port. Pre-existing: the old code returned nil in the same place. Worth a portTaken message one
      day, not in this PR.
  3. proxyapp/hooks_test.go:184-191 — http.Get has no bound.

    • A child that binds, logs the listening line and then hangs before Serve would hang the test
      until the binary's -timeout. The old poll failed within 20 s. Everything between the log line and
      Serve is synchronous (main_run.go:933-1026), so I see no path to it.

What I checked

  • The full diff, all 8 files, and the code around each change.
  • Boot order in main_run.go. The hosted capture refusal (line 553) runs before
    listenAndAnnounce (line 933), so runMain's "exit before the listening line" is a correct refusal
    signal. hooks.Mount (line 950) runs before srv.Serve (line 1026), so any HTTP response implies
    the hook routes are mounted — the removed retry in get is safe.
  • Log format. The child env is scrubbed, so logging.Setup defaults to the text handler
    (internal/logging/logging.go:71), which prints addr=127.0.0.1:port unquoted. The waitListening
    attr match works. The scrub also removes the CG_LOG_FILE/CG_LOG_FORMAT drift that JSON mode would
    cause — the plausible cause of the old TestNoHooksKeepsTheBinaryDefaults laptop failure.
  • Env allow list. Every variable the boot path reads (UPSTREAMS, CONTROL_DB, DASHBOARD_*,
    CG_LOG_*, keys) is either scrubbed or set per test. GOCOVERDIR is kept, so coverage still works.
    HOME is a private temp dir, so claudeCompactAtStart is deterministic. All runMain/bootAndGet
    callers were checked against the new signature and the scrubbed env.
  • Races in the helpers. syncBuffer.watch/fire run under one mutex. c.exited closes only after
    cmd.Wait returns, so pipe output is complete before the exit branch scans it, and
    ProcessState.ExitCode() is read only after <-c.exited. A listening line written just before an
    exit is still counted (the exit branch re-scans). No t method is called from a non-test goroutine.
  • timingguard. The new helper uses time.NewTimer as a safety bound, which no rule flags
    (sleep, poll, time.After). The two removed baseline lines match the now-zero counts in
    hooks_test.go and shutdown_test.go.
  • Cleanup order. startChild registers the kill before t.TempDir's removal (LIFO), so the child
    dies before its HOME dir disappears.
  • I did not run builds or tests (live tests not approved for this review). The removal of
    TestNoHooksKeepsTheBinaryDefaults from scripts/release/known-laptop-failures.txt rests on the
    env scrub making the child deterministic; the PR's own local-tests run is the proof to check before
    merge.

…r the shell env

Test-only, no behavior change.

- The child of bootAndGet and runMain gets an allow-listed env and a private HOME.
  A DASHBOARD_CONTENT=1 in the shell no longer breaks TestNoHooksKeepsTheBinaryDefaults.
- Both helpers wait for the child's "context-guru-proxy listening" line or its exit,
  with a 90 s safety bound. "Booted" now means only that the line appeared.
- TestGracefulShutdownWithSSEClient waits with testutil.WaitFor.
- TestNoHooksKeepsTheBinaryDefaults leaves known-laptop-failures.txt.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: DAVID AMID <[email protected]>
… probe

Test-only, no behavior change.

- The output watch runs its match func after every write. A listening line split
  across 2 writes now ends in ready. A unit test feeds it in 2 writes.
- bootAndGet probes with a 60 s client timeout.
- runMain says its code is not an exit code when the child still runs.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: DAVID AMID <[email protected]>
@amiddavid

Copy link
Copy Markdown
Collaborator Author

Fixed in the new head. Thanks to both reviewers.

  1. Split line: the watch now runs a match func after every write. A listening line that arrives in 2 writes ends in ready, not at the 90 s bound. New test TestWaitListeningSeesALineSplitAcrossWrites feeds it in 2 writes. A second test checks that another addr does not match.
  2. Probe bound: bootAndGet uses a client with a 60 s timeout. A child that logs listening and hangs now fails with a clear message.
  3. runMain code: a comment now says the code is not an exit code when the child still runs.
  4. Third port collision returns nil: left as is. It is older than this PR. It belongs in its own change.

Rebased on origin/main. The 5 target tests and the 2 new tests pass at -race -count=10. go test ./internal/timingguard/, gofmt and vet pass.

@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 resumed 1 of 2 2 of 2 e6bba04ab1e1 approve

Verdict: approve

The fix commit e6bba04 answers every round-1 note, and the rebase onto the
new main (#1366) is clean. No new defect.

Findings

None.

Earlier findings, round 1

Mine (all non-blocking):

  1. Split-write race in waitListening — fixed. watch now takes a match
    func and fire runs it after every write (hostedenv_helpers_test.go:62),
    so a line split across 2 writes still fires. The one-shot goroutine is gone.
    TestWaitListeningSeesALineSplitAcrossWrites feeds the line in 2 writes and
    proves both halves: not fired after the first, fired after the second.
  2. Fabricated exit code 0 in runMain — fixed with the comment at
    hostedenv_test.go:44 ("code is not an exit code here").
  3. known-laptop-failures.txt removal — the author reports the 5 target tests
    and the 2 new tests pass at -race -count=10. The local-tests run at this
    head stays the live proof before merge, as in round 1.

Reviewer 2's:

  1. Same split-write race — fixed as above. Agree; no new proof to add.
  2. Third port collision returns got=nil — rejected by the author: it is
    older than this PR and belongs in its own change. I checked the reason: the
    old bootAndGetOnce returned nil in the same place before this PR, and
    the repo rule keeps a main defect off a feature branch. The reason is right.
  3. Unbounded http.Get — fixed. probeClient bounds each probe at 60 s
    (hooks_test.go:143), so a child that logs "listening" and hangs fails with
    the child's output, not at the binary's -timeout.

Non-blocking

  • hostedenv_helpers_test.go:62 — fire now runs the match func over the whole
    buffer on every write, and hasListeningLine splits the buffer into lines
    each time. That is O(writes × output size). The children in these tests print
    at most a few hundred lines, so it cannot matter here. Worth a note only if
    the watch ever moves to a child with large output.

What I checked

  • Last review: round 1, 7025dac, 2026-11-24T17:57:02Z.
  • New commits read: 2 (d83ae3f "boot helpers read the child's output, not the
    clock or the shell env" — the round-1 change rebased; e6bba04 "re-check the
    listening line on every write, bound the probe" — the fixes). The new base
    commit e54d499 (#1366) sits under them.
  • Read in full: 2 reviews, 1 comment, 0 inline comments (from the three files).
  • New items since my last review, and what I did:
    • Reviewer 2's round-1 review (17:57:39Z): read in full. Checked each of its
      three notes against the new head (fixed, rejected-with-reason, fixed).
    • Author comment (18:17:33Z): read in full. Each claim checked against
      e6bba04; all four answers match the code.
    • Rebase onto e54d499: diffed the PR's own files across the rebase
      (7025dac → d83ae3f). The only PR-file changes the rebase brings are
      #1366's own edits now under the PR: RequireTiming in two metricspush
      tests and testutil.TimingEnabled() && on the shutdown-time assertion
      (shutdown_test.go:75), which merges cleanly with this PR's
      testutil.WaitFor on the line above. No PR content was lost or changed.
    • Fix commit e6bba04: read the full diff. watch's new match-func shape has
      exactly three callers (waitListening, the two new tests), all on the new
      signature. waitListening keeps the exit-branch re-check through
      hasListeningLine. The new test file has no timing pattern, so no
      timingguard baseline entry is needed. hooks_test.go re-adds time for
      the 60 s client timeout, which the guard does not flag.
  • Commit messages: DCO sign-off and Assisted-By: present on both commits.
    Both say "Test-only, no behavior change", and the diffs match the claim.

@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 resumed 2 of 2 2 of 2 e6bba04ab1e1 approve

Verdict: approve

The new head fixes all three of my round-1 notes, two with a new unit test. The rebase onto
origin/main (#1366) changed none of the PR's own content except the intended merge in
shutdown_test.go. I found no defect in the new code.

Findings

None.

Earlier findings, now resolved

  1. Watcher checked the addr= part only once (mine, round 1; also reviewer 1).

    • Fixed. watch now takes a match func and runs it after every write
      (hostedenv_helpers_test.go:58-76), so a listening line split across two writes fires on the
      second. waitListening shrank to one watch plus the exit re-check (:128-145).
    • TestWaitListeningSeesALineSplitAcrossWrites (hostedenv_watch_test.go) feeds the line in two
      writes and proves both halves: no fire after the first, fire after the second. The
      no-early-fire check is deterministic — both writes and both fire calls happen under the buffer
      mutex before the select. TestWaitListeningIgnoresAnotherAddr covers the wrong-addr case.
  2. http.Get had no bound (mine, round 1).

    • Fixed. probeClient bounds each probe at 60 s (hooks_test.go:141-143), under the 90 s
      childBound, so a hung child fails with the buffer in the message.
  3. runMain's made-up exit code 0 (reviewer 1's note; I raised it as a doc gap too).

    • Fixed. The comment at hostedenv_test.go:44 says the code is not an exit code when the child
      still runs.
  4. Third port collision returns got=nil (mine, round 1).

    • Rejected by the author: it is older than this PR and belongs in its own change. The reason is
      right — the same content was in the pre-PR code, and the repo rule gives a main defect its own
      issue and PR. I keep nothing.

Non-blocking

  • hostedenv_helpers_test.go:35-36,57 — two comments still describe the old substring watch:
    "when the output first contains a string" and "each watch whose string is now in the output". The
    code now runs a match func. Words only; no behavior.

What I checked

  • Last review: round 1, 7025dac56a6d3beae84d01c6412f19f7cee0f591, 2026-11-24T17:57:39Z.
  • New commits read: 3 in 7025dac5..HEAD — e54d499a (new base, #1366 from main, message and stat
    read), d83ae3fb (the round-1 change re-applied on the new base), e6bba04a (the fix commit,
    full diff read).
  • Read in full: 2 reviews, 1 comment, 0 inline comments (from the three saved files).
  • New items since my last review, and what I did about each:
    • Author comment 2026-11-24T18:17:33Z: lists the four dispositions above and the test note
      (-race -count=10 on the 5 target and 2 new tests, timingguard, gofmt, vet). I checked each
      claim against the diff; the code matches it. I ran nothing myself (live tests not approved).
    • Rebase onto #1366: I diffed 7025dac5 vs d83ae3fb on the PR's own paths. Only
      proxyapp/shutdown_test.go differs, by the intended merge — the PR's testutil.WaitFor plus
      #1366's testutil.TimingEnabled() guard on the 2 s assertion. proxyapp/metricspush picks up
      #1366's RequireTiming calls unchanged. No PR content was lost or altered.
    • Fix commit e6bba04a: reviewed line by line (below).
  • The new watch design: match runs under the buffer mutex from fire, the closure captures only
    the immutable attr, and the exited branch re-checks the same predicate through String(), so a
    line written just before an exit still counts. watch fires at registration, so a line printed
    before waitListening is called is still seen.
  • timingguard at the new head: probeClient's Timeout: 60 * time.Second and the time.NewTimer
    bound match no flagged pattern; the new test file uses no time at all; the baseline needs no
    change and got none.
  • The PR diff against the new base (e54d499a..HEAD) is the round-1 content plus the fix commit;
    nothing else entered.

@amiddavid

Copy link
Copy Markdown
Collaborator Author

Local tests at e6bba04ab1e1: fail (Darwin, go1.27.4)

Step Result
vet pass
build-purego pass
build-record pass
vet-record pass
depguard pass
race-proxy pass
race-dash FAIL
race-plugin pass
race-rest pass
race-record pass
node-timing pass (flaky: passed on the 2nd run)

Skipped: TestBobReleasePythonSuite (Bob plugin on hold, #1221).
timing tests: run (this PR adds or changes one)

  • race-dash: flaky on the 1st run, passed on the rerun: TestPlanReplayStaysNearTheFixedKCost

Log tail of race-dash:

	/Users/davidamid/git/context-guru/.claude/worktrees/proxyapp-boot/dash/toolinventory.go:928 +0x24c
github.com/rossoctl/context-guru/dash.(*Recorder).RecordInventory.func1()
	/Users/davidamid/git/context-guru/.claude/worktrees/proxyapp-boot/dash/toolinventory.go:897 +0x38
github.com/rossoctl/context-guru/dash.(*Recorder).startInBackground.func1()
	/Users/davidamid/git/context-guru/.claude/worktrees/proxyapp-boot/dash/capture.go:424 +0x7c
created by github.com/rossoctl/context-guru/dash.(*Recorder).startInBackground in goroutine 28174
	/Users/davidamid/git/context-guru/.claude/worktrees/proxyapp-boot/dash/capture.go:424 +0x134

goroutine 28288 [select]:
database/sql.(*DB).connectionOpener(0xc001044340, {0x105684778, 0xc001c914f0})
	/opt/homebrew/Cellar/go/1.27.4/libexec/src/database/sql/sql.go:1266 +0xbc
created by database/sql.OpenDB in goroutine 28287
	/opt/homebrew/Cellar/go/1.27.4/libexec/src/database/sql/sql.go:846 +0x250
FAIL	github.com/rossoctl/context-guru/dash	1514.277s
FAIL

@amiddavid
amiddavid merged commit 776492c into main Nov 24, 2026
8 checks passed
@github-project-automation github-project-automation Bot moved this from New/ToDo to Done in Rossoctl Issue Prioritization Nov 24, 2026
amiddavid added a commit that referenced this pull request Nov 24, 2026
test(release): give race-dash the same 40 m limit as race-record

Part A runs the dash race tests with a 25 m limit. On the shared
laptop (10 CPUs, load 190-400) the run took 1507 s and the rerun
1514 s. Both hit "panic: test timed out after 25m0s" on PR #1371.
That PR did not touch dash.

Raise the limit to 40 m, as race-record has. Add a comment that
says why.

docs(release): say dash has a 40 m limit in the Part A docs

The header of part-a.sh and RELEASING.md still said "dash 25m".
Change both to "dash 40m" to match the script.


Test script only, no behavior change. Round 2 approved.

Assisted-By: Claude Opus 5.5
Signed-off-by: DAVID AMID <[email protected]>
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