Repository navigation
Conversation
… array guard The core bugs (fm-brief.sh apostrophe parse break, fm-spawn.sh empty shared_args under set -u) were already fixed by PR kunchenguid#173 with a regression test. This closes the remaining gaps from the same audit: - ci.yml: add a bash -n sweep over bin/*.sh and bin/backends/*.sh to the lint job, catching syntax regressions shellcheck's parser tolerates. - fm-brief.sh: warning comment ahead of the three DOD heredoc-in-$() blocks, since the bash 3.2 apostrophe trap does not reproduce on CI. - fm-supervise-daemon.sh: guard the one remaining possibly-empty array expansion (should_force_self prefixes; read -ra yields an empty array when the input's first line is empty, which errors under 3.2 set -u). - CONTRIBUTING.md: record the macOS bash 3.2 compatibility rule and the two known traps; mark the bash -n sweep as CI-enforced. Audited all of bin/ for both hazard classes: no other unguarded possibly-empty expansions, and all remaining $(cat <<EOF) bodies have balanced apostrophes. Verified with /bin/bash 3.2.57 on macOS.
|
Speaking as Kun's firstmate: closing this as stale. It has been waiting on a contributor update for 14+ days with no author push or comment. Reopen if you want to pick it back up. |
…patch picker or the status second look (kunchenguid#302) * fix(bin): never send Harbour or never-send-listed text to the dispatch picker or the status second look The dispatch resolver now takes its off path for a private-app brief, named by --project or by the brief's scaffolded setup line, matching the command guard's always-excluded project. The status second look leaves out lines from private-app tasks and lines matching config/dispatch-never-send before the request is built, and withholds the whole scan when that list is unreadable. * no-mistakes(document): Sync second-look and resolver evidence with never-send exemptions
meisbokai
left a comment
There was a problem hiding this comment.
Review-rectify pass (independent re-review of the full PR diff at b3714f39).
Verdict: APPROVE — clean. (Submitted as a comment review because GitHub refuses a formal APPROVE from the PR's own author account; the verdict stands as written.) No new findings beyond what this branch's earlier review rounds already fixed; every fix on the branch (restricted backfill, 23def80/PR #295 client-authorship anchor, DEFAULT FALSE down shape, dropped impossible-replay claim, NULL-unknown rows deliberately left non-round-trippable) matches the accepted design and holds up under an independent pass.
| ID | Severity | Finding | Decision | Fix |
|---|---|---|---|---|
| — | none | Migration 000073 up: backfill correctly restricted to provable rows (earn_membership_points = TRUE only), NULL-unknown rows preserved, known-flag rows untouched; atomic-deploy window documented |
accepted (no change) | none needed |
| — | none | Down migration DEFAULT FALSE shape + documented non-round-trippable NULLs | accepted (no change) | none needed |
| — | none | Sweep: no remaining two-value DerivedRedeemable() callers, no SQL outside migrations/tests names redeemable, CSV export never named the column, all Redeemable usages are the JSON-only db:"-" field or unrelated domain terms |
accepted (no change) | none needed |
| — | none | Docs (api-contract, RUNBOOK incl. NULL-count verification query + deploy-order, ohip-endpoints, ADR 0001, CODEMAPS) consistent with the dropped column | accepted (no change) | none needed |
Basis: go build ./... and go vet ./... clean; go test ./internal/models/... ./internal/database/... ./internal/handlers/... ./internal/services/pms/... all green (incl. the new 000073 up/down migration probe against real PostgreSQL, which pins all four backfill rules, known-flag preservation, the non-destructive drop, and the DEFAULT FALSE down shape).
Intent
Fix macOS bash 3.2 compatibility gaps in the firstmate bin/ toolbelt. Original task: a bash 3.2 heredoc-in-command-substitution apostrophe bug made bin/fm-brief.sh fail to parse entirely (blocking all brief scaffolding on macOS), and bin/fm-spawn.sh batch mode failed under 3.2 set -u on an empty shared_args array; audit all of bin/ for both hazard classes and add a cheap CI regression guard. Investigation showed the two core bugs were already fixed on main by PR #173 (apostrophe reworded, shared_args guarded, regression test added), so this change deliberately covers only the remaining scope: (1) add a bash -n sweep over bin/.sh and bin/backends/.sh to the existing CI lint job, as the task explicitly requested, with a comment noting the 3.2-specific bug does not reproduce on the runner's newer bash; (2) add a warning comment ahead of the three DOD heredoc blocks in bin/fm-brief.sh - the task's prescribed proportionate fallback; (3) guard the one remaining possibly-empty array expansion found by the audit: should_force_self() prefixes in bin/fm-supervise-daemon.sh, where read -ra yields an empty array when the input's first line is empty and bash 3.2 set -u errors; the guard pattern used was mandated by the task and the empty case was empirically verified on /bin/bash 3.2.57; (4) record the bash 3.2 compatibility rule and both traps in CONTRIBUTING.md and mark the bash -n pre-push check as CI-enforced. The audit found no other unguarded possibly-empty array expansions and all remaining heredoc bodies have balanced apostrophes, so no further code changes were needed - a small diff is the intended outcome. All acceptance criteria verified locally with system /bin/bash 3.2.57. A previous pipeline run (01KWWFH1M3YCNQTCHTH8HESYKF) already validated this exact content - review, test, document, and lint all completed, with the test step fixing a pre-existing cmux jq-1.6 exit-status bug and deflaking the tmux smoke test - and failed only at the push step due to a 403 before the gate was reconfigured with the fork push target; this rerun delivers through the fork per the captain-approved flow.
What Changed
bin/toolbelt for macOS system bash 3.2: guarded the possibly-emptyprefixesarray expansion inshould_force_self()inbin/fm-supervise-daemon.sh(empty"${arr[@]}"errors underset -uon 3.2), added a warning comment ahead of the heredoc-in-$(...)DOD blocks inbin/fm-brief.sh(an unbalanced apostrophe there breaks parsing of the whole script on 3.2), added abash -nsweep overbin/*.shandbin/backends/*.shto the CI lint job, and recorded both 3.2 traps and the compatibility rule inCONTRIBUTING.mdand the firstmate-coding-guidelines skill.fm_backend_cmux_surface_existsinbin/backends/cmux.shto capture the CLI output and gate on the CLI's own exit status before piping intojq -e, since jq 1.6's-eexits 0 on empty input and would misread a failed CLI call as "surface exists"; documented the gate indocs/cmux-backend.md.Risk Assessment
✅ Low: A small, deliberately-scoped hardening change (CI syntax sweep, one canonical array guard matching existing repo usage, an exit-status gate fixing a real jq-1.6 false success, test deflaking, and docs) with no behavior-changing surprises and only theoretical residual edges.
Testing
Baseline full suite passed; on top of that I demonstrated the change working as an end user would hit it on macOS bash 3.2.57 — the CI bash -n sweep over all 50 bin scripts, fm-brief.sh scaffolding a complete brief end-to-end, and the real should_force_self() surviving the empty-array set -u case that provably crashes without the guard — and re-ran the seven relevant test files (including the three deflaked flaky ones), all green. No visual artifacts because this is a pure CLI/shell change with no rendered surface; transcripts are the product-level evidence.
Evidence: bash -n parse sweep on macOS bash 3.2.57 (all 50 bin scripts clean)
$ /bin/bash --version | head -1 GNU bash, version 3.2.57(1)-release (arm64-apple-darwin25) $ for f in bin/.sh bin/backends/.sh; do /bin/bash -n "$f" || echo "PARSE FAIL: $f"; done # exact CI sweep, run on macOS system bash 3.2 all 50 scripts parse clean under bash 3.2.57Evidence: fm-brief.sh end-to-end under bash 3.2.57 (scaffolds brief incl. heredoc DOD section)
Evidence: should_force_self set -u guard: shipped form clean vs pre-fix unbound-variable crash on bash 3.2.57
guarded (shipped) form: exit=1 (no crash, correctly no match) # Counterfactual: the PRE-FIX unguarded loop 'for prefix in "${prefixes[@]}"' on the same input: /bin/bash: prefixes[@]: unbound variableEvidence: Relevant test subset run (brief, spawn-batch, daemon, cmux, watcher-lock, tmux smoke, afk-inject e2e) — all pass
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
bin/backends/cmux.sh:397- Residual jq-1.6 edge: if fm_backend_cmux_cli exits 0 but emits empty output, the empty input still reachesjq -e, which exits 0 on jq 1.6 and would falsely report the surface as existing. The new|| return 1gate covers the real failure mode (CLI failure), and a successfullist-panes --jsonalways emits a JSON document, so this is theoretical; adding[ -n "$out" ] || return 1would close it completely.tests/fm-backend-tmux-smoke.test.sh:113- The tag-line-80 poll times out silently after 100 iterations (~20s) instead of callingfaillike the shell-ready poll above it does; on timeout the test falls through to the capture assertions, which still fail with the pane content but with a less direct message ("a 3-line capture should still contain the most recent output") than an explicit "pane never finished printing" failure would give.🔧 **Test** - 1 issue found → auto-fixed (2) ✅
command -v tmux >/dev/null || { echo "tmux is required for e2e tests" >&2; exit 1; }; tmux -V; rc=0; for t in tests/*.test.sh; do echo "== $t =="; bash "$t" || rc=1; done; exit "$rc"🔧 Fix: deflake afk-inject e2e loop readiness and HUP wait
1 error still open:
command -v tmux >/dev/null || { echo "tmux is required for e2e tests" >&2; exit 1; }; tmux -V; rc=0; for t in tests/*.test.sh; do echo "== $t =="; bash "$t" || rc=1; done; exit "$rc"🔧 Fix: reset SIGHUP for watcher-arm HUP test; widen tmux smoke wait
✅ Re-checked - no issues remain.
command -v tmux >/dev/null || { echo "tmux is required for e2e tests" >&2; exit 1; }; tmux -V; rc=0; for t in tests/*.test.sh; do echo "== $t =="; bash "$t" || rc=1; done; exit "$rc"baseline: full suitefor t in tests/*.test.sh; do bash "$t"; done(ran green before this round)for f in bin/*.sh bin/backends/*.sh; do /bin/bash -n "$f"; doneon macOS system bash 3.2.57 — the exact new CI sweep, all 50 scripts parse cleanmanual e2e:FM_HOME=<tmp> /bin/bash bin/fm-brief.sh fix-widget-a1 myrepounder bash 3.2.57 — brief scaffolds and renders the full Definition-of-done heredoc sectionmanual guard check: realshould_force_self()extracted from bin/fm-supervise-daemon.sh run under/bin/bash -u3.2.57 with empty-first-line FM_INJECT_SKIP — guarded form exits 1 cleanly; pre-fix unguarded form reproducesprefixes[@]: unbound variablebash tests/fm-brief.test.sh(apostrophe-wording regression guard)bash tests/fm-spawn-batch.test.sh(batch empty shared_args regression)bash tests/fm-daemon.test.shbash tests/fm-backend-cmux.test.sh(covers the surface_exists jq exit-status gate change)bash tests/fm-watcher-lock.test.sh(deflaked SIGHUP test)bash tests/fm-backend-tmux-smoke.test.sh(deflaked)bash tests/fm-afk-inject-e2e.test.sh(deflaked)✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.