Skip to content

feat(skills): add the /updatethecaptain repeating worker report loop - #2724

Open
EternalTime wants to merge 4 commits into
kunchenguid:mainfrom
EternalTime:fm/fm-updatethecaptain-skill
Open

EternalTime wants to merge 4 commits into
kunchenguid:mainfrom
EternalTime:fm/fm-updatethecaptain-skill

Conversation

@EternalTime

Copy link
Copy Markdown

Intent

Let the captain ask to be kept posted on the workers and get a plain-English update covering every worker straight away and then every ten minutes - what each has finished, what it is doing now, what is left, and how long it needs - with any question a worker has for the captain surfaced at the top of the message, running until no worker is left or the captain stops the updates.

What Changed

  • Added the updatethecaptain skill (.agents/skills/updatethecaptain/SKILL.md): it builds the in-flight worker list from bin/fm-bearings-snapshot.sh --all-in-flight plus bin/fm-crew-state.sh, reports every worker in plain English across four parts - finished, working on now, still to do, how long it needs - places any worker question for the captain at the top of the message, reports once immediately, repeats on each timer wake, and ends when the list is empty. The companion updatethecaptain-stop skill disarms the loop and is a no-op when nothing is armed.
  • Added bin/fm-captain-report-timer.sh with arm / status / disarm, which generates a trust-bound custom watcher check (state/captain-report.check.sh plus its trust binding and a private state/.captain-report-timer stamp) so the ten-minute repeat rides the existing authenticated check dispatch rather than a background process. Default interval 600s, accepted range 60-86400, idempotent arm and disarm, and the armed check plus its stamp and trust binding are rolled back if registration or verification fails.
  • Wired the feature into the surrounding surfaces: AGENTS.md section 9 routes /updatethecaptain and /updatethecaptain-stop to the skills and section 3 documents the new stamp artifact, the README built-in-skills table and docs/scripts.md gained the new entries, docs/documentation-audiences.json classifies both SKILL.md files, and tests/fm-captain-report-timer.test.sh adds 13 cases covering cadence, idempotence, rollback, and a real bin/fm-watch.sh dispatch drained through bin/fm-wake-drain.sh.

Risk Assessment

✅ Low: The change is purely additive, rides the existing authenticated custom-check dispatch rather than introducing a new execution path, carries a focused test suite, and every round-1 concern the user chose to fix is now resolved with correctly scoped, minimal edits.

Testing

I ran the change's own suite (tests/fm-captain-report-timer.test.sh, 13 cases green), the doc/AGENTS.md suites its non-code edits touch, and the runner's coverage guard, then drove the captain's actual experience end-to-end against the real binaries: the skill's fleet read listing three live workers, an unadorned arm landing on the ten-minute cadence, a nine-minute sweep staying quiet, two consecutive ticks each dispatched by a real bin/fm-watch.sh and durably queued by fm-wake-drain.sh (the committed suite only proves one, so this is where the repeat is demonstrated), the loop ending by itself once the rebuilt worker list is empty, and /updatethecaptain-stop disarming cleanly and staying harmless when nothing is running. I also re-probed the round-1 timing flake with 14 concurrent copies of the suite - 182/182 cases ok, no failures. No screenshot applies: the change ships no rendered UI, only a skill contract and a shell timer, and the captain-facing surface is a chat message, which I captured as the three markdown report files. Those report bodies are prose the skill instructs the agent to write rather than code output, so I authored them by following SKILL.md against the fleet state stage 1 really produced, which lets a reviewer check the four-part-per-worker format, the question pinned at the top, the closing line for a finished worker, and an overrun stated plainly before the new estimate. Everything passed and I found nothing actionable.

Evidence: Captain-visible E2E transcript of the whole report loop
==============================================================
 STAGE 1 - the captain types /updatethecaptain
 Step 2 of the skill: read every worker under way from this
 home's own durable records. This is the list the report covers.
==============================================================

$ PATH="/var/folders/ym/vnmfjh5n7dn2vdzdgy7zrbjh0000gn/T//fm-captain-e2e.PXN7GW/fleetbin:$PATH" FM_HOME='/var/folders/ym/vnmfjh5n7dn2vdzdgy7zrbjh0000gn/T//fm-captain-e2e.PXN7GW/home' FM_STATE_OVERRIDE='/var/folders/ym/vnmfjh5n7dn2vdzdgy7zrbjh0000gn/T//fm-captain-e2e.PXN7GW/home/state' '/Users/owlshome/.no-mistakes/worktrees/5e738cfca1e1/01M0H1BF9MF05ZJVMBP3VRCDEN/bin/fm-bearings-snapshot.sh' --all-in-flight --fields bodies
schema: fm-bearings.v1
home: fm-captain-e2e.PXN7GW/home
generated: "2026-08-21T02:36:37Z"
prs: "not_requested (run: /bearings include PRs)"
in_flight[3]{id,kind,state,doing}:
  checkout-flow,ship,working,harness busy (claude-hook)
  login-page,ship,working,harness busy (claude-hook)
  search-ranking,scout,working,harness busy (claude-hook)
secondmates: []
decisions_open: []
landed: []
gates: []
reports: []
recorded_prs: []
bodies: []
omitted[6]{surface,reveal}:
  task paths,"--fields paths"
  watch/steer actions,"--fields actions"
  healthy endpoint detail,"--fields endpoints"
  full scout-report inventory,"--all-reports"
  superseded queued items,"--all-queued"
  live PR discovery + checks,"--include-prs"

The skill reports IMMEDIATELY off that list, before it arms anything.
The captain-visible message it writes is in:
  /var/folders/ym/vnmfjh5n7dn2vdzdgy7zrbjh0000gn/T/no-mistakes-evidence/01M0H1BF9MF05ZJVMBP3VRCDEN/captain-report-tick-1.md

==============================================================
 STAGE 2 - arm the repeating ten-minute timer (skill step 4)
==============================================================

$ bin/fm-captain-report-timer.sh arm      # the skill arms with no --interval
armed: state/captain-report.check.sh interval=600s

$ bin/fm-captain-report-timer.sh status
armed interval=600s due-in=600s

600s = ten minutes. That is the cadence the captain asked for, and it is
the default an unadorned arm runs - the skill passes no interval at all.

==============================================================
 STAGE 3 - two consecutive ticks through a REAL watcher
 Each tick is dispatched by bin/fm-watch.sh and lands in the
 durable wake queue, which is what actually re-invokes the
 report. Nothing here is a background shell job.
==============================================================

$ # first, a watcher sweep 9 minutes in - not due yet
$ bash state/captain-report.check.sh      # what the watcher runs
(no output - the timer stays quiet before its ten minutes)

$ # ---- tick 1: ten minutes have elapsed ----
$ bin/fm-watch.sh    # the real supervision cycle, one sweep
check: /var/folders/ym/vnmfjh5n7dn2vdzdgy7zrbjh0000gn/T//fm-captain-e2e.PXN7GW/timer/state/captain-report.check.sh: captain report due

$ bin/fm-wake-drain.sh     # the durable queue the report is re-invoked from
1787279799	1	check	/var/folders/ym/vnmfjh5n7dn2vdzdgy7zrbjh0000gn/T//fm-captain-e2e.PXN7GW/timer/state/captain-report.check.sh	check: /var/folders/ym/vnmfjh5n7dn2vdzdgy7zrbjh0000gn/T//fm-captain-e2e.PXN7GW/timer/state/captain-report.check.sh: captain report due

$ bash state/captain-report.check.sh     # immediately after: silent again
(no output - one elapsed interval produced exactly one report, not a repeat)

Tick 1 is the captain's second report, ten minutes after the immediate one.
The captain-visible message is in: /var/folders/ym/vnmfjh5n7dn2vdzdgy7zrbjh0000gn/T/no-mistakes-evidence/01M0H1BF9MF05ZJVMBP3VRCDEN/captain-report-tick-2.md

$ # ---- tick 2: ten minutes have elapsed ----
$ bin/fm-watch.sh    # the real supervision cycle, one sweep
check: /var/folders/ym/vnmfjh5n7dn2vdzdgy7zrbjh0000gn/T//fm-captain-e2e.PXN7GW/timer/state/captain-report.check.sh: captain report due

$ bin/fm-wake-drain.sh     # the durable queue the report is re-invoked from
1787279800	2	check	/var/folders/ym/vnmfjh5n7dn2vdzdgy7zrbjh0000gn/T//fm-captain-e2e.PXN7GW/timer/state/captain-report.check.sh	check: /var/folders/ym/vnmfjh5n7dn2vdzdgy7zrbjh0000gn/T//fm-captain-e2e.PXN7GW/timer/state/captain-report.check.sh: captain report due

$ bash state/captain-report.check.sh     # immediately after: silent again
(no output - one elapsed interval produced exactly one report, not a repeat)

Tick 2 proves the loop repeats rather than firing once.

==============================================================
 STAGE 4 - the loop ends by itself when no worker is left
==============================================================

$ # the last worker finished, so step 2 rebuilds an empty list:

$ PATH="/var/folders/ym/vnmfjh5n7dn2vdzdgy7zrbjh0000gn/T//fm-captain-e2e.PXN7GW/fleetbin:$PATH" FM_HOME='/var/folders/ym/vnmfjh5n7dn2vdzdgy7zrbjh0000gn/T//fm-captain-e2e.PXN7GW/home' FM_STATE_OVERRIDE='/var/folders/ym/vnmfjh5n7dn2vdzdgy7zrbjh0000gn/T//fm-captain-e2e.PXN7GW/home/state' '/Users/owlshome/.no-mistakes/worktrees/5e738cfca1e1/01M0H1BF9MF05ZJVMBP3VRCDEN/bin/fm-bearings-snapshot.sh' --all-in-flight | sed -n '1,10p'
schema: fm-bearings.v1
home: fm-captain-e2e.PXN7GW/home
generated: "2026-08-21T02:36:41Z"
prs: "not_requested (run: /bearings include PRs)"
in_flight: []
secondmates: []
decisions_open: []
landed[3]{id,what,artifact,owner}:
  search-ranking,Slow search investigated,"-",(main)
  login-page,Rebuilt the login page,"-",(main)

$ bin/fm-captain-report-timer.sh disarm     # skill step 6
disarmed

$ bin/fm-captain-report-timer.sh status
not armed

Final captain-visible message: /var/folders/ym/vnmfjh5n7dn2vdzdgy7zrbjh0000gn/T/no-mistakes-evidence/01M0H1BF9MF05ZJVMBP3VRCDEN/captain-report-final.md

==============================================================
 STAGE 5 - /updatethecaptain-stop, the captain's own off switch
==============================================================

$ bin/fm-captain-report-timer.sh arm         # a loop is running
armed: state/captain-report.check.sh interval=600s

$ bin/fm-captain-report-timer.sh disarm      # captain types /updatethecaptain-stop
disarmed

$ bash state/captain-report.check.sh          # nothing left to fire
(no such file - the timer and every artifact are gone)

$ bin/fm-captain-report-timer.sh disarm      # stopping again is harmless
not armed

==============================================================
 END - immediate report, ten-minute repeat, ends on an empty
 fleet or on the captain's word.
==============================================================
Evidence: Ten-minute cadence and two consecutive watcher-dispatched ticks (excerpt)
$ bin/fm-captain-report-timer.sh arm # the skill arms with no --interval
armed: state/captain-report.check.sh interval=600s

$ bin/fm-captain-report-timer.sh status
armed interval=600s due-in=600s

$ # a watcher sweep 9 minutes in - not due yet
$ bash state/captain-report.check.sh
(no output - the timer stays quiet before its ten minutes)

$ # ---- tick 1: ten minutes have elapsed ----
$ bin/fm-watch.sh # the real supervision cycle, one sweep
check: <state>/captain-report.check.sh: captain report due

$ bin/fm-wake-drain.sh # the durable queue the report is re-invoked from
1787279799 1 check <state>/captain-report.check.sh check: <state>/captain-report.check.sh: captain report due

$ bash state/captain-report.check.sh # immediately after: silent again
(no output - one elapsed interval produced exactly one report, not a repeat)

$ # ---- tick 2: ten minutes have elapsed ----
$ bin/fm-watch.sh
check: <state>/captain-report.check.sh: captain report due

$ bin/fm-wake-drain.sh
1787279800 2 check <state>/captain-report.check.sh check: <state>/captain-report.check.sh: captain report due

$ # ---- the last worker finished ----
$ bin/fm-captain-report-timer.sh disarm # skill step 6
disarmed
$ bin/fm-captain-report-timer.sh status
not armed

$ # ---- /updatethecaptain-stop ----
$ bin/fm-captain-report-timer.sh disarm # captain stops the updates
disarmed
$ bin/fm-captain-report-timer.sh disarm # stopping again is harmless
not armed
Evidence: Immediate report - worker question at the top, four parts for all three workers
<!-- The immediate report, sent out of the /updatethecaptain invocation itself.
     Written by firstmate following .agents/skills/updatethecaptain/SKILL.md
     against the three workers stage 1 of captain-loop-e2e.txt actually lists. -->

**Question from the login-page worker:**

The password reset screen needs one line of copy telling people the reset link expires after an hour.
Do you want the plain version, "This link expires in 1 hour", or the warmer one, "For your security, this link stops working after an hour"?
Either goes straight in; nothing else is waiting on the answer.

Here is where all three workers stand.

**Login page rebuild**

- Finished: the sign-in screen and the "forgot password" screen both look and behave the way the new design says, on desktop and on a phone.
- Now: waiting on your answer above about the expiry wording.
- Left: drop the chosen line in, run the screens past the checks, and open the change for review.
- How long: about 40 minutes once you answer, and it is idle until then.

**Checkout total fix**

- Finished: tracked down why the total was a penny off - tax was being rounded twice - and written the fix.
- Now: running the test suite over the fix.
- Left: read the results, add a test that pins the penny case, and open the change for review.
- How long: roughly an hour and a half. That is a rough guess, because it depends on whether the suite comes back clean.

**Slow search investigation**

- Finished: nothing yet, it has only just started.
- Now: reading how search results are ranked today, to find where the time goes.
- Left: measure the slow path, work out the cause, and write up what it would take to fix.
- How long: a rough guess of three hours to a written answer.

I will send this again every ten minutes until all three are done, or until you tell me to stop.
Evidence: Ten-minute repeat - overrun stated plainly, finished worker's closing line, new question surfaced
<!-- Tick 1 of the timer: the ten-minute repeat, sent off the durable check wake
     shown in stage 3 of captain-loop-e2e.txt. Written per
     .agents/skills/updatethecaptain/SKILL.md. -->

**Question from the slow-search worker:**

Search can be made fast in two ways, and they trade off against each other.
Caching the top thousand queries makes almost every search instant, but a brand-new product can take up to five minutes to show up in results.
Rebuilding the ranking index instead keeps results current to the second, and takes about a day of work rather than an hour.
Which do you want it to aim for?

Where all three stand now.

**Login page rebuild**

- Finished: both sign-in screens are rebuilt, and your expiry line - "This link expires in 1 hour" - is in.
- Now: running the screens past the checks before opening the change for review.
- Left: open the change for review, then it is done.
- How long: I said 40 minutes last time and it has run past that; the checks flagged one spacing problem on a phone screen. Another 25 minutes.

**Checkout total fix**

- Finished: the penny-off total is fixed and pinned by a test, and the change is open for review and merged.
- This one is done and drops off the list after this message.

**Slow search investigation**

- Finished: measured the slow path, and the ranking step is where nearly all the time goes.
- Now: waiting on your answer above about which of the two approaches to aim for.
- Left: write up the recommended fix in full, with what it costs and what it buys.
- How long: about an hour after you answer, and it is idle until then.

Still going every ten minutes until these finish or you stop the updates.
Evidence: Closing report when no worker is left running
<!-- The closing report at stage 4 of captain-loop-e2e.txt, where step 2 rebuilds
     an empty list. Written per .agents/skills/updatethecaptain/SKILL.md step 6. -->

All three workers are finished, so this is the last of these updates.

- **Login page rebuild** - delivered: both sign-in screens rebuilt to the new design, with your "This link expires in 1 hour" wording in place. Merged.
- **Checkout total fix** - delivered: the penny-off total is fixed, with a test pinning the rounding case so it cannot come back. Merged.
- **Slow search investigation** - delivered: a written answer on why search is slow, with the two changes that would fix it and what each is worth.

Nothing is running now, so the ten-minute updates have stopped on their own.
Say the word whenever you want them again.
Evidence: E2E driver that produced the transcript
#!/usr/bin/env bash
# End-to-end drive of the /updatethecaptain report loop, from the captain's side.
# Every line below "$ " is a real command run against the real firstmate binaries
# in this checkout; everything printed under it is that command's real output.
set -u

ROOT=$1
EV=$2
WORK=$(mktemp -d "${TMPDIR:-/tmp}/fm-captain-e2e.XXXXXX")
trap 'rm -rf "$WORK"' EXIT

say() { printf '%s\n' "$*"; }
run() { printf '\n$ %s\n' "$*"; eval "$@" 2>&1; }

. "$ROOT/tests/lib.sh" >/dev/null 2>&1 || true

# ---------------------------------------------------------------- stage 1
say "=============================================================="
say " STAGE 1 - the captain types /updatethecaptain"
say " Step 2 of the skill: read every worker under way from this"
say " home's own durable records. This is the list the report covers."
say "=============================================================="

HOME_DIR="$WORK/home"
mkdir -p "$HOME_DIR/state" "$HOME_DIR/data" "$HOME_DIR/config" \
         "$HOME_DIR/projects/login-wt" "$HOME_DIR/projects/checkout-wt" \
         "$HOME_DIR/projects/search-wt"
export FM_ROOT_OVERRIDE="$WORK/fixture-root"
mkdir -p "$FM_ROOT_OVERRIDE"

cat > "$HOME_DIR/data/backlog.md" <<'EOF'
## In flight
- [ ] login-page - Rebuild the login page (repo: storefront) (kind: ship) (since 2026-08-20)
- [ ] checkout-flow - Fix the checkout total (repo: storefront) (kind: ship) (since 2026-08-20)
- [ ] search-ranking - Investigate slow search (repo: storefront) (kind: scout) (since 2026-08-20)

## Queued

## Done
EOF

write_meta() {  # <file> <kv...>
  local f=$1; shift
  : > "$f"
  for kv in "$@"; do printf '%s\n' "$kv" >> "$f"; done
  chmod 600 "$f"
}

write_meta "$HOME_DIR/state/login-page.meta" \
  "window=storefront:fm-login-page" "worktree=$HOME_DIR/projects/login-wt" \
  "project=storefront" "harness=claude" "kind=ship" "mode=no-mistakes"
printf 'working: password reset copy needs the captain to choose the wording\n' \
  > "$HOME_DIR/state/login-page.status"

write_meta "$HOME_DIR/state/checkout-flow.meta" \
  "window=storefront:fm-checkout-flow" "worktree=$HOME_DIR/projects/checkout-wt" \
  "project=storefront" "harness=claude" "kind=ship" "mode=no-mistakes"
printf 'working: rounding fix written, tests running\n' \
  > "$HOME_DIR/state/checkout-flow.status"

write_meta "$HOME_DIR/state/search-ranking.meta" \
  "window=storefront:fm-search-ranking" "worktree=$HOME_DIR/projects/search-wt" \
  "project=storefront" "harness=claude" "kind=scout" "mode=scout"
printf 'working: just dispatched\n' > "$HOME_DIR/state/search-ranking.status"

FLEETBIN="$WORK/fleetbin"
mkdir -p "$FLEETBIN"
cat > "$FLEETBIN/tmux" <<'SH'
#!/usr/bin/env bash
case "${1:-}" in
  display-message) printf '%%1\n' ;;
  capture-pane) printf 'all quiet\n> \n' ;;
  list-windows) printf 'fm-login-page\nfm-checkout-flow\nfm-search-ranking\n' ;;
esac
exit 0
SH
chmod +x "$FLEETBIN/tmux"
for id in login-page checkout-flow search-ranking; do
  gen=$(FM_STATE_OVERRIDE="$HOME_DIR/state" "$ROOT/bin/fm-busy-event.sh" arm "$HOME_DIR/state" "$id")
  FM_STATE_OVERRIDE="$HOME_DIR/state" "$ROOT/bin/fm-busy-event.sh" apply "$HOME_DIR/state" "$id" busy \
    --gen "$gen" --source claude-hook --event user-prompt-submit >/dev/null 2>&1
done
run "PATH=\"$FLEETBIN:\$PATH\" FM_HOME='$HOME_DIR' FM_STATE_OVERRIDE='$HOME_DIR/state' '$ROOT/bin/fm-bearings-snapshot.sh' --all-in-flight --fields bodies"

say ""
say "The skill reports IMMEDIATELY off that list, before it arms anything."
say "The captain-visible message it writes is in:"
say "  $EV/captain-report-tick-1.md"

# ---------------------------------------------------------------- stage 2
say ""
say "=============================================================="
say " STAGE 2 - arm the repeating ten-minute timer (skill step 4)"
say "=============================================================="

TSTATE="$WORK/timer/state"
mkdir -p "$TSTATE"
TIMER="$ROOT/bin/fm-captain-report-timer.sh"
tm() { FM_HOME="$WORK/timer" FM_STATE_OVERRIDE="$TSTATE" "$TIMER" "$@"; }

printf '\n$ bin/fm-captain-report-timer.sh arm      # the skill arms with no --interval\n'
tm arm 2>&1
printf '\n$ bin/fm-captain-report-timer.sh status\n'
tm status 2>&1
say ""
say "600s = ten minutes. That is the cadence the captain asked for, and it is"
say "the default an unadorned arm runs - the skill passes no interval at all."

# ---------------------------------------------------------------- stage 3
say ""
say "=============================================================="
say " STAGE 3 - two consecutive ticks through a REAL watcher"
say " Each tick is dispatched by bin/fm-watch.sh and lands in the"
say " durable wake queue, which is what actually re-invokes the"
say " report. Nothing here is a background shell job."
say "=============================================================="

FAKEBIN="$WORK/timer/fakebin"
mkdir -p "$FAKEBIN"
cat > "$FAKEBIN/tmux" <<'SH'
#!/usr/bin/env bash
exit 1
SH
cat > "$FAKEBIN/fm-crew-state.sh" <<'SH'
#!/usr/bin/env bash
printf 'state: unknown \xc2\xb7 source: none \xc2\xb7 e2e stub\n'
SH
chmod +x "$FAKEBIN/tmux" "$FAKEBIN/fm-crew-state.sh"

age() { printf '%s\n' "$(( $(date +%s) - $1 ))" > "$TSTATE/.captain-report-timer"; }

printf '\n$ # first, a watcher sweep 9 minutes in - not due yet\n'
age 540
printf '$ bash state/captain-report.check.sh      # what the watcher runs\n'
out=$(bash "$TSTATE/captain-report.check.sh" 2>/dev/null)
if [ -z "$out" ]; then say "(no output - the timer stays quiet before its ten minutes)"; else say "$out"; fi

tick() {  # <n>
  local n=$1
  local wout="$WORK/timer/watch.$n.out"
  local dout="$WORK/timer/drain.$n.out"
  local pid i
  printf '\n$ # ---- tick %s: ten minutes have elapsed ----\n' "$n"
  age 600
  printf '$ bin/fm-watch.sh    # the real supervision cycle, one sweep\n'
  PATH="$FAKEBIN:$PATH" FM_STATE_OVERRIDE="$TSTATE" \
    FM_CREW_STATE_BIN="$FAKEBIN/fm-crew-state.sh" \
    FM_POLL=1 FM_SIGNAL_GRACE=1 FM_CHECK_INTERVAL=1 FM_HEARTBEAT=999999 \
    "$ROOT/bin/fm-watch.sh" > "$wout" 2>&1 &
  pid=$!
  i=0
  while kill -0 "$pid" 2>/dev/null && [ "$i" -lt 200 ]; do sleep 0.1; i=$((i+1)); done
  wait "$pid" 2>/dev/null || true
  cat "$wout"
  printf '\n$ bin/fm-wake-drain.sh     # the durable queue the report is re-invoked from\n'
  FM_STATE_OVERRIDE="$TSTATE" "$ROOT/bin/fm-wake-drain.sh" > "$dout" 2>/dev/null || true
  grep -F "captain-report" "$dout" || cat "$dout"
  printf '\n$ bash state/captain-report.check.sh     # immediately after: silent again\n'
  local again
  again=$(bash "$TSTATE/captain-report.check.sh" 2>/dev/null)
  if [ -z "$again" ]; then
    say "(no output - one elapsed interval produced exactly one report, not a repeat)"
  else
    say "$again"
  fi
}

tick 1
say ""
say "Tick 1 is the captain's second report, ten minutes after the immediate one."
say "The captain-visible message is in: $EV/captain-report-tick-2.md"
tick 2
say ""
say "Tick 2 proves the loop repeats rather than firing once."

# ---------------------------------------------------------------- stage 4
say ""
say "=============================================================="
say " STAGE 4 - the loop ends by itself when no worker is left"
say "=============================================================="

printf '\n$ # the last worker finished, so step 2 rebuilds an empty list:\n'
rm -f "$HOME_DIR/state/login-page.meta" "$HOME_DIR/state/login-page.status" \
      "$HOME_DIR/state/checkout-flow.meta" "$HOME_DIR/state/checkout-flow.status" \
      "$HOME_DIR/state/search-ranking.meta" "$HOME_DIR/state/search-ranking.status"
cat > "$HOME_DIR/data/backlog.md" <<'EOF'
## In flight

## Queued

## Done
- [x] login-page - Rebuilt the login page (repo: storefront) (kind: ship) (merged 2026-08-20)
- [x] checkout-flow - Fixed the checkout total (repo: storefront) (kind: ship) (merged 2026-08-20)
- [x] search-ranking - Slow search investigated (repo: storefront) (kind: scout) (merged 2026-08-20)
EOF
run "PATH=\"$FLEETBIN:\$PATH\" FM_HOME='$HOME_DIR' FM_STATE_OVERRIDE='$HOME_DIR/state' '$ROOT/bin/fm-bearings-snapshot.sh' --all-in-flight | sed -n '1,10p'"

printf '\n$ bin/fm-captain-report-timer.sh disarm     # skill step 6\n'
tm disarm 2>&1
printf '\n$ bin/fm-captain-report-timer.sh status\n'
tm status 2>&1
say ""
say "Final captain-visible message: $EV/captain-report-final.md"

# ---------------------------------------------------------------- stage 5
say ""
say "=============================================================="
say " STAGE 5 - /updatethecaptain-stop, the captain's own off switch"
say "=============================================================="

STOPSTATE="$WORK/stop/state"
mkdir -p "$STOPSTATE"
st() { FM_HOME="$WORK/stop" FM_STATE_OVERRIDE="$STOPSTATE" "$TIMER" "$@"; }
printf '\n$ bin/fm-captain-report-timer.sh arm         # a loop is running\n'
st arm 2>&1
printf '\n$ bin/fm-captain-report-timer.sh disarm      # captain types /updatethecaptain-stop\n'
st disarm 2>&1
printf '\n$ bash state/captain-report.check.sh          # nothing left to fire\n'
if [ -e "$STOPSTATE/captain-report.check.sh" ]; then
  bash "$STOPSTATE/captain-report.check.sh" 2>/dev/null
  say "(check still present - unexpected)"
else
  say "(no such file - the timer and every artifact are gone)"
fi
printf '\n$ bin/fm-captain-report-timer.sh disarm      # stopping again is harmless\n'
st disarm 2>&1
say ""
say "=============================================================="
say " END - immediate report, ten-minute repeat, ends on an empty"
say " fleet or on the captain's word."
say "=============================================================="
Evidence: Flake re-probe: 14 concurrent runs of the timer suite
$ for i in $(seq 1 14); do bash tests/fm-captain-report-timer.test.sh > /tmp/ctr.$i.log 2>&1 & done; wait
ok lines: 182 (13 cases x 14 runs)
not ok lines: NO FAILURES
- Outcome: 🔧 1 issue found → auto-fixed ✅ across 2 runs (17m20s)

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

🔧 **Review** - 6 issues found → auto-fixed ✅
  • ⚠️ .agents/skills/updatethecaptain/SKILL.md:33 - The skill declares its no-change-tick exception only against AGENTS.md section 8 ("That is a deliberate exception to section 8's rule that no-change updates are not captain-facing progress"), while line 23 says section 9 "owns how to talk to the captain" and "Write every line of every report through that contract." Section 9 (AGENTS.md:472-473) still says "Do not surface automatic fixes, retries, routine progress, or internal supervision mechanics" and "When a routine operational update's specific event requires no action but a response must be sent, reply exactly Captain, shipshape.". A ten-minute tick where nothing changed is precisely a routine operational update requiring no action, so as written section 9 directs the exact-string reply and contradicts the required behavior "get a plain-English update covering every worker straight away and then every ten minutes". Consider extending the exception paragraph to name section 9's routine-progress prohibition and the Captain, shipshape. rule explicitly, or adding the carve-out to the two new AGENTS.md section 9 lines (AGENTS.md:478-479).
  • ⚠️ bin/fm-captain-report-timer.sh:192 - fm_custom_check_registered &#34;$STATE&#34; &#34;$ID&#34; || die &#34;the timer check did not register&#34; exits without removing the artifacts it just published, unlike the fm-check-register.sh failure branch immediately above (lines 185-191), which removes CHECK, STAMP, and TRUST. If this assertion fails (a concurrent write or a TOCTOU race between register.sh's own final verify and this one), state/captain-report.check.sh is left behind mode 0700 with a trust binding that no longer matches its bytes. bin/fm-watch.sh:938-947 then fails fm_custom_check_snapshot_prepare for it, appends it to rejected_checks, and lines 962-967 append a wake and call wake for "rejected unauthenticated state checks" - which exits the watcher and burns a firstmate turn on every check sweep (FM_CHECK_INTERVAL, default 300s) indefinitely, since nothing ever removes the orphan. Mirror the rollback: remove CHECK, STAMP, and TRUST before dying here too.
  • ⚠️ README.md:178 - The "Built-in skills" section states "Firstmate ships these user-invocable built-in skills" and its table enumerates all five existing skills carrying user-invocable: true (/afk, /ahoy, /bearings, /updatefirstmate, /stow). Both new skills also carry user-invocable: true (.agents/skills/updatethecaptain/SKILL.md:7, .agents/skills/updatethecaptain-stop/SKILL.md:7) but neither is added to the table, so the documented captain-facing command set is now incomplete for a feature the captain is expected to invoke by name. Add /updatethecaptain and /updatethecaptain-stop rows.
  • ℹ️ AGENTS.md:99 - The state/ inventory in section 3 enumerates every artifact class the runtime writes, including private dot-files such as .pr-check-quarantine/, .pr-check-migration.log, and .pr-check-migration-scan-v1. The timer's new stamp state/.captain-report-timer (bin/fm-captain-report-timer.sh:53, mode 0600, one epoch-seconds line) is a new artifact class and is not listed, so the inventory no longer describes everything a home can contain. captain-report.check.sh and captain-report.check-trust are already covered by the generic &lt;id&gt;.check.sh / &lt;id&gt;.check-trust entries.
  • ℹ️ bin/fm-captain-report-timer.sh:62 - usage() { sed -n &#39;2,20p&#39; ... } prints header lines 2-20, but the usage block ends at line 18 (status ... Exits 0 either way.). Line 19 is a bare # and line 20 is the first line of the rationale paragraph, so --help and every argument error end with the dangling fragment "The timer rides the watcher's existing authenticated custom-check dispatch". Use 2,18p, or print the whole header the way bin/fm-procevent.sh:123 does.
  • ℹ️ bin/fm-captain-report-timer.sh:53 - The fixed ID=captain-report occupies the same state/&lt;id&gt;.check.sh namespace as task ids, and fm_task_id_path_safe (bin/fm-pr-lib.sh:93-99) has no reserved-name list. A task literally named captain-report would let bin/fm-pr-check.sh overwrite the armed timer check with a PR poll, and bin/fm-teardown.sh:746 would silently delete it, ending the report loop with no notice to the captain. The probability is very low and x-watch already shares this namespace by the same convention, so this is noted rather than actionable.

🔧 Fix: roll back armed check on verify failure, fix usage range, document timer
✅ Re-checked - no issues remain.

🔧 **Test** - 1 issue found → auto-fixed ✅
  • ⚠️ tests/fm-captain-report-timer.test.sh:47 - tests/fm-captain-report-timer.test.sh shipped a timing flake: age_stamp backdated the stamp from the value arm wrote, but the generated check measures against the CURRENT time, so any delay between arm and a "not yet due" probe eats its 1-second margin and fires the timer. It failed on an ordinary local run ("not ok - the timer printed one second early") and reproduced in 1 of 14 concurrent runs of the committed version. Fixed by anchoring the helper (now set_elapsed) to the current time and giving early probes a 3-second margin; 14 concurrent runs of the fixed suite are clean.
  • bash tests/fm-captain-report-timer.test.sh - all 13 cases pass, including the real-watcher case that drives bin/fm-watch.sh and bin/fm-wake-drain.sh
  • New focused case test_default_cadence_is_ten_minutes - arm with no --interval runs at 600s, stays silent just short of ten minutes, and wakes once past it
  • Flake probe: 14 concurrent runs of the test file as committed at a4df23d (1 failure) versus 14 concurrent runs of the fixed file (0 failures, 13 ok each)
  • bash tests/fm-documentation-audiences.test.sh - covers the two new SKILL.md entries added to docs/documentation-audiences.json
  • Manual end-to-end walk of the skill procedure over a sandbox home: bin/fm-bearings-snapshot.sh --all-in-flight, bin/fm-crew-state.sh &lt;id&gt;, bin/fm-captain-report-timer.sh arm|status|disarm, a real bin/fm-watch.sh dispatching the due check, and bin/fm-wake-drain.sh showing the durable check wake
  • Verified every command the skill's procedure names exists and accepts the flags it uses (fm-session-start.sh, fm-bearings-snapshot.sh --all-in-flight, fm-crew-state.sh, fm-captain-report-timer.sh)

🔧 Fix: fix timing flake in captain-report timer test
✅ Re-checked - no issues remain.

  • bash tests/fm-captain-report-timer.test.sh - all 13 cases pass, including the case driving a real bin/fm-watch.sh and draining the durable wake queue
  • 14 concurrent copies of tests/fm-captain-report-timer.test.sh - 182/182 cases ok, confirming the round-1 timing flake fix holds under load
  • bash tests/fm-documentation-audiences.test.sh - docs/documentation-audiences.json gained both new SKILL.md entries
  • bash tests/fm-ensure-agents-md.test.sh and bash tests/fm-supervision-instructions.test.sh - the AGENTS.md surfaces the change edits
  • bash bin/fm-test-run.sh --check-coverage - the new suite is mapped into a lane (total=152)
  • Manual E2E: bash captain-loop-e2e.sh - fm-bearings-snapshot.sh --all-in-flight over a 3-worker home, fm-captain-report-timer.sh arm (interval=600s, due-in=600s), a 9-minute sweep staying silent, two consecutive real bin/fm-watch.sh ticks each queued by bin/fm-wake-drain.sh as a check wake, an emptied fleet ending the loop via disarm, and /updatethecaptain-stop on both an armed and an unarmed home
✅ **Document** - passed

✅ No issues found.

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

✅ No issues found.

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