Repository navigation
Conversation
…aunchd daemon A real no-mistakes run with a temporary HOME or NM_HOME registers a KeepAlive launchd job in the real gui/<uid> domain; deleting the temp directory removes the plist file but not the loaded job, so the daemon respawns forever and recreates its root. Add the rule, with the exact bootout command, to the ship and scout brief safety rules and to the repo's no-mistakes Test-agent instructions.
Author
|
[AGENT] Closing as stale (no activity for more than 5 days) during the backlog cleanup Javi requested on 2026-10-16. The branch is kept; reopen this PR if the work is still needed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
After a Firstmate task finished and was cleaned up, a
no-mistakesdaemon kept running and respawning.It was the launchd job
com.kunchenguid.no-mistakes.daemon.049534d3, installed by a realno-mistakesrun that had a temporaryHOMEandNM_HOME.no-mistakes daemon startinstalls aKeepAlive=true,RunAtLoad=trueLaunchAgent labeledcom.kunchenguid.no-mistakes.daemon.<sha256(realpath(root))[:8]>.With a temporary
HOME, the plist is written under<tmp>/home/Library/LaunchAgents, butlaunchctl bootstrap gui/<uid>loads the job into the real per-user domain, whichHOMEdoes not scope.Deleting the temporary directory removes the plist file but leaves the loaded job in place.
Killing the daemon only makes launchd respawn it, and the new process recreates its root (a fresh
config.yamlanddaemon.lock).The only way to end it is
launchctl bootout gui/<uid>/<label>.Firstmate's own
bin/never registers a no-mistakes service, and its deterministic tests replace the binary with fakes.The leak comes from an agent-driven step, such as a worker experiment or the agent-driven no-mistakes Test step, running the real CLI with a temporary
HOME/NM_HOME.Reproduction (from the diagnosis)
launchctl listshowedcom.kunchenguid.no-mistakes.daemon.049534d3next to the real daemon...b870f7aa.049534d3is the sha256 prefix of/private/var/folders/.../tmp.X2jzezfrC7/nm, andb870f7aais the prefix of/Users/javiermoya/.no-mistakes.launchctl bootout.Fix
This is fix 4 of the orphan-process diagnosis, Firstmate side only.
bin/fm-brief.shgains rule 8 in both the ship and the scout brief safety rules.The rule text lives in one single-quoted
NM_TEMP_HOME_RULEvariable, so the command renders unexpanded and has a single owner inside the script.It says never to run the real
no-mistakeswith a temporaryHOMEorNM_HOME.If that is unavoidable, the worker must boot out that temporary daemon job, never the shared one, in the same cleanup.
The bootout has to run before the directory is deleted and while
NM_HOMEnames the temporary root, which is$HOME/.no-mistakeswhen onlyHOMEwas temporary.The command is
launchctl bootout gui/$(id -u)/com.kunchenguid.no-mistakes.daemon.$(printf %s "$(cd "$NM_HOME" && pwd -P)" | shasum -a 256 | cut -c1-8)..no-mistakes.yamltest.instructionsgets the same rule, because the no-mistakes Test agent never sees a worker brief.This is the one deliberate second copy.
Out of scope and not implemented: the optional read-only startup check for leftover labels, any change to the no-mistakes project, and the other fixes from the diagnosis, which ship as separate PRs.
Tests (TDD)
tests/fm-brief.test.shtest_ship_and_scout_forbid_temp_home_no_mistakesrenders no-mistakes, direct-PR, local-only and scout briefs.For each one it asserts the prohibition and the exact, unexpanded bootout command, using a fixed-string match.
tests/fm-nm-test-contract.test.shtest_nm_test_instructions_forbid_temp_home_daemonparses.no-mistakes.yamlas YAML, the same way the existing contract test does, and asserts the same rule and command intest.instructions.RED, before the fix:
GREEN, after the fix:
That run covers every script that consumes
fm-brief.sh, plus the tests that read.no-mistakes.yaml.The live Herdr e2e scripts that
--changedselects were deliberately not run, because this task is not authorized to drive Herdr lifecycle.After the review rewording,
fm-brief.test.sh,fm-nm-test-contract.test.shandfm-lint.shwere re-run and passed.Independent review
A separate Claude subagent reviewed the change read-only from four angles: functional tests, architecture and isolation, anti-slop simplification, and requirement alignment.
It found no blockers.
origin/mainsources and pass with the fix.HOMEis temporary was implicit, where an unsetNM_HOMEwould makecd ""hash the wrong directory. The rule now says$HOME/.no-mistakes.NM_HOMEstill names the temporary root. The rule now says so and adds "never the shared one", so it cannot be read as conflicting with rule 7.NM_HOMEis temporary andHOMEis real, the temporary label's plist probably stays in the real~/Library/LaunchAgentsafter bootout and could reload at the next login.The reviewer inferred this and did not reproduce it.
The rule's main line (never do this) already prevents it, and the task asked for exactly the bootout command, so removing the plist is left to the upstream fix below.
Suggested upstream issue for no-mistakes
Instructions acknowledged
/Users/javiermoya/.claude/CLAUDE.md. Applied: everything is in English, TDD was followed (RED recorded before GREEN), new code is within the size limits, and there are no filler abstractions. The independent multi-angle review above was run. No merge is requested or performed here./ssd/datos-mac/workspace/config/development-policy.mdis absent (No such file or directory).AGENTS.mdandCONTRIBUTING.md, and loaded.agents/skills/firstmate-coding-guidelines/SKILL.mdbefore editing. Applied: the one-owner rule (one variable for both scaffolds, with the YAML copy justified above), tests that exercise the public scaffold and parsed config, shellcheck andbin/fm-lint.shclean, and nocommands.testadded.The
PR must be raised via no-mistakescheck may therefore report its expected result for a non-pipeline PR.