Skip to content

fix(core): stop the host API from starting at login once core is down - #135

Merged
arthware-dev merged 1 commit into
mainfrom
fix/core-launchagent
Sep 24, 2026
Merged

arthware-dev merged 1 commit into
mainfrom
fix/core-launchagent

Conversation

@arthware-dev

Copy link
Copy Markdown
Contributor

Summary

  • stack down core left the dev.famstack.api LaunchAgent in ~/Library/LaunchAgents with RunAtLoad, so the next login started the host API on 42001 while core was reported down. After stack destroy core or stack uninstall it pointed at a deleted wrapper and launchd kept respawning it.
  • core's stop hook now unloads the agent and removes the plist; stack up core writes it again. A plist with the same label that starts another instance's wrapper is left alone.
  • The remote e2e runner no longer deletes the plist by hand after a run. The install lane's pristine reset still does, for crashed runs.

@arthware-dev

Copy link
Copy Markdown
Contributor Author

Both problems confirmed on the remote test Mac before the fix, on the previous main, in a scratch instance:

  • up core, then down core: the plist stayed, agent not loaded, 42001 closed. launchctl bootstrap gui/<uid> of the leftover plist (what a login does) loaded the agent and 42001 answered again.
  • up core, then destroy core: the plist stayed, pointing at <data_dir>/core/famstack-api, which destroy had deleted. Bootstrapping it: state = spawn scheduled, last exit code = 78: EX_CONFIG, launchd retrying under KeepAlive.

Unit: tests/unit/stacklets/test_core_launchagent.py drives the real hooks through the framework's down and destroy with a temporary home and a recording launchctl stub. 4 of its 6 tests fail against the old stop hook. make lint and make test-unit pass locally.

@arthware-dev

Copy link
Copy Markdown
Contributor Author

After the fix, on the remote test Mac, in a scratch instance:

Step plist agent loaded 42001
up core present yes open
down core absent no closed
down core again absent no closed
up core present yes open
uninstall --yes absent no closed
uninstall --yes again absent no closed

The first-run install lane on this branch (script/test remote install fix/core-launchagent, at cf591ea): 10 passed, 1 xfailed (the known "printed command on PATH" case), and the reset left the Mac pristine.

`stack down core` only unloaded the `dev.famstack.api` LaunchAgent and
left its plist in `~/Library/LaunchAgents` with RunAtLoad set. At the
next login launchd started the API on port 42001 again while core was
reported down. After `stack destroy core` or `stack uninstall` the
plist pointed at a wrapper in the deleted data dir, and launchd kept
trying to spawn it.

core's stop hook now unloads the agent and removes the plist, so down,
destroy and uninstall leave nothing for launchd to start. `stack up
core` writes it again as before. A plist with the same label that
starts another instance's wrapper is left loaded and in place.
@arthware-dev
arthware-dev merged commit 1678e2f into main Sep 24, 2026
1 check passed
@arthware-dev
arthware-dev deleted the fix/core-launchagent branch October 7, 2026 11:51
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