Skip to content

fix(test): write the fake reporter's argv and env atomically and clean the shared delegate dir at exit (#702) - #884

Merged
ajianaz merged 3 commits into
developfrom
fix/flaky-delegation-and-effort-tests
Nov 17, 2026
Merged

ajianaz merged 3 commits into
developfrom
fix/flaky-delegation-and-effort-tests

Conversation

@ajianaz

@ajianaz ajianaz commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

What

Makes the stand-in child scripts of two lib test modules write their argv and env records atomically, and removes the shared-delegate-data-<pid>-<hex> directory of the tole-cli lib tests when the test process exits.

Why

delegation::delegate::tests::a_child_with_a_complete_report_settles_done_and_the_parent_sees_it_fenced failed once on CI (PR #880, run 43971776253, job no-mcp profile; the PR did not touch delegation code). The assertion at delegate_tests.rs ~991 (env.contains("TOLE_DELEGATION_REPORT=...")) printed a truncated environment. Root cause: the stand-in child wrote env > file in place; a CI runner's environment is over 4 KiB and env writes it in several chunks, so a reader that woke between two chunks took a prefix for the whole file. fake_tole already had the temp-and-rename fix (#828); fake_reporter (and the discussion reviewer_bin) did not. A test race, not a product bug. an_independent_participant_is_a_consult_child_settled_with_its_report (#702) uses the same fake_reporter and is covered by the same fix.

The lib tests also left one shared-delegate-data-* directory per run in TMPDIR (79 accumulated locally); only a 6-hour sweep at the next start removed them.

Changes

  • crates/tole-cli/src/delegation/delegate_tests.rs: fake_reporter writes argv and env to *.tmp and renames them into place. data_dir() registers an atexit hook that removes its own per-process directory; the start-up sweep stays for killed runs.
  • crates/tole-cli/src/discuss/tool_tests.rs: reviewer_bin gets the same temp-and-rename treatment for argv and env.

Tests only; no production code changed.

Testing

  • The failure could NOT be reproduced locally. The fix rests on the CI log (truncated env in the panic message) plus reading the code.
  • Stress with taskset -c 0, 3-4 busy loops, --test-threads=16, all green: wire_size_missions 100 loops; delegation lib 40 loops default and 40 loops --no-default-features; session_effort_e2e 8 loops; agents 10 loops. 80 delegation-lib loops left no new shared-delegate-data-* dir.
  • Reviewed and left unchanged: session_effort_e2e (fork/exec mutex from flaky test: session_effort_e2e::a_rejecting_provider_still_answers_without_the_parameter (session lock still held by the test process) #646, mock reads until the body parses), wire_size_missions (port 0, reads to Content-Length, read timeout), and the agents load guard (the tests already open it to its bound of 64 load per CPU, which a CI runner cannot reach).
  • fmt, clippy (--all-features, --no-default-features, shell-tools only), cargo check -p tole-core --no-default-features --tests: clean. Full cargo test --no-fail-fast with TOLE_REQUIRE_BWRAP=1 in the default, --no-default-features and shell-tools profiles: no failures. Delegation and discuss lib tests re-run 3x default and once --no-default-features after the last change: green.
  • A pre-PR independent review reported NO BLOCKER (it checked the prefix-read diagnosis, the atomic rename in the same directory, the per-process atexit cleanup, and ran the delegation lib tests including under taskset -c 0). CI: all 19 checks green and Cora Review "No issues found" on the final head.
  • cora is not installed on the author's host; the CI Cora review is the gate.

Refs #702, #712, #738

…d remove the shared data dir at exit

The stand-in reporter wrote env in several chunks, so a reader that woke between two of them took a prefix for the whole file (seen on CI in a_child_with_a_complete_report_settles_done). Write to a temp name and rename, as fake_tole does. The shared-delegate-data dir of the lib tests is now removed by an atexit hook; the start sweep stays for killed runs. Refs #702 #712.
…ically

Same prefix-read race as the delegation reporter: env leaves the process in several writes. Refs #702.
@github-actions

Copy link
Copy Markdown

🔍 Cora AI Code Review

✅ No issues found. Code looks good!


Review powered by cora-code · BYOK · MIT

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.

2 participants