Repository navigation
fix(bin): avoid bash 5.2 sibling $() in recovery mint and delivery log - #5773
Merged
kunchenguid merged 5 commits intoSep 26, 2026
Merged
kunchenguid merged 5 commits into
kunchenguid merged 5 commits into
Conversation
Sibling command substitutions on one line can empty a recovery generation under bash 5.2 when a CHLD trap is set. Mint pid/epoch sequentially, refuse empty tokens before write, and clean delivery fields before printf. Co-authored-by: Cursor <[email protected]>
Sibling command substitutions on one line can empty a recovery generation under bash 5.2 when a CHLD trap is set. Mint pid/epoch sequentially, refuse empty tokens before write, and clean delivery fields before printf. Co-authored-by: Cursor <[email protected]>
Remove the new pid/date refusal and grammar guard so a mint miss still yields a grammar-valid token and a durable wake row, matching accepted review intent. Drop the fake-failing-date case that locked in the refuse. Co-authored-by: Cursor <[email protected]>
Keep the superseded pre-rebase tip reachable so private-mirror reconciliation can proceed after the rewritten history and follow-up mint-semantics fix. Tree unchanged (ours strategy).
Owner
|
Speaking as Kun's firstmate: this is merged. Thank you @Lakescape — really appreciate you taking the time on this. contract-class: restore — removes the Bash 5.2 sibling |
wpartin
added a commit
to wpartin/firstmate
that referenced
this pull request
Sep 27, 2026
Intent
Remove the Bash 5.2 sibling $() hazard from recovery-generation mint and wake-delivery logging while preserving nonempty generations and the prior mint failure semantics (grammar-valid token and durable wake row on pid/date miss). Keep the accepted post-review fix that drops the refuse/grammar-guard paths.
What Changed
_fm_recovery_marker_write_lockedinbin/fm-wake-lib.shno longer builds the recovery generation from two sibling$()substitutions on one line. It now gets the pid throughfm_current_pid's output-variable form, storesdate +%sin its own assignment, and then buildspid.epoch.suffix. As before, a failed pid or date lookup is not checked, so the mint still produces a grammar-valid token and the durable wake row still appends.watch_delivery_publishinbin/fm-push-transition-lib.shnow runs the identity and reason cleaners as separate assignments before a singleprintf. It no longer passes them toprintfas sibling$()arguments. This avoids the bash 5.2 parse error that sibling substitutions can trigger when a CHLD trap is set.test_recovery_mint_and_delivery_log_avoid_sibling_substtotests/fm-wake-queue.test.sh. The test checks that:pid.epoch.suffixform;trap : CHLD,fm_recovery_marker_publishstill writes a valid generation without a parse error.🤖 Generated with Claude Code
Risk Assessment
✅ Low: The change only splits sibling $() into sequential assignments in two helpers. The earlier refusal paths and grammar guard are gone. Pid and date misses still produce the old
.epoch.suffix/pid..suffixtoken, and every caller already runs the write inside anif !context, so errexit behavior is unchanged.Testing
Called the wake-queue and delivery-log libraries directly under /bin/bash 3.2, with isolated FM_STATE_OVERRIDE dirs, on both base and target. Four scenarios ran: normal mint, a date miss, a pid miss injected at mint, and a delivery-log line. The target matched base's observable state in all four: grammar-valid nonempty generations, durable rows appended, and a 3-field log line. The focused regression-test run is recorded as untested here because the prior payload did not mark it as a live product run. An earlier pid-miss attempt that shadowed
shhung in lock acquisition on both base and target: the lock needs a pid before mint runs, so this hang is pre-existing and unrelated to the change. The injection was then narrowed to the mint call site. The Bash 5.2 CHLD-trap scenario is untested because no Bash 5.2 binary is available. No UI surface is involved.Evidence: Mint and delivery-log scenarios, base 72b63ee vs target bca1f0d (bash 3.2)
Source: Mint and delivery-log scenarios, base 72b63ee vs target bca1f0d (bash 3.2)
Evidence: Focused wake-queue test run including new sibling-subst regression test
Source: Focused wake-queue test run including new sibling-subst regression test
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.
Base-vs-target driver (git archive 72b63ee bininto a temp dir) running realfm_wake_appendfor a normal check wake, with marker and queue state capturedFake failingdateput first on PATH duringfm_wake_append: marker token grammar and queue row compared, base vs targetfm_current_pidwrapped to fail only when called from_fm_recovery_marker_write_locked(locks still get a pid) duringfm_wake_append: marker token and queue row compared, base vs targetwatch_delivery_publishwith a TAB in the identity and a newline in the reason:.watch-deliveries.logline and field count compared, base vs targetFocused run of tests/fm-wake-queue.test.sh helpers plustest_wake_publish_requires_atomic_recovery_evidence,test_recovery_mint_and_delivery_log_avoid_sibling_subst,test_legacy_generationless_wake_is_adopted,test_stale_recovery_generation_cannot_touch_a_newer_episode(exit 0, no failures)✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.