Skip to content

chore(agent): gate test-only section_names; fix wait test on ubuntu-26.04 - #377

Open
t11z wants to merge 4 commits into
mainfrom
claude/relaxed-fermat-fjv0m1
Open

t11z wants to merge 4 commits into
mainfrom
claude/relaxed-fermat-fjv0m1

Conversation

@t11z

@t11z t11z commented Dec 1, 2026 •

Copy link
Copy Markdown
Collaborator

What & why

Scheduled dead-code sweep. One new finding (high confidence):

  • Gated kenny-agent/src/telemetry/collectors/mod.rs::section_names behind #[cfg(test)]. kenny-agent is a bin-only crate (no [lib], no tests/), and the only callers are the module's own tests. Before this, the function shipped in the release binary under #[allow(dead_code)].

CI fix found along the way

kenny-agent (Rust) failed on every run on the new ubuntu-26.04 runners, in agent_update::tests::wait_times_out_while_another_process_runs_target. This will also hit main on its next agent CI run. The test copied /bin/sleep and ran it as a child. On 26.04 that copy exits immediately; I never found out exactly why. Once the child was a fresh copy of the test binary, spawning it also hit ETXTBSY. That happens when a concurrent test forks while the copy is still open for writing. Changes:

  • The child is now a private copy of the test binary, running an #[ignore]d helper (sleep_helper_child) that only sleeps when KENNY_WAIT_TEST_SLEEP_CHILD is set. The test no longer depends on any distro tool.
  • Spawning retries on ExecutableFileBusy for up to about 1 s.
  • If the child exits early, the test fails with its exit status.
  • The "no /bin/sleep, skip" branch is gone, so the test now also runs (and passes) on the Windows job.

Sweep results (not changed here)

Checklist

  • Tests pass: cargo test (agent): 588 passed, 1 ignored (the child-process helper). Server is untouched. CI is green on Linux and Windows.
  • Lint/format clean: cargo fmt --check, cargo clippy --all-targets (no warnings)
  • If the wire contract changed: n/a
  • If the change is architectural: n/a
  • Docs updated where relevant: n/a

https://claude.ai/code/session_01QcqxZRb56sRXGZEAdGhPwz


Generated by Claude Code

`collectors::section_names` has no caller outside the module's own tests
in this bin-only crate; it was kept in the release binary under
`#[allow(dead_code)]`. Compile it only for tests instead.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01QcqxZRb56sRXGZEAdGhPwz

t11z commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator Author

The kenny-agent (Rust) job failed on handlers::agent_update::tests::wait_times_out_while_another_process_runs_target (must report not-free while a process still runs target, agent_update.rs:843). 587 other tests passed.

I don't think this PR caused it:

  • The diff only changes section_names() in telemetry/collectors/mod.rs, which neither agent_update.rs nor this test touches.
  • I couldn't reproduce it locally: 15 isolated runs and 13 full-suite runs (including --test-threads=16) all passed.
  • The same job is green on main (188a84b) and on recent PRs.

The test only waits 200 ms for a spawned child before taking a process snapshot, so it is timing-sensitive under runner load. I haven't confirmed the race yet. I'll re-run the failed job once this workflow finishes; GitHub refuses a re-run while the Windows jobs are still going. If it fails again, I'll treat it as a real race and fix the test properly.


Generated by Claude Code

`wait_times_out_while_another_process_runs_target` copies /bin/sleep to a
private path and runs it. On ubuntu-26.04 runners /bin/sleep is a symlink
into uutils' multicall coreutils binary, which picks its applet from
argv[0]; under the copy's name it printed "function/utility not found" and
exited at once, so the wait saw no holder and the test failed every run.

Set argv[0] to "sleep" (harmless for GNU sleep) and assert the child is
still alive before measuring, so an early exit fails with a clear message.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01QcqxZRb56sRXGZEAdGhPwz

t11z commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator Author

Update: I found the real cause, and it wasn't timing. The re-run failed the same way. Both runs used ubuntu-26.04 runners. There, /bin/sleep is a symlink into uutils' multicall coreutils binary, which decides what to do from argv[0]. The test copies it to kenny-wait-test-<pid> and runs the copy. Under that name the binary prints function/utility not found and exits immediately, so the wait finds nothing holding the target.

Pushed 1d1bd8b: it runs the copy with argv[0] = sleep (GNU sleep ignores this) and asserts the child is still alive before measuring. I checked it against a stand-in multicall binary: the CI panic at line 843 reproduces without the fix, and the test passes with it. main will hit the same failure on its next agent CI run, so this commit fixes it there too.


Generated by Claude Code

…/sleep

On ubuntu-26.04 runners the copied /bin/sleep exits immediately even when
started with argv[0] "sleep", so the wait saw no holder and
wait_times_out_while_another_process_runs_target failed every run. The
shape of a distro's sleep (multicall, wrapper, symlink) is not ours to
depend on.

The child now runs a private copy of the test binary itself, filtered to
an #[ignore]d helper that sleeps only when KENNY_WAIT_TEST_SLEEP_CHILD is
set. This removes the "no /bin/sleep, skip" branch, so the test also runs
on Windows; an early child exit fails loudly with its status.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01QcqxZRb56sRXGZEAdGhPwz

t11z commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator Author

Correction to my last comment: the argv[0] commit is 831b4df, not 1d1bd8b, and it did not fix the failure. On ubuntu-26.04 the copied /bin/sleep still exits immediately when started as sleep, so my "multicall argv[0]" diagnosis was incomplete. I still don't know exactly what 26.04's sleep is.

accaaf9 removes the dependency on it altogether. The test now copies its own test binary and runs it filtered to an #[ignore]d helper, sleep_helper_child. The helper only sleeps when KENNY_WAIT_TEST_SLEEP_CHILD is set, so a plain cargo test -- --ignored stays fast. If the child exits early, the test now fails with its exit status. There's no longer a "no /bin/sleep, skip" branch, so the test also runs on the Windows job now. Locally all 588 agent tests pass, and fmt and clippy -D warnings are clean.


Generated by Claude Code

CI on accaaf9 failed spawning the freshly copied test binary with "Text
file busy": a concurrent test thread forked while `fs::copy` still held
the copy open for writing, and that inherited fd lives in the forked
child until it execs. Retry the spawn on ExecutableFileBusy (up to ~1 s);
any other error still fails the test.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01QcqxZRb56sRXGZEAdGhPwz

t11z commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator Author

CI on accaaf9 got further and hit a different, well-understood error: spawn child running target: Text file busy (ETXTBSY). A concurrent test thread forked while fs::copy still held the fresh copy open for writing, and that inherited fd lives in the forked process until it execs. 01a8c62 retries the spawn on ExecutableFileBusy for up to about 1 s; any other error still fails the test.

This race may also explain the original /bin/sleep failure. I'll confirm or rule that out once CI on 01a8c62 finishes.


Generated by Claude Code

@t11z t11z changed the title chore(agent): gate test-only section_names behind cfg(test) chore(agent): gate test-only section_names; fix wait test on ubuntu-26.04 Dec 1, 2026
t11z pushed a commit that referenced this pull request Dec 3, 2026
`agent_update::tests::wait_times_out_while_another_process_runs_target`
fails on every `kenny-agent (Rust)` run on the ubuntu-26.04 runners,
independent of the change under test (also red on #375 and #356). This
takes the agent_update.rs hunk from #377 unchanged: the child is a copy of
the test binary running an ignored sleep helper instead of a copy of
/bin/sleep, spawning retries on ETXTBSY, and an early child exit fails
with its status. The hunk is byte-identical to #377's, so whichever PR
merges first, the other merges cleanly.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01QcqxZRm2PPzksU2suv6wqw
Signed-off-by: Claude <[email protected]>

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.

2 participants