Skip to content

fix(bin): parameterize task-branch prefix and retry swallowed herdr Enter - #2706

Open
chappellerj wants to merge 5 commits into
kunchenguid:mainfrom
chappellerj:fm/fmsendretry-u2
Open

chappellerj wants to merge 5 commits into
kunchenguid:mainfrom
chappellerj:fm/fmsendretry-u2

Conversation

@chappellerj

Copy link
Copy Markdown

What Changed

  • bin/fm-brief.sh now resolves the ship task branch prefix from config/branch-prefix (defaulting to fm/) instead of hardcoding it, and bin/fm-promote.sh follows the same resolved prefix when promoting a scout to a ship branch.
  • bin/backends/herdr.sh detects a swallowed follow-up Enter on herdr Claude panes and retries it, preventing a submitted send from silently stalling.
  • Updated AGENTS.md, docs/configuration.md, docs/architecture.md, docs/herdr-backend.md, and docs/verification/runtime-backends.md to document the branch-prefix config and the herdr swallow-retry behavior, correcting a stale swallow-verdict claim and an undocumented FM_BACKEND_HERDR_SWALLOW_RETRIES variable.
  • Added/expanded tests in tests/fm-brief.test.sh (branch-prefix default, configured value, blank-file fallback) and tests/fm-backend-herdr.test.sh (swallow detection and retry sweep).

Risk Assessment

✅ Low: Both changes are narrowly scoped, well-tested with exact-call-count assertions, and the one known gap (fm-merge-local.sh/fm-review-diff.sh not yet honoring config/branch-prefix) is explicitly and accurately disclosed in docs rather than silently left broken.

Testing

Ran the colocated fm-brief.sh test suite (23/23 passing, including all three new branch-prefix tests) and isolated the two new/modified herdr swallow-sweep tests plus a baseline non-swallow regression test (all passing); the full fm-backend-herdr.test.sh suite was still running cleanly (76+ passed, 0 failed) at report time due to its real-sleep-based timing. Beyond unit tests, I produced direct CLI evidence generating real briefs with bin/fm-brief.sh under a configured config/branch-prefix (ryan-fm/) and confirmed the branch-creation step, push rule, and definition-of-done text consistently use the configured prefix across no-mistakes and local-only modes, while an unconfigured home still defaults to fm/ — demonstrating the end-user-facing behavior the change was meant to fix.

Evidence: fm-brief.sh branch-prefix end-to-end CLI transcript (configured ryan-fm/ prefix across no-mistakes/local-only modes, and default fm/ when unconfigured)
=== no-mistakes mode, configured prefix ryan-fm/ ===
scaffolded: /var/folders/tl/tc0684vd5wbd7fhg_l_cqcv80000gn/T/tmp.36RLEdKVGk/data/demo-nm/brief.md (ship, mode=no-mistakes; replace {TASK})
--- relevant brief.md lines ---
18:1. First action: create your branch: `git checkout -b ryan-fm/demo-nm`
22:1. Never push to the default branch. Never merge a PR.

=== local-only mode, configured prefix ryan-fm/ ===
scaffolded: /var/folders/tl/tc0684vd5wbd7fhg_l_cqcv80000gn/T/tmp.36RLEdKVGk/data/demo-local/brief.md (ship, mode=local-only; replace {TASK})
18:1. First action: create your branch: `git checkout -b ryan-fm/demo-local`
56:The task is complete only when committed on your branch `ryan-fm/demo-local`. Do NOT push, do NOT open a PR, do NOT merge.
58:When it is implemented and committed, append `done: ready in branch ryan-fm/demo-local` to the status file and stop.

=== no-mistakes mode, NO config (default fm/) ===
scaffolded: /var/folders/tl/tc0684vd5wbd7fhg_l_cqcv80000gn/T/tmp.IVu2pj94oP/data/demo-default/brief.md (ship, mode=no-mistakes; replace {TASK})
18:1. First action: create your branch: `git checkout -b fm/demo-default`

Pipeline

Updates from git push no-mistakes

⏭️ **intent** - skipped

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

✅ **Review** - passed

✅ No issues found.

✅ **Test** - passed

✅ No issues found.

  • bash tests/fm-brief.test.sh (full file, 23/23 ok, including the 3 new branch-prefix tests: test_branch_prefix_defaults_to_fm, test_branch_prefix_honors_configured_value, test_branch_prefix_blank_file_falls_back_to_default)
  • Isolated run of test_send_text_submit_detects_swallowed_enter and test_send_text_submit_swallow_sweep_lands_a_stubborn_enter from tests/fm-backend-herdr.test.sh via a spliced runner sourcing tests/lib.sh and tests/herdr-test-safety.sh — both pass
  • Isolated run of test_send_text_submit_detects_landed_send (baseline non-swallow path, unmodified by this change) to confirm no regression in the ordinary send-confirmation path
  • Full bash tests/fm-backend-herdr.test.sh suite run in background (in progress at report time: 76+/181 tests passed, 0 failures, spanning tests both before and after the modified swallow-sweep tests in file order)
  • Manual end-to-end CLI verification: FM_HOME=<tmp> bin/fm-brief.sh <id> firstmate --mode no-mistakes with config/branch-prefix=ryan-fm/, --mode local-only with the same config, and --mode no-mistakes with no config file present, inspecting the generated brief.md branch-creation/push/DOD lines directly
  • bash -n syntax check on bin/backends/herdr.sh, bin/fm-brief.sh, bin/fm-promote.sh
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

fm-send to a herdr-backed claude pane repeatedly reported the Enter
swallowed with the text left in the composer, while a manual operator
follow-up fm-send --key Enter reliably landed the same text every
time. fm_backend_herdr_send_text_submit's retry loop now runs a
bounded (FM_BACKEND_HERDR_SWALLOW_RETRIES, default 2) Enter-only
sweep itself when it is about to report a genuine idle-baseline
swallow, instead of failing out and leaving the operator to do it by
hand. Every other unsubmittable state still reports pending/unknown
exactly as before.
Generated ship briefs hardcoded fm/<id> branch language, which
overrode per-task instructions to use a different prefix in a shared
repo where another fleet already owns the fm/* namespace, and crews
pushed into that other fleet's namespace. bin/fm-brief.sh now reads a
local, gitignored config/branch-prefix file (absent = default fm/)
and uses it consistently across the branch-creation step, the push
rule, and every mode's <prefix><id> mention.
…d FM_BACKEND_HERDR_SWALLOW_RETRIES, missing fm-brief CONFIG resolution note, and hardcoded fm/ branch text in fm-promote.sh
…-diff

The no-mistakes document gate flagged that bin/fm-merge-local.sh and
bin/fm-review-diff.sh still hardcoded fm/<id> and did not read
config/branch-prefix, so a captain who configures a non-default
prefix would have local-only merges and diff review silently look
for the wrong branch name and fail - a functional hole in the
branch-prefix feature this branch ships, not a documentation gap.

Extracted the resolution into bin/fm-branch-prefix-lib.sh
(fm_branch_prefix_resolve) as the single owner, and pointed
bin/fm-brief.sh at the shared helper too so all three scripts agree
on the same branch name.
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate:

Scheduled firstmate-oss pass. Diff reviewed against main (head 813d9dec4fa211985abe3b1f5b88282c45a0aa9a). No security risk. Approving the pending first-time fork workflow runs.

Split classification (do not treat as one bucket):

  • Branch-prefix parameterization: opt-in. config/branch-prefix is local/gitignored, absent/blank = historical fm/, not inherited. Shared via fm_branch_prefix_resolve so brief, fm-merge-local, and fm-review-diff name the same branch.
  • Herdr swallowed-Enter sweep: corrective. Bounded FM_BACKEND_HERDR_SWALLOW_RETRIES (default 2) Enter-only follow-up only on a proven idle-baseline swallow; other unsubmittable states still report pending/unknown. Fail-closed preserved.

VISION (per section, both halves unless noted):

  • One captain, one interface: aligns. Briefs stop silently overriding a configured prefix; a stubborn herdr swallow is retried then still reported honestly if it remains pending.
  • Authority is explicit and never inferred: aligns. Prefix is an option to enable, default unchanged. Extra Enters are not a new grant; they retry an already-authorized send.
  • Scripts own the mechanics, agents own the judgment: aligns. Resolution and the swallow sweep are deterministic scripts.
  • A restart is a non-event: aligns for prefix (durable config). Herdr sweep is in-memory send mechanics only (cannot tell / not durable state).
  • Delegation with a spine: aligns. Ship contract, merge, and review agree on the branch name.
  • The fleet outlives any vendor: aligns. Prefix is harness-agnostic; herdr change stays in the herdr adapter.
  • Scope: aligns. Command-layer contract/adapter work, not workshop.

Merge-eligible: YES. Neither half is default-behavior.

Overlap: this PR and #2700 both add tests/fm-merge-local.test.sh and both patch bin/fm-merge-local.sh — hard conflict if both merge. This PR and #2704 both touch bin/fm-brief.sh / tests/fm-brief.test.sh (likely additive). #2705 teardown identity still keys only on fm/*, so a configured non-fm/ prefix would not trip the foreign-task refusal.

@kunchenguid kunchenguid left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Speaking as Kun's firstmate: reviewed the full diff. No security risk. Split: prefix is opt-in, herdr swallow sweep is corrective. Approve pending first-time fork CI.

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