Skip to content

fix(brief): cover direct secondmate helper cleanup - #6

Merged
V4f1k merged 1 commit into
mainfrom
fm/secondmate-lifecycle-process-cleanup
Aug 22, 2026
Merged

fix(brief): cover direct secondmate helper cleanup#6
V4f1k merged 1 commit into
mainfrom
fm/secondmate-lifecycle-process-cleanup

Conversation

@V4f1k

@V4f1k V4f1k commented Aug 22, 2026

Copy link
Copy Markdown
Owner

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

  • Moved the shared helper-process cleanup contract to the common brief-generation path and added it to persistent secondmate charters, including exact identity tracking, bounded same-turn cleanup, exit verification, and restrictions on broad or non-owned cleanup.
  • Extended regression coverage for the persistent secondmate contract while preserving the corresponding ordinary ship and scout brief output.

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
persistent charter cleanup headings: 1
scout cleanup headings: 1
ship cleanup headings: 1
shared generated cleanup contract: MATCH across persistent, scout, and ship outputs
persistent idle-by-default boundary: PRESENT
persistent routed-work-only boundary: PRESENT
forbidden broad/shared/non-owned cleanup: PRESENT

Generated persistent charter contract includes exact identity tracking, available launcher-child tracking, bounded same-turn cleanup, exit verification, out-of-worktree coverage, and forbidden broad/non-owned cleanup.

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.sh
  • Direct bin/fm-brief.sh generation 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.

@V4f1k
V4f1k merged commit e3ace8f into main Aug 22, 2026
13 checks passed
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