Skip to content

fix(bin): report the push's own error when remote inheritance fails - #5658

Merged
kunchenguid merged 1 commit into
kunchenguid:mainfrom
karotkriss:fm/fm-up-5295-inherit-failure-item
Sep 25, 2026
Merged

kunchenguid merged 1 commit into
kunchenguid:mainfrom
karotkriss:fm/fm-up-5295-inherit-failure-item

Conversation

@karotkriss

Copy link
Copy Markdown
Contributor

Intent

Fixes #5295

When pushing inherited material to a remote second mate fails, session start reports SECONDMATE_SYNC: ... remote inheritance failed on <host>: <reason> with the first line of the push's combined output as the reason.
The push prints one unchanged: line per item before it fails, so the reported reason names the first unchanged item (for example config/crew-dispatch.json) instead of the error that stopped the push, and the reader is sent to the wrong file.
Separately, the shared captain preferences header check fails with a generic message that does not say which required phrase is missing, which leaves a home whose header states the requirements in another language no way to tell what the check wants.
Make the session-start line report the push's own error line when there is one (falling back to today's first line when there is not), and make the header check's failure name the first required phrase it did not find, on both the local and the remote inheritance paths.
Do not change which headers pass the check.

What Changed

  • Added remote_inherit_failure_reason in fm-ff-lib.sh and used it in fm-bootstrap.sh's secondmate_sync, so the SECONDMATE_SYNC: ... remote inheritance failed line reports the push's own error: line, falling back to the first output line only when there is none, instead of naming the first unchanged: item.
  • Made shared_captain_header_valid in fm-config-inherit-lib.sh print the first required phrase it did not find and return 1, and had both propagate_shared_captain_preferences (local path) and fm-remote-inherit-push.sh (remote path) append missing "<phrase>" to their header-rejection message; the remote script now reuses the library function instead of its own copy. The accepted header set is unchanged.
  • Extended fm-bootstrap-network-parallel.test.sh and fm-shared-captain-inheritance.test.sh to cover the new failure-reason and missing-phrase reporting.

Risk Assessment

✅ Low: Small, well-bounded shell fix that surfaces the push's own error line and names the missing header phrase without altering the accept set, with behavioral tests and a net reduction via deduplication.

Testing

Both affected test suites pass, including the two new regression tests. I additionally drove the two changed shell functions directly: the reason helper now returns the push's error: line (not the leading unchanged: config/crew-dispatch.json) and falls back to the first line for an interrupted push with no error, and the header check returns empty/rc0 for a valid header while naming the first missing phrase (must not be edited there, or main-authoritative for a header in another language) with rc1. The full bootstrap E2E test confirms the SECONDMATE_SYNC line reports the shared-captain header problem rather than an earlier unchanged item. These are backend CLI/shell behaviors with no rendered UI surface, so evidence is CLI transcripts rather than screenshots. Worktree left clean; evidence written to the evidence directory.

  • Live validation: ✅ go - 5 of 5 scenarios driven live against the product
Scenario Result Live Evidence
Remote inheritance push fails after printing unchanged items; session-start names the real error, not the first unchanged item ✅ pass live bash tests/fm-bootstrap-network-parallel.test.sh new test drives fm-bootstrap.sh end-to-end; SECONDMATE_SYNC line names the shared-captain header problem and asserts no unchanged: in the reason (i…
Reason falls back to the first line when the push emitted no error line (interrupted/unknown-shape failure) ✅ pass live remote_inherit_failure_reason on input with no error: line returns the first line unchanged (failure-reason-old-vs-new.log)
Header check names the first required phrase it did not find (English and non-English headers) ✅ pass live bash tests/fm-shared-captain-inheritance.test.sh new test; plus live shared_captain_header_valid returning must not be edited there and main-authoritative (header-check-names-missing-phrase.log)
A valid shared-captain header still passes (accept set unchanged) ✅ pass live Valid fixture returns rc=0 with empty missing output in both the test suite and the live invocation (header-check-names-missing-phrase.log)
Remote push path (fm-remote-inherit-push.sh) appends the missing phrase to its die reason using the shared check ✅ pass live Bootstrap E2E test exercises fm-remote-inherit-push.sh; the reported reason shared captain preferences have no valid primary-authoritative header originates from that script's die path (inherit-fail…
Evidence: Failure reason: old first_line vs new error-line selection + fallback

Source: Failure reason: old first_line vs new error-line selection + fallback

OLD (first_line): unchanged: config/crew-dispatch.json NEW (remote_inherit_failure_reason): error: shared captain preferences have no valid primary-authoritative header: missing "must not be edited there" No-error fallback: connection reset by host-sm

--- push combined output ---
unchanged: config/crew-dispatch.json
unchanged: config/crew-harness
error: shared captain preferences have no valid primary-authoritative header: missing "must not be edited there"
unchanged: data/other.md
--- OLD behavior (first_line): ---
unchanged: config/crew-dispatch.json
--- NEW behavior (remote_inherit_failure_reason): ---
error: shared captain preferences have no valid primary-authoritative header: missing "must not be edited there"
--- fallback when no error line (interrupted push) ---
connection reset by host-sm
Evidence: Header check names the first missing phrase; valid header still passes

Source: Header check names the first missing phrase; valid header still passes

valid header: rc=0 missing='' missing a phrase: rc=1 missing='must not be edited there' foreign-language header: rc=1 missing='main-authoritative'

--- valid header ---
rc=0 missing=''
--- header missing a phrase ---
rc=1 missing='must not be edited there'
--- foreign-language header ---
rc=1 missing='main-authoritative'
Evidence: Bootstrap E2E: SECONDMATE_SYNC failure line output

Source: Bootstrap E2E: SECONDMATE_SYNC failure line output

=== parallel bootstrap network output ===
SECONDMATE_LIVENESS: secondmate bravo: skipped: remote host unavailable or endpoint state unknown; route preserved on host-bravo
SECONDMATE_SYNC: secondmate alpha: skipped: remote tracked-file sync failed on host-alpha: synthetic tracked-file sync refusal for host-alpha
SECONDMATE_SYNC: secondmate bravo: skipped: remote tracked-file sync failed on host-bravo: 
SECONDMATE_SYNC: secondmate bravo: skipped: remote inheritance failed on host-bravo: 
SECONDMATE_SYNC: secondmate charlie: skipped: remote tracked-file sync failed on host-charlie: remote secondmate checkout is dirty; sync skipped
=== parallel remote operation timeline ===
START host-alpha fm-remote-doctor.sh 
START host-charlie fm-remote-doctor.sh 
START host-bravo fm-remote-doctor.sh 
START fleet-fetch git fetch
END fleet-fetch git fetch
END host-alpha fm-remote-doctor.sh 
END host-bravo fm-remote-doctor.sh 
END host-charlie fm-remote-doctor.sh 
START host-alpha fm-remote-secondmate-control.sh state
START host-charlie fm-remote-secondmate-control.sh state
END host-alpha fm-remote-secondmate-control.sh state
END host-charlie fm-remote-secondmate-control.sh state
QUICK host-alpha fm-remote-secondmate-control.sh route
QUICK host-charlie fm-remote-secondmate-control.sh route
START host-alpha fm-remote-secondmate-control.sh sync
START host-bravo fm-remote-secondmate-control.sh sync
START host-charlie fm-remote-secondmate-control.sh sync
END host-alpha fm-remote-secondmate-control.sh sync
END host-bravo fm-remote-secondmate-control.sh sync
END host-charlie fm-remote-secondmate-control.sh sync
QUICK host-alpha fm-remote-inherit.sh absent
QUICK host-bravo fm-remote-inherit.sh absent
QUICK host-charlie fm-remote-inherit.sh absent
QUICK host-alpha fm-remote-inherit.sh absent
QUICK host-charlie fm-remote-inherit.sh absent
QUICK host-alpha fm-remote-inherit.sh absent
QUICK host-charlie fm-remote-inherit.sh absent
QUICK host-alpha fm-remote-inherit.sh absent
QUICK host-charlie fm-remote-inherit.sh absent
QUICK host-alpha fm-remote-inherit.sh absent
QUICK host-charlie fm-remote-inherit.sh absent
QUICK host-alpha fm-remote-inherit.sh absent
QUICK host-charlie fm-remote-inherit.sh absent
QUICK host-alpha fm-remote-inherit.sh absent
QUICK host-charlie fm-remote-inherit.sh absent
QUICK host-alpha fm-remote-inherit.sh absent
QUICK host-charlie fm-remote-inherit.sh absent
QUICK host-alpha fm-remote-inherit.sh absent
QUICK host-charlie fm-remote-inherit.sh absent
QUICK host-alpha fm-remote-inherit.sh absent
QUICK host-charlie fm-remote-inherit.sh absent
=== fallback bootstrap network output ===
SECONDMATE_LIVENESS: secondmate bravo: skipped: remote host unavailable or endpoint state unknown; route preserved on host-bravo
SECONDMATE_SYNC: secondmate alpha: skipped: remote tracked-file sync failed on host-alpha: synthetic tracked-file sync refusal for host-alpha
SECONDMATE_SYNC: secondmate bravo: skipped: remote tracked-file sync failed on host-bravo: 
SECONDMATE_SYNC: secondmate bravo: skipped: remote inheritance failed on host-bravo: 
SECONDMATE_SYNC: secondmate charlie: skipped: remote tracked-file sync failed on host-charlie: remote secondmate checkout is dirty; sync skipped
=== fallback remote operation timeline ===
START host-alpha fm-remote-doctor.sh 
START fleet-fetch git fetch
END fleet-fetch git fetch
END host-alpha fm-remote-doctor.sh 
START host-alpha fm-remote-secondmate-control.sh state
END host-alpha fm-remote-secondmate-control.sh state
QUICK host-alpha fm-remote-secondmate-control.sh route
START host-bravo fm-remote-doctor.sh 
END host-bravo fm-remote-doctor.sh 
START host-charlie fm-remote-doctor.sh 
END host-charlie fm-remote-doctor.sh 
START host-charlie fm-remote-secondmate-control.sh state
END host-charlie fm-remote-secondmate-control.sh state
QUICK host-charlie fm-remote-secondmate-control.sh route
START host-alpha fm-remote-secondmate-control.sh sync
END host-alpha fm-remote-secondmate-control.sh sync
QUICK host-alpha fm-remote-inherit.sh absent
QUICK host-alpha fm-remote-inherit.sh absent
QUICK host-alpha fm-remote-inherit.sh absent
QUICK host-alpha fm-remote-inherit.sh absent
QUICK host-alpha fm-remote-inherit.sh absent
QUICK host-alpha fm-remote-inherit.sh absent
QUICK host-alpha fm-remote-inherit.sh absent
QUICK host-alpha fm-remote-inherit.sh absent
QUICK host-alpha fm-remote-inherit.sh absent
QUICK host-alpha fm-remote-inherit.sh absent
START host-bravo fm-remote-secondmate-control.sh sync
END host-bravo fm-remote-secondmate-control.sh sync
QUICK host-bravo fm-remote-inherit.sh absent
START host-charlie fm-remote-secondmate-control.sh sync
END host-charlie fm-remote-secondmate-control.sh sync
QUICK host-charlie fm-remote-inherit.sh absent
QUICK host-charlie fm-remote-inherit.sh absent
QUICK host-charlie fm-remote-inherit.sh absent
QUICK host-charlie fm-remote-inherit.sh absent
QUICK host-charlie fm-remote-inherit.sh absent
QUICK host-charlie fm-remote-inherit.sh absent
QUICK host-charlie fm-remote-inherit.sh absent
QUICK host-charlie fm-remote-inherit.sh absent
QUICK host-charlie fm-remote-inherit.sh absent
QUICK host-charlie fm-remote-inherit.sh absent
=== inherit-failure bootstrap output ===
SECONDMATE_SYNC: secondmate sm: skipped: remote inheritance failed on host-sm: error: shared captain preferences have no valid primary-authoritative header: missing "must not be edited there"

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

✅ **Review** - passed

✅ No issues found.

✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 5 of 5 scenarios driven live against the product
Scenario Result Live Evidence
Remote inheritance push fails after printing unchanged items; session-start names the real error, not the first unchanged item ✅ pass live bash tests/fm-bootstrap-network-parallel.test.sh new test drives fm-bootstrap.sh end-to-end; SECONDMATE_SYNC line names the shared-captain header problem and asserts no unchanged: in the reason (i…
Reason falls back to the first line when the push emitted no error line (interrupted/unknown-shape failure) ✅ pass live remote_inherit_failure_reason on input with no error: line returns the first line unchanged (failure-reason-old-vs-new.log)
Header check names the first required phrase it did not find (English and non-English headers) ✅ pass live bash tests/fm-shared-captain-inheritance.test.sh new test; plus live shared_captain_header_valid returning must not be edited there and main-authoritative (header-check-names-missing-phrase.log)
A valid shared-captain header still passes (accept set unchanged) ✅ pass live Valid fixture returns rc=0 with empty missing output in both the test suite and the live invocation (header-check-names-missing-phrase.log)
Remote push path (fm-remote-inherit-push.sh) appends the missing phrase to its die reason using the shared check ✅ pass live Bootstrap E2E test exercises fm-remote-inherit-push.sh; the reported reason shared captain preferences have no valid primary-authoritative header originates from that script's die path (inherit-fail…
  • bash tests/fm-bootstrap-network-parallel.test.sh (includes new test_remote_inheritance_failure_names_its_own_error_not_an_unchanged_item, drives fm-bootstrap.sh + fm-remote-inherit-push.sh end-to-end)
  • bash tests/fm-shared-captain-inheritance.test.sh (includes new test_header_check_names_the_missing_phrase)
  • Manual live invocation of remote_inherit_failure_reason from fm-ff-lib.sh contrasting old first_line vs new behavior and the no-error-line fallback
  • Manual live invocation of shared_captain_header_valid from fm-config-inherit-lib.sh on a valid, a phrase-missing, and a foreign-language header
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

Fixes kunchenguid#5295

Session start now reports a remote inheritance failure using the
push's own error line instead of the first unchanged item that
happened to print before it, and the shared captain preferences
header check now names the first required phrase it did not find,
on both the local and remote inheritance paths.
@kunchenguid
kunchenguid merged commit e97390a into kunchenguid:main Sep 25, 2026
19 checks passed

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: this is merged. Thank you @karotkriss — really appreciate you taking the time on this.

mituso89 pushed a commit to mituso89/firstmate that referenced this pull request Sep 26, 2026
…henguid#5658)

Fixes kunchenguid#5295

Session start now reports a remote inheritance failure using the
push's own error line instead of the first unchanged item that
happened to print before it, and the shared captain preferences
header check now names the first required phrase it did not find,
on both the local and remote inheritance paths.
mehulbhagwani pushed a commit to mehulbhagwani/firstmate that referenced this pull request Sep 26, 2026
…henguid#5658)

Fixes kunchenguid#5295

Session start now reports a remote inheritance failure using the
push's own error line instead of the first unchanged item that
happened to print before it, and the shared captain preferences
header check now names the first required phrase it did not find,
on both the local and remote inheritance paths.
mehulbhagwani pushed a commit to mehulbhagwani/firstmate that referenced this pull request Sep 26, 2026
…henguid#5658)

Fixes kunchenguid#5295

Session start now reports a remote inheritance failure using the
push's own error line instead of the first unchanged item that
happened to print before it, and the shared captain preferences
header check now names the first required phrase it did not find,
on both the local and remote inheritance paths.
ashkonmousavi added a commit to ashkonmousavi/firstmate that referenced this pull request Sep 26, 2026