Skip to content

Tests wait for real state instead of short fixed deadlines - #53

Merged
Perdikis10 merged 4 commits into
mainfrom
publish/v0.17.1-test-waits
Nov 16, 2026
Merged

Perdikis10 merged 4 commits into
mainfrom
publish/v0.17.1-test-waits

Conversation

@Perdikis10

@Perdikis10 Perdikis10 commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

CI on the 0.17.1 merge commit (c868a52f, run 43895031119) failed six times in a row, each time on a timing test in a Linux job (four parallel workers per job). Each wait either gave up after a few seconds or read state that the code under test had not finished producing yet. This changes only how the tests wait; every assertion stays.

  • Generous bounds where a wait returns as soon as its state appears (the bound only limits a failure):
    • The bots crash fixtures (scripts/qa/bots_peer_recovery.py, tests/test_bots_process_recovery.py): the child process imports the engine before it starts. They also stop at once if the child exits.
    • The live TUI tests (tests/test_mid_turn_input.py): synthetic key streams are parsed on a background thread.
    • _wait_for_line and the worker joins in tests/test_ide_stdio_bridge.py.
  • Wait for the worker to retire, not just for a final status. A bridge job's final status is recorded before its worker writes its last events (the browser handoff notice) and releases the session. docs/ide_protocol.md says so: "A retained terminal result is history, not proof of worker/resource cleanup or readiness." The resolved-review tests and the reused-session test now wait for the worker before reading those events, sending the next turn or closing the session.
  • Forge swarm: join the second thread before checking that it stopped; it sets its event in a finally block and still has to unwind.

Validation, Python 3.13.18, 10-core Mac, pytest -n 8 on the failing tests:

  • With busy loops on every core: before, the peer crash fixture failed in 1 of 4 rounds; after, 7 of 7 rounds passed.
  • With 40 busy loops: before, the TUI truncation test failed in 4 of 4 rounds; after, 4 of 4 rounds passed.
  • The five changed test files pass in full: 551 passed.
  • ruff check and ruff format --check are clean; scripts/qa/check_public_repo.py passed.

Second commit (ccc6573): the first CI run on this PR failed on Python 3.13 in test_ide_stdio_bridge.py::test_chat_completion_exposes_host_verification_verdict[True], which read session.status right after a terminal event while last_job was still empty. A job moves from active_job to last_job at its worker's final ownership handoff, after its terminal events. Nine bridge tests that read retired-job state now join the started job workers first (_wait_for_job_workers). tests/test_ide_stdio_bridge.py passed in full twice under 40 busy loops on the Mac.

Third and fourth commits. The second CI run failed in three Linux jobs, on more timing tests and on tests that interfere when they share a worker:

  • A Git fixture hit another repository's sample pre-commit hook (Attempt to add a non-ASCII file name).
  • test_scheduler_keeps_ticking_while_provider_is_busy[False] failed in two jobs at once.
  • The peer crash child exited with code 1.

The changes:

  • 4ef7ea96: the bots crash fixtures now print the child's error output when it exits early.
  • 858c074f: CI runs the Linux test suites serially again, as on every main run before 0.17.1 (about 50 min per job, 120-min limit). Parallel workers (from 0.17.1) can return once the suite is safe to share workers.

CI on the 0.17.1 merge commit failed six times in a row, each time on a timing
test (four parallel workers per Linux job). Each wait either gave up after a
few seconds or read state that the code under test had not finished producing
yet. The fixes keep every assertion and change only how the tests wait:

- Waits that return as soon as their state appears now have generous bounds,
  because the bound only limits a failure: the bots crash fixtures (a child
  process imports the engine first) and the live TUI tests (synthetic key
  streams are parsed on a background thread). The crash fixtures also stop at
  once if their child process exits.
- A bridge job's final status is recorded before its worker writes its last
  events (the browser handoff notice) and releases the session
  (docs/ide_protocol.md). The resolved-review tests and the reused-session test
  now wait for the worker to retire before reading those events, sending the
  next turn or closing the session.
- The Forge swarm test joins its second thread before checking that it stopped;
  the thread sets its event in a finally block and still has to unwind.

Under synthetic CPU load (busy loops on every core), the old peer crash fixture
and the TUI truncation test failed, and the new tests passed every round.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 16, 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-16T17:27:07.782976Z 18450f6 PR opened
ℹ️ 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.

A job's final status and terminal events come before its worker's final
ownership handoff, which is when the session moves the job from active_job to
last_job (docs/ide_protocol.md). Nine tests waited for a terminal event and then
read session.status, session.list or job.status expecting the job to be
retired; on a busy CI worker the read could land first (Python 3.13:
test_chat_completion_exposes_host_verification_verdict[True] read a missing
last_job). They now join the started job workers first, through one helper.
With fail-fast waits, the peer crash fixture now reports when its child process
exits before entering the blocking provider (CI, Python 3.13 and 3.14: "exited
early with code 1"), but not why. Both crash fixtures write the child's error
output to a file in the test's temporary folder and include its end in that
failure, so the cause is visible in CI logs.
0.17.1 brought in four parallel pytest workers per Linux job. On GitHub's
4-CPU runners the suite is not yet reliable that way: eight runs in a row
failed at least one Linux job on timing tests. The races fixed in the previous
commits explain some of them. Others show tests interfering with each other
when they share a worker: a Git fixture hit another repository's sample hook,
and a schedule tick test failed in two jobs at once. Serial runs passed on main
on Nov 14, at about 50 minutes per job, within the 120-minute job limit.
Parallel runs can return once the suite is safe to share workers.
@Perdikis10
Perdikis10 merged commit e2d5d4d into main Nov 16, 2026
7 of 12 checks passed
@Perdikis10
Perdikis10 deleted the publish/v0.17.1-test-waits branch November 18, 2026 16:04
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