Skip to content

feat(bin): name new worker branches feature/<task-id> while still resolving fm/<task-id> - #3

Merged
demy00 merged 4 commits into
mainfrom
fm/fm-branch-prefix-feature-b8
Sep 24, 2026
Merged

demy00 merged 4 commits into
mainfrom
fm/fm-branch-prefix-feature-b8

Conversation

@demy00

@demy00 demy00 commented Sep 23, 2026 •

Copy link
Copy Markdown
Owner

Intent

The captain's ask, 2026-09-23, verbatim: "can you switch to using feature branches instead
of fm?"

Today every worker branch firstmate creates is named fm/. He wants
feature/.

Context he did not state but that makes this more than cosmetic: several of his
repositories only run their automated checks on branches matching main, develop or
feature/**. A branch named fm/... matches none of those, so worker branches get no checks
at all until a pull request is opened. Renaming them makes those checks run immediately.

What Changed

  • Add bin/fm-task-branch-lib.sh as the single owner of the worker branch naming convention: new workers create feature/<task-id>, and helper functions list, resolve, and export (as JSON) both the current feature/ prefix and the legacy fm/ prefix.
  • Ship and promotion briefs (fm-brief.sh, fm-promote.sh, fm-dod-lib.sh) now render the branch name from the lib instead of hardcoding fm/<id>, and fm-merge-local.sh / fm-review-diff.sh resolve the task's branch under either prefix, current convention first.
  • fm-bearings-snapshot.sh maps PR heads back to task ids for both prefixes; a feature/<id> head is labeled as a task only when <id> is a known in-flight or backlog task, while fm/<id> heads map unconditionally. Tests cover the new lib, branch resolution, and the PR head labeling rules; docs updated to describe the convention.

Existing fm/ branches are not renamed and still resolve

No existing branch, local or remote, is renamed by this change. Three lanes are running on fm/<task-id> branches today, and renaming a branch out from under a running pipeline would strand it. The compatibility path is deliberate: only a newly created worker branch gets the feature/<task-id> name, and every lookup keeps recognising fm/<task-id>.

bin/fm-task-branch-lib.sh is the single owner of both prefixes. It names new branches feature/<task-id>, lists fm/<task-id> as a legacy candidate, and prefers the current name when both exist for one task. These subsystems were updated to resolve through it, so live work keeps resolving after this merges:

  • Review diff (bin/fm-review-diff.sh) resolves the task's branch under feature/ first, then fm/, before falling back to the checked-out branch.
  • Local-only landing (bin/fm-merge-local.sh) fast-forwards the default branch from whichever of the two names exists for the task.
  • Bearings PR cross-reference (bin/fm-bearings-snapshot.sh) maps a PR head under either prefix back to its task. An fm/ head maps unconditionally, exactly as before. A feature/ head is labelled as a task only when its id matches a task record the snapshot already holds, because humans also branch under feature/**.
  • Ship briefs, scout promotion, and the definition-of-done text (bin/fm-brief.sh, bin/fm-promote.sh, bin/fm-dod-lib.sh) render the new name for new workers only. A relaunch reuses the task's stored brief, so a worker already on fm/<task-id> is never told to switch.

Tests pin both halves: a new worker branch is named feature/<task-id>, a task whose only branch is fm/<task-id> still resolves for review diff and local landing, the current name wins over an fm/ twin, and the bearings mapping keeps its fm/ behaviour while ignoring an unknown feature/ id.

Pre-existing suite failures observed, not touched

The repository's changed-file test selection ran 81 scripts on this branch; 7 failed. All 7 fail identically on an export of the untouched base commit a08f79c4 on the same machine, with the same assertion messages, so they are pre-existing and unrelated to this change. They are filed as their own work and deliberately left alone here:

Script Failing assertion (identical on base)
tests/fm-calm-pi-extension.test.sh render_export_dom did not exhaust its bounded retries on a Chrome that never finished
tests/fm-muse-harness.test.sh fm-harness.sh under process 'muse-bin-0.1.0-R708.1' reported '', expected muse
tests/fm-harness-precedence.test.sh codex ancestry alone resolved '', expected codex (the ancestry signal is not live)
tests/fm-calm-claude-mod.test.sh plugin shape check did not complete (missing: 'shape-ok')
tests/fm-teardown.test.sh herdr-preflight-missing-adapter: teardown continued without its required preflight
tests/fm-backlog-atomicity.test.sh a timed-out verification did not report the preservation as attempted, not verified
tests/fm-teardown-endpoint-safety.test.sh valid cleanup removed the independent control window

Evidence: bin/fm-test-run.sh over those seven scripts on the base export printed FM_TEST_SUMMARY total=7 failed=7, versus total=81 failed=7 for the changed-file run on this branch, with the seven not ok lines matching one for one.

Risk Assessment

✅ Low: The rename is routed through a single library, every branch lookup resolves both prefixes with the current name winning, the record-gated PR mapping traces correctly for known, legacy, and unknown heads, and only two informational test-hygiene notes remain.

Testing

Ran all eight directly touched test scripts through the repo runner (all pass, including the new feature/-head record check, legacy fm/ mapping, and both-branch-name landing tests) and performed manual end-to-end verification with transcripts: rendered briefs instruct workers to create feature/<id>, the local-only merge lands both feature/ and legacy fm/ branches, review-diff resolves both names by task id, and the bearings board labels feature/ PR heads only when the id matches a known task record while fm/ heads keep their unconditional mapping. No UI surface is involved, so no screenshot was captured.

Evidence: E2E transcript: rendered briefs, local merge of feature/ and fm/ branches, review-diff under both names

Source: E2E transcript: rendered briefs, local merge of feature/ and fm/ branches, review-diff under both names

===== A. fm-brief.sh: the rendered brief tells a NEW worker to create feature/<task-id> =====

$ fm-brief.sh add-login-a1 some-proj --mode no-mistakes
  scaffolded: /private/var/folders/y9/b8qt1d396lv9cfh42ft2gt7r0000gn/T/e2e-feature-branch.rnAONO/brief-home/data/add-login-a1/brief.md (ship, mode=no-mistakes; replace {TASK} and {FIRSTMATE_SPEC})
-- lines of data/add-login-a1/brief.md that name the worker branch:
  22:1. First action: create your branch: `git checkout -b feature/add-login-a1`

$ fm-brief.sh fix-header-b2 some-proj --mode direct-PR
  scaffolded: /private/var/folders/y9/b8qt1d396lv9cfh42ft2gt7r0000gn/T/e2e-feature-branch.rnAONO/brief-home/data/fix-header-b2/brief.md (ship, mode=direct-PR; replace {TASK} and {FIRSTMATE_SPEC})
-- lines of data/fix-header-b2/brief.md that name the worker branch:
  22:1. First action: create your branch: `git checkout -b feature/fix-header-b2`
  25:1. Never push to the default branch (push only your `feature/fix-header-b2` branch). Never merge a PR.

$ fm-brief.sh tidy-docs-c3 some-proj --mode local-only
  scaffolded: /private/var/folders/y9/b8qt1d396lv9cfh42ft2gt7r0000gn/T/e2e-feature-branch.rnAONO/brief-home/data/tidy-docs-c3/brief.md (ship, mode=local-only; replace {TASK} and {FIRSTMATE_SPEC})
-- lines of data/tidy-docs-c3/brief.md that name the worker branch:
  22:1. First action: create your branch: `git checkout -b feature/tidy-docs-c3`
  25:1. Never push to any remote and never open a PR. Work only on your `feature/tidy-docs-c3` branch; firstmate handles the merge into local `main`.
  79:The task is complete only when committed on your branch `feature/tidy-docs-c3`. Do NOT push, do NOT open a PR, do NOT merge.
  81:When it is implemented and committed, append `done [at=<epoch>]: ready in branch feature/tidy-docs-c3` to the status file and stop.

===== B. fm-merge-local.sh: lands a feature/<id> branch AND a pre-rename fm/<id> branch =====

$ git -C sample branch --list        # before
  + feature/land-feature-1
  * main
$ git -C sample log --oneline main    # before
  ea32515 initial
$ fm-merge-local.sh land-feature-1
  merged feature/land-feature-1 into local main (ea32515 -> 1879324) in /private/var/folders/y9/b8qt1d396lv9cfh42ft2gt7r0000gn/T/e2e-feature-branch.rnAONO/merge-feature/projects/sample
  exit=0
$ git -C sample log --oneline main    # after
  1879324 delivery on feature/land-feature-1
  ea32515 initial

$ git -C sample branch --list        # before
  + fm/land-fm-1
  * main
$ git -C sample log --oneline main    # before
  7c079e8 initial
$ fm-merge-local.sh land-fm-1
  merged fm/land-fm-1 into local main (7c079e8 -> 8bd0406) in /private/var/folders/y9/b8qt1d396lv9cfh42ft2gt7r0000gn/T/e2e-feature-branch.rnAONO/merge-fm/projects/sample
  exit=0
$ git -C sample log --oneline main    # after
  8bd0406 delivery on fm/land-fm-1
  7c079e8 initial

===== C. fm-review-diff.sh: reviews the task branch under feature/ and under legacy fm/ =====

$ git -C wt branch --list
  * (HEAD detached at refs/heads/main)
    feature/task-x1
  + main
$ fm-review-diff.sh task-x1
  diff base: origin/main
   feature.txt | 1 +
   1 file changed, 1 insertion(+)
  
  diff --git a/feature.txt b/feature.txt
  new file mode 100644
  index 0000000..5acb343
  --- /dev/null
  +++ b/feature.txt
  @@ -0,0 +1 @@
  +change made on feature/task-x1

$ git -C wt branch --list
  * (HEAD detached at refs/heads/main)
    fm/task-x1
  + main
$ fm-review-diff.sh task-x1
  diff base: origin/main
   feature.txt | 1 +
   1 file changed, 1 insertion(+)
  
  diff --git a/feature.txt b/feature.txt
  new file mode 100644
  index 0000000..37521ce
  --- /dev/null
  +++ b/feature.txt
  @@ -0,0 +1 @@
  +change made on fm/task-x1
Evidence: E2E transcript: bearings --include-prs PR head to task mapping (known/unknown feature/ heads, fm/ heads)

Source: E2E transcript: bearings --include-prs PR head to task mapping (known/unknown feature/ heads, fm/ heads)

===== D. fm-bearings-snapshot.sh --include-prs: PR head -> task mapping =====

-- default-feature-head: gh returned these PR heads:
  #9  head=feature/ship-task
-- task ids this home has a record of (from data/backlog.md, every section):
  dead-gate   done-a   live-gate   scout-x   ship-task 
-- candidate_prs as the captain sees them (num / head-derived task):
  #9  task=ship-task

-- legacy-fm-head: gh returned these PR heads:
  #9  head=fm/ship-task
-- task ids this home has a record of (from data/backlog.md, every section):
  dead-gate   done-a   live-gate   scout-x   ship-task 
-- candidate_prs as the captain sees them (num / head-derived task):
  #9  task=ship-task

-- feature-heads-known-and-unknown: gh returned these PR heads:
  #11  head=feature/login-redesign
  #12  head=feature/live-gate
  #13  head=feature/done-a
-- task ids this home has a record of (from data/backlog.md, every section):
  dead-gate   done-a   live-gate   scout-x   ship-task 
-- candidate_prs as the captain sees them (num / head-derived task):
  #11  task=-
  #12  task=live-gate
  #13  task=done-a

-- legacy-fm-head-without-record: gh returned these PR heads:
  #21  head=fm/orphan-lane
  #22  head=feature/orphan-lane
  #23  head=feature/
  #24  head=hotfix/ship-task
-- task ids this home has a record of (from data/backlog.md, every section):
  dead-gate   done-a   live-gate   scout-x   ship-task 
-- candidate_prs as the captain sees them (num / head-derived task):
  #21  task=orphan-lane
  #22  task=-
  #23  task=-
  #24  task=-
Evidence: Rendered local-only brief (data/<id>/brief.md) naming feature/tidy-docs-c3

Source: Rendered local-only brief (data/<id>/brief.md) naming feature/tidy-docs-c3

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 some-proj, 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 feature/tidy-docs-c3`

# Rules
1. Never push to any remote and never open a PR. Work only on your `feature/tidy-docs-c3` branch; firstmate handles the merge into local `main`.
2. Stay inside this worktree; modify nothing outside it.
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}" >> '/private/var/folders/y9/b8qt1d396lv9cfh42ft2gt7r0000gn/T/e2e-feature-branch.rnAONO/brief-home/state/tidy-docs-c3.status'`
   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:` - ONLY when you are deliberately idling on a
   known external wait you expect to clear on its own (an upstream release, a rate-limit reset, a scheduled window, or your own validation round):
   firstmate then leaves your idle pane alone and rechecks it on a long
   cadence instead of treating it as a possible wedge. 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.

   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 stop, restart, or update the shared `no-mistakes` daemon - it is one instance serving
   every lane/home, so restarting 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.

# Firstmate instruction inbox
Firstmate steers you through durable message files in '/private/var/folders/y9/b8qt1d396lv9cfh42ft2gt7r0000gn/T/e2e-feature-branch.rnAONO/brief-home/state/tidy-docs-c3.inbox'.
When a terminal message says an instruction is waiting there - and at any natural checkpoint when you are unsure - list '/private/var/folders/y9/b8qt1d396lv9cfh42ft2gt7r0000gn/T/e2e-feature-branch.rnAONO/brief-home/state/tidy-docs-c3.inbox'/*.msg, read and act on each message in numeric order, then acknowledge each handled message by moving it: `mv '/private/var/folders/y9/b8qt1d396lv9cfh42ft2gt7r0000gn/T/e2e-feature-branch.rnAONO/brief-home/state/tidy-docs-c3.inbox'/NNN.msg '/private/var/folders/y9/b8qt1d396lv9cfh42ft2gt7r0000gn/T/e2e-feature-branch.rnAONO/brief-home/state/tidy-docs-c3.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
If `AGENTS.md` or `CLAUDE.md` already exists, or if this task produced durable project-intrinsic knowledge, run `~/.no-mistakes/worktrees/f2cfe607828c/01M37N1B146PY49H0CTEEF6YX4/bin/fm-ensure-agents-md.sh .` in the worktree.
Record only project knowledge useful to almost every future session.
For anything the codebase already shows, prefer a pointer to the authoritative file, command, or doc over copying the detail.
If you touch a project `AGENTS.md`, follow `~/.no-mistakes/worktrees/f2cfe607828c/01M37N1B146PY49H0CTEEF6YX4/bin/fm-ensure-agents-md.sh`'s self-governance contract in the same pass.
Keep it proportionate: skip `AGENTS.md` edits for trivial tasks that produced no durable project knowledge.

# Definition of done
Delivery contract: mode=local-only
This task ships **local-only**: no remote, no PR, no pipeline.
The task is complete only when committed on your branch `feature/tidy-docs-c3`. Do NOT push, do NOT open a PR, do NOT merge.
Keep your branch a clean fast-forward onto the current default branch - if `main` has advanced, rebase onto it so the eventual merge stays a fast-forward.
When it is implemented and committed, append `done [at=<epoch>]: ready in branch feature/tidy-docs-c3` to the status file and stop.
The configured merge authority approves the ready branch, then firstmate merges it into local `main` through the guarded fast-forward path.
Evidence: Evidence script used to produce the transcripts

Source: Evidence script used to produce the transcripts

#!/usr/bin/env bash
# Manual end-to-end evidence for: worker branches are named feature/<task-id>,
# while branches created earlier as fm/<task-id> still resolve everywhere.
set -u
ROOT=~/.no-mistakes/worktrees/f2cfe607828c/01M37N1B146PY49H0CTEEF6YX4
EV=~/.no-mistakes/evidence/01M37N1B146PY49H0CTEEF6YX4
. "$ROOT/tests/lib.sh"
fm_git_identity fmtest [email protected]
T=$(fm_test_tmproot e2e-feature-branch)

hr() { printf '\n===== %s =====\n' "$*"; }

exit_after_d=1
[ "${ONLY_D:-0}" = 1 ] && skip_abc=1 || skip_abc=0
if [ "$skip_abc" = 0 ]; then
hr "A. fm-brief.sh: the rendered brief tells a NEW worker to create feature/<task-id>"
home="$T/brief-home"; mkdir -p "$home/data"
for id_mode in "add-login-a1:no-mistakes" "fix-header-b2:direct-PR" "tidy-docs-c3:local-only"; do
  id=${id_mode%%:*}; mode=${id_mode##*:}
  printf '\n$ fm-brief.sh %s some-proj --mode %s\n' "$id" "$mode"
  FM_HOME="$home" "$ROOT/bin/fm-brief.sh" "$id" some-proj --mode "$mode" 2>&1 | sed 's/^/  /'
  printf -- '-- lines of data/%s/brief.md that name the worker branch:\n' "$id"
  grep -n 'feature/\|fm/' "$home/data/$id/brief.md" | sed 's/^/  /'
done
cp "$home/data/tidy-docs-c3/brief.md" "$EV/rendered-brief-local-only.md"

hr "B. fm-merge-local.sh: lands a feature/<id> branch AND a pre-rename fm/<id> branch"
for branch in feature fm; do
  id="land-$branch-1"; h="$T/merge-$branch"
  mkdir -p "$h/state" "$h/data" "$h/config" "$h/projects"
  proj="$h/projects/sample"; wt="$h/projects/$id"
  fm_git_worktree "$proj" "$wt" "$branch/$id"
  printf 'landed from %s\n' "$branch" > "$wt/delivery.txt"
  git -C "$wt" add delivery.txt; git -C "$wt" commit -qm "delivery on $branch/$id"
  fm_write_meta "$h/state/$id.meta" "window=firstmate:fm-$id" "endpoint_task_id=$id" \
    "worktree=$wt" "project=$proj" "harness=codex" "kind=ship" "mode=local-only" "spawn_gen=fixture-$id"
  printf '\n$ git -C sample branch --list        # before\n'; git -C "$proj" branch --list | sed 's/^/  /'
  printf '$ git -C sample log --oneline main    # before\n'; git -C "$proj" log --oneline main | sed 's/^/  /'
  printf '$ fm-merge-local.sh %s\n' "$id"
  FM_ROOT_OVERRIDE="$ROOT" FM_HOME="$h" FM_STATE_OVERRIDE="$h/state" FM_DATA_OVERRIDE="$h/data" \
    FM_CONFIG_OVERRIDE="$h/config" "$ROOT/bin/fm-merge-local.sh" "$id" 2>&1 | sed 's/^/  /'
  printf '  exit=%s\n' "${PIPESTATUS[0]}"
  printf '$ git -C sample log --oneline main    # after\n'; git -C "$proj" log --oneline main | sed 's/^/  /'
done

hr "C. fm-review-diff.sh: reviews the task branch under feature/ and under legacy fm/"
for branch in feature fm; do
  id="task-x1"; c="$T/review-$branch"; mkdir -p "$c/state"
  fm_git_init_commit "$c/seed"; fm_git_add_origin "$c/seed" "$c/origin.git"
  git clone -q "$c/origin.git" "$c/project"; git -C "$c/project" remote set-head origin main 2>/dev/null || true
  git -C "$c/project" worktree add -q -b "$branch/$id" "$c/wt" main
  printf 'change made on %s/%s\n' "$branch" "$id" > "$c/wt/feature.txt"
  git -C "$c/wt" add feature.txt; git -C "$c/wt" commit -qm "work on $branch/$id"
  git -C "$c/wt" checkout -q --detach main   # park the worktree elsewhere: lookup must be by name
  fm_write_meta "$c/state/$id.meta" "window=firstmate:fm-$id" "endpoint_task_id=$id" \
    "worktree=$c/wt" "project=$c/project" "harness=codex" "kind=ship" "mode=direct-PR"
  touch "$c/state/.last-watcher-beat"
  printf '\n$ git -C wt branch --list\n'; git -C "$c/wt" branch --list | sed 's/^/  /'
  printf '$ fm-review-diff.sh %s\n' "$id"
  FM_ROOT_OVERRIDE="$ROOT" FM_HOME="$c" FM_STATE_OVERRIDE="$c/state" "$ROOT/bin/fm-review-diff.sh" "$id" 2>&1 | sed 's/^/  /'
done

fi
hr "D. fm-bearings-snapshot.sh --include-prs: PR head -> task mapping"
# Reuse the bearings suite's own fixture helpers (everything before its first test).
sed -n '1,369p' "$ROOT/tests/fm-bearings-snapshot.test.sh" \
  | sed "s#^\. \"\$(dirname \"\${BASH_SOURCE\[0\]}\")/lib.sh\"#. \"$ROOT/tests/lib.sh\"#" > "$T/bearings-helpers.sh"
. "$T/bearings-helpers.sh"
show() {  # <label> <env-var-or-empty>
  local home fb json
  home=$(make_home "$1"); write_fixture "$home"; fb=$(make_fakebin "$home"); : > "$home/net.log"
  if [ -n "$2" ]; then json=$(env "$2=1" bash -c '. "$0"; run "$1" "$2" --include-prs --json' "$T/bearings-helpers.sh" "$home" "$fb")
  else json=$(run "$home" "$fb" --include-prs --json); fi
  printf '\n-- %s: gh returned these PR heads:\n' "$1"
  ( PATH="$fb:$PATH" ${2:+env $2=1} gh pr list 2>/dev/null | jq -r '.[] | "  #\(.number)  head=\(.headRefName)"' )
  printf -- '-- task ids this home has a record of (from data/backlog.md, every section):\n'
  sed -n 's/^- \[.\] \([a-z0-9-]*\).*/  \1/p' "$home/data/backlog.md" | sort | tr '\n' ' '; printf '\n'
  printf -- '-- candidate_prs as the captain sees them (num / head-derived task):\n'
  printf '%s' "$json" | jq -r '.candidate_prs[] | "  #\(.num)  task=\(.task)"'
}
show default-feature-head ""
show legacy-fm-head FAKE_GH_LEGACY_BRANCH
show feature-heads-known-and-unknown FAKE_GH_FEATURE_HEADS

# Reviewer-decided boundary: the record check applies to feature/ heads only.
# A legacy fm/<id> head is still labelled even when <id> has no record.
show_custom_gh() {  # <label> <json>
  local home fb json
  home=$(make_home "$1"); write_fixture "$home"; fb=$(make_fakebin "$home"); : > "$home/net.log"
  printf '#!/usr/bin/env bash\necho "gh $*" >> "$NET_LOG"\ncat <<'"'"'JSON'"'"'\n%s\nJSON\n' "$2" > "$fb/gh"; chmod +x "$fb/gh"
  json=$(run "$home" "$fb" --include-prs --json)
  printf '\n-- %s: gh returned these PR heads:\n' "$1"
  ( PATH="$fb:$PATH" gh pr list 2>/dev/null | jq -r '.[] | "  #\(.number)  head=\(.headRefName)"' )
  printf -- '-- task ids this home has a record of (from data/backlog.md, every section):\n'
  sed -n 's/^- \[.\] \([a-z0-9-]*\).*/  \1/p' "$home/data/backlog.md" | sort | tr '\n' ' '; printf '\n'
  printf -- '-- candidate_prs as the captain sees them (num / head-derived task):\n'
  printf '%s' "$json" | jq -r '.candidate_prs[] | "  #\(.num)  task=\(.task)"'
}
show_custom_gh legacy-fm-head-without-record \
  '[{"number":21,"title":"Old lane","url":"https://github.com/kunchenguid/firstmate/pull/21","headRefName":"fm/orphan-lane","reviewDecision":"","mergeable":"MERGEABLE","statusCheckRollup":[]},{"number":22,"title":"Human branch","url":"https://github.com/kunchenguid/firstmate/pull/22","headRefName":"feature/orphan-lane","reviewDecision":"","mergeable":"MERGEABLE","statusCheckRollup":[]},{"number":23,"title":"Bare prefix","url":"https://github.com/kunchenguid/firstmate/pull/23","headRefName":"feature/","reviewDecision":"","mergeable":"MERGEABLE","statusCheckRollup":[]},{"number":24,"title":"Unrelated","url":"https://github.com/kunchenguid/firstmate/pull/24","headRefName":"hotfix/ship-task","reviewDecision":"","mergeable":"MERGEABLE","statusCheckRollup":[]}]'
Evidence: Bearings PR mapping as the captain sees it
-- feature-heads-known-and-unknown: gh returned these PR heads:
#11 head=feature/login-redesign
#12 head=feature/live-gate
#13 head=feature/done-a
-- task ids this home has a record of: dead-gate done-a live-gate scout-x ship-task
-- candidate_prs:
#11 task=-
#12 task=live-gate
#13 task=done-a

-- legacy-fm-head-without-record:
#21 head=fm/orphan-lane -> task=orphan-lane
#22 head=feature/orphan-lane -> task=-
#23 head=feature/ -> task=-
#24 head=hotfix/ship-task -> task=-
Evidence: Runner output of the bearings and captain-hold suites (both exit 0)

Source: Runner output of the bearings and captain-hold suites (both exit 0)

FM_TEST_BEGIN 2026-09-23T17:56:43Z tests/fm-bearings-snapshot.test.sh family=snapshot-bearings expected_gate_skip=optional-binary
ok - task teardown during metadata capture is omitted without aborting the snapshot
ok - current state and decision hints share one captured status observation
ok - reused live state is discarded when task generation changes
ok - large local snapshot overlaps local reads with byte-identical serial and concurrent projections
ok - remote ledgers collect concurrently under one budget, reuse aged cache, and cancel wedged collectors
ok - a missing remote ledger stays explicitly unreadable without remote summary computation
ok - Domain Alpha structured state overrides a stale parent Phase 7 event
ok - GNU stat file reads select -c without BSD filesystem-report pollution
ok - parent activity evidence is bounded and disclosed
ok - Bearings excludes a status-only child decision
ok - a structured child captain hold reaches Captain's Call
ok - missing, invalid, unreadable, malformed, and unavailable-child homes stay explicit unknowns
ok - oversized ledgers stay strict unknown
ok - secondmate and per-home child counts are bounded, disclosed, and explicitly expandable
ok - parent decisions remain untrusted contradiction evidence
ok - parent evidence reconciliation distinguishes matching holds, blocks, and decisions
ok - nonprogressing child states are explicit and inconsistent terminal rows invalidate
ok - registry unavailability and bounded truncation remain explicit
ok - repeated snapshots keep the same current landed baseline and ignore prior reports
ok - default output is bounded, local-only, and marks omitted surfaces
ok - TOON and JSON are parity representations of the same model
ok - landed includes secondmate-managed merges alongside main-home merges
ok - landed accepts only kind-owned delivery artifacts while answered questions stay out
ok - kind fallback matches tasks-axi word boundaries and preserves scout deliveries
ok - kindless v1 summaries retain report artifacts from fresh and cached ledgers
ok - default landed selection balances one dominant home with sparse homes
ok - landed selection refills capacity after sparse homes exhaust
ok - landed selection uses deterministic home order when homes exceed the cap
ok - landed selection preserves deterministic home and internal tie ordering
ok - landed selection handles no landed items
ok - --all-landed keeps the complete global landed output
ok - landed stays bounded with per-home + overall caps and omitted[] disclosure
ok - Bearings keeps a live blocker in structured live state and never converts it to Charted Next queue work
ok - action-free items (working/done/queued/landed) do not leak into Captain's Call
ok - main orphan in-flight stays out of Underway and is disclosed in omitted/gates
ok - main unstructured current is disclosed while structured siblings still project
ok - counterfactual meta clears main inventory warning and projects the live task
ok - working captain holds retain main and secondmate bucket surfaces
ok - active children reach Underway independently of a home captain hold
ok - blank legacy summary names use their durable identifier
ok - newest filed gates are selected before snapshot bounds
ok - Underway rows carry the durable task name and gates carry their filed date
ok - mixed secondmate roles, partial state, and captain readiness project independently
ok - main and secondmate captain actionability use the same blocker readiness
ok - a completed scout with decision-like report prose is a pointer, not pending
ok - an authoritative captain hold surfaces end-to-end
ok - current report pointers surface
ok - queued body prose never hides an item from the board
ok - --include-prs is the only path that fetches, and it enriches correctly
ok - --include-prs maps a PR on the earlier fm/ worker branch back to its task
ok - --include-prs labels a feature/ head as a task PR only when a task record matches its id
ok - a partial GitHub failure degrades gracefully
ok - Perl fallback bounds stalled GitHub calls without coreutils timeout
ok - all fleet-sized sections are capped with counted opt-in expansion
ok - captain-held tasks of any kind reach Captain's Call, deferral is honored, and landed excludes answered calls
ok - structured hold buckets decide Captain's Call, Charted Next, and the reveal
ok - a blocked deferred hold stays gated when its date arrives and is revealed by --all-decisions
ok - revealed deferred holds display their deferral reason while live calls stay unannotated
ok - live PR enrichment caps repositories with counted expansion
ok - per-repository open-PR caps are disclosed with an expansion knob
ok - projection and TOON rendering failures exit nonzero with diagnostics
FM_TEST_END 2026-09-23T18:00:21Z tests/fm-bearings-snapshot.test.sh exit=0 duration_ms=218526 gate_skip=false
FM_TEST_BEGIN 2026-09-23T18:00:21Z tests/fm-captain-hold-lifecycle.test.sh family=pure-contract-unit expected_gate_skip=none
ok - report-only unresolved captain call is reproduced and completion refuses before loss
ok - both body-decoding paths work without the allow_nonref default
ok - cleanup preserves every byte of a retained body's non-ASCII characters
ok - the completion gate attests captain-held inventory and transfers open status decisions
ok - answer records the captain's words, closes idempotently, and releases routed work
ok - the completion gate accepts an answered captain call pruned into the archive
ok - the gate still refuses an archived call with no recorded answer and an unknown key
ok - the completion gate unions archived and live inventory and keeps a held call open
ok - the gate reads tasks-axi's default archive in a home that configures none
ok - the gate reads the archive the user's tasks-axi config names
ok - the gate refuses a reused key whose newest archived close recorded no answer
ok - the gate accepts a reused key whose newest archived close is answered
ok - release frees held work with the captain's words recorded and the body preserved
ok - captain holds become visible only after their hold-set timestamp is durable
ok - an interrupted answer preserves its hold age until close retry
ok - a deferred captain call leaves the live Captain's Call until its date and stays answerable
ok - an out-of-band close is recordable with the captain's word and nothing else
ok - ended visual review follows the same captain-hold completion owner
ok - resolved findings and decision-like prose do not create captain-held tasks
ok - terminal single-owner stale status decisions do not block empty inventory
ok - main-home and secondmate-home captain calls remain correctly routed
ok - a secondmate home publishes each hold occurrence and its answer on the parent channel
ok - secondmate resolutions publish before retiring durable retry triggers
ok - a bound channel's captured answers close their captain-held tasks at answer time
ok - only a bound captured source creates reconcile requests
ok - normal answers and their replays retire reconcile requests
ok - reconcile closes a moot call with evidence and keeps an active one open with a note
ok - reconcile outcomes apply durable mutations once across partial failures
ok - a channel source with no decision binding closes nothing
ok - legacy identities, metadata, bindings, and the shim keep working
ok - a board answer reaches the keyed-answer intake and wakes firstmate
ok - the chat channel feeds the same keyed-answer intake a captured review does
ok - completion and verification validate origins before constructing paths
ok - a status resolution over a still-open captain-held task is signalled, not closed
ok - a captain call with no routed work, a verified transfer, an open decision, and an answered call all stay silent
ok - cleanup leaves a captain-held work item open with its deliverable, and only an answer closes it
ok - release and scout report retention distinguish deliveries from rejected merge answers
ok - an interrupted cleanup keeps the captain call recoverable and session start retains it
ok - an answer before cleanup replay preserves the retained report
ok - an unusable pending-close record names its reason instead of a bare refusal
ok - an unsupported relocated report does not wedge the captain's answer
ok - cleanup retains captain calls in the configured backlog
ok - merge approval releases before zero-retention cleanup records completion
ok - the PR merge entrypoint refuses a captain-held task before merging
ok - the local merge entrypoint refuses a captain-held task before merging
ok - the PR merge entrypoint separates an unreadable authority record from an absent one
ok - the local merge entrypoint separates an unreadable authority record from an absent one
ok - merge entrypoints reject unsafe identities and absent state before locking
ok - merge entrypoints refuse a replacement incarnation after waiting for cleanup
ok - merge entrypoints own task state before forced cleanup can retire it
ok - a released merge passes the guarded entrypoint and remains recently landed
ok - cleanup refuses a ship row when its captain hold cannot be read
ok - skipped on markdown-only tasks-axi: verify against a beads-migrated hold
ok - skipped on markdown-only tasks-axi: verify against a prefix-migrated hold
ok - skipped on markdown-only tasks-axi: prefer a marker-noted row over a prefix namesake
ok - skipped on markdown-only tasks-axi: complete against a beads-migrated hold
ok - skipped on markdown-only tasks-axi: verify an unresolvable beads legacy id
ok - skipped on markdown-only tasks-axi: verify a derived pre-collapse key
ok - captain-hold mutations address the beads backend without a markdown override
ok - skipped on markdown-only tasks-axi: captain-hold create under due.required without types.custom
FM_TEST_END 2026-09-23T18:07:00Z tests/fm-captain-hold-lifecycle.test.sh exit=0 duration_ms=398311 gate_skip=false
FM_TEST_SUMMARY total=2 failed=0 skipped_gate=0 duration_ms=616946
FM_TEST_SUMMARY_FAMILY family=pure-contract-unit count=1 duration_ms=398311 failed=0
FM_TEST_SUMMARY_FAMILY family=snapshot-bearings count=1 duration_ms=218526 failed=0
FM_TEST_SLOWEST rank=1 script=tests/fm-captain-hold-lifecycle.test.sh duration_ms=398311
FM_TEST_SLOWEST rank=2 script=tests/fm-bearings-snapshot.test.sh duration_ms=218526
exit=0

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

⚠️ **Review** - 2 infos
  • ⚠️ bin/fm-bearings-snapshot.sh:308 - The PR-to-task mapping now claims any PR whose head starts with feature/ as a firstmate task. The captain's stated reason for the rename is that these repositories already gate checks on feature/**, so humans use that namespace too. A human PR on feature/login-redesign will surface in candidate_prs with task=login-redesign even though no such task exists, where the earlier fm/ prefix was firstmate-only and could not collide. The smallest remedy (cross-checking the parsed id against known task records before labelling it) extends the change beyond the rename, so it needs authorization rather than an auto-fix; the alternative is accepting the ambiguous label as inherent to the requested convention.
  • ℹ️ bin/fm-task-branch-lib.sh:51 - fm_task_branch_id has no caller in bin/; only its own test exercises it. The bearings jq consumer reimplements the same prefix parse via fm_task_branch_prefixes_json. Either drop the helper and its test, or keep it only if a shell consumer is planned.

🔧 Fix: label feature/ PR heads only for known tasks
2 infos still open:

  • ℹ️ tests/fm-bearings-snapshot.test.sh:1440 - The user's fix instruction required that the task-record check apply only to feature/ heads and NOT to fm/ heads. The legacy test uses headRefName fm/ship-task, and ship-task has an in-flight record, so the test passes equally whether or not the record check is (wrongly) applied to fm/ heads too. Pin the constraint: add an fm/<id> head whose id has no record (for example fm/orphan-lane) to the FAKE_GH_LEGACY_BRANCH fixture and assert its task is "orphan-lane", not "-". Current code already behaves this way (the jq only gates when $p == $current), so this is a coverage pin, not a defect.
  • ℹ️ tests/fm-review-diff.test.sh:14 - The new case (f) description says that when the worktree holds neither feature/<id> nor fm/<id>, "a stray checked-out branch is not mistaken for the task". bin/fm-review-diff.sh lines 75-78 do the opposite (unchanged pre-existing behaviour): with no candidate branch it falls back to the currently checked-out branch. Neither new test exercises the neither-exists case, so the comment documents behaviour the code does not have. Reword the comment to describe the real fallback, or drop that clause.
✅ **Test** - passed

✅ No issues found.

  • bin/fm-test-run.sh tests/fm-task-branch-lib.test.sh tests/fm-review-diff.test.sh tests/fm-tangle-guard.test.sh tests/fm-task-delivery.test.sh tests/fm-control-relaunch.test.sh tests/fm-brief.test.sh (6 scripts, failed=0)
  • bin/fm-test-run.sh tests/fm-bearings-snapshot.test.sh tests/fm-captain-hold-lifecycle.test.sh (2 scripts, failed=0, including the new feature/-head record check and legacy fm/ mapping tests)
  • Manual E2E fm-brief.sh &lt;id&gt; some-proj --mode {no-mistakes,direct-PR,local-only}: rendered brief.md names git checkout -b feature/&lt;id&gt; and the rules/DoD lines name the feature/ branch
  • Manual E2E fm-merge-local.sh land-feature-1 and fm-merge-local.sh land-fm-1: main fast-forwards onto a feature/ branch and onto a pre-rename fm/ branch
  • Manual E2E fm-review-diff.sh task-x1 with the worktree detached: diff resolves from feature/task-x1, and from fm/task-x1 when only that exists
  • Manual E2E fm-bearings-snapshot.sh --include-prs --json with stubbed gh: feature/ship-task and fm/ship-task -> labelled; feature/live-gate (queued) and feature/done-a (done) -> labelled; feature/login-redesign (no record), feature/, hotfix/ship-task -> task=-; fm/orphan-lane (no record) -> still labelled orphan-lane
  • git status --porcelain --ignored clean after testing; evidence written only under the evidence directory
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

…olving fm/<task-id>

bin/fm-task-branch-lib.sh becomes the one owner of the worker branch naming
convention. New workers create feature/<task-id> so project repositories whose
automated checks run only on main, develop, or feature/** branches check a
worker branch from its first push. Branches already created under fm/<task-id>
are never renamed: every lookup, match, and parse (review diff, local-only
landing, bearings PR-to-task mapping) recognises both prefixes, current name
first, so work under way keeps resolving.
… (legacy fm/ branch PR mapping and feature/ head labeling only for known task records) in tests/fm-bearings-snapshot.test.sh, but the "Stock macOS Bash snapshot compatibility" job in .github/workflows/ci.yml still asserted a hardcoded count of 59 passing Bearings tests. The suite itself passed every test; only the count check failed (got 61). Fix: updated the expected count in .github/workflows/ci.yml from 59 to 61 (both the comparison and the error message). No other files changed. Verification: ran `/bin/bash tests/fm-bearings-snapshot.test.sh` locally under stock GNU bash 3.2.57(1)-release (arm64-apple-darwin25). Exit code 0, 61 lines matching '^ok - ', no non-ok output
@demy00
demy00 merged commit 89e1459 into main Sep 24, 2026
19 of 20 checks passed
demy00 added a commit that referenced this pull request Sep 30, 2026
… The CI job "Behavior portable serial 4" failed on one test, `tests/fm-fleet-ledger.test.sh`, with `fm-merge-local: error: branch feature/on-lifecycle-t1 does not exist`. I got the same failure locally. - **Cause:** Fork change #3 makes `fm-spawn` name new worker branches `feature/<task-id>` and record that name in the task's meta. This test comes from upstream, and it still pre-creates the worker checkout on `fm/<task-id>`. So spawn records `feature/...`, and `fm-merge-local` then can't find that branch. The script code is fine; the test was never updated for the fork's naming. - **Fix:** In `tests/fm-fleet-ledger.test.sh`, `make_case` now creates the checkout on `feature/$TASK`. The fork's own tests already do this in the same setup (for example `tests/fm-captain-hold-lifecycle.test.sh`). Resolving old `fm/` branches is unchanged. - **Check:** `bash tests/fm-fleet-ledger.test.sh` now passes locally (exit 0, every case ok)
demy00 added a commit that referenced this pull request Oct 16, 2026
## Conflict resolutions

The trial merge listed 13 conflicted files; the actual merge also conflicts in `tests/fm-procevent.test.sh` (14 total).

| File | Fork origin | Resolution |
| --- | --- | --- |
| `.agents/skills/agent-skill-trigger-index/SKILL.md` | 09efd59 (#6, clickup-tickets) | Fork's `clickup-tickets` trigger line re-added to upstream's list unchanged. |
| `AGENTS.md` | 3843b2c (#8, skill selection); 89e1459 (#3, `feature/` prefix) | Fork's `fm-skill-select.sh --apply` line and the `feature/` default wording re-applied on upstream's new section 7 text (upstream added `--base-branch` and self-repo consent lines next to it; both kept). |
| `README.md` | 89e1459 (#3), via earlier fork syncs | Default ship-branch prefix wording stays `feature/` in upstream's rewritten bullet. |
| `bin/fm-captain-hold.sh` | 999f9d8 (#1, done-archive evidence) | Fork's done-archive lookup re-applied unchanged on upstream's version. |
| `bin/fm-dod-lib.sh` | 89e1459 (#3), 16cc4bd | Upstream's new base-branch/forge/consent code kept; its two `fm/$id` defaults now call `fm_task_branch` and the lib sources `fm-task-branch-lib.sh`, as the fork did before. |
| `bin/fm-procevent-lavish.sh` | 826e32b, 79d101b, d0ac8f4, cbfb295 (#7) | True clash, decided by the captain (option A) - see below. |
| `bin/fm-spawn.sh` | 89e1459 (#3), 16cc4bd, b7edc11, 153f4e2, de04c2d | Fork's `feature/` branch naming and legacy-brief branch binding re-applied unchanged on upstream's version. |
| `bin/fm-timeout-lib.sh` | 9e8b923 (bash without `BASHPID`) | Upstream fixed the same macOS bash 3.2 bug independently (5838f10, kunchenguid#6028, perl watchdog takes the pre-exec parent). Took upstream's code; the fork's regression test for it is kept and passes on upstream's fix. |
| `docs/architecture.md` | 89e1459 (#3) | `feature/` default and the `fm-task-branch-lib.sh` ownership line re-applied. |
| `tests/fm-brief.test.sh` | 89e1459 (#3), via earlier fork syncs | Expected branch names stay `feature/<id>` in upstream's updated cases. |
| `tests/fm-calm-pi-extension.test.sh` | bc3f178 (#10), 1757302 (#8 CI fix) | Upstream fixed the `/reload` geometry flake its own way (`wait_for_geometry_reload` on a durable status row), so the fork's `pipe-pane` version is dropped. Kept the fork's lookup-counting export renderer, the report-based Chrome hang attempt check, and the `tuiMode: regular` settings pin next to upstream's `--tui-mode regular` flag. |
| `tests/fm-procevent.test.sh` | #7 | Both test sets kept; see the Lavish decision. |
| `tests/fm-review-diff.test.sh` | 89e1459 (#3) | Fork's two unrecorded-`feature/` branch cases re-added; case letters shifted after upstream's new cases. |
| `tests/fm-timeout-lib.test.sh` | 9e8b923 | Fork's no-`BASHPID` test kept on top of upstream's tests. |

## Decision: Lavish list-form parser (captain chose option A)

Both sides fixed the same bug: Lavish emits queued feedback as a TOON list (not a table) when items carry nested content, and the adapter read it as an empty, complete result.

- Fork (#7): one parser that flattens and presents every nested field (table-cell `target:`, `attachments:`, other `fields:`, message uid/selector/text), adds `unpresented_items:`, and refuses `complete: yes` when nested content cannot be parsed.
- Upstream (fc8972c, kunchenguid#5404): one parser that skips nested targets and attachments; its tests assert nested content is absent from `read`. It also adds stricter refusals (unrecognized header keeps its declared count and counts as malformed; `answers`/`reconciles` exit 3 when not fully accounted for), and 228b27d renames the message count to `captain_message_count`.

Options:

- **A (chosen):** keep the fork's presenting parser, port upstream's strictness onto it (declared count + malformed on an unrecognized header, `answers`/`reconciles` exit 3, `captain_message_count`), keep both test sets, and adapt upstream's three "absent" assertions to check nested content appears only under its own labelled section and never replaces the item's own text.
  Cost: this region will likely conflict again on the next upstream sync.
- **B:** take upstream's parser and tests wholesale and drop the fork's nested presentation.
  Cost: Lavish reads lose table-cell location, text-selection range, and image attachment paths.
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