Skip to content

Launcher: recover after a requested stop when the dead lock owner is its own stopped asset - #67

Merged
tmori merged 1 commit into
mainfrom
fix/recover-after-normal-stop
Oct 16, 2026
Merged

tmori merged 1 commit into
mainfrom
fix/recover-after-normal-stop

Conversation

@tmori

@tmori tmori commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

Problem (found on a rebuilt Business Pack Foundation with Core 1.4.0 / hako-cmd 1.4.0): after a normal stop of an Urban run, hako-cmd check reported ABORT. The Urban car plant (urban-car-hakoniwa-asset) is the master and takes the master lock every step, so the Launcher's terminate landed while it held the lock. The next start was refused as fail-stop, so Urban could not be started twice in a row. The former runtime.cleanup_mmap_on_start used to hide this.

Change (agreed with @tmori): a requested stop is not a crash. In terminate(), when the session ends TERMINATED (not FAILED), _recover_after_normal_stop() runs hako-cmd recover only if:

  • every managed process is stopped;
  • hako-cmd check reports ABORT;
  • the ABORT owner PID is one of the assets this Launcher ran.

hako-cmd recover itself still refuses while a recorded Hakoniwa process lives, which covers descendants on Windows, where descendant verification is unavailable. FAILED sessions and owners this Launcher did not run keep their evidence, as before. HakoCli.recover() was added for this.

Verified:

  • 3 new tests (own stopped asset → recovered; foreign owner → kept; FAILED → kept); 134 tests pass.
  • Real run: the Rainbow loop on Urban. After the first run's stop, the log shows normal stop: cleared the lock left by stopped asset(s) [46872] (hako-cmd recover).

Follow-up for the proper fix (C++ assets releasing the lock on a stop signal): see #66.

🤖 Generated with Claude Code

…aster-lock owner is one of its own stopped assets

A requested stop terminates the assets; an Urban car plant is the master and takes the
lock every step, so a stop landing while it held the lock left it recorded as held by a
dead owner and the next start fail-stopped. When the session ends TERMINATED, every
managed process is stopped, and hako-cmd check reports ABORT with an owner this Launcher
ran, run hako-cmd recover (it refuses while a recorded Hakoniwa process lives). FAILED
sessions and foreign owners keep their evidence.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@tmori
tmori merged commit 1de0b21 into main Oct 16, 2026
8 checks passed
@tmori
tmori deleted the fix/recover-after-normal-stop branch October 16, 2026 10:33
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.

1 participant