Skip to content

Keep fake Codex task alive through delivery test claim handoff - #1104

Merged
max-sixty merged 1 commit into
mainfrom
fix/ci-35972927203
Sep 24, 2026
Merged

max-sixty merged 1 commit into
mainfrom
fix/ci-35972927203

Conversation

@leaf-agent

Copy link
Copy Markdown
Collaborator

The two Codex delivery failures in main CI run 35972927203 come from the test harness letting its fake Codex task exit before transferring the page claim to the pytest worker. In that gap, the detached adapter can see no live owner and exit, or treat the offline sibling as the only remaining page.

The shared under_codex fixture can now hold the fake task until a test releases it. Both affected tests wait for the adapter lease, transfer the claim while the task is alive, then let the starting command end. This makes the process lifetime in the test match the Codex task it models while preserving the assertions about delivery after the command ends.

Verified: the five focused Codex cases pass with two pytest workers, and pre-commit passes on both changed files.

@max-sixty
max-sixty merged commit 5d8979d into main Sep 24, 2026
4 checks passed
@max-sixty
max-sixty deleted the fix/ci-35972927203 branch September 24, 2026 08:53
max-sixty pushed a commit that referenced this pull request Sep 24, 2026
The everyday test in [main CI run
35977934891](https://github.com/max-sixty/leaf/actions/runs/35977934891)
failed because its fake Codex task exited before the page claim moved to
the pytest process. In that gap, the detached delivery carrier could see
a dead owner and exit. The same setup race was fixed for two neighboring
tests in #1104; this test still used the earlier order.

Hold the fake task until the carrier starts and the claim transfers,
then let the starting command exit before checking queued delivery and
the turn-ended stamp. The assertions still exercise delivery after the
command ends.

Verified: the four focused Codex cases pass, and pre-commit passes on
the changed file.

Co-authored-by: leaf-agent <[email protected]>
max-sixty pushed a commit that referenced this pull request Sep 24, 2026
The nightly Codex transport test could lose its detached carrier before
checking the requested transport: its fake task exited before the page
claim transferred to pytest. Hold that task until the carrier starts and
the claim moves, then let the starting command exit before asserting
that a later start reports the running transport. This applies the same
claim handoff used by the neighboring delivery tests in #1104.

The [failed nightly
run](https://github.com/max-sixty/leaf/actions/runs/35981383445)
reported a missing App Server socket instead of the expected transport
diagnostic. The focused transport test and pre-commit pass locally.

Co-authored-by: leaf-agent <[email protected]>
max-sixty added a commit that referenced this pull request Oct 5, 2026
…#1798)

#1774 removed the polling loop that held `under_codex`'s fake Codex
task, and every SIGKILL in `tests/`. This change tells the next author
the rule that loop broke, and adds a test so the suite rejects SIGKILL
again.

The loop came from a `tend-ci-fix` run that opened #1104. The section "A
process the suite starts ends with the run" in `tests/AGENTS.md` only
said which fixture owns each resource. The change did take its process
from `spawn`, and two reviews read that as proof of cleanup: "the
fixture closes surviving processes on failure". `spawn` only ended the
runner, though, so its shell survived.

- **`tests/AGENTS.md`** now states the property itself, as checks you
can run:
- Many suite runs share one machine, so a process a test starts ends on
every way out of the test. `spawn`'s teardown ends a child and its group
on a pass, failure or interrupt. A worker that dies runs no teardown, so
a process that would otherwise run on carries its own link to the
worker: the session claim for a page server, the worker's pipe for a
held process.
- A held process blocks on a pipe the worker holds, as `session_process`
does. It never polls for a file the test body has yet to write.
- A test ends a process with SIGTERM or by closing that pipe, never
SIGKILL.
- To check a new held process: make the test fail right after starting
it, then run `pgrep -fl <tmp_path>`. On the pre-#1774 tree that finds
the leaked shell; on #1774 it finds nothing.
- **`test_no_test_ends_a_process_with_sigkill`** reads `tests/*.py` and
fails on `Popen.kill()`, `signal.SIGKILL`, signal 9 passed to `kill`,
`killpg` or `send_signal`, or a shell `kill -9` / `kill -KILL`. Each
form planted in a scratch test made it fail, naming the line, and
`os.kill(pid, 0)` still passes.

I scored the guidance with and without the new text:

| Scenario | Without | With |
|---|---|---|
| Codex reviewing #1104 in a checkout at its base: flags the leak | 4/6
| 4/6 |
| Those reviews: ask for a pipe hold that ends with the worker (instead
of a `finally` that keeps the poll) | 0/4 | 4/4 |
| Writing a crashed-lease-holder test: avoids SIGKILL | 0/3 | 3/3 |
| Writing a session stand-in: blocks on a worker-held pipe | 1/3 | 3/3 |
| Reviewing a correct pipe-held test: no false process findings | clean
| clean |

The guidance doesn't make a reviewer notice the leak more often. What
stops it now is #1774's change to `spawn`; the guidance shapes how the
fix is written.

> _This was written by Claude Code on behalf of max-sixty_

---------

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
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