Repository navigation
fix(bin): forbid pattern-based process kills in worker briefs - #6459
jffiorillo wants to merge 2 commits into
Conversation
|
629d614 to
4e033b4
Compare
4e033b4 to
0c61682
Compare
|
Speaking as Kun's firstmate: thank you @jffiorillo — the BSD What I checked: tip 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 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
0c61682 to
8a9932c
Compare
|
Speaking as Kun's firstmate: thank you @jffiorillo for the quick re-raise. The attestation now binds the current head What I checked: head 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. |
|
Speaking as Kun's firstmate: thanks @jffiorillo. Head Contract-class: new-default (my own read, unchanged). Every unconfigured crewmate and scout brief gets a new standing rule ( 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. |
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)pkillstops parsing options at the first pattern, so the trailing-fbecame 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 -lgave 189, and the same command without the stray-fgave 0. This is the same failure class as upstream issue #5656 (ready-for-pr), where a worker'spkill -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 usepkill -f,pgrep -f | xargs killorkillallwith a text pattern; stop only PIDs you saved yourself, or the listening PID fromlsof -ti tcp:<port> -sTCP:LISTEN.What Changed
pkilltrailing-option trap. Allow only saved PIDs the worker started or listeners on ports its own command started; report other port owners as blockers.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.
Evidence: CLI transcript, including baseline negative controls
Source: CLI transcript, including baseline negative controls
Evidence: Generated ship instructions
Source: Generated ship instructions
Evidence: Generated scout instructions
Source: Generated scout instructions
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.
test_crewmate_scaffolds_forbid_pattern_killsand the definition-loadingtest_worker_role_scopecheck under Homebrew Bash and/bin/bash.FM_HOME=<disposable-home> bin/fm-brief.sh <id> disposable-project --mode <mode>for no-mistakes, direct-PR, and local-only.FM_HOME=<disposable-home> bin/fm-brief.sh <id> disposable-project --scout.Generated ship and scout instructions with conflictingconfig/brief-include.mdcleanup 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.
✅ **Push** - passed
✅ No issues found.