Skip to content

fix(bin): forbid pattern-based process kills in worker briefs - #6459

Open
jffiorillo wants to merge 2 commits into
kunchenguid:mainfrom
jffiorillo:fm/firstmate-pkill-guard
Open

jffiorillo wants to merge 2 commits into
kunchenguid:mainfrom
jffiorillo:fm/firstmate-pkill-guard

Conversation

@jffiorillo

@jffiorillo jffiorillo commented Oct 3, 2026 •

Copy link
Copy Markdown

Intent

Prevent workers from killing every other process on the machine with a pattern kill, and open the upstream PR for that pkill guard.

Context: on 2026-10-02 at 21:56:25Z a ship worker on macOS stopped its own Firebase emulators with pkill -f "firebase.json" -f. macOS (BSD) pkill stops parsing options at the first pattern, so the trailing -f became a second pattern. That SIGTERMed about 190 processes owned by the user whose command line contains -f: every Herdr pane shell (argv[0] -fish), every Electron/Chromium helper (--field-trial-handle), so all browser tabs and the terminal's helpers, plus other agents (--output-format). Every sibling worker died; only the issuing worker survived, because pkill skips its own ancestors. A read-only reproduction confirmed the match set: pgrep -f "nomatch" -f | wc -l gave 189, and the same command without the stray -f gave 0. This is the same failure class as upstream issue #5656 (ready-for-pr), where a worker's pkill -f "wrangler dev" killed sibling agents whose argv held the launch brief. That issue's suggested fix 2 is a scaffold rule in worker briefs: never use pkill -f, pgrep -f | xargs kill or killall with a text pattern; stop only PIDs you saved yourself, or the listening PID from lsof -ti tcp:<port> -sTCP:LISTEN.

What Changed

  • Add a shared rule to ship and scout briefs forbidding process kills by name or pattern, including the BSD pkill trailing-option trap. Allow only saved PIDs the worker started or listeners on ports its own command started; report other port owners as blockers.
  • Add regression coverage across all ship modes and scout briefs, checking prohibited commands, listener restrictions, and identical rule text.

Risk Assessment

✅ Low: The bounded change consistently adds the agreed process-kill restriction to ship and scout briefs, with assertions against generated output.

Testing

Focused tests and real scaffold CLI scenarios passed; baseline negative controls reproduced the missing guard. Saved emitted instructions and CLI evidence, then removed disposable fixtures. Validation covers the generated instruction contract, not model compliance.

  • Live validation: ✅ go - 3 of 3 scenarios driven live against the product
Scenario Result Live Evidence
Generate ship instructions in all three delivery modes: each prohibits pkill, killall, and pgrep piped to kill, explains the BSD trap, and permits only saved own PIDs or an owned listener. ✅ pass live CLI transcript; generated ship instructions
Generate scout instructions: the identical process rule requires reporting another process holding the port as a blocker. ✅ pass live CLI transcript; generated scout instructions
Supply home additions requesting the historic unsafe cleanup: ship and scout output retain the guard and explicitly give core rules precedence. ✅ pass live CLI transcript; adversarial cleanup request and rule precedence
Evidence: CLI transcript, including baseline negative controls

Source: CLI transcript, including baseline negative controls

$ /opt/homebrew/bin/bash ~/.no-mistakes/worktrees/e6b6b3f653a0/01M5JEM71RVT9PFSZFF4C9DYZ1/tests/.kill-brief-selected.test.sh
ok - fm-brief: scaffolds leave the worker role scope to the launch boundary and keep the secondmate contract
ok - fm-brief.sh: every crewmate scaffold forbids pattern kills
exit=0
$ /bin/bash ~/.no-mistakes/worktrees/e6b6b3f653a0/01M5JEM71RVT9PFSZFF4C9DYZ1/tests/.kill-brief-selected.test.sh
ok - fm-brief: scaffolds leave the worker role scope to the launch boundary and keep the secondmate contract
ok - fm-brief.sh: every crewmate scaffold forbids pattern kills
exit=0
$ ~/.no-mistakes/worktrees/e6b6b3f653a0/01M5JEM71RVT9PFSZFF4C9DYZ1/bin/fm-brief.sh ship-no-mistakes disposable-project --mode no-mistakes
scaffolded: ~/.no-mistakes/worktrees/e6b6b3f653a0/01M5JEM71RVT9PFSZFF4C9DYZ1/.kill-brief-validation-pxq6q30r/home/data/ship-no-mistakes/brief.md (ship, mode=no-mistakes; replace {TASK} and {FIRSTMATE_SPEC})
exit=0
Emitted ship-no-mistakes process rule:
9. Never stop processes by name or pattern (`pkill`, `killall`, `pgrep ... | xargs kill`): a pattern
   also matches sibling agents and the operator's shells and apps, and BSD `pkill -f PAT -f` reads
   the trailing `-f` as a second pattern that matches every command line containing `-f`. Kill only
   PIDs you started and saved, or the listener from `lsof -ti tcp:<port> -sTCP:LISTEN` on a port
   your own command started; if anything else holds the port, do not kill it - report a blocker.

$ ~/.no-mistakes/worktrees/e6b6b3f653a0/01M5JEM71RVT9PFSZFF4C9DYZ1/bin/fm-brief.sh ship-direct-PR disposable-project --mode direct-PR
scaffolded: ~/.no-mistakes/worktrees/e6b6b3f653a0/01M5JEM71RVT9PFSZFF4C9DYZ1/.kill-brief-validation-pxq6q30r/home/data/ship-direct-PR/brief.md (ship, mode=direct-PR; replace {TASK} and {FIRSTMATE_SPEC})
exit=0
Emitted ship-direct-PR process rule:
9. Never stop processes by name or pattern (`pkill`, `killall`, `pgrep ... | xargs kill`): a pattern
   also matches sibling agents and the operator's shells and apps, and BSD `pkill -f PAT -f` reads
   the trailing `-f` as a second pattern that matches every command line containing `-f`. Kill only
   PIDs you started and saved, or the listener from `lsof -ti tcp:<port> -sTCP:LISTEN` on a port
   your own command started; if anything else holds the port, do not kill it - report a blocker.

$ ~/.no-mistakes/worktrees/e6b6b3f653a0/01M5JEM71RVT9PFSZFF4C9DYZ1/bin/fm-brief.sh ship-local-only disposable-project --mode local-only
scaffolded: ~/.no-mistakes/worktrees/e6b6b3f653a0/01M5JEM71RVT9PFSZFF4C9DYZ1/.kill-brief-validation-pxq6q30r/home/data/ship-local-only/brief.md (ship, mode=local-only; replace {TASK} and {FIRSTMATE_SPEC})
exit=0
Emitted ship-local-only process rule:
9. Never stop processes by name or pattern (`pkill`, `killall`, `pgrep ... | xargs kill`): a pattern
   also matches sibling agents and the operator's shells and apps, and BSD `pkill -f PAT -f` reads
   the trailing `-f` as a second pattern that matches every command line containing `-f`. Kill only
   PIDs you started and saved, or the listener from `lsof -ti tcp:<port> -sTCP:LISTEN` on a port
   your own command started; if anything else holds the port, do not kill it - report a blocker.

$ ~/.no-mistakes/worktrees/e6b6b3f653a0/01M5JEM71RVT9PFSZFF4C9DYZ1/bin/fm-brief.sh scout disposable-project --scout
scaffolded: ~/.no-mistakes/worktrees/e6b6b3f653a0/01M5JEM71RVT9PFSZFF4C9DYZ1/.kill-brief-validation-pxq6q30r/home/data/scout/brief.md (scout; replace {TASK} and {FIRSTMATE_SPEC})
exit=0
Emitted scout process rule:
9. Never stop processes by name or pattern (`pkill`, `killall`, `pgrep ... | xargs kill`): a pattern
   also matches sibling agents and the operator's shells and apps, and BSD `pkill -f PAT -f` reads
   the trailing `-f` as a second pattern that matches every command line containing `-f`. Kill only
   PIDs you started and saved, or the listener from `lsof -ti tcp:<port> -sTCP:LISTEN` on a port
   your own command started; if anything else holds the port, do not kill it - report a blocker.

$ ~/.no-mistakes/worktrees/e6b6b3f653a0/01M5JEM71RVT9PFSZFF4C9DYZ1/bin/fm-brief.sh ship-conflicting-additions disposable-project --mode local-only
scaffolded: ~/.no-mistakes/worktrees/e6b6b3f653a0/01M5JEM71RVT9PFSZFF4C9DYZ1/.kill-brief-validation-pxq6q30r/home/data/ship-conflicting-additions/brief.md (ship, mode=local-only; replace {TASK} and {FIRSTMATE_SPEC})
exit=0
ship-conflicting-additions: guard preserved; appended cleanup request explicitly defers to Rules.
$ ~/.no-mistakes/worktrees/e6b6b3f653a0/01M5JEM71RVT9PFSZFF4C9DYZ1/bin/fm-brief.sh scout-conflicting-additions disposable-project --scout
scaffolded: ~/.no-mistakes/worktrees/e6b6b3f653a0/01M5JEM71RVT9PFSZFF4C9DYZ1/.kill-brief-validation-pxq6q30r/home/data/scout-conflicting-additions/brief.md (scout; replace {TASK} and {FIRSTMATE_SPEC})
exit=0
scout-conflicting-additions: guard preserved; appended cleanup request explicitly defers to Rules.
$ /bin/bash ~/.no-mistakes/worktrees/e6b6b3f653a0/01M5JEM71RVT9PFSZFF4C9DYZ1/bin/.kill-brief-base.sh base-ship disposable-project --mode no-mistakes
scaffolded: ~/.no-mistakes/worktrees/e6b6b3f653a0/01M5JEM71RVT9PFSZFF4C9DYZ1/.kill-brief-validation-pxq6q30r/home/data/base-ship/brief.md (ship, mode=no-mistakes; replace {TASK} and {FIRSTMATE_SPEC})
exit=0
base-ship: expected regression reproduced: emitted brief lacks process-kill rule.
$ /bin/bash ~/.no-mistakes/worktrees/e6b6b3f653a0/01M5JEM71RVT9PFSZFF4C9DYZ1/bin/.kill-brief-base.sh base-scout disposable-project --scout
scaffolded: ~/.no-mistakes/worktrees/e6b6b3f653a0/01M5JEM71RVT9PFSZFF4C9DYZ1/.kill-brief-validation-pxq6q30r/home/data/base-scout/brief.md (scout; replace {TASK} and {FIRSTMATE_SPEC})
exit=0
base-scout: expected regression reproduced: emitted brief lacks process-kill rule.
Disposable homes and temporary test executables removed.
Evidence: Generated ship instructions

Source: Generated ship instructions

You are a crewmate: an autonomous worker agent managed by firstmate. Work on your own; do not wait for a human.

# Task
## Captain's intent
{TASK}

## Firstmate spec
{FIRSTMATE_SPEC}

# Herdr lifecycle declaration - NOT ENABLED
**HARD SAFETY GATE:** this scaffold cannot inspect the task text filled in above.
If the task will start, stop, delete, restart, profile, or otherwise drive Herdr lifecycle behavior, stop and regenerate the brief with `--herdr-lab` before dispatch.
Do not add Herdr lifecycle commands to this unguarded brief by hand.

# Setup
You are in a disposable git worktree of disposable-project, at a detached HEAD on a clean default branch.

**Verify isolation before anything else.** Run `pwd -P` and `git rev-parse --show-toplevel`; both must resolve to the disposable task worktree you were launched in, such as a treehouse pool path or an Orca-managed worktree, not the primary checkout firstmate operates from.
The path check is authoritative: `git rev-parse --git-dir` and `git rev-parse --git-common-dir` can help inspect the repo, but they do not prove you are outside the primary checkout.
If the top-level path is the primary checkout or not the worktree you were launched in, STOP - do not branch or commit here - append `blocked [at=<epoch>]: launched in primary checkout, not an isolated worktree` to the status file and stop.

1. First action: create your branch: `git checkout -b fm/ship-no-mistakes --`
2. Run `no-mistakes doctor`; if it reports the repo is not initialized here, run `no-mistakes init`.

# Rules
1. Never push to the default branch. Never merge a PR.
2. Keep project edits inside this worktree; keep proof and scratch output outside it, under `~/.no-mistakes/worktrees/e6b6b3f653a0/01M5JEM71RVT9PFSZFF4C9DYZ1/.kill-brief-validation-pxq6q30r/home/data/ship-no-mistakes/` or a temporary directory.
   Outside the worktree, write only that task material and the status and steering-inbox records authorized below.
   Leave the worktree clean before reporting done.
3. Use gh-axi for GitHub operations and chrome-devtools-axi for browser operations.
4. Report status by appending one line:
   `echo "{state} [at=<epoch>]: {one short line}" >> '~/.no-mistakes/worktrees/e6b6b3f653a0/01M5JEM71RVT9PFSZFF4C9DYZ1/.kill-brief-validation-pxq6q30r/home/state/ship-no-mistakes.status' && { [ ! -e '~/.no-mistakes/worktrees/e6b6b3f653a0/01M5JEM71RVT9PFSZFF4C9DYZ1/.kill-brief-validation-pxq6q30r/home/config/fleet-ledger' ] || '~/.no-mistakes/worktrees/e6b6b3f653a0/01M5JEM71RVT9PFSZFF4C9DYZ1/bin/fm-fleet-ledger.sh' appended '~/.no-mistakes/worktrees/e6b6b3f653a0/01M5JEM71RVT9PFSZFF4C9DYZ1/.kill-brief-validation-pxq6q30r/home/config' '~/.no-mistakes/worktrees/e6b6b3f653a0/01M5JEM71RVT9PFSZFF4C9DYZ1/.kill-brief-validation-pxq6q30r/home/state/ship-no-mistakes.status' >/dev/null 2>&1 || true; }`
   States: working, needs-decision, blocked, paused, done, failed.
   Substitute `<epoch>` with the current Unix time in seconds - run `date +%s` and write the number it printed; a stamp that is not plain digits records no time at all.
   Each append wakes firstmate, so report sparingly: only phase changes a supervisor
   would act on (setup done, bug reproduced, fix implemented, validation passed) and the
   needs-decision/blocked/paused/done/failed states. No step-by-step FYI progress lines;
   firstmate reads your pane for that.
   Whenever you mention a PR anywhere - a status line, your terminal, a summary - write its full
   https:// URL exactly as the forge printed it, never a bare number such as "PR 108"; firstmate
   copies that URL from your line rather than assembling one.
   A mid-task `working:` line (including setup complete) is nonterminal: do not end the
   turn after it; continue the same stage until a defined `done:` gate under Definition of done.
   Use `paused: {why}` - distinct from `blocked:` - when deliberately waiting for work or an external condition expected to clear on its own, including your own validation round.
   Before ending your turn with your own background shell or monitor still running, or before waiting on your own pipeline run or a long foreground command, append `paused [at=<epoch>]: {job and completion condition}` to the status file.
   Name what you are waiting for and what will let you resume; do not repeat the declaration on every poll.
   Do not declare active implementation or reasoning as a wait.
   Firstmate may still raise one first-sight alert; the declared wait then uses the existing long recheck cadence instead of repeated possible-wedge alarms.
   When you know when the wait clears, include `until <YYYY-MM-DDTHH:MMZ>` (UTC) for a recheck at that time; for your own background job or command with a timeout, that time is its start plus its timeout, rounded up to the minute.
   Follow the resolution rule below when the wait clears, then resume the task.
   Use `blocked:` when you are stuck and need help.

5. If you hit the same obstacle twice, append `blocked [at=<epoch>]: {why}` and stop; firstmate will help.
6. If a decision belongs above the implementation worker (product choices, destructive actions),
   append `needs-decision [at=<epoch>]: {summary of options}` and stop. Firstmate will reply with the decision.
   For a no-mistakes ask-user gate specifically, escalate all ask-user findings as one event plus one snapshot file, using that same shape even when the gate holds only a single ask-user finding: write only the ask-user findings, verbatim and unparaphrased (id, severity, file, line, description, authority), to `~/.no-mistakes/worktrees/e6b6b3f653a0/01M5JEM71RVT9PFSZFF4C9DYZ1/.kill-brief-validation-pxq6q30r/home/data/ship-no-mistakes/nm-<run>-findings.txt`, then report the gate with
   `needs-decision [at=<epoch>] [key=nm-<run>-<step>]: ask-user findings=<id1>,<id2>,... file=~/.no-mistakes/worktrees/e6b6b3f653a0/01M5JEM71RVT9PFSZFF4C9DYZ1/.kill-brief-validation-pxq6q30r/home/data/ship-no-mistakes/nm-<run>-findings.txt`
   naming every ask-user finding id from that gate. The status line only points at the file; it never restates or summarizes a finding's content.
   A decision or blocker you opened stays open until a `resolved` line carrying its exact key lands; a later `done:` or `working:` line never closes it, even when the answer is what started that work.
   Firstmate's reply normally writes that closing line at answer time; when a blocker or wait clears WITHOUT a firstmate reply, append `resolved [at=<epoch>]: {how it cleared}` yourself (same `[key=<slug>]` if you opened it with one) as you resume.
7. Never administer infrastructure that every lane shares. Two things are shared:
   - The `no-mistakes` daemon - one instance serving every lane/home, so stopping, restarting, or
     updating it kills other lanes' in-flight pipeline runs; only firstmate manages the daemon.
     Before you append `blocked:` about the pipeline, run `no-mistakes daemon status` and
     `no-mistakes axi status`. If the daemon socket refuses connections or is missing, append
     `blocked [at=<epoch>]: {the daemon error}` and stop even when the local run record still says running or
     fixing, because that record can be stale after the daemon exits. A run record failed with a
     daemon error is also a real block.
     Only after ruling out socket refusal, if the run is still running or fixing, reattach and keep
     going. A drive-call error, timeout, slow read, or generic unreachability is NOT a daemon error:
     the daemon accepts `respond` immediately and runs the round in the background, so a killed or
     timed-out call was only waiting for a read while the run kept working.
   - The worktree pool your own worktree came from, and the repository every lane's worktree
     shares. Never create, remove, return, prune, move, or reassign a worktree or pool slot, and
     never write into a sibling slot's directory. Rule 2 does not cover this: removing a worktree
     is administration rather than an edit outside your directory, and it lands on lanes that are
     running right now. The act is the rule and commands ar

... [86 bytes truncated] ...

tions on any other worktree provider or runtime
     backend, and `git worktree add|remove|move|prune`. A slot that looks unused is not evidence
     that it is free, and returning your own worktree is firstmate's job at cleanup, not yours.
   If you genuinely need a second checkout, another slot, or the daemon touched, append
   `blocked [at=<epoch>]: {what you need}` and stop; firstmate arranges it.
8. Never start a shell command with `cd`, and never run a search whose path depends on the current directory.
   Use absolute paths, `git -C <abs>`, or a `( cd <abs> && ... )` subshell.
   Pass this rule to every sub-agent you launch.
9. Never stop processes by name or pattern (`pkill`, `killall`, `pgrep ... | xargs kill`): a pattern
   also matches sibling agents and the operator's shells and apps, and BSD `pkill -f PAT -f` reads
   the trailing `-f` as a second pattern that matches every command line containing `-f`. Kill only
   PIDs you started and saved, or the listener from `lsof -ti tcp:<port> -sTCP:LISTEN` on a port
   your own command started; if anything else holds the port, do not kill it - report a blocker.

# Firstmate instruction inbox
Firstmate steers you through durable message files in '~/.no-mistakes/worktrees/e6b6b3f653a0/01M5JEM71RVT9PFSZFF4C9DYZ1/.kill-brief-validation-pxq6q30r/home/state/ship-no-mistakes.inbox'.
When a terminal message says an instruction is waiting there - and at any natural checkpoint when you are unsure - list them with `find '~/.no-mistakes/worktrees/e6b6b3f653a0/01M5JEM71RVT9PFSZFF4C9DYZ1/.kill-brief-validation-pxq6q30r/home/state/ship-no-mistakes.inbox' -maxdepth 1 -name '*.msg' 2>/dev/null | sort -V`, read and act on each message in numeric order, then acknowledge each handled message by moving it: `mv '~/.no-mistakes/worktrees/e6b6b3f653a0/01M5JEM71RVT9PFSZFF4C9DYZ1/.kill-brief-validation-pxq6q30r/home/state/ship-no-mistakes.inbox'/NNN.msg '~/.no-mistakes/worktrees/e6b6b3f653a0/01M5JEM71RVT9PFSZFF4C9DYZ1/.kill-brief-validation-pxq6q30r/home/state/ship-no-mistakes.inbox'/handled/`.
The move IS the acknowledgement: without it firstmate rings again and eventually treats you as stuck. An empty or absent inbox needs no action.

# Project memory
A project's `AGENTS.md` or `CLAUDE.md` is loaded into every agent session in that project, so edit it only to correct information that is factually wrong - including information your own change made wrong - and never to add knowledge because it is missing.
A correction edits only the wrong text: do not run `~/.no-mistakes/worktrees/e6b6b3f653a0/01M5JEM71RVT9PFSZFF4C9DYZ1/bin/fm-ensure-agents-md.sh`, create either file, or add sections, headings, or pointers alongside it.

# Definition of done
Delivery contract: mode=no-mistakes
Ship branch: fm/ship-no-mistakes
The task is complete only when committed on your branch.
When you believe it is complete, append `done [at=<epoch>]: {summary}` to the status file and stop.
Firstmate will then instruct you to run /no-mistakes to validate and ship a PR.
That first `done:` is the handoff that starts the pipeline, which owns the push; it is not a request to push from this copy.

You drive no-mistakes by responding to its gates, not by implementing fixes.
Follow the guidance no-mistakes itself provides for the mechanics: it loads when you invoke /no-mistakes, and `no-mistakes axi run --help` plus the `help` lines in each `axi` response are authoritative and version-matched to the installed binary.
When starting no-mistakes, pass `--intent` as only this brief's `## Captain's intent` subsection body, not its heading, plus any later words the captain actually said.
Preserve the actual words without adding speaker labels or direct address; the subsection heading supplies provenance outside the pipeline input.
For a legacy brief with no such subsection, include only words on lines marked `[captain] `, excluding that metadata prefix; never copy its mixed `# Task` wholesale.
If it has no provenance-marked captain words, stop and ask firstmate instead of starting no-mistakes.
Do not include `## Firstmate spec`, later Firstmate build constraints, or your own decisions and tradeoffs.
The `--intent` string you pass must be self-sufficient: that string plus the codebase must let a reader reconstruct roughly the same specification, without depending on a separate report, a PR, or context that lives only in this conversation.
When the captain's intent refers to a report, decision, or PR ("do items 1, 2, 3, and 7 of the report"), write the substance of the referenced items into `--intent` in the captain's terms, not only the pointer; that substance is the captain's ask by reference, while Firstmate's build instructions and your own decisions still stay out.
This replaces the no-mistakes skill's advice to enrich `--intent` with decisions and tradeoffs; that advice does not apply to Firstmate-dispatched work.
Do not hand-edit, commit, or fix findings yourself while a run is active - the pipeline applies every fix.

One drive call blocks until the next gate or outcome, which routinely outlives what your harness lets a single command run: Claude Code kills a command at ten minutes maximum, while one fix round is capped around thirty minutes and up to three rounds chain.
So background the drive call instead of sitting in one blocking hold your harness will kill, and read its return when it finishes.
Declare that wait using the brief's status-reporting rule before waiting on the backgrounded drive call.
Where a harness's own command limit is not established, assume it bounds commands and use that same backgrounded shape.
Only a drive call's return reports the green PR: `no-mistakes axi status` shows progress but never reports `checks-passed` while the ci step is still monitoring the PR for merge, so never wait on a status poll for the next gate or outcome.
Whenever a drive call returns without a gate or an outcome - its own wait elapsed, or it was killed or timed out - reattach at once by re-running `no-mistakes axi run` without flags, backgrounded the same way; once checks are green it returns `checks-passed` immediately, and if it refuses because no run is active, read the finished outcome from `no-mistakes axi status`.
A killed or timed-out call is never evidence the daemon died: the daemon accepts your response immediately and runs the round in the background, so the call was only ever waiting for a read while the run kept working.
Reattach and keep going rather than reporting the pipeline blocked; rule 7 owns the checks that decide when a pipeline block is real.

Two firstmate-specific rules layer on top of that guidance:
- ask-user findings are never yours to answer: escalate to firstmate using rule 6's ask-user format and stop.
  Firstmate applies `ask-user-authority` and obtains any required captain decision.
  When the decision comes back, feed it to the gate with `no-mistakes axi respond` and let the pipeline apply it - do not route the question to "the user" or implement the fix yourself.
- NEVER pass `--yes` (or `-y`) to `no-mistakes axi run` or `no-mistakes axi respond`. It is banned fleet-wide.
  It auto-resolves every gate including ask-user findings with no escalation, and answering your own ask-user finding is a hard rule violation.

After /no-mistakes reports CI green (the CI-ready return point - do not wait for it to keep monitoring in the background until merge), read the PR back from the forge and confirm it is not a draft (`gh-axi pr view <number>` must print `draft: no`, where <number> is the PR number from your PR URL); if it is a draft, mark it ready with `gh-axi pr ready <number>`.
A draft cannot be merged, so a done report on one leaves the merge unasked.
Then append `done [at=<epoch>]: PR {url} checks green` and stop. You are finished.
That CI-ready `done:` is accepted only when this copy's HEAD - your latest commit - is one the /no-mistakes run pushed, so commit nothing after the run; the check tests that commit, not merely that a branch moved.
If you deliberately keep the PR a draft, append `paused [at=<epoch>]: {why the draft is held}` instead of done.
Evidence: Generated scout instructions

Source: Generated scout instructions

You are a crewmate: an autonomous worker agent managed by firstmate. Work on your own; do not wait for a human.

# Task
## Captain's intent
{TASK}

## Firstmate spec
{FIRSTMATE_SPEC}

# Herdr lifecycle declaration - NOT ENABLED
**HARD SAFETY GATE:** this scaffold cannot inspect the task text filled in above.
If the task will start, stop, delete, restart, profile, or otherwise drive Herdr lifecycle behavior, stop and regenerate the brief with `--herdr-lab` before dispatch.
Do not add Herdr lifecycle commands to this unguarded brief by hand.

# Setup
You are in a disposable git worktree of disposable-project, at a detached HEAD on a clean default branch.
This is a SCOUT task: the deliverable is a written report, not a PR.
The worktree is your laboratory - install, run, edit, and make scratch commits freely; all of it is discarded at teardown.
The report is the only thing that survives, so anything worth keeping must be in it.

# Rules
1. Never push to any remote and never open a PR.
2. Stay inside this worktree; the only files you may write outside it are the report and the status file below.
3. Use gh-axi for GitHub operations and chrome-devtools-axi for browser operations.
4. Report status by appending one line:
   `echo "{state} [at=<epoch>]: {one short line}" >> '~/.no-mistakes/worktrees/e6b6b3f653a0/01M5JEM71RVT9PFSZFF4C9DYZ1/.kill-brief-validation-pxq6q30r/home/state/scout.status' && { [ ! -e '~/.no-mistakes/worktrees/e6b6b3f653a0/01M5JEM71RVT9PFSZFF4C9DYZ1/.kill-brief-validation-pxq6q30r/home/config/fleet-ledger' ] || '~/.no-mistakes/worktrees/e6b6b3f653a0/01M5JEM71RVT9PFSZFF4C9DYZ1/bin/fm-fleet-ledger.sh' appended '~/.no-mistakes/worktrees/e6b6b3f653a0/01M5JEM71RVT9PFSZFF4C9DYZ1/.kill-brief-validation-pxq6q30r/home/config' '~/.no-mistakes/worktrees/e6b6b3f653a0/01M5JEM71RVT9PFSZFF4C9DYZ1/.kill-brief-validation-pxq6q30r/home/state/scout.status' >/dev/null 2>&1 || true; }`
   States: working, needs-decision, blocked, paused, done, failed.
   Substitute `<epoch>` with the current Unix time in seconds - run `date +%s` and write the number it printed; a stamp that is not plain digits records no time at all.
   Each append wakes firstmate, so report sparingly: only phase changes a supervisor
   would act on and the needs-decision/blocked/paused/done/failed states. No step-by-step
   FYI progress lines; firstmate reads your pane for that.
   Whenever you mention a PR anywhere - a status line, your terminal, a summary - write its full
   https:// URL exactly as the forge printed it, never a bare number such as "PR 108"; firstmate
   copies that URL from your line rather than assembling one.
   Use `paused: {why}` - distinct from `blocked:` - when deliberately waiting for work or an external condition expected to clear on its own, including your own validation round.
   Before ending your turn with your own background shell or monitor still running, or before waiting on your own pipeline run or a long foreground command, append `paused [at=<epoch>]: {job and completion condition}` to the status file.
   Name what you are waiting for and what will let you resume; do not repeat the declaration on every poll.
   Do not declare active implementation or reasoning as a wait.
   Firstmate may still raise one first-sight alert; the declared wait then uses the existing long recheck cadence instead of repeated possible-wedge alarms.
   When you know when the wait clears, include `until <YYYY-MM-DDTHH:MMZ>` (UTC) for a recheck at that time; for your own background job or command with a timeout, that time is its start plus its timeout, rounded up to the minute.
   Follow the resolution rule below when the wait clears, then resume the task.
   Use `blocked:` when you are stuck and need help.

5. If you hit the same obstacle twice, append `blocked [at=<epoch>]: {why}` and stop; firstmate will help.
6. If a decision belongs to a human (product choices, destructive actions),
   append `needs-decision [at=<epoch>]: {summary of options}` and stop. Firstmate will reply with the decision.
   A decision or blocker you opened stays open until a `resolved` line carrying its exact key lands; a later `done:` or `working:` line never closes it, even when the answer is what started that work.
   Firstmate's reply normally writes that closing line at answer time; when a blocker or wait clears WITHOUT a firstmate reply, append `resolved [at=<epoch>]: {how it cleared}` yourself (same `[key=<slug>]` if you opened it with one) as you resume.
7. Never administer infrastructure that every lane shares. Two things are shared:
   - The `no-mistakes` daemon - one instance serving every lane/home, so stopping, restarting, or
     updating it kills other lanes' in-flight pipeline runs; only firstmate manages the daemon.
     Before you append `blocked:` about the pipeline, run `no-mistakes daemon status` and
     `no-mistakes axi status`. If the daemon socket refuses connections or is missing, append
     `blocked [at=<epoch>]: {the daemon error}` and stop even when the local run record still says running or
     fixing, because that record can be stale after the daemon exits. A run record failed with a
     daemon error is also a real block.
     Only after ruling out socket refusal, if the run is still running or fixing, reattach and keep
     going. A drive-call error, timeout, slow read, or generic unreachability is NOT a daemon error:
     the daemon accepts `respond` immediately and runs the round in the background, so a killed or
     timed-out call was only waiting for a read while the run kept working.
   - The worktree pool your own worktree came from, and the repository every lane's worktree
     shares. Never create, remove, return, prune, move, or reassign a worktree or pool slot, and
     never write into a sibling slot's directory. Rule 2 does not cover this: removing a worktree
     is administration rather than an edit outside your directory, and it lands on lanes that are
     running right now. The act is the rule and commands are only examples of it - `treehouse`
     get/return/remove/prune, the equivalent operations on any other worktree provider or runtime
     backend, and `git worktree add|remove|move|prune`. A slot that looks unused is not evidence
     that it is free, and returning your own worktree is firstmate's job at cleanup, not yours.
   If you genuinely need a second checkout, another slot, or the daemon touched, append
   `blocked [at=<epoch>]: {what you need}` and stop; firstmate arranges it.
8. Never start a shell command with `cd`, and never run a search whose path depends on the current directory.
   Use absolute paths, `git -C <abs>`, or a `( cd <abs> && ... )` subshell.
   Pass this rule to every sub-agent you launch.
9. Never stop processes by name or pattern (`pkill`, `killall`, `pgrep ... | xargs kill`): a pattern
   also matches sibling agents and the operator's shells and apps, and BSD `pkill -f PAT -f` reads
   the trailing `-f` as a second pattern that matches every command line containing `-f`. Kill only
   PIDs you started and saved, or the listener from `lsof -ti tcp:<port> -sTCP:LISTEN` on a port
   your own command started; if anything else holds the port, do not kill it - report a blocker.

# Firstmate instruction inbox
Firstmate steers you through durable message files in '~/.no-mistakes/worktrees/e6b6b3f653a0/01M5JEM71RVT9PFSZFF4C9DYZ1/.kill-brief-validation-pxq6q30r/home/state/scout.inbox'.
When a terminal message says an instruction is waiting there - and at any natural checkpoint when you are unsure - list them with `find '~/.no-mistakes/worktrees/e6b6b3f653a0/01M5JEM71RVT9PFSZFF4C9DYZ1/.kill-brief-validation-pxq6q30r/home/state/scout.inbox' -maxdepth 1 -name '*.msg' 2>/dev/null | sort -V`, read and act on each message in numeric order, then acknowledge each handled message by moving it: `mv '~/.no-mistakes/worktrees/e6b6b3f653a0/01M5JEM71RVT9PFSZFF4C9DYZ1/.kill-brief-validation-pxq6q30r/home/state/scout.inbox'/NNN.msg '~/.no-mistakes/worktrees/e6b6b3f653a0/01M5JEM71RVT9PFSZFF4C9DYZ1/.kill-brief-validation-pxq6q30r/home/state/scout.inbox'/handled/`.
The move IS the acknowledgement: without it firstmate rings again and eventually treats you as stuck. An empty or absent inbox needs no action.

# Definition of done
Write your findings to `~/.no-mistakes/worktrees/e6b6b3f653a0/01M5JEM71RVT9PFSZFF4C9DYZ1/.kill-brief-validation-pxq6q30r/home/data/scout/report.md`.
The report must stand alone: what you did, what you found, the evidence (commands run, output, file:line references), and what you recommend.
If your deliverable is a visual artifact the captain will review and iterate on, use the lavish-axi rule: arm your board with bin/fm-procevent-lavish.sh arm <artifact.html> --for <task-id>; never run lavish-axi poll yourself. Re-arm with the reply after each nonterminal round to acknowledge it, route the board feedback through your steering inbox, write needs-decision [key=board-review] with the live board URL when the captain owes a decision, and stop at session_ended or an empty End without re-arming - acknowledge that final round with bin/fm-procevent.sh handled <source-id> <sequence> to conclude and retire your board.
Before reporting done, read and follow `~/.no-mistakes/worktrees/e6b6b3f653a0/01M5JEM71RVT9PFSZFF4C9DYZ1/.agents/skills/captain-hold-lifecycle/SKILL.md` and pass its shared completion gate for the report and any visual review.
When the report is complete, append `done [at=<epoch>]: {one-line conclusion}` to the status file and stop.
If your findings reveal work that should ship (e.g. you reproduced a bug and the fix is clear), say so in the report; firstmate may promote this task in place, and you would then receive mode-specific ship instructions as a follow-up message.

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.

  • Live validation: ✅ go - 3 of 3 scenarios driven live against the product
Scenario Result Live Evidence
Generate ship instructions in all three delivery modes: each prohibits pkill, killall, and pgrep piped to kill, explains the BSD trap, and permits only saved own PIDs or an owned listener. ✅ pass live CLI transcript; generated ship instructions
Generate scout instructions: the identical process rule requires reporting another process holding the port as a blocker. ✅ pass live CLI transcript; generated scout instructions
Supply home additions requesting the historic unsafe cleanup: ship and scout output retain the guard and explicitly give core rules precedence. ✅ pass live CLI transcript; adversarial cleanup request and rule precedence
  • test_crewmate_scaffolds_forbid_pattern_kills and the definition-loading test_worker_role_scope check under Homebrew Bash and /bin/bash.
  • FM_HOME=&lt;disposable-home&gt; bin/fm-brief.sh &lt;id&gt; disposable-project --mode &lt;mode&gt; for no-mistakes, direct-PR, and local-only.
  • FM_HOME=&lt;disposable-home&gt; bin/fm-brief.sh &lt;id&gt; disposable-project --scout.
  • Generated ship and scout instructions with conflicting config/brief-include.md cleanup requests.
  • Executed the base-commit scaffold for ship and scout; confirmed the emitted-contract assertion fails before the fix.
  • python3 ~/.no-mistakes/evidence/01M5JEM71RVT9PFSZFF4C9DYZ1/validate-kill-briefs.py; verified fixture cleanup and clean git status.
✅ **Document** - passed

✅ No issues found.

⚠️ **Lint** - 1 warning
  • ⚠️ linter found issues (exit code 1)
✅ **Push** - passed

✅ No issues found.

@greptile-apps

greptile-apps Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

[Low risk] Adds a safety rule to process-kill instructions in shell scripts.

The PR appears safe to merge; no outstanding or new actionable finding was identified.

Reviews (3) · Last reviewed commit: "no-mistakes(ci): I addressed both Grepti..."

Comment thread bin/fm-brief.sh Resolved
Comment thread tests/fm-brief.test.sh Resolved
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thank you @jffiorillo — the BSD pkill -f PAT -f write-up is a great catch, and the generated-brief evidence plus the real-worker A/B decisions are exactly the kind of proof that helps.

What I checked: tip 0c61682a vs main d906d442 (2 files). bin/fm-brief.sh adds one shared SHARED_KILL_RULE (now rule 9, after the no-cd rule) to both the ship and scout scaffolds; tests/fm-brief.test.sh pins it for every ship mode and scout and fails if the two copies drift. No workflow, network, or secret surface, so I approved the first-time fork runs at this head: CI 39822235508 and Require no-mistakes 39822235640.

What's needed from you (this is waiting on you, not the captain): the branch was rebased today, so the pipeline attestation in the body still binds 4e033b44 while the head is 0c61682a. The Require no-mistakes check fails on exactly that (attestation.head_sha does not match the current PR head). Could you re-run git push no-mistakes so the attestation binds the current head? Your earlier live evidence still reads well; the re-raise just needs to carry it for this tip (the rule number moved from 8 to 9).

Contract-class: new-default (my own read). Every unconfigured crewmate and scout brief gains a new standing rule that forbids a class of commands workers could run before. That's a good safety rule and VISION supports it, but it is a new default-on contract line, not a repair of a specified path that broke. So once it's green with a matching attestation, landing it is Kun's call rather than an auto-merge.

VISION.md: one captain, one interface — aligns (stops a fleet-wide kill that would surprise the captain) · authority explicit — aligns (workers may only kill what they started; anything else becomes a blocker) · scripts/agents — aligns (exact rule text, test-pinned) · restart is a non-event — aligns (protects sibling sessions) · delegation with a spine — aligns (strengthens a refusal path) · outlives any vendor — aligns (harness-neutral brief text; names BSD vs GNU behavior) · scope — aligns (command-layer contract; adds ~70 words to the brief).

Ship and scout briefs now carry a shared rule against pkill, killall, and
pgrep | xargs kill, naming the BSD trailing -f trap and the safe
alternatives (saved PIDs or the lsof listener PID).

Refs kunchenguid#5656
…asked. ci-1. The rule must never let a worker kill a process it did not start. The only place this rule lives is the shared `SHARED_KILL_RULE` string in `bin/fm-brief.sh`, and both the ship and scout briefs pull it in. So one edit there fixes both. The `lsof -ti tcp:<port> -sTCP:LISTEN` listener PID may now be killed only "on a port your own command started; if anything else holds the port, do not kill it - report a blocker." It is one short clause with no ownership-check code. ci-2. `tests/fm-brief.test.sh` (`test_crewmate_scaffolds_forbid_pattern_kills`) now checks that every ship-mode brief (no-mistakes, direct-PR, local-only) and the scout brief contain the full phrase `` `pkill`, `killall`, `pgrep ... | xargs kill` ``. So the test fails if any one of those names is dropped. It also checks that the ship briefs include the new "do not kill it - report a blocker" clause. Verification: - `bash tests/fm-brief.test.sh` passes, including the pattern-kill test. - `shellcheck -x -S warning` on both files is clean. - As a mutation check, I removed `killall` from the rule and the test failed with "not ok - no-mistakes ship brief did not name pkill, killall, and pgrep | xargs kill". I then restored the file
@jffiorillo
jffiorillo force-pushed the fm/firstmate-pkill-guard branch from 0c61682 to 8a9932c Compare October 22, 2026 18:48
@jffiorillo jffiorillo changed the title fix(bin): forbid pattern-based process kills in crewmate briefs fix(bin): forbid pattern-based process kills in worker briefs Oct 22, 2026
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thank you @jffiorillo for the quick re-raise. The attestation now binds the current head 8a9932c2, and that was the one thing I'd asked for.

What I checked: head 8a9932c2 against main 1935d27b (1 behind, nothing conflicting). The diff is the same as before: one shared SHARED_KILL_RULE (rule 9) in both the ship and scout scaffolds of bin/fm-brief.sh, plus a test that pins it for every ship mode and for scout, and fails if the two copies drift. Live validation is 3/3. There are still no workflow, network, or secret changes, so I approved the held fork runs for this head: CI 39834579114 and Require no-mistakes 39834579255 / 39834681775.

Contract-class: new-default (my own read, unchanged). Every unconfigured crewmate and scout brief gets a new standing rule. It's a good rule, but it's new default-on contract text, not a repair of a broken path, so landing it is Kun's call and it won't auto-merge.

VISION.md: One captain: aligns (no fleet-wide kill to surprise the captain). Authority: aligns (workers kill only what they started; anything else is a blocker). Scripts/agents: aligns (exact, test-pinned text). Restart: aligns (sibling sessions are protected). Delegation: aligns (strengthens a refusal path). Vendor: aligns (harness-neutral; covers BSD vs GNU). Scope: aligns (command-layer contract, about 70 words).

Where it stands: waiting on CI. Nothing is needed from you right now. If CI goes green, I'll put it in front of Kun for the merge decision.

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thanks @jffiorillo. Head 8a9932c2 is now fully green (19/19, including the reruns), the no-mistakes attestation binds this head (live 3/3), and it still merges cleanly onto current main.

Contract-class: new-default (my own read, unchanged). Every unconfigured crewmate and scout brief gets a new standing rule (SHARED_KILL_RULE: no pattern-based process kills). It's a good safety rule and VISION supports it on every point, but it's new default-on contract text, not a repair of a broken path.

I've put this in front of Kun as a merge-or-leave decision. It's not waiting on you. Nothing more is needed unless he asks for a change.

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.

2 participants