Keep web launcher job status tied to its process #2798
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2798"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ubiquitarianism/leonida. Originally posted by weeeeeeeeees1 on 2026-11-30T22:51:14Z.
Claimed in the coordination issue as LAUNCHER-JOB-STATE-OWNERSHIP.
What and why
The web launcher can accept a new job as soon as the previous child exits, while its output worker is still draining stdout. The previous worker could then overwrite the new job’s status or clear its kind.
This change passes the exact spawned process to its worker and checks process ownership under the launcher lock before publishing progress or recording an exit status. It also updates the current job’s kind and exit status together.
Tested
mainand passes with the fix. The current-worker test confirms exit status is still recorded.scripts/check_no_game_data.pyandgit diff --checkpassed.GPUs tested: n/a. The tests use synthetic processes and do not launch the game.
AI-assisted: yes. OpenAI Codex (GPT-6) prepared the patch, and GPT-6.2 Astra independently reviewed the diff.
Checklist
main.Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-30T22:53:38Z.
Verified by OreoFR on macOS 27.2.1, Apple M5, Python 3.12, head
6e317eadc, main2878a3911. CPU only, no game.MEASURED
tests/test_launcher_serve.py): 1 failed, 11 passed. The only failure isJobTests::test_old_follower_leaves_the_new_job_state_intact.test_current_follower_publishes_its_exit_statuspasses on main, as expected, since it guards the existing behavior.test_launcher_serve,test_leonida_launcher,test_shell_launchers,test_win_launchers), main vs green: 33 → 35 passed, 2 skipped on both sides (test_win_launchers.py:42and:99, which need PowerShell or cmd.exe). This includes the 7 shell-launcher tests you had to skip on Windows; they pass here on both sides.READ IN CODE
processgoes into a local variable first and is assigned toself.processonly afterspawnsucceeds, so a failed spawn no longer leaves a half-set state behind. The worker gets that exact object, notself.processread again later.set_state(process, …)and the exit path both checkself.process is not processunderself.lock, then updatekindandjob_statetogether inside the lock. A worker whose process has been replaced therefore neither publishes progress nor clears the new job's kind or state.Exited with code N.throughsay(), and returns before_send("state"). Fine as is: the log line is accurate, and the new job has already sent its own state.AI-assisted: Claude Code
Imported from ubiquitarianism/leonida. Originally posted by aegish-zagi on 2026-12-01T04:53:02Z.
Verification — VERIFY-2798
Verdict: PASS
6e317eadc1c5dc11b1b6ee802778e0b570ca88de| merge state vs main: clean merge with current main5dd6d444fin a scratch worktree (merge commite13280ac0), no conflicts. Diff:launcher/serve.py(+15/−5) andtests/test_launcher_serve.py(+36).python -I tests/test_launcher_serve.pylauncher/serve.pyFAILED (failures=1) — the new ownership case: an old follower clearing the new job's state ('' != 'play'). It passes with the fix: clean red→green.set_statenow takes the owning process and returns early under the lock whenself.process is not process; the exit path in_followmakes the same ownership check before clearingkind/job_state;startcaptures the spawned process in a local and passes that exact object to its follower thread instead of re-readingself.process. The change is confined to the race described; no other launcher behaviour touched. No game data.AI-assisted: yes (Muse Wonder, Muse by Meta)
Imported from ubiquitarianism/leonida. Originally posted by KelboLive on 2026-12-01T05:51:09Z.
Review: COMMENTED
The state half is right and the test genuinely guards it: identity against the live
Popencloses the race (launcher/serve.py:322-325, repeated on the exit path at:370-374),running()polls the same object, so there is no pid-reuse hole, and nothing is left behind on a crash. Onorigin/maina stale worker leaveskind='' state='Exited with code 7'; here it stayskind='play' state='Starting'. Real-process checks (immediate exit, kill, still running) behave as described, and the tests are 12 / 15 / 3 green.One leak remains, and it is the same race in the log rather than the state:
_followstill callsself.say(f"Exited with code {code}.")before the ownership check (serve.py:369vs:371), and the per-lineself.say(line)at:362is never gated. I reproduced it deterministically (holding the launcher lock so the old follower cannot finish draining): after the new job's> <command>header, the shared log received the old worker'sold-a,old-b,old-candExited with code 0., while the state correctly stayedStarting. That line also feeds the page's log drawer and, as the last line, the log chip (launcher/index.html:596) — so the pill says "Starting" and the chip says "Exited with code 0." The Tk launcher already drops every event from a non-current process (tools/leonida_launcher.py:614-615); please gate the appends the same way (keep draining, drop the writes) and move the check ahead of the exitsay.Also: both new tests are
Mock-based and neither assertslauncher.log— in the stale test the log is['loading', 'Exited with code 7.']even on this head, so the leak passes.assertNotIn("Exited with code 7.", launcher.log)fails today and would pin the fix.Out of scope but worth a sentence: a restarted launcher forgets the job entirely (new
LauncherreportsReadywhile the old child runs), since tracking is in-memory only — "tied to its process" holds for one launcher lifetime.Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-01T11:59:22Z.
Independent check of
6e317eadcmerged ontobf30e2585. The three launcher suites passed 34 tests. I also tested a specific start-order case with stub processes. Job B begins while job A has spawned its process but has yet to create its output follower. Checking that each follower receives the process started by its own request extends the existing job-status coverage.Using the verifier from #2817, reversing individual source edits in
launcher/serve.pywas detected in 4 of 8 cases with the original tests and 7 of 8 with that extratest_launcher_serve.pycase. The test pauses thread creation deterministically and requires neither a game executable nor a timing delay.AI-assisted with OpenAI Codex.
Imported from ubiquitarianism/leonida. Originally posted by andrew-ai on 2026-12-02T00:54:03Z.
Verified the ownership change with two actual Python child processes on Windows, using Launcher.start and the production output follower. I held the first follower at entry, let its child exit 3, started a second child waiting for a temporary file, then released the first follower. On the parent revision, the second child was still running but kind was empty and the status said Exited with code 3. At
6e317eadcthe live child retained its kind and Starting status. After releasing that child, the launcher reported Ready on both revisions. The controlled delay makes this a deterministic reproduction; I checked the launcher state directly. Codex-assisted.Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T18:00:54Z.
RUN (independent run on Windows, head
6e317eadc1c5dc11b1b6ee802778e0b570ca88de, merged intomain45dc41f95c1cd0dcc29c2c50582e0e9af8a77259withgit merge --no-ff)Merge was clean (merge commit
ae03b0a19). CPU only, no game, no cargo.Green
tests/test_launcher_serve.py: 12 tests OK.tests/test_leonida_launcher.py: 26 OK.tests/test_win_launchers.py: 6 OK.tests/test_shell_launchers.py: 7 skipped (non-Windows only).python -I scripts/check_no_game_data.py launcher/serve.py tests/test_launcher_serve.py: clean.Red
launcher/serve.pyswapped back (restored afterwards): 1 failure,JobTests.test_old_follower_leaves_the_new_job_state_intact. The other 11 pass, includingtest_current_follower_publishes_its_exit_status, which guards existing behaviour and is expected to pass on main. Clean red to green.Review
startkeeps the spawned process in a local and passes that exact object to the follower.set_state(process, ...)and the exit path checkself.process is not processunderself.lock.kindandjob_stateare now updated together. Correct for the state race._followstill callsself.say("Exited with code N.")before the ownership check, and the per-linesay(line)is ungated. A stale worker can therefore still put its lines and "Exited with code N." into the shared log after the new job's header, so the log chip can show an exit line while the state says Starting. Confirmed by reading the code at this head. The Tk launcher drops all events from a non-current process. The tests do not assertlauncher.log, so this leak passes them.Not covered
Verdict: PARTIAL
The state fix is correct and its test fails on main and passes on the head. The reviewer's log-leak question is still open and unpinned by a test.
AI-assisted (Claude Code), models: Claude Opus 5.5 (checker), separate Claude Opus 5.5 judge.
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T18:01:20Z.
Verified on Linux (Python 3.13.18): head
6e317eadcmerged into currentmain45dc41f95(clean merge, throwaway detached tree). Ready.Red/green (source reverted, tests kept):
git checkout origin/main -- launcher/serve.pyon the merge, same test file:test_current_follower_publishes_its_exit_statuspasses on both sides, which is right: it guards the normal exit path against the new ownership check, it is not the regression test.Review of
launcher/serve.py:start()now binds the spawned process to a local before publishing it under the lock, and hands that exact object to_follow, so a follower can no longer read a laterself.process.set_state(process, text)and the end of_followboth drop the update whenself.process is not process; the exit status is written inside the same lock that checks ownership, so there is no window between the check and the write.Exited with code N.to the shared log. That is a log line, not job state, and seems intended.No defects found. CI on this head is at
action_required(fork workflow approval), not failing; the earlier macOS and Windows checks in this thread agree with the Linux result here.Verdict: ready (needs a maintainer to approve the CI runs).
AI-assisted verification: Claude Opus (Claude Code), separate agent per batch.
Generated by Claude Code