Skip to content

fix(bin): parallelize startup network sweeps - #2927

Merged
kunchenguid merged 4 commits into
mainfrom
fm/fm-startup-network-parallel-r1
Aug 24, 2026
Merged

fix(bin): parallelize startup network sweeps#2927
kunchenguid merged 4 commits into
mainfrom
fm/fm-startup-network-parallel-r1

Conversation

@kunchenguid

Copy link
Copy Markdown
Owner

Intent

Parallelize session-start network sweeps in bin/fm-startup-network.sh and bin/fm-bootstrap.sh: run per-secondmate remote liveness/relaunch concurrently rather than a sequential for-loop; run per-secondmate convergence sync concurrently; overlap project-clone refresh (fleet_sync) with those sweeps where they are independent. Keep the 120-second overall stage bound and the existing fail-closed guards (dirty worktree, unknown remote, unreachable remote; never force, stash, or discard unlanded work). Every per-mate SECONDMATE_LIVENESS: and SECONDMATE_SYNC: line must still be emitted, attributed to the correct mate, and not lost, duplicated, or interleave-corrupted under concurrency. Liveness must finish before sync because sync consumes respawned ids; do not overlap liveness with sync. Gitignore files and directories whose names start with scratchpad (scratchpad, scratchpad2/, scratchpad-foo) so untracked scratch no longer trips the remote-secondmate dirty-sync guard, without newly ignoring any currently-tracked path. Include a concurrency-safety regression test and keep colocated tests updated. Worker output is captured per-mate and replayed in original spawn order so concurrent probes cannot interleave or mis-attribute lines; respawned ids are recorded via files because background subshells cannot mutate parent state; sequential fallback remains if mktemp -d fails; the parent waits on explicit PIDs, never a bare wait.

What Changed

  • Run per-secondmate liveness and convergence probes concurrently while preserving liveness-before-sync ordering, respawned IDs, ordered diagnostics, and a sequential fallback.
  • Overlap project clone refresh with independent secondmate sweeps using explicit PID waits.
  • Ignore scratchpad* paths and add regression coverage for concurrency safety, fail-closed behavior, and dirty-sync guards.

Risk Assessment

✅ Low: The implementation is well-bounded, preserves liveness-before-sync ordering and fail-closed behavior, captures per-mate output deterministically, retains explicit-PID waits and sequential fallback, and includes behavioral concurrency coverage.

Testing

Exercised the network-only bootstrap through fake remote endpoints in parallel and with forced mktemp -d failure, demonstrating concurrent liveness and sync sweeps, fleet-fetch overlap, strict liveness-before-sync ordering, spawn-order output replay, and preserved dirty/unreachable fail-closed diagnostics. Gitignore behavior, secondmate dirty-work guards, fleet-sync safety, and the startup stage bound also passed targeted tests; an exploratory broad bootstrap run exceeded its local 180-second limit after the relevant assertions had passed.

Evidence: Bootstrap parallel/fallback output and remote-operation timeline

Source: Bootstrap parallel/fallback output and remote-operation timeline

=== 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 
END host-bravo fm-remote-doctor.sh 
END host-alpha 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
START fleet-fetch git fetch
END host-charlie fm-remote-secondmate-control.sh state
END host-alpha fm-remote-secondmate-control.sh state
QUICK host-charlie fm-remote-secondmate-control.sh route
QUICK host-alpha fm-remote-secondmate-control.sh route
END fleet-fetch git fetch
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-bravo fm-remote-secondmate-control.sh sync
END host-alpha fm-remote-secondmate-control.sh sync
END host-charlie fm-remote-secondmate-control.sh sync
QUICK host-bravo fm-remote-inherit.sh absent
QUICK host-alpha fm-remote-inherit.sh absent
QUICK host-charlie 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-alpha fm-remote-inherit.sh absent
QUICK host-charlie fm-remote-inherit.sh absent
QUICK host-charlie fm-remote-inherit.sh absent
QUICK host-alpha 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 
END host-alpha fm-remote-doctor.sh 
START host-alpha fm-remote-secondmate-control.sh state
START fleet-fetch git fetch
END host-alpha fm-remote-secondmate-control.sh state
QUICK host-alpha fm-remote-secondmate-control.sh route
END fleet-fetch git fetch
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
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

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.

  • bash tests/fm-bootstrap-network-parallel.test.sh
  • FM_TEST_EVIDENCE_FILE=/Users/kunchen/.no-mistakes/evidence/01M0S38M6EC9BH7VZ9W4PBJVD8/bootstrap-network-parallel-transcript.txt bash tests/fm-bootstrap-network-parallel.test.sh
  • bash tests/fm-gitignore-config.test.sh
  • bash tests/fm-secondmate-sync.test.sh
  • bash tests/fm-startup-network.test.sh
  • bash tests/fm-fleet-sync.test.sh
  • bash tests/fm-bootstrap.test.sh — exploratory broad run stopped at the 180-second local timeout after its relevant network partition, lock-ownership, and timing checks passed
✅ **Document** - passed

✅ No issues found.

🔧 **Lint** - 1 issue found → auto-fixed (2) ✅
  • ⚠️ linter found issues (exit code 1)

🔧 Fix: Fix empty environment assignment lint warning
1 warning still open:

  • ⚠️ linter found issues (exit code 1)

🔧 Fix: Confirm lint passes with pinned actionlint
✅ Re-checked - no issues remain.

✅ **Push** - passed

✅ No issues found.

kunchenguid and others added 4 commits August 23, 2026 22:18
Run per-secondmate liveness and convergence probes concurrently and overlap clone refresh, while replaying each mate's fail-closed diagnostic in original order. Ignore scratchpad* so untracked scratch no longer blocks remote sync.

Co-authored-by: Cursor <cursoragent@cursor.com>
@greptile-apps

greptile-apps Bot commented Aug 24, 2026

Copy link
Copy Markdown

Confidence Score: 5/5

The PR appears safe to merge; no concrete changed-code failure remains after checking the new concurrency, result propagation, shared-resource, and timing paths.

The parallel workers retain explicit synchronization and isolated output capture, liveness completes before convergence consumes respawned IDs, and the overlapped fleet refresh operates on a separate mutation surface.

Reviews (1): Last reviewed commit: "no-mistakes: apply CI fixes" | Re-trigger Greptile

@kunchenguid
kunchenguid merged commit fb2ce5b into main Aug 24, 2026
14 checks passed
@kunchenguid
kunchenguid deleted the fm/fm-startup-network-parallel-r1 branch August 24, 2026 06:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant