Skip to content

feat(bin): enforce durable dispatch restrictions - #5

Merged
Hozzy02 merged 8 commits into
mainfrom
fm/fm-dispatch-restriction
Sep 12, 2026
Merged

Hozzy02 merged 8 commits into
mainfrom
fm/fm-dispatch-restriction

Conversation

@Hozzy02

@Hozzy02 Hozzy02 commented Sep 12, 2026 •

Copy link
Copy Markdown
Owner

What Changed

  • Add a per-home CLI to set, list, and explicitly lift durable task dispatch restrictions independently of backlog lifecycle state.
  • Enforce restrictions under task locks across ship and scout spawn, relaunch, and scout promotion paths.
  • Preserve active restrictions through local and remote backlog handoffs and retries, with unsafe or incomplete restriction data rejected.

Secondmate Propagation Decision

The task brief asked us to decide, and explain here, how a restriction set in the main home reaches a secondmate home: automatic inheritance through secondmate-provisioning's inherited-local-material channel, or per-home enforcement.

We concluded per-home enforcement is correct, not automatic inheritance. That inherited-local-material channel is a fixed list of home-wide config knobs (crew-harness, backlog-backend, captain-shared.md, etc.) that converge byte-for-byte across every secondmate home on every sync. A dispatch restriction is not home-wide config — it is data scoped to one task id, and a task belongs to exactly one home's backlog at a time (work routed to a secondmate already lives in that secondmate's own backlog, never mirrored back to the main backlog, per AGENTS.md section 10). So a restriction is set directly in whichever home actually holds the task:

  • Locally, via FM_HOME=<secondmate-home> bin/fm-dispatch-restrict.sh set ....
  • Remotely, via the existing bin/fm-on.sh <secondmate-id> fm-dispatch-restrict.sh ... channel, which already runs any bin/fm-*.sh script in a remote secondmate's home — no new cross-home channel was invented.

The one case that needed real handling: bin/fm-backlog-handoff.sh moves a task's ownership from the main home to a secondmate home, so it now carries an existing dispatch-restriction record along with the item (both the local-copy path and the remote outbox/payload delivery path via bin/fm-backlog-receive.sh), otherwise a restricted item could become dispatchable just by being handed off. The source home deliberately keeps its own copy after a handoff; only an explicit lift removes it, independently in either home. This is documented as the authoritative contract in bin/fm-dispatch-restrict.sh's own header (one-owner rule), with a one-line pointer in AGENTS.md section 10.

Merge

Merged by the captain via bin/fm-pr-merge.sh on explicit authorization, as squash commit 4a2fc09 with a clean subject and body — no Co-Authored-By trailer. The delivery contract (mode=no-mistakes, yolo=off) was honored: the driving worker stopped at a green, unmerged PR and the captain merged it explicitly.

Risk Assessment

✅ Low: Captain, the fixes now close the promotion, relaunch, direct-spawn, and handoff symlink paths while preserving the intended per-home restriction and locking invariants.

Testing

Focused automated testing verified the restriction across dispatch, relaunch, promotion, handoff, and completion; direct CLI evidence demonstrated set/list/refuse/lift behavior end to end. All change-specific checks passed, while one reproducible and unchanged baseline Herdr teardown test failed.

Evidence: Dispatch restriction CLI lifecycle transcript

Set/list showed the captain-authored restriction; spawn exited 1 with the reason and exact lift command. After lift, spawn advanced to the ordinary missing-brief check.

$ fm-dispatch-restrict.sh set demo-queued-task --reason "captain requested queue hold" --by captain
restricted demo-queued-task in /var/folders/t1/8htjz3j91cqcfslff4w76zqc0000gn/T/no-mistakes-evidence/01M2AWBNCPFXKH18F36W4CQ3WK/dispatch-restriction-cli-home (by=captain at=2026-09-12T18:11:12Z reason=captain requested queue hold)

$ fm-dispatch-restrict.sh list
demo-queued-task	by=captain	at=2026-09-12T18:11:12Z	reason=captain requested queue hold

$ fm-spawn.sh demo-queued-task projects/alpha --mode no-mistakes --yolo off
error: task demo-queued-task is under a captain dispatch restriction set by captain on 2026-09-12T18:11:12Z: captain requested queue hold
error: this spawn is refused; lift it deliberately first with: bin/fm-dispatch-restrict.sh lift demo-queued-task
exit=1

$ fm-dispatch-restrict.sh lift demo-queued-task
lifted demo-queued-task in /var/folders/t1/8htjz3j91cqcfslff4w76zqc0000gn/T/no-mistakes-evidence/01M2AWBNCPFXKH18F36W4CQ3WK/dispatch-restriction-cli-home

$ fm-spawn.sh demo-queued-task projects/alpha --mode no-mistakes --yolo off
error: no brief at /var/folders/t1/8htjz3j91cqcfslff4w76zqc0000gn/T/no-mistakes-evidence/01M2AWBNCPFXKH18F36W4CQ3WK/dispatch-restriction-cli-home/data/demo-queued-task/brief.md
exit=1 (expected ordinary missing-brief refusal; restriction gate cleared)
- Outcome: ⚠️ 1 warning across 1 run (27m47s)

Pipeline

Updates from git push no-mistakes

⏭️ **intent** - skipped

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

🔧 **Review** - 1 issue found → auto-fixed (2) ✅
  • 🚨 bin/fm-spawn.sh:1085 - A restriction set after a scout starts can still be bypassed: fm-promote.sh converts that scout to kind=ship and authorizes implementation without consulting the restriction. Extend the dispatch gate to the scout-to-ship transition and serialize it with the same .spawn-&lt;id&gt;.lock, so set/lift cannot race promotion.

🔧 Fix: Captain, harden dispatch restrictions across all transition paths
1 error still open:

  • 🚨 bin/fm-backlog-handoff.sh:282 - Handoff still follows a symlinked source restriction directory: if $DATA/dispatch-restrictions points outside the data tree, local handoff copies a matching external file and remote handoff base64-encodes and transmits it. Apply fm_dispatch_restrict_dir_validate before both source-read loops, treating a missing directory as “no restrictions” but refusing an unsafe one.

🔧 Fix: Captain, block symlinked restriction reads during backlog handoff
✅ Re-checked - no issues remain.

⚠️ **Test** - 1 warning
  • ⚠️ tests/fm-teardown.test.sh:1612 - Pre-existing test failure: the Herdr missing-adapter teardown scenario unexpectedly continues instead of refusing. It reproduced in isolation, but the failing function and the teardown/backend sources it exercises are unchanged from the base commit, so this target did not cause it. The restriction-specific teardown persistence case passed.
  • bin/fm-test-run.sh tests/fm-dispatch-restrict.test.sh tests/fm-backlog-handoff.test.sh tests/fm-remote-backlog-handoff.test.sh tests/fm-control-relaunch.test.sh tests/fm-task-delivery.test.sh tests/fm-teardown.test.sh
  • Isolated test_herdr_flat_teardown_preflight_refuses_before_changes from tests/fm-teardown.test.sh using a transient wrapper, then removed the wrapper
  • Compared the failing function and bin/fm-teardown.sh, bin/fm-backend.sh, and bin/backends/herdr.sh against base commit 9bd02325f7e148b623378e1c43ae47489792c3ee
  • Manual isolated-home CLI flow: fm-dispatch-restrict.sh set, list, restricted fm-spawn.sh, lift, then unrestricted fm-spawn.sh; captured the transcript artifact
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

Hozzy02 and others added 8 commits September 12, 2026 09:19
A captain "keep this queued, do not dispatch" instruction used to be only a
recorded working practice, so an agent (or a secondmate reconciling its own
home at startup) could dispatch it anyway. tasks-axi hold is not durable
enough for this either, since completing any related task clears it.

Add bin/fm-dispatch-restrict.sh (set/list/lift) and its storage owner
bin/fm-dispatch-restrict-lib.sh: a durable per-task-id record under
data/dispatch-restrictions/ that nothing in the ordinary backlog/task
lifecycle touches. bin/fm-spawn.sh now refuses a ship or scout spawn for a
restricted id, naming who restricted it, why, and the exact lift command;
--secondmate spawns are exempt since that id names the secondmate's own
identity, not a backlog task. Lifting is the only thing that clears it.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01HW29AtjyX3dfDNFoCpBNuD
@Hozzy02
Hozzy02 merged commit 4a2fc09 into main Sep 12, 2026
13 checks passed
@Hozzy02
Hozzy02 deleted the fm/fm-dispatch-restriction branch September 26, 2026 00:41
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