fix(brief): cover direct secondmate helper cleanup - #6
Merged
Conversation
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.
Intent
Define and validate the persistent-secondmate process-cleanup lifecycle contract.
This is the separately routed follow-up created after the captain split persistent-secondmate semantics from the ordinary worker-brief cleanup change on 2026-08-15. The earlier ordinary-worker change is not proof that persistent-secondmate behavior was changed.
Start from the five-part authority analysis at /home/firstmate/homes/fleet-platform/data/brief-uklid-zateze/decision-secondmate-process-cleanup-contract.md. Reconstruct the current persistent-secondmate lifecycle from its authoritative owners before editing: generated charter text, routed task instructions, normal cleanup, and any skill or documentation that claims ownership. Identify where a process created directly by a persistent secondmate can outlive the exact turn that created or used it, and distinguish that case from processes created by ordinary workers already covered by their generated instructions.
Implement the narrowest single-owner contract supported by that evidence. It must require a persistent secondmate that directly creates synthetic load or another long-lived helper to record every exact process identity immediately, clean up only those recorded identities through a bounded same-turn path, and verify exit before continuing or ending the turn. It must cover helpers outside a task worktree and launcher-created children when their identities are available. It must forbid guessed identities, broad pkill -f, shared-daemon restart, cleanup of processes the secondmate did not create, and deferring cleanup to ordinary task cleanup. Do not duplicate the full contract across multiple prose owners; keep one authoritative statement and concise trigger or cross-reference stubs where needed.
Do not turn this into a generic process supervisor, host-wide process discovery mechanism, new teardown killer, or Herdr lifecycle feature. Do not weaken persistent secondmates' idle-by-default, routed-work-only, no-unlanded-work, or exact-scope boundaries. If evidence shows that satisfying the requested behavior requires one of those broader mechanisms or materially changes another lifecycle contract, report the decision instead of expanding the task.
Add or update public-interface regression coverage for every generated output or lifecycle surface that changes, including a persistent secondmate charter and ordinary worker/scout output where relevant. Tests must prove the contract appears exactly where the chosen ownership model requires and that unrelated generation behavior remains unchanged. Use the repository's Bash 3.2-compatible patterns, one-sentence-per-line Markdown style, and existing colocated test runners. Run affected tests, bin/fm-lint.sh, bin/fm-doc-audience-check.sh for maintained prose changes, and any focused live or compatibility verification required by firstmate-coding-guidelines.
Acceptance criteria: the persistent-secondmate boundary and current owners are evidenced before implementation; one authoritative owner defines the direct-helper cleanup contract without drifting copies; generated persistent-secondmate instructions enforce exact identity tracking, bounded same-turn cleanup, and verified exit or an equally direct single-owner mechanism justified by evidence; ordinary routed-worker coverage remains correct and is not used as a substitute for persistent-secondmate coverage; no generic process discovery, broad kill path, shared-daemon restart, or unrelated lifecycle expansion is introduced; focused tests, repository lint, documentation checks, no-mistakes review, and CI pass.
The Herdr lifecycle declaration is not enabled, so do not add Herdr lifecycle commands. The implementation decision is to move the existing shared generated cleanup section to the earliest common brief-generation boundary and inject that same generated contract into persistent secondmate charters, while retaining ordinary ship and scout coverage; no runtime teardown mechanism or broader process supervisor is added.
What Changed
Risk Assessment
✅ Low: The change cleanly centralizes the existing cleanup contract and emits it for persistent secondmate, scout, and ship briefs without altering unrelated lifecycle behavior.
Testing
Affected behavior tests and direct generated-interface checks passed; persistent idle/routed boundaries remained present, and the worktree stayed clean. Lint/static-analysis commands were not run because this assigned test phase forbids them; no maintained prose changed.
Evidence: Generated persistent-secondmate cleanup contract
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
✅ **Review** - passed
✅ No issues found.
✅ **Test** - passed
✅ No issues found.
bash tests/fm-brief.test.shDirectbin/fm-brief.shgeneration for persistent-secondmate, scout, and ordinary ship briefs with cross-path contract comparison✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.