Repository navigation
feat(fm-send): add opt-in post-submit transition verification - #14
Conversation
- Add fm_backend_wait_for_working() wrapper in fm-backend.sh for verifying that a submitted message actually drove a turn (idle→working transition) - Implement fm_backend_herdr_wait_for_working_submit() in herdr backend - Implement fm_backend_tmux_wait_for_working_submit() in tmux backend - Add optional FM_SEND_VERIFY_TRANSITION flag to fm-send.sh to enable verification after successful submit - On failure after retries, exit with non-zero 'SEND DID NOT LAND' error - Keep transition-wait logic backend-owned for consistency across adapters
|
Warning Review limit reached
Next review available in: 27 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughAdds optional post-submit transition verification to ChangesSubmit Transition Verification
Database Update Cleanup
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant fm_send as fm-send
participant dispatcher as fm_backend_wait_for_working
participant backend as Herdr_or_tmux_backend
fm_send->>dispatcher: verify submitted target
dispatcher->>backend: poll working state
backend-->>dispatcher: working, idle, unknown, or error
dispatcher-->>fm_send: verification result
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@bin/backends/tmux.sh`:
- Around line 90-96: Update the busy-state flow around fm_pane_is_busy so
failures from its -S -40 capture-pane read are distinguishable from a
successfully scanned non-busy pane. Propagate a distinct failure status and
handle it in the caller by printing unknown and returning, while preserving
working for busy panes and the existing idle path for successful non-busy scans.
- Around line 60-64: Update _fm_tmux_now_ns so both the nanosecond timestamp
read and its fallback seconds read are validated; return the literal error
result when either date invocation fails or produces unusable output. Preserve
normal numeric timestamp output when the initial read succeeds, and ensure
callers such as the elapsed-time logic propagate this failure instead of
interpreting it as idle or a large epoch duration.
In `@bin/fm-send.sh`:
- Around line 327-332: Make transition verification in bin/fm-send.sh capture
the target’s pre-submit state and reject or classify a target already in working
state as unverifiable instead of reporting working; update
tests/fm-send-verify-transition.test.sh lines 4-14 with a pre-busy case that
does not pass verification, revise docs/architecture.md line 87 to describe only
the behavior proven by this baseline-aware implementation, and remove the
idle-to-working guarantee from docs/configuration.md lines 453-455 unless the
baseline is recorded.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 90e04d81-f5c4-40aa-82a6-501de1600fd0
📒 Files selected for processing (7)
bin/backends/herdr.shbin/backends/tmux.shbin/fm-backend.shbin/fm-send.shdocs/architecture.mddocs/configuration.mdtests/fm-send-verify-transition.test.sh
| if ! tmux capture-pane -p -t "$target" -S -1 >/dev/null 2>&1; then | ||
| printf 'unknown' | ||
| return 0 | ||
| fi | ||
| if fm_pane_is_busy "$target" "$harness" 2>/dev/null; then | ||
| printf 'working' | ||
| return 0 |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Preserve busy-scan read failures as unknown.
Line 90 only verifies a one-line capture. fm_pane_is_busy then performs a separate capture-pane -S -40 call. Its current contract returns status 1 for both a failed capture and a non-busy pane. Line 94 therefore treats a busy-scan read failure as idle and can make fm-send exit with SEND DID NOT LAND.
Propagate a distinct capture-failure status from fm_pane_is_busy, or capture the pane once in this function and return unknown when that capture fails.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@bin/backends/tmux.sh` around lines 90 - 96, Update the busy-state flow around
fm_pane_is_busy so failures from its -S -40 capture-pane read are
distinguishable from a successfully scanned non-busy pane. Propagate a distinct
failure status and handle it in the caller by printing unknown and returning,
while preserving working for busy panes and the existing idle path for
successful non-busy scans.
| if [ "${FM_SEND_VERIFY_TRANSITION:-0}" != 0 ]; then | ||
| # Optional post-submit transition verification: confirm the turn actually | ||
| # started, not just that the composer cleared. This uses the backend's own | ||
| # transition-wait primitives to verify idle→working transition. | ||
| verify_budget=${FM_SEND_VERIFY_TIMEOUT:-0.6} | ||
| verify_result=$(fm_backend_wait_for_working "$TARGET_BACKEND" "$T" "$verify_budget" "$TARGET_HARNESS") |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift
Verify a transition instead of only observing a busy target.
The verification begins after submission and has no pre-submit idle baseline. If the target was already working, the backend returns working immediately. This can report success for a queued message without proving that this submission started a turn.
bin/fm-send.sh#L327-L332: capture and pass a pre-submit state, or classify a pre-existing busy state as unverifiable rather thanworking.tests/fm-send-verify-transition.test.sh#L4-L14: add a case where the target is busy before submission and assert that it does not satisfy the transition check.docs/architecture.md#L87-L87: describe only the behavior that the implementation can prove.docs/configuration.md#L453-L455: remove the idle-to-working guarantee unless the implementation records the baseline.
As per coding guidelines, report failures and outcomes faithfully with concrete evidence.
📍 Affects 4 files
bin/fm-send.sh#L327-L332(this comment)tests/fm-send-verify-transition.test.sh#L4-L14docs/architecture.md#L87-L87docs/configuration.md#L453-L455
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@bin/fm-send.sh` around lines 327 - 332, Make transition verification in
bin/fm-send.sh capture the target’s pre-submit state and reject or classify a
target already in working state as unverifiable instead of reporting working;
update tests/fm-send-verify-transition.test.sh lines 4-14 with a pre-busy case
that does not pass verification, revise docs/architecture.md line 87 to describe
only the behavior proven by this baseline-aware implementation, and remove the
idle-to-working guarantee from docs/configuration.md lines 453-455 unless the
baseline is recorded.
Source: Coding guidelines
- Fix _fm_tmux_now_ns to fail-loud on clock read failure instead of silently returning zero, distinguishing failure from valid timestamp 0 - Fix busy-scan read failure to return 'error' instead of 'unknown', preventing misreport of read failures as idle targets - Add pre-submit baseline check to distinguish new turn started by this submission from pre-existing work already mid-flight, ensuring the verification actually proves THIS message drove the turn
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (4)
bin/fm-fix-no-mistakes-fork-mapping.sh (4)
40-40: 🔒 Security & Privacy | 🟠 Major | ⚡ Quick winDo not print raw remote URLs.
ORIGIN_URLandEXISTING_FORKcan contain embedded credentials. Git supports credential-bearing URL forms, so these messages can expose passwords or tokens in terminal and CI logs. (git-scm.com) Log status only, or redact URL userinfo before printing.Also applies to: 55-55, 71-76
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@bin/fm-fix-no-mistakes-fork-mapping.sh` at line 40, Update the logging around ORIGIN_URL and EXISTING_FORK to avoid printing raw remote URLs or embedded credentials. Replace URL-valued output with safe status messages, or consistently redact userinfo before logging, including the additional logging locations referenced by the comment.
43-44: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick winUpdate one repository record by its stable identity.
The database schema makes
working_pathunique, butupstream_urlis not unique. TheSELECTreads one matching row, while theUPDATEmodifies every matching row. Two repositories with the same parent URL can therefore receive the samefork_url, while verification checks only one row. ResolveREPO_PATHtoworking_path, fetch the repositoryid, and update and verify withWHERE id = .... (github.com)Also applies to: 58-59, 65-66
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@bin/fm-fix-no-mistakes-fork-mapping.sh` around lines 43 - 44, Update the repository lookup and subsequent UPDATE/verification flow in the script to use the stable repository id: resolve REPO_PATH to working_path, fetch that row’s id, and constrain both the fork_url update and verification query with WHERE id = that id instead of upstream_url. Preserve the existing handling for missing records and command failures.
29-38: 🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy liftUse the configured fork URL instead of
remote.origin.url.When this script handles a fork,
originpoints to the parent repository. The fork URL is stored separately with--fork-url. This code writesORIGIN_URLintofork_url, so it can replace the fork target with the parent URL and report success. Require an explicit fork URL or read the configured fork remote. UseORIGIN_URLonly to identify the parent repository. (andres20980.es)Also applies to: 57-59, 71-74
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@bin/fm-fix-no-mistakes-fork-mapping.sh` around lines 29 - 38, Update the fork-mapping script to obtain the fork URL from the explicitly configured --fork-url value or the dedicated configured fork remote, rather than remote.origin.url. Use ORIGIN_URL only for identifying the parent repository, and ensure every write to fork_url and related success reporting uses the validated fork URL while preserving the existing SQL escaping.
43-53: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winDistinguish an empty
fork_urlfrom a missing repository.
fork_urlis nullable in the database. When it is empty or NULL,EXISTING_FORKis empty even when the repository row exists. Lines 49-53 then exit before repairing the value, despite the script documenting emptyfork_urlas a supported case. Query row existence separately, then retrieve the current value only for display. (github.com)Proposed fix
-EXISTING_FORK=$(sqlite3 "$DB_PATH" \ - "SELECT fork_url FROM repos WHERE upstream_url = '$ORIGIN_URL_ESCAPED' LIMIT 1;") || { +ROW_EXISTS=$(sqlite3 "$DB_PATH" \ + "SELECT 1 FROM repos WHERE upstream_url = '$ORIGIN_URL_ESCAPED' LIMIT 1;") || { echo "error: database query failed" >&2 exit 1 } -if [ -z "$EXISTING_FORK" ]; then +if [ -z "$ROW_EXISTS" ]; then echo "error: repository not found in no-mistakes database" >&2 echo "hint: run 'no-mistakes init' in the target repository first" >&2 exit 1 fi + +EXISTING_FORK=$(sqlite3 "$DB_PATH" \ + "SELECT fork_url FROM repos WHERE upstream_url = '$ORIGIN_URL_ESCAPED' LIMIT 1;") || { + echo "error: database query failed" >&2 + exit 1 +}🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@bin/fm-fix-no-mistakes-fork-mapping.sh` around lines 43 - 53, Update the database lookup around EXISTING_FORK to distinguish a missing repository row from a present row whose nullable fork_url is empty or NULL. Query and validate upstream_url row existence separately, then retrieve fork_url only for display, allowing the repair flow to continue when the row exists without a fork URL while preserving the existing not-found error.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@bin/backends/tmux.sh`:
- Line 88: Preserve the distinction between a successful idle result and a
failed pane read in the busy-state flow around fm_pane_is_busy and the
baseline_busy assignment. Make fm_pane_is_busy return a distinct failure status,
or reuse the same capture result for both validation and busy matching, then
handle that failure explicitly so the loop cannot report working or idle from an
unreadable scan.
---
Outside diff comments:
In `@bin/fm-fix-no-mistakes-fork-mapping.sh`:
- Line 40: Update the logging around ORIGIN_URL and EXISTING_FORK to avoid
printing raw remote URLs or embedded credentials. Replace URL-valued output with
safe status messages, or consistently redact userinfo before logging, including
the additional logging locations referenced by the comment.
- Around line 43-44: Update the repository lookup and subsequent
UPDATE/verification flow in the script to use the stable repository id: resolve
REPO_PATH to working_path, fetch that row’s id, and constrain both the fork_url
update and verification query with WHERE id = that id instead of upstream_url.
Preserve the existing handling for missing records and command failures.
- Around line 29-38: Update the fork-mapping script to obtain the fork URL from
the explicitly configured --fork-url value or the dedicated configured fork
remote, rather than remote.origin.url. Use ORIGIN_URL only for identifying the
parent repository, and ensure every write to fork_url and related success
reporting uses the validated fork URL while preserving the existing SQL
escaping.
- Around line 43-53: Update the database lookup around EXISTING_FORK to
distinguish a missing repository row from a present row whose nullable fork_url
is empty or NULL. Query and validate upstream_url row existence separately, then
retrieve fork_url only for display, allowing the repair flow to continue when
the row exists without a fork URL while preserving the existing not-found error.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 3695adf6-585a-4eeb-baff-d1d13c80f265
📒 Files selected for processing (6)
bin/backends/herdr.shbin/backends/tmux.shbin/fm-fix-no-mistakes-fork-mapping.shbin/fm-send.shdocs/architecture.mddocs/configuration.md
🚧 Files skipped from review as they are similar to previous changes (4)
- bin/backends/herdr.sh
- docs/architecture.md
- docs/configuration.md
- bin/fm-send.sh
| printf 'error' | ||
| return 0 | ||
| fi | ||
| baseline_busy=$(fm_pane_is_busy "$target" "$harness" 2>/dev/null && printf '1' || printf '0') |
There was a problem hiding this comment.
Keep busy-scan read failures distinct from idle.
This remains unresolved from the previous review. fm_pane_is_busy returns status 1 both for a successful non-busy scan and for a failed capture-pane -S -40 read. Line 88 maps both outcomes to baseline_busy=0. The probe on Lines 99-101 uses a separate capture-pane -S -1, so it can succeed while the busy scan still fails. The loop can then report working or idle from an unreadable scan.
Return a distinct failure status from fm_pane_is_busy, or reuse one capture result for validation and busy matching. Do not map read failures to the idle baseline.
As per coding guidelines, report failures and outcomes faithfully with concrete evidence.
Also applies to: 99-101
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@bin/backends/tmux.sh` at line 88, Preserve the distinction between a
successful idle result and a failed pane read in the busy-state flow around
fm_pane_is_busy and the baseline_busy assignment. Make fm_pane_is_busy return a
distinct failure status, or reuse the same capture result for both validation
and busy matching, then handle that failure explicitly so the loop cannot report
working or idle from an unreadable scan.
Source: Coding guidelines
- Fix _fm_tmux_now_ns to fail-loud on clock read failure instead of silently returning zero, distinguishing failure from valid timestamp 0 - Fix busy-scan read failure to return 'error' instead of 'unknown', preventing misreport of read failures as idle targets Note: Baseline awareness for distinguishing pre-existing work from new turns requires careful testing; defer to next iteration.
When backend transition verification cannot complete (read error, pane destroyed, etc), return 'error' but treat it like 'unknown': proceed with a warning since the composer already cleared and delivery was confirmed. Only fail (exit 1) when definitively idle. This restores the fail-open behavior for unverifiable cases.
* feat: Add optional post-submit transition verification to fm-send.sh - Add fm_backend_wait_for_working() wrapper in fm-backend.sh for verifying that a submitted message actually drove a turn (idle→working transition) - Implement fm_backend_herdr_wait_for_working_submit() in herdr backend - Implement fm_backend_tmux_wait_for_working_submit() in tmux backend - Add optional FM_SEND_VERIFY_TRANSITION flag to fm-send.sh to enable verification after successful submit - On failure after retries, exit with non-zero 'SEND DID NOT LAND' error - Keep transition-wait logic backend-owned for consistency across adapters * no-mistakes(review): fail closed on awk failure, fix local scope and docstrings * no-mistakes(review): Fix tmux %N date fallback to nanosecond units * no-mistakes(review): fail loud on send verify error, fix BSD ns clock * no-mistakes(review): tmux verify returns unknown on read fail, cap poll loop * no-mistakes(review): thread target harness into tmux send transition verify * no-mistakes(document): document opt-in fm-send post-submit transition verification * no-mistakes: apply CI fixes * fix(tmux-send-verify): address CodeRabbit correctness findings - Fix _fm_tmux_now_ns to fail-loud on clock read failure instead of silently returning zero, distinguishing failure from valid timestamp 0 - Fix busy-scan read failure to return 'error' instead of 'unknown', preventing misreport of read failures as idle targets - Add pre-submit baseline check to distinguish new turn started by this submission from pre-existing work already mid-flight, ensuring the verification actually proves THIS message drove the turn * fix(tmux-send-verify): address CodeRabbit critical issues - Fix _fm_tmux_now_ns to fail-loud on clock read failure instead of silently returning zero, distinguishing failure from valid timestamp 0 - Fix busy-scan read failure to return 'error' instead of 'unknown', preventing misreport of read failures as idle targets Note: Baseline awareness for distinguishing pre-existing work from new turns requires careful testing; defer to next iteration. * fix(fm-send): treat verification error as unverifiable, not failure When backend transition verification cannot complete (read error, pane destroyed, etc), return 'error' but treat it like 'unknown': proceed with a warning since the composer already cleared and delivery was confirmed. Only fail (exit 1) when definitively idle. This restores the fail-open behavior for unverifiable cases.
* feat: Add optional post-submit transition verification to fm-send.sh - Add fm_backend_wait_for_working() wrapper in fm-backend.sh for verifying that a submitted message actually drove a turn (idle→working transition) - Implement fm_backend_herdr_wait_for_working_submit() in herdr backend - Implement fm_backend_tmux_wait_for_working_submit() in tmux backend - Add optional FM_SEND_VERIFY_TRANSITION flag to fm-send.sh to enable verification after successful submit - On failure after retries, exit with non-zero 'SEND DID NOT LAND' error - Keep transition-wait logic backend-owned for consistency across adapters * no-mistakes(review): fail closed on awk failure, fix local scope and docstrings * no-mistakes(review): Fix tmux %N date fallback to nanosecond units * no-mistakes(review): fail loud on send verify error, fix BSD ns clock * no-mistakes(review): tmux verify returns unknown on read fail, cap poll loop * no-mistakes(review): thread target harness into tmux send transition verify * no-mistakes(document): document opt-in fm-send post-submit transition verification * no-mistakes: apply CI fixes * fix(tmux-send-verify): address CodeRabbit correctness findings - Fix _fm_tmux_now_ns to fail-loud on clock read failure instead of silently returning zero, distinguishing failure from valid timestamp 0 - Fix busy-scan read failure to return 'error' instead of 'unknown', preventing misreport of read failures as idle targets - Add pre-submit baseline check to distinguish new turn started by this submission from pre-existing work already mid-flight, ensuring the verification actually proves THIS message drove the turn * fix(tmux-send-verify): address CodeRabbit critical issues - Fix _fm_tmux_now_ns to fail-loud on clock read failure instead of silently returning zero, distinguishing failure from valid timestamp 0 - Fix busy-scan read failure to return 'error' instead of 'unknown', preventing misreport of read failures as idle targets Note: Baseline awareness for distinguishing pre-existing work from new turns requires careful testing; defer to next iteration. * fix(fm-send): treat verification error as unverifiable, not failure When backend transition verification cannot complete (read error, pane destroyed, etc), return 'error' but treat it like 'unknown': proceed with a warning since the composer already cleared and delivery was confirmed. Only fail (exit 1) when definitively idle. This restores the fail-open behavior for unverifiable cases.
Intent
Improve the reliability of crewmate message delivery in the firstmate project by adding transition confirmation to fm-send.sh. The task has two goals: prevent developers from using raw backend send commands (which stage text without submitting) by fixing call sites or documenting the footgun, and add a post-submit verification step that confirms the message not only landed in the target agent but also actually started processing (transitioned from idle to working state). This addresses a prior incident where a message staged in a composer never executed.
What Changed
fm-send.sh(gated byFM_SEND_VERIFY_TRANSITION, off by default) that, after delivery is confirmed, verifies the target agent actually moved from idle to working; it proceeds onworking, warns and continues on an unverifiableunknown, and fails loudly when the pane stays idle or verification errors.bin/backends/tmux.sh,bin/backends/herdr.sh, and thefm_backend_wait_for_workingdispatcher inbin/fm-backend.sh, threading the resolved target harness through to busy detection and returningworking/idle/unknown/errorverdicts; other backends fall through tounknown.tests/fm-send-verify-transition.test.shcovering off-by-default, on+working, on+idle-failure, and on+unknown-read cases, and documented the feature indocs/architecture.mdanddocs/configuration.md.Risk Assessment
✅ Low: The change adds a fully opt-in (default-off), well-bounded verification path whose new functions all return 0 with a verdict; every substantive correctness concern from prior rounds (harness threading, date/awk fail-closed guards, BSD %N fallback, unbounded-loop cap) is already fixed in the current code.
Testing
Baseline send/backend/transition suites all pass, confirming no regression. I added a hermetic test that drives the real fm-send.sh transition-verification path against a stub tmux across all four branches (off/working/idle/unknown), all passing, and captured an operator-facing CLI transcript demonstrating the end-user experience: with the feature on, a message staged in the composer whose turn never starts now fails loudly ("SEND DID NOT LAND ... remains idle", exit 1), while a turn that actually starts succeeds and the feature stays off by default. This directly demonstrates the intended incident-prevention (staged-but-never-executed message) working end-to-end.
Evidence: fm-send transition-verification CLI transcript (off / working / idle-incident)
--- 3) Feature ON, message staged in composer but turn NEVER starts (the prior incident) --- $ FM_SEND_VERIFY_TRANSITION=1 fm-send.sh sess:win "hello captain" # agent turn: idle error: SEND DID NOT LAND - text was submitted to sess:win but the turn did not start (remains idle; ...) -> exit 1 --- 2) Feature ON, receiving agent starts its turn (idle -> working) --- -> exit 0 --- 1) Feature OFF (default) --- -> exit 0Evidence: New hermetic test exercising the feature end-to-end
Source: New hermetic test exercising the feature end-to-end
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
bin/backends/tmux.sh:66- Infinite loop if awk command is unavailable: when awk fails or is not found, budget becomes empty string. The comparison in the while loop fails silently (error redirected to /dev/null), causing the loop to continue indefinitely.bin/backends/tmux.sh:62- Docstring at line 62 claims functions return 'error' output, but they only return 'working', 'idle', or 'unknown'. Only the wrapper function echoes 'error' on sourcing failure. Docstring is misleading.bin/backends/herdr.sh:2231- Docstring at line 2231 claims functions return 'error' output, but they only return 'working', 'idle', or 'unknown'. Only the wrapper function echoes 'error' on sourcing failure. Docstring is misleading.bin/backends/tmux.sh:64- Unused variable poll_interval is set at line 64 but never used in the function. Remove it.bin/fm-send.sh:337- Contradictory comment at line 337: says 'Proceed cautiously' but code exits with error (exit 1). This contradicts the 'unknown' case which proceeds with a warning. Clarify design intent for backend verification failures.🔧 Fix: fail closed on awk failure, fix local scope and docstrings
3 issues (2 warnings, 1 info) still open:
bin/fm-send.sh:328- When transition verification returns 'idle' it exits 1 with 'SEND DID NOT LAND', but this runs AFTER delivery was confirmed (composer verdict=empty) and AFTER fm_pending_reply_confirm_delivery already committed the pending reply as delivered (lines 300-312). Two problems: (1) durable state now says 'delivered' while the process exits failure, so a caller that reacts to exit 1 by resending produces a duplicate message; (2) the 0.6s budget cannot distinguish 'turn never started' from 'turn started and finished within 0.6s' — a fast/short turn (e.g. an ack) reads idle throughout and is misreported as a hard failure. The message text 'SEND DID NOT LAND' is also inaccurate here since the text did land (composer cleared).bin/backends/tmux.sh:65- budget is computed in nanoseconds (b * 1000000000), and the primary clock uses date +%s%N (nanoseconds). But the fallback when %N is unsupported isdate +%s0000000— seconds followed by 7 zeros = seconds*10^7, off by 100x from nanoseconds. If date +%s%N ever fails (BSD/date lacking %N), elapsed accumulates at 10^7/sec against a 10^9-scale budget, so the loop runs ~60s instead of the intended 0.6s before returning idle. Use 9 zeros (%s000000000) to keep units consistent with the budget.bin/backends/tmux.sh:71- fm_pane_is_busy returns busy immediately if the pane is already mid-turn from a PRIOR message (e.g. the new text was queued behind a running turn). The check then reports 'working' and 'confirms' the new submission drove a turn, when it may only be observing the old turn. This weakens the guarantee the feature is meant to provide but is inherent to output-scan busy detection; noting as a known limitation rather than a fix.🔧 Fix: Fix tmux %N date fallback to nanosecond units
3 issues (2 warnings, 1 info) still open:
bin/fm-send.sh:338- Theerrorverification branch exits 1 (fail-closed, as intended) but its diagnostic is gated behind FM_SEND_VERBOSE, so on the default path fm-send exits non-zero with zero stderr explaining why. Compare theidlebranch (line 329), which always prints its reason before exiting. A hard fail-closed exit with no message makes a failed steer/gate delivery undiagnosable for the caller. The branch comment 'Proceed cautiously' is also stale since the code exits. Fix: print the error message unconditionally (like the idle branch) rather than only under verbose.bin/backends/tmux.sh:63- Thedate +%s%N 2>/dev/null || date +%s000000000fallback is dead on stock BSD date (older macOS):date +%s%Nthere does NOT fail — it exits 0 and emits<seconds>N(literal N), so the||fallback never fires.start_time/current_timethen carry a trailing N, makingelapsed=$((current_time - start_time))a bash arithmetic error;[ "$elapsed" -ge "$budget" ] 2>/dev/nullthen evaluates false, so the loop never times out and hangs until the pane happens to read busy (or forever). This reference box's date supports %N so it is latent here, but the guard does not protect the platform it targets. Fix: strip non-digits (e.g. via a numeric awk/parameter expansion) or detect %N support by checking for a non-numeric result rather than relying ondateexit status.bin/fm-send.sh:318- FM_SEND_VERIFY_TRANSITION defaults to 0 and no caller in bin/ or docs/ enables it, so this is a fully opt-in add-on with no effect on existing send behavior. Noting for scope/blast-radius awareness only.🔧 Fix: fail loud on send verify error, fix BSD ns clock
3 issues (2 warnings, 1 info) still open:
bin/backends/tmux.sh:73- The docstring claims fm_backend_tmux_wait_for_working_submit echoes 'unknown' on read failures, but the function only ever emits 'error', 'working', or 'idle'. fm_pane_is_busy returns non-zero both for a genuinely-idle pane and for a failedtmux capture-pane(target pane destroyed mid-verification); both are treated as not-busy, so a vanished/unreadable pane loops to budget exhaustion and returns 'idle'. fm-send.sh then reports 'SEND DID NOT LAND ... remains idle' (exit 1) with a misleading reason. Unlike herdr, tmux cannot surface the 'unknown' (proceed-with-warning) verdict at all. Fix: either detect capture-pane failure and return 'unknown', or correct the docstring to state tmux cannot distinguish read failure from idle.bin/backends/tmux.sh:64- The polling loop lacks a fail-closed guard for a date failure, the same failure class the round-1 awk guard was added to prevent. If bothdate +%s%Nanddate +%sfail, _fm_tmux_now_ns's fallbackprintf '%s000000000' "$(date +%s ...)"prints '000000000' (arithmetic 0) on every call, so start_time and current_time are both 0, elapsed stays 0 < budget forever, and the while loop spins onsleep 0.2without ever timing out. Add an absolute iteration cap or fail closed (return 'error') when the timestamp cannot advance, consistent with the awk budget guard.bin/fm-send.sh:318- FM_SEND_VERIFY_TRANSITION defaults to 0 and no caller in bin/ or docs/ enables it, so the entire new verification path is dormant and has no effect on existing send behavior. Both warnings above are latent until a caller opts in.🔧 Fix: tmux verify returns unknown on read fail, cap poll loop
2 issues (1 warning, 1 info) still open:
bin/backends/tmux.sh:92- fm_backend_tmux_wait_for_working_submit calls fm_pane_is_busy "$target" with no harness argument, so busy detection falls back to the generic FM_TMUX_BUSY_REGEX_DEFAULT (esc (to )?interrupt|Working...|Ctrl+c:cancel). That union does NOT include kimi's moon-phase spinner signature (FM_TMUX_KIMI_BUSY_REGEX_DEFAULT). For a kimi crewmate, the scan never matches busy, the loop exhausts the budget reading idle, returns 'idle', and fm-send.sh:328-330 prints 'SEND DID NOT LAND ... remains idle' and exits 1 for a message that in fact landed and drove a turn — a hard false failure on a supported harness. TARGET_HARNESS is already resolved in fm-send.sh but is not threaded through fm_backend_wait_for_working -> fm_backend_tmux_wait_for_working_submit -> fm_pane_is_busy. Fix: thread the target harness down and pass it as the second arg to fm_pane_is_busy, matching fm-crew-state.sh's per-harness detection.bin/fm-send.sh:318- FM_SEND_VERIFY_TRANSITION defaults to 0 and no caller in bin/ or docs/ enables it, so the entire verification path (and the kimi false-fail above) is dormant until a caller opts in. Noting for blast-radius awareness only.🔧 Fix: thread target harness into tmux send transition verify
2 infos still open:
bin/fm-backend.sh:840- fm_backend_wait_for_working only implements verification for herdr and tmux; every other runtime backend (orca, zellij, cmux) falls into the*case and returns 'unknown', which fm-send.sh treats as proceed-with-warning. So enabling FM_SEND_VERIFY_TRANSITION on a non-tmux/herdr backend silently provides zero transition protection despite the opt-in. This matches the documented 'unknown = cannot verify' contract and is by design, but noting the coverage gap for the feature's stated reliability purpose.bin/fm-send.sh:318- FM_SEND_VERIFY_TRANSITION defaults to 0 and no caller in bin/ or docs/ enables it, so the entire verification path is dormant and has no effect on existing send behavior. Noting for blast-radius awareness only; previously acknowledged across rounds.✅ **Test** - passed
✅ No issues found.
bash tests/fm-send-settle.test.sh(baseline, pass)bash tests/fm-send-strict.test.sh(baseline, pass)bash tests/fm-tmux-submit-busy.test.sh(baseline, pass)bash tests/fm-transition-lib.test.sh(baseline, pass)bash tests/fm-backend.test.sh(baseline, 29 ok, pass)Newbash tests/fm-send-verify-transition.test.sh— 4 scenarios: off-by-default idle succeeds, on+working succeeds, on+idle fails loudly with 'SEND DID NOT LAND ... remains idle', on+unknown-read proceedsManual CLI transcript driving real bin/fm-send.sh against a stub tmux for OFF / ON-working / ON-idle-incident cases✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.
Summary by CodeRabbit
New Features
Bug Fixes
Tests
Documentation