Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .agents/skills/firstmate-codexapp/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ For a Firstmate-managed task, include an explicit status instruction:

```text
Append supervisor-visible status lines to <absolute-firstmate-home>/state/<task-id>.status.
Use only these prefixes for status changes: working:, needs-decision:, blocked:, paused:, done:, failed:.
Use only these prefixes for status changes: working:, needs-decision:, blocked:, paused:, validation-ready:, done:, failed:.
Follow the task brief's status-reporting rule for declaring and resolving waits; bin/fm-brief.sh owns that rule.
Before doing substantive work, append "working: Codex Desktop thread started".
```
Expand Down
2 changes: 1 addition & 1 deletion .agents/skills/ship-landing/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Run `bin/fm-pr-check.sh <id> <PR url>` with the URL copied from that ready signa
That blocked reading is the gate working, not a stuck worker, so steer the worker on the commit the refusal names rather than waiting.
A direct-PR worker pushes that commit to its PR branch, and a local-only worker commits it on its ship branch.
A no-mistakes worker re-validates it with /no-mistakes so the pipeline stays the one publisher; it never pushes from its copy.
In no-mistakes mode the earlier `done [at=<epoch>]: {summary}` is the pipeline handoff and is not gated.
In no-mistakes mode the earlier `validation-ready [at=<epoch>]: {summary}` (or a legacy pre-validation `done:` from a worker briefed before that verb existed) is the pipeline handoff and is not gated.
Tell the captain the PR's full `https://...` URL copied from the worker's ready line, the resolved checks-green crew-state line, or the task's `pr=` metadata, a concise outcome summary, and the no-mistakes risk level when applicable.
A captain instruction to merge is explicit authority; `yolo` is the only standing routine merge authority.
For any custom `state/<id>.check.sh` you write yourself, keep it an ordinary single-link mode-`0700` file, print one line only when firstmate should wake, print nothing otherwise, finish before `FM_CHECK_TIMEOUT`, then bind its current bytes with `bin/fm-check-register.sh <id>` before the watcher may execute it.
Expand Down
6 changes: 4 additions & 2 deletions bin/fm-brief.sh
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,8 @@ case "$MODE" in
esac
RULE1=$(fm_ship_rule_one "$MODE" "$ID" "$BRANCH" "$FORGE" "$BASE_BRANCH") || exit 1
DOD=$(fm_dod_block "$MODE" "$ID" "$BRANCH" "$FORGE" "$BASE_BRANCH") || exit 1
HANDOFF_STATE=
[ "$MODE" != no-mistakes ] || HANDOFF_STATE='validation-ready, '

cat > "$BRIEF" <<EOF
You are a crewmate: an autonomous worker agent managed by firstmate. Work on your own; do not wait for a human.
Expand All @@ -704,7 +706,7 @@ $RULE1
3. Use gh-axi for GitHub operations and chrome-devtools-axi for browser operations.
4. Report status by appending one line:
\`$STATUS_APPEND\`
States: working, needs-decision, blocked, $PAUSED_VERB, done, failed.
States: working, needs-decision, blocked, $PAUSED_VERB, ${HANDOFF_STATE}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
Expand All @@ -714,7 +716,7 @@ $RULE1
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.
turn after it; continue the same stage until a defined handoff or \`done:\` gate under Definition of done.
$CREWMATE_PAUSE_INSTRUCTIONS
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),
Expand Down
15 changes: 8 additions & 7 deletions bin/fm-classify-lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ unset _fm_classify_nounset
# declaration cannot disappear behind an earlier recognized line. Continuation
# prose is not a prefix and stays off that path. Recognized verbs keep the
# classification below.
FM_CLASSIFY_CAPTAIN_RE_DEFAULT='done:|needs-decision:|blocked:|failed:|PR ready|checks green|ready in branch|merged'
FM_CLASSIFY_CAPTAIN_RE_DEFAULT='validation-ready:|done:|needs-decision:|blocked:|failed:|PR ready|checks green|ready in branch|merged'

# The declared-wait verb. A crew (or firstmate steering it) appends
# paused: <reason>
Expand Down Expand Up @@ -173,7 +173,7 @@ last_status_line() { # <status-file> [<previous-event-var>]
# 0 when <verb> is exactly one recognized status verb, with no leftover token.
_fm_status_verb_recognized() { # <verb>
case "$1" in
working|needs-decision|blocked|done|failed|note|\
working|validation-ready|needs-decision|blocked|done|failed|note|\
"${FM_CLASSIFY_PAUSED_VERB:-$FM_CLASSIFY_PAUSED_VERB_DEFAULT}"|\
"${FM_CLASSIFY_RESOLVE_VERB:-$FM_CLASSIFY_RESOLVE_VERB_DEFAULT}"|\
"${FM_CLASSIFY_CAPTAIN_HELD_VERB:-$FM_CLASSIFY_CAPTAIN_HELD_VERB_DEFAULT}")
Expand Down Expand Up @@ -275,21 +275,22 @@ _fm_classify_matches() { # <line> <pattern>
return "$matched"
}

# 0 if the given (last) status line's leading verb is a real terminal captain verb
# (done, needs-decision, blocked, failed). Free-text tokens alone never count here;
# 0 if the given (last) status line's leading verb ends a worker stage and
# requires supervisor action (validation-ready, done, needs-decision, blocked,
# failed). Free-text tokens alone never count here;
# callers that need legacy free-text matching use status_is_captain_relevant.
status_is_terminal_verb() {
local line=$1 verb
[ -n "$line" ] || return 1
verb=$(status_line_verb "$line")
case "$verb" in
done|needs-decision|blocked|failed) return 0 ;;
validation-ready|done|needs-decision|blocked|failed) return 0 ;;
*) return 1 ;;
esac
}

# 0 if the given (last) status line matches a captain-relevant verb.
# Verb-aware by default: terminal verbs always match; nonterminal progress verbs
# Verb-aware by default: supervisor-actionable verbs always match; progress verbs
# (working, resolved, captain-held) and paused never match from free-text prose;
# only lines without those leading verbs may still match free-text tokens for
# legacy bare lines such as "merged" or "PR ready".
Expand All @@ -312,7 +313,7 @@ status_is_captain_relevant() {
status_prefix_unrecognized "$line" && return 0
if [ -z "${FM_CAPTAIN_RE+x}" ]; then
case "$verb" in
done|needs-decision|blocked|failed) return 0 ;;
validation-ready|done|needs-decision|blocked|failed) return 0 ;;
esac
fi
_fm_status_unstamped "$line" unstamped
Expand Down
7 changes: 5 additions & 2 deletions bin/fm-crew-state.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# fm-crew-state.sh - deterministic read of a crew's CURRENT state.
#
# Why this exists: state/<id>.status is an append-only, best-effort EVENT LOG.
# Crews append only wake-worthy transitions (done/needs-decision/blocked/paused/failed)
# Crews append only wake-worthy transitions (validation-ready/done/needs-decision/blocked/paused/failed)
# and nothing when they silently resume, so `tail -1` of that log reports the
# last EVENT, not the current STATE. After firstmate resolves a needs-decision
# or blocked and the crew resumes (responds to the gate, the pipeline fixes, it
Expand Down Expand Up @@ -257,7 +257,7 @@ map_log_state() { # <line>
fi
case "$(status_line_verb "$1")" in
working) echo working ;;
needs-decision) echo parked ;;
validation-ready|needs-decision) echo parked ;;
blocked) echo blocked ;;
done) echo "done" ;;
failed) echo failed ;;
Expand Down Expand Up @@ -1308,6 +1308,9 @@ fi
# the verb->state mapping (including the configurable paused verb), so reusing its
# `unknown` verdict as the "not a state" test needs no second verb list here.
if [ -n "$LOG_VERB" ]; then
if fm_dod_is_validation_handoff "$KIND" "$(meta_value mode)" "$LOG_LINE"; then
emit parked status-log "ready for validation; firstmate starts /no-mistakes${SEP}$(status_line_note "$LOG_LINE")"
fi
if [ "$LOG_VERB" = "done" ]; then
emit_ship_status_done
fi
Expand Down
33 changes: 24 additions & 9 deletions bin/fm-dod-lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@
# (secondmate ledger-first publish of a child done). A ship `done:` is not
# accepted while the named head exists only in the worker's disposable copy.
# The check tests that head, not whether some branch moved. In no-mistakes
# mode the pre-validation `done: {summary}` is the pipeline handoff and is
# not gated; only the later CI-ready `done: PR <url> checks green` is, or on a
# mode `validation-ready: {summary}` is the pipeline handoff and is not gated;
# a legacy pre-validation `done: {summary}` remains a handoff for live workers.
# Only the later CI-ready `done: PR <url> checks green` is gated, or on a
# Gerrit project the later `done: PR <change url> published for review`. The
# named head is the worker copy's HEAD, except that a done naming the task's
# recorded pr= passes when the forge holds that head: a forge-reported
Expand Down Expand Up @@ -436,9 +437,9 @@ This project's review server is Gerrit: it has no pull requests and no forge CI
Pass \`--skip push,pr,ci\` on every \`no-mistakes axi run\` for this task, and skip nothing else: \`review\`, \`test\`, \`document\`, and \`lint\` are the whole point of the run.
Those three are the only steps that reach a forge, and skipping them is a supported outcome, not a degraded one.
The task is complete only when committed on your branch.
When you believe it is complete, append \`done [at=<epoch>]: {summary}\` to the status file and stop.
Firstmate will then instruct you to run /no-mistakes to validate.
That first \`done:\` is the handoff that starts the pipeline; it is not a request to publish.
When the implementation is committed, append \`validation-ready [at=<epoch>]: {summary}\` to the status file and stop.
Firstmate starts the validation run by instructing you to run /no-mistakes.
That \`validation-ready:\` line is the handoff; it is not a request to publish.

EOF
fm_nm_driving_block "$forge"
Expand Down Expand Up @@ -494,9 +495,9 @@ EOF
Delivery contract: mode=no-mistakes
Ship branch: $branch
The task is complete only when committed on your branch.
When you believe it is complete, append \`done [at=<epoch>]: {summary}\` to the status file and stop.
Firstmate will then instruct you to run /no-mistakes to validate and ship a PR.
That first \`done:\` is the handoff that starts the pipeline, which owns the push; it is not a request to push from this copy.
When the implementation is committed, append \`validation-ready [at=<epoch>]: {summary}\` to the status file and stop.
Firstmate starts the validation run by instructing you to run /no-mistakes to validate and ship a PR.
That \`validation-ready:\` line is the handoff to firstmate; the pipeline owns the push.
${nm_base}
EOF
fm_nm_driving_block "$forge"
Expand Down Expand Up @@ -546,13 +547,27 @@ fm_dod_note_reports_published_change() { # <note>
return 1
}

# 0 when a no-mistakes ship line is a validation handoff, including the
# pre-validation done: emitted by workers briefed before validation-ready existed.
fm_dod_is_validation_handoff() { # <kind> <mode> <line>
local verb note
[ "$1" = ship ] || return 1
case "$2" in no-mistakes|'') ;; *) return 1 ;; esac
verb=$(status_line_verb "$3")
[ "$verb" = validation-ready ] && return 0
[ "$verb" = "done" ] || return 1
note=$(status_line_note "$3")
! fm_dod_note_reports_ci_ready "$note" && ! fm_dod_note_reports_published_change "$note"
}

# 0 when this ship done: is one the named-head gate must accept or refuse.
# no-mistakes pre-validation done: is the pipeline handoff and is not gated.
# A validation handoff, including a legacy pre-validation done:, is not gated.
# Empty mode is treated as no-mistakes, the unregistered-project default.
fm_dod_should_gate_ship_done() { # <kind> <mode> <line>
local note
[ "$1" = ship ] || return 1
[ "$(status_line_verb "$3")" = "done" ] || return 1
fm_dod_is_validation_handoff "$@" && return 1
note=$(status_line_note "$3")
case "$2" in
direct-PR|local-only) return 0 ;;
Expand Down
15 changes: 8 additions & 7 deletions bin/fm-inactive-reconcile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# not a watcher, daemon, PR poll, or forge client of its own.
# In a secondmate home every `scan` invocation, which is every watcher poll,
# first runs the LEDGER-FIRST parent delivery: a direct child whose status
# ledger ends in a whole `done:` or `failed:` line has stated its own outcome,
# ledger ends in a whole finished `done:` or `failed:` line has stated its outcome,
# so that line is published on the parent channel at once through
# bin/fm-parent-channel-lib.sh from this unstamped payload:
# <state> [key=child-outcome-<child>-<state>-<fp8>]: child <child> <state>: <note> [pr=<url>] [mode=<mode>] [yolo=<posture>] [report=data/<child>/report.md]
Expand All @@ -19,7 +19,7 @@
# published only when bin/fm-dod-lib.sh accepts the named head, so an
# unpushed copy is not reported upstream as ready. The cadence path uses
# fm-crew-state.sh, which applies the same gate: a no-mistakes
# pre-validation `done: {summary}` still reads done (the pipeline handoff),
# pre-validation legacy `done: {summary}` remains a validation handoff,
# while a CI-ready or direct-PR/local-only done whose head lives only in the
# disposable copy reads blocked and is not a terminal inactive outcome.
# A line still being appended (no trailing newline yet)
Expand Down Expand Up @@ -369,11 +369,12 @@ notice_parent_report_failed() { # <record> <fingerprint> <payload>
# selected through the shared latest-event reader, so the ledger path owns a
# terminal record whose continuation prose trails it, and an unfinished line of
# ordinary prose withholds nothing.
child_terminal_ledger_line() { # <status>
local status=$1 snapshot last marker='__FM_LEDGER_SNAPSHOT_END__'
child_terminal_ledger_line() { # <status> <meta>
local status=$1 meta=$2 snapshot last marker='__FM_LEDGER_SNAPSHOT_END__'
[ -f "$status" ] && [ ! -L "$status" ] && [ -s "$status" ] || return 1
last=$(last_status_line "$status")
case "$(status_line_verb "$last")" in done|failed) ;; *) return 1 ;; esac
fm_dod_is_validation_handoff "$(meta_field "$meta" kind)" "$(meta_field "$meta" mode)" "$last" && return 1
snapshot=$(cat "$status"; printf '%s' "$marker") || return 1
case "$snapshot" in
*$'\n'"$marker") ;;
Expand Down Expand Up @@ -415,7 +416,7 @@ claim_inactive_report_for_ledger() { # <task> <incarnation> <state> <ledger-fing
report_child_ledger_locked() { # <id> <meta>
local id=$1 meta=$2 status last previous state note pr mode yolo data incarnation fingerprint predecessor_head outcome_key line
status="$STATE/$id.status"
last=$(child_terminal_ledger_line "$status") || return 0
last=$(child_terminal_ledger_line "$status" "$meta") || return 0
state=$(status_line_verb "$last")
pr=$(pr_for_task "$meta" "$last")
incarnation=$(meta_incarnation "$meta")
Expand Down Expand Up @@ -506,7 +507,7 @@ reconcile_direct_child_locked() { # <id> <meta> <secondmate-id-or-empty> <timeou
status_line_verb "$last" | grep -Fx captain-held >/dev/null 2>&1 && return 0
# A ledger that states its own outcome is the ledger-first path's to deliver.
if [ -n "$self" ]; then
child_terminal_ledger_line "$status" >/dev/null
child_terminal_ledger_line "$status" "$meta" >/dev/null
case "$?" in 0|2) return 0 ;; esac
fi
age=$(last_activity_age "$meta" "$status" "$turn")
Expand All @@ -516,7 +517,7 @@ reconcile_direct_child_locked() { # <id> <meta> <secondmate-id-or-empty> <timeou
[ "$state_rc" -ne 124 ] || return 3
last=$(last_status_line "$status")
if [ -n "$self" ]; then
child_terminal_ledger_line "$status" >/dev/null
child_terminal_ledger_line "$status" "$meta" >/dev/null
case "$?" in 0|2) return 0 ;; esac
fi
case "$state_line" in
Expand Down
2 changes: 1 addition & 1 deletion docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -2467,7 +2467,7 @@ FM_WATCHER_STALL_BOUND= # live-holder stall bound; default and arm/re-arm
FM_SIGNAL_GRACE=30 # seconds to coalesce nearby status and turn-end signals into one wake
FM_WATCHER_CLEANUP_LOCK_BOUND= # optional watcher EXIT marker-lock wait; default and validation: docs/watcher-continuity.md
FM_TURNEND_CHURN_ABSORB_SECS=900 # longest one endpoint's bare turn-ends may be deferred on pane-churn evidence alone; only consulted when config/turnend-churn-absorb is present
FM_CAPTAIN_RE='done:|needs-decision:|blocked:|failed:|PR ready|checks green|ready in branch|merged' # captain-relevant status regex; nonterminal progress verbs remain excluded even when their prose matches
FM_CAPTAIN_RE='validation-ready:|done:|needs-decision:|blocked:|failed:|PR ready|checks green|ready in branch|merged' # captain-relevant status regex; nonterminal progress verbs remain excluded even when their prose matches
FM_CLASSIFY_PAUSED_VERB=paused # leading declared-wait status verb; bin/fm-classify-lib.sh owns its meaning and legacy external-wait label; excluded from FM_CAPTAIN_RE and distinct from blocked
FM_STALE_ESCALATE_SECS=240 # idle seconds before a provably-working stale pane with no open keyed status decision escalates, unless that pane's own worker declared a wait that has not elapsed, or, where config/wedge-defer-parked-gate arms it, that pane's crew is parked at a validation gate awaiting the supervisor's decision on it that the crew raised under that run's key and nobody has answered yet, either of which takes the FM_PAUSE_RESURFACE_SECS recheck below instead; stale panes whose crew is not provably working surface immediately unless admitted directly to the declared-wait cadence, while a live idle declared wait still surfaces once before that cadence bounds repeats; at that same escalation moment a recovery-grade agent-state probe (docs/architecture.md owns that dead-record contract) reports a pane whose endpoint is proven `dead` or `missing` once and stops re-escalating it while it stays that way
FM_BUSY_TURN_MAX_SECS=3600 # maximum age without a completed turn or explicit native-harness progress (bin/fm-watch.sh owns marker selection), before the same wedge escalation used for a provably-working non-busy stale takes over; inspection-only, never an automatic interrupt or restart; a declared external wait, an attended verified captain-held transfer, or - where config/wedge-defer-parked-gate arms it - a validation gate of the crew's own awaiting the supervisor's still-unanswered decision takes the FM_PAUSE_RESURFACE_SECS recheck below instead
Expand Down
8 changes: 7 additions & 1 deletion tests/fm-bearings-snapshot.test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -920,7 +920,13 @@ EOF
"harness=claude" "kind=ship" "mode=no-mistakes"
record_claude_state "$mate/state" "done" idle
record_claude_state "$mate/state" failed idle
printf 'done: complete\n' > "$mate/state/done.status"
# A bare `done:` is now the no-mistakes validation handoff, not a finished
# report (issue 7251), so this terminal case needs a CI-ready done: note
# whose named head the gate can verify.
fm_git_init_commit "$mate/projects/done"
git -C "$mate/projects/done" update-ref refs/remotes/origin/main \
"$(git -C "$mate/projects/done" rev-parse HEAD)"
printf 'done: PR https://example.test/o/r/pull/9 checks green\n' > "$mate/state/done.status"
printf 'failed: stopped\n' > "$mate/state/failed.status"
rm "$mate/state/parked.meta" "$mate/state/parked.status"
refresh_local_secondmate_ledgers "$home"
Expand Down
Loading
Loading