Skip to content

fix(core): remove the known test flakes and give command-tree teardown a 10 s confirmation budget - #520

Merged
lg2m merged 8 commits into
mainfrom
fix/test-flakes
Nov 1, 2026
Merged

lg2m merged 8 commits into
mainfrom
fix/test-flakes

Conversation

@lg2m

@lg2m lg2m commented Oct 31, 2026 •

Copy link
Copy Markdown
Collaborator

Change

This removes the known test flakes (findings A1, A3 and A4). It also raises the command-tree exit-confirmation budget from 2 s to 10 s (owner decision 3).

  • A1, goal-notice reopen tests. The goal stays active after the user run settles, so the scheduler can queue a goal-origin run. close() then cancels that run, and replaying with u64::MAX appended 3 extra messages. Both revision_notices_across_reactive_checkpoint_overflow_reopen_in_order and client_revision_notice_reopens_as_the_exact_model_window now replay only through the user run's prompt ordinal. The second test also now waits for its run to finish (finished_for(run)), not just any RunFinished.
  • A3, retire_delivery_history. The helper deleted from events through a second rusqlite connection while the store could be in the middle of a write. That made the runtime itself fail with session persistence failed: sqlite reported DatabaseBusy. A #[doc(hidden)] SessionRuntime::expire_delivery_history_for_test now prunes the journal on the store worker, using the production events::prune, which keeps the usage meter consistent. Two other live-store raw deletes in src/headless.rs now use the same seam. The one in canonical_reply_channel_order_survives_database_maintenance closes the store first, so it stays as it is.
  • A4, process-tree teardown.
    • Production: one EXIT_CONFIRMATION (10 s) now replaces the fixed 2 s budgets in reap_watcher, confirm_stopped and native_exit::confirm. Confirmation still finishes as soon as the exit is seen: on Linux it waits on pidfd poll, elsewhere it polls every 10 ms. So only the failure path waits longer. With the change, cancel_and_timeout_kill_descendants_that_left_the_group takes 6.2 s → 6.1 s, a_yielded_escaped_tree_dies_when_the_run_ends 2.1 s → 2.0 s, and a_killed_server_takes_its_commands_with_it 0.04 s → 0.03 s.
    • Test helpers: a new process_has_exited reads the /proc/<pid>/stat state and treats Z/X as exited; non-Linux platforms keep kill(pid, 0). assert_process_exits and the orphan test use it. Escaped processes get reparented to init or a subreaper, so kill(pid, 0) was measuring how late that process reaps them.
    • Discovery: escaped trees now write $PPID $$ to a fifo in the test workspace before they exec sleep. That replaces spawning ps -A in a yield_now busy loop for up to 10 s, and probing for timeout/setsid by running subprocesses (they are now looked up on PATH). All synchronous setup and /proc reads run on the blocking pool.

Verification

The loaded-core recipe is the one from the findings: 3 busy loops pinned to core 0, taskset -c 0 cargo nextest run --profile ci --stress-count 100.

Test Before After
goals::revision_notices_across_reactive_checkpoint_overflow_reopen_in_order 23/100 failed 0/100 (--retries 0)
goals::client_revision_notice_reopens_as_the_exact_model_window 70/100 failed 0/100 (--retries 0)
A3: 3 retire_delivery_history callers, 8 busy loops on 2 cores, -j 8, --retries 0, 300 iterations 6/300 iterations failed (foreground_goal_reopen_replays_work_before_client_adoption: DatabaseBusy) 0/300
A4: 3 shell tests run under a subreaper that reaps late (prctl(PR_SET_CHILD_SUBREAPER) + waitpid on its own child only) 3/3 failed ("still alive after the kill deadline", "the command outlived the process that started it") 3/3 passed; 30/30 stress iterations of all three plus the new zombie tests
A4: 3 shell tests, 4 concurrent stress loops × 25, 6 busy loops on 1 core 100/100 passed 100/100 passed
  • The A4 load stress did not reproduce the 2 s budget timeout locally, on main or with the fix. The CI history shows "could not confirm the command exit" and "still alive" failures on 4-vCPU runners. The late-reaper run reproduces the zombie mode deterministically, which matches the CI failure of a_killed_server_takes_its_commands_with_it (run 40810178056: 10.07 s, then "outlived").
  • New regression tests: tools::shell::exit_tests::an_unreaped_zombie_counts_as_exited and a_running_process_has_not_exited. The first makes a real zombie with waitid(WNOWAIT) and asserts that kill(pid, 0) still succeeds on it while the helper reports it as exited.
  • cargo xtask check: passed on e4321b4c.

No tests were deleted or renamed. One sleep moved with its function, so its line number in xtask/src/legacy-sleeps.txt changed (4802 → 4796); the count stays at 11/11.

Known impact

  • When teardown really cannot confirm an exit, it now reports the error after 10 s instead of 2 s. The success path is unchanged.
  • I skipped STOP_OBSERVERS (pid-keyed) and TEST_EXECUTIONS_STARTED (process-global). Neither appears in any recorded failure, and fixing them means changing the observer API for tests outside this scope. They are listed as follow-ups.
  • I skipped A5 (Windows a_detached_daemon_… "did not start serving within 30s"). It was seen once, and I could not reproduce it without Windows. Follow-up.

lg2m added 3 commits October 31, 2026 16:30
The goal stays active after the user run settles, so the scheduler may queue
a goal-origin successor that close() cancels. Replaying the whole session
then appends that successor's notices. Both reopen tests now replay through
the user run's prompt ordinal.
retire_delivery_history deleted events through a second SQLite connection
while the runtime could be mid-transaction, which made the store report
DatabaseBusy. A test seam on SessionRuntime prunes the journal on the store
worker instead.
The 2 s confirmation budgets failed on loaded runners with "could not confirm
the command exit". Confirmation still returns as soon as every process is
gone, so only the failure path waits longer.

Test helpers now treat zombies as exited, since escaped processes are reaped
by init or a subreaper on its own schedule, and escaped trees report their
pids through a fifo instead of being found by polling ps.
@lg2m lg2m added the ci:full label Oct 31, 2026
@lg2m

lg2m commented Oct 31, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-01T01:29:32.776848Z e4321b4 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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ac74ce26f2

ℹ️ 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".

Comment thread crates/qq-core/src/tools.rs Resolved
@lg2m

lg2m commented Nov 1, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2a874bee20

ℹ️ 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".

Comment thread crates/qq-core/src/tools.rs Resolved
@lg2m

lg2m commented Nov 1, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 295a202273

ℹ️ 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".

Comment thread crates/qq-core/src/tools/shell.rs Resolved
@lg2m

lg2m commented Nov 1, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c0edc3d415

ℹ️ 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".

Comment thread crates/qq-core/src/tools.rs Resolved
@lg2m

lg2m commented Nov 1, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 764847d36c

ℹ️ 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".

Comment thread crates/qq-core/src/tools.rs Resolved
@lg2m

lg2m commented Nov 1, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: e4321b4cb5

ℹ️ 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".

@lg2m
lg2m merged commit a7a9495 into main Nov 1, 2026
10 checks passed
@lg2m
lg2m deleted the fix/test-flakes branch November 1, 2026 02:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant