Skip to content

🤖 tests: replace fixed-count waits and short-lived processes in the manager monitor tests - #8112

Open
ThomasK33 wants to merge 1 commit into
mainfrom
fix/bg-manager-tests-deadline-waits
Open

ThomasK33 wants to merge 1 commit into
mainfrom
fix/bg-manager-tests-deadline-waits

Conversation

@ThomasK33

@ThomasK33 ThomasK33 commented Nov 10, 2026 •

Copy link
Copy Markdown
Member

Summary

30 tests in backgroundProcessManager.test.ts still waited with a loop of a fixed number of short tries (34 loops, 25 to 50 ms each), so each wait ended after 1.5 to 6 s whatever the host did. They now wait on the condition with a 20 s deadline (waitForCondition, as #8081 did for other tests). A verifier of #8081 named these tests as the leftover.

Changes

Test file only: src/node/services/backgroundProcessManager.test.ts.

Change Tests
34 fixed-count loops become waitForCondition(..., MONITOR_WAIT) 30 tests: the monitor failure and retirement tests, the settlement wake tests, the retained-batch tests, and the in-flight read tests
The process lives 60 s (was 5 or 10 s) when the test waits for a failure retirement 12 tests. A process that exits retires the monitor as "completed", not "failed", so a slow wait saw the wrong reason.
A gate file ends the script after the test's read or snapshot "still wakes on natural exit when a filtered read did not show the matched line" (was sleep 0.5) and "acknowledging one flush preserves only later retained batches" (BATCH_B was printed after sleep 0.5)
Limits sit at least 10 s above the sum of a test's waits A test with two waits has 60 s. Tests that had an explicit 15 s limit and now wait 20 s use the 30 s file default.
"wakes for a zero-output process (never suppressed by the offset gate)" waits for a match with the default 20 s (was 6 s) one test (the filtered-read test above changed its 6 s wait too)

I did not change these:

  • Eight sleeps of 300 or 400 ms before an assertion that nothing else happened. They are negative windows: a signal cannot prove that an event does not come.
  • Three loops that read every page of a log (readAllPages, readEverything, drainAndRebuild) and two loops that call a function four times. They are not waits.

Validation

  • Slow host, simulated. I added await Bun.sleep(1_500) right after the spawn in the two gate tests and ran each version once:

    Version "still wakes on natural exit ..." "acknowledging one flush ..."
    main fails (toEqual) fails
    this branch passes passes

    The old script exits 0.5 s after it starts, so a delay before the first read lets the exit flush the match first. The gate file removes that race.

  • Limits. check-limits.py (below) checks 70 tests that call readExitCodeWhenWritten, waitForCondition or waitForMonitorMatch. It reports 0 tests with a limit below their waits plus 10 s.

  • backgroundProcessManager.test.ts passes 171 of 171 tests on this branch.

  • make typecheck, make static-check, make lint-eslint, make dry-check and make crap-check pass.

  • I ran no stress copies (the host's memory cap bans them), so I have no pass-rate numbers under load for these tests.

check-limits.py

Run it from the repo root (python3 check-limits.py). It exits 1 and lists the tests below their waits.

# For each test that calls readExitCodeWhenWritten, waitForCondition or waitForMonitorMatch, the test limit (explicit or the file default of
# 30 s) must exceed the sum of its waits (20 s per readExitCodeWhenWritten or waitForCondition call, plus
# any timeout_secs of a tool call) by at least 10 s.
import re,sys
bad=0; n=0
for f in ['src/node/services/backgroundProcessManager.test.ts','src/node/services/tools/bash_output.test.ts']:
    lines=open(f).read().split('\n')
    starts=[i for i,l in enumerate(lines) if re.match(r'\s*(it|test)(\.each\(.*\))?\(',l)]
    for i in starts:
        ind=lines[i][:len(lines[i])-len(lines[i].lstrip())]
        j=next((k for k in range(i+1,len(lines)) if lines[k]==ind+'});' or re.fullmatch(re.escape(ind)+r'\}, [0-9_]+\);',lines[k])),None)
        if j is None: continue
        body='\n'.join(lines[i:j+1])
        if not any(h in body for h in ('readExitCodeWhenWritten(','waitForCondition(','waitForMonitorMatch(')): continue
        m=re.fullmatch(re.escape(ind)+r'\}, ([0-9_]+)\);',lines[j])
        limit=int(m.group(1).replace('_','')) if m else 30_000
        waits=20_000*(body.count('readExitCodeWhenWritten(')+body.count('waitForCondition('))
        for arg in re.findall(r'waitForMonitorMatch\(manager(?:, *([0-9_]+))?\)',body):
            waits+=int(arg.replace('_','')) if arg else 20_000
        waits+=int(sum(float(x) for x in re.findall(r'timeout_secs: *([0-9.]+)',body))*1000)
        n+=1
        if limit<waits+10_000:
            bad+=1; print(f"TOO LOW {f.split('/')[-1]}:{i+1} limit={limit} waits={waits}: {lines[i].strip()[:70]}")
print(f"checked {n} tests, {bad} below their waits")
sys.exit(1 if bad else 0)

Risks

Test-only. A higher deadline can turn a slow pass into a pass, and a hang still fails at the test's limit with its own assertion. The 12 longer-lived processes rely on afterEach to stop them, as the sibling tests with sleep 30 already do.


Generated with xum • Model: anthropic:claude-sonnet-5-5 • Thinking: xhigh • Cost: $56.89

…anager monitor tests

Twenty-nine monitor tests waited with a loop of a fixed number of 25 to 50 ms tries, so the wait
ended after 1.5 to 6 s whatever the host did. They wait on the condition with a 20 s deadline. The
tests that expect a failure retirement used scripts that exit after 5 to 10 s and now live 60 s,
since a process that exits retires the monitor as completed. Two tests whose script exited on a
timer (a filtered read, two retained batches) wait for a gate file instead. Limits sit above the
sum of each test's waits.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-10T17:21:44.014369Z 7e4205d Manual request
🔒 Security Review ✅ Completed 2026-11-10T17:22:54.291435Z 7e4205d Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

Copy link
Copy Markdown
Contributor

🟢 e2e stories (Haiku): 14 passed

22 agent steps · 7 replayed from cache · 15 model calls · 47.1k tokens (27% cached)
Spend: $0.09 of the $1.00 cap (proxy ledger)

All 14 tests in 9 files
Test Agent Time
🟢 chatRestart.e2e.ts · 1 passed 1 step · 1 call 6.1s
🟢 a chat survives a restart of the server 1 step · 1 call 6.1s
🟢 compaction.e2e.ts · 1 passed 1 step · 1 call 5.2s
🟢 /compact replaces the old chat with a summary 1 step · 1 call 5.2s
🟢 pluginTrustRestart.e2e.ts · 1 passed 4 steps · 2 calls 11.7s
🟢 a trusted plugin hook stays trusted after the server restarts 4 steps · 2 calls 11.7s
🟢 settingsRoundTrip.e2e.ts · 1 passed 2 steps · 1 call 10.7s
🟢 a chat survives trips through Settings 2 steps · 1 call 10.7s
🟢 sidebarPerWorkspace.e2e.ts · 1 passed 4 steps · 1 call 6.4s
🟢 a new workspace starts with its right sidebar collapsed while another keeps it open 4 steps · 1 call 6.4s
🟢 smoke.e2e.ts · 1 passed 2 steps · 1 call 3.1s
🟢 the agent opens the playground workspace 2 steps · 1 call 3.1s
🟢 streamErrors.e2e.ts · 1 passed 1 step · 1 call 7.9s
🟢 stream errors show in the chat, and the chat recovers 1 step · 1 call 7.9s
🟢 todoNudge.e2e.ts · 1 passed 1 step · 1 call 4.4s
🟢 the agent finishes open TODO items after the turn-end nudge 1 step · 1 call 4.4s
🟢 touchAlignment.e2e.ts · 6 passed 6 steps · 6 calls 24.6s
🟢 the Settings close button is level with the title on a touch screen 390px wide 1 step · 1 call 4.2s
🟢 the Settings close button is level with the title on a touch screen 768px wide 1 step · 1 call 4.3s
🟢 Backup settings checkboxes are small and level with their labels on a touch phone 1 step · 1 call 4.6s
🟢 the heartbeat checkbox is small and level with its label on a touch phone 1 step · 1 call 4.2s
🟢 a reply's model and time stay on one line on a touch phone 1 step · 1 call 3.8s
🟢 the workspace actions menu stays on the title row on a touch phone 1 step · 1 call 3.4s

e2e 0.20.0 · 1m 25s · web · run artifacts

🟢 e2e Electron stories (Haiku): 3 passed

3 agent steps · 3 model calls · 7.9k tokens (33% cached)
Spend: $0.01 of the $1.00 cap (proxy ledger)

All 3 tests in 3 files
Test Agent Time
🟢 electron/deepLink.e2e.ts · 1 passed 1 step · 1 call 8.1s
🟢 a deep link of a second launch starts a chat in the running app 1 step · 1 call 8.1s
🟢 electron/menuBar.e2e.ts · 1 passed 1 step · 1 call 7.4s
🟢 the workspace menu bar is the desktop title bar 1 step · 1 call 7.4s
🟢 electron/smoke.e2e.ts · 1 passed 1 step · 1 call 6.9s
🟢 Xum Electron opens the playground workspace 1 step · 1 call 6.9s

e2e 0.20.0 · 25.5s · electron · run artifacts

🟢 e2e agent repros (Haiku): no tests selected

Spend: $0.00 of the $1.00 cap (proxy ledger)

e2e 0.20.0 · 7.9s · 2 targets (web, phone) · run artifacts

@ThomasK33

Copy link
Copy Markdown
Member Author

@codex security review

Head: 7e4205d

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

Reviewed commit: 7e4205d6ee

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: 7e4205d6ee

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

This branch has not been deployed

No deployments
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