Skip to content

fix(spawn): reject FM_ROOT unconditionally in worktree detection - #187

Closed
atqamz wants to merge 14 commits into
kunchenguid:mainfrom
atqamz:fm/fm-spawn-race-fix
Closed

atqamz wants to merge 14 commits into
kunchenguid:mainfrom
atqamz:fm/fm-spawn-race-fix

Conversation

@atqamz

@atqamz atqamz commented Jul 2, 2026 •

Copy link
Copy Markdown

Intent

Fix two failing CI checks on the already-open cross-fork PR #187 (fm/fm-spawn-race-fix -> kunchenguid:main), which fixes a race in fm-spawn.sh worktree detection (unconditionally rejecting FM_ROOT as the resolved worktree instead of gating on a timing-sensitive seen-project flag) plus its regression test tests/fm-spawn-worktree-wait.test.sh. That worktree-detection fix itself is already validated and correct and must not change. The two CI failures being fixed here are process issues, not logic bugs: (1) the new test file was committed as mode 100644 instead of 100755, and CI invokes tests/*.test.sh directly rather than through bash, so the non-executable file aborted with exit 126 - fixed by chmod +x and recording the bit in git; (2) PR #187 was originally raised manually via gh pr create instead of through no-mistakes, so the PR body is missing the deterministic no-mistakes signature the 'Require no-mistakes' check greps for - this run re-raises it through the pipeline via a fork remote (atqamz/firstmate) since the PR author has no push access to the upstream repo, so the pipeline pushes to the fork and updates the existing cross-fork PR #187 against kunchenguid/firstmate. No other code changes are intended or wanted on this branch.

What Changed

  • bin/fm-spawn.sh and bin/backends/orca.sh: drop the timing-sensitive seen_proj gate and unconditionally reject FM_ROOT as a resolved spawn worktree, closing a race where a crewmate could be launched against the primary checkout instead of an isolated worktree.
  • tests/fm-spawn-worktree-wait.test.sh: add regression coverage for the worktree-wait/detection race, and fix its file mode to executable (100755) so the test harness, which invokes tests/*.test.sh directly, can run it.
  • Update related backend/dispatch/harness test fakes (fm-backend*.test.sh, fm-secondmate-harness.test.sh, fm-secondmate-sync.test.sh, fm-spawn-dispatch-profile.test.sh, fm-tangle-guard.test.sh, fm-grok-harness.test.sh, fm-bootstrap.test.sh, fm-session-start.test.sh, fm-x-mode.test.sh) to model a project-first pane flow consistent with the new detection logic.
  • Document the configurable spawn worktree timeout and unconditional FM_ROOT rejection in docs/configuration.md, docs/architecture.md, and docs/zellij-backend.md.

Risk Assessment

✅ Low: Diff = chmod fix (verified 100755 on new test file) + already-landed prior commits (FM_ROOT unconditional rejection, configurable timeout, orca JSON-parse guard, PATH portability in tests). Logic reviewed end to end: FM_ROOT_REAL/PROJ_ABS_REAL comparison is correct and order-independent, all make_spawn_fakebin call sites updated consistently for the new proj param, orca.sh JSON parse failure now exits 1 and every caller already treats nonzero as generic failure. No functional or behavioral changes beyond what intent describes.

Testing

Completed 1 recorded test check.

  • Outcome: ⚠️ 1 error across 4 runs (49m34s)

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

🔧 **Rebase** - 8 issues found → auto-fixed ✅
  • ⚠️ CONTRIBUTING.md - merge conflict rebasing onto origin/main
  • ⚠️ bin/backends/herdr.sh - merge conflict rebasing onto origin/main
  • ⚠️ bin/fm-send.sh - merge conflict rebasing onto origin/main
  • ⚠️ docs/architecture.md - merge conflict rebasing onto origin/main
  • ⚠️ docs/configuration.md - merge conflict rebasing onto origin/main
  • ⚠️ docs/herdr-backend.md - merge conflict rebasing onto origin/main
  • ⚠️ docs/scripts.md - merge conflict rebasing onto origin/main
  • ⚠️ tests/fm-backend-herdr.test.sh - merge conflict rebasing onto origin/main

🔧 Fix applied.
✅ Re-checked - no issues remain.

✅ **Review** - passed

✅ No issues found.

⚠️ **Test** - 1 error
  • 🚨 tests failed with exit code 1
  • 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: Running full test suite in background to triage remaining failures; will continue on completion
1 error still open:

  • 🚨 tests failed with exit code 1
  • 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: confirm worktree-wait test executable and passing, no code changes needed
1 error still open:

  • 🚨 tests failed with exit code 1
  • 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: Waiting for full test suite run to finish before final fix summary
1 error still open:

  • 🚨 tests failed with exit code 1
  • 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"
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

@kunchenguid

Copy link
Copy Markdown
Owner

thanks for this. quick note on process - i require PRs to come through no-mistakes, which is why the "PR must be raised via no-mistakes" check is red here (this was opened directly).

the reason i ask for it: no-mistakes runs review, tests, lint, and docs on your branch before the PR is opened, so contributions arrive already validated. that keeps the quality bar high and keeps me from having to hand-review every change - i maintain this solo, so it's the only way i keep up.

can you re-raise it through no-mistakes? running the pipeline on your branch opens/updates the PR through the gate and turns that check green. the change looks useful, it just needs to come through that path. ping me if the setup gives you trouble.

@atqamz

atqamz commented Jul 7, 2026

Copy link
Copy Markdown
Author

will do in a moment

@atqamz

atqamz commented Jul 7, 2026

Copy link
Copy Markdown
Author

This branch was taken through the no-mistakes pipeline: intent, rebase, review, document, and lint all pass.

The single test-step finding is pre-existing full-suite flakiness (unrelated test files that fail only under the full ~100+ file suite load), reverified as unrelated to this diff across several standalone reproductions.

Also folded in a review finding that hardened the worktree-detection guard: it now rejects a departure to FM_ROOT unconditionally instead of relying on ordering/timing (seen-project-first) to catch it, closing a latent tangle edge case.

Rebased onto the current default branch to clear a conflict in docs/configuration.md (both sides' documentation lines kept).

@atqamz

atqamz commented Jul 7, 2026

Copy link
Copy Markdown
Author

@kunchenguid re-raised thru no-mistakes, let me know if there's anything more I should do!

atqamz added 9 commits July 9, 2026 06:03
…timeout

Reconciles PR #187 onto #294's canonicalized worktree-wait loop. A pane
freshly created for a spawn can transiently report its cwd as FM_ROOT
(itself a valid worktree the isolation guard cannot reject) before the
shell finishes cd'ing into the project, so a departure is only accepted
once the pane has actually been seen at the project. The wait bound is
now configurable via FM_SPAWN_WORKTREE_TIMEOUT (default 60), used in
both the poll count and the error message.
review-1 flagged that once seen_proj was set, a later FM_ROOT pane read
could still be accepted as the worktree, tangling the primary checkout.
Accept a departure only when the pane resolves to neither the project
nor FM_ROOT, regardless of poll order - simpler and closes the gap.
CI invokes tests/*.test.sh directly, not via bash; the file was
committed without the executable bit, causing exit 126.
…ocs/architecture.md; other docs already matched code.
@atqamz atqamz changed the title fix(spawn): gate worktree detection on seen-project and make timeout configurable fix(spawn): reject FM_ROOT unconditionally in worktree detection Jul 9, 2026
@kunchenguid

kunchenguid commented Jul 10, 2026 •

Copy link
Copy Markdown
Owner

Thanks for the PR! This branch currently has a merge conflict with the base branch.

When you get a chance, please rebase onto (or merge) the latest base branch, resolve the conflict, and push. After that, checks will re-run and the PR will get looked at again.

Noted for firstmate#187 at 057c38c5.

# Conflicts:
#	bin/fm-spawn.sh
#	tests/fm-backend.test.sh
@atqamz

atqamz commented Jul 11, 2026

Copy link
Copy Markdown
Author

@kunchenguid done, let me know if there's more to do

@kunchenguid kunchenguid removed the wheelhouse:pending-contributor-action Managed by Wheelhouse label Jul 11, 2026
fm-teardown.sh sources bin/fm-lock-lib.sh (added in #453), so the
BASE_REF-extracted old teardown bin needs the lib reachable. Add it to
OLD_BIN_UNCHANGED_SIBLINGS. #453 landed green only because its own
merge-base predated the lib; any branch merging current main hits the
missing-file failure in the scout-teardown conformance test.
@atqamz

atqamz commented Jul 11, 2026

Copy link
Copy Markdown
Author

@kunchenguid resolved the Behavioral test failing
https://github.com/kunchenguid/firstmate/actions/runs/29152052151/job/86550833796

LMK if there's more!

*also LMK if you not comfortable got tagged a lot, hehe

@kunchenguid

kunchenguid commented Jul 11, 2026 •

Copy link
Copy Markdown
Owner

Thanks for the PR! This branch currently has a merge conflict with the base branch.

When you get a chance, please rebase onto (or merge) the latest base branch, resolve the conflict, and push. After that, checks will re-run and the PR will get looked at again.

Noted for firstmate#187 at 3711f848.

@kunchenguid kunchenguid removed the wheelhouse:pending-contributor-action Managed by Wheelhouse label Jul 12, 2026
@kunchenguid

kunchenguid commented Jul 21, 2026 •

Copy link
Copy Markdown
Owner

Automated reminder: thanks for the PR! This branch currently has a merge conflict with the base branch.

When you get a chance, please rebase onto (or merge) the latest base branch, resolve the conflict, and push. After that, checks will re-run and the PR will get looked at again.

Noted for firstmate#187 at 35efefb7.

@atqamz

atqamz commented Jul 21, 2026

Copy link
Copy Markdown
Author

Superseded by main: two-stable-reads (#765), herdr projection (#784), gate-refuse-lib (#518), and other PRs landed the same fixes through separate paths. The remaining unique value (FM_ROOT rejection, configurable timeout) is marginal given the two-stable-reads approach already prevents transient acceptance.

@atqamz atqamz closed this Jul 21, 2026
@atqamz
atqamz deleted the fm/fm-spawn-race-fix branch July 21, 2026 22:47
fritznoff pushed a commit to fritznoff/starship that referenced this pull request Nov 2, 2026
…napshot (kunchenguid#187)

* fix(bin): render the to-do page's open tickets live from the intake snapshot

The Your open tickets section lived in the hand-written morning detail file,
so every 30-minute re-render repeated the 06:20 read. The page now renders
it from data/channel-intake/tickets.json on every build, stamped with the
snapshot's own read time, labels a snapshot over an hour old as out of date,
says so when it cannot be read, and drops any morning copy of the table.
fm-channel-intake.sh tickets is the validated atomic writer the HubSpot pass
calls each run.

* no-mistakes(review): fix morning-section drop, snapshot validation, and ticket freshness window

* no-mistakes(review): drop emptied wrappers, allow empty subject, document interval key

* no-mistakes(review): take the ticket array on stdin only

* no-mistakes(review): suppress the empty legacy morning reference fold

* no-mistakes(document): Reflow the to-do renderer header's open-tickets prose
fritznoff pushed a commit to fritznoff/starship that referenced this pull request Nov 2, 2026
… to-do (kunchenguid#188)

* feat(todo): rank partner-facing asks awaiting the captain first

The channel intake assesses a ticket or email-thread timeline passed to
observe --timeline-file: partner-facing when it has an external contact,
company or participant; awaiting the captain when a partner message has no
real reply, a promise naming him or tech has no later outbound, or a
colleague note asking him is unanswered. A send with no EMAIL engagement is
an auto-acknowledgement, and Waiting on contact alone asks nothing of him.

The to-do page, todo, brief and alert order put those asks first, oldest ask
first. HubSpot claims name the Waiting on contact stage and hand out a
bounded periodic re-scan of every owner's tickets naming the captain, and a
timeline re-read counts as verification.

* no-mistakes(review): tighten awaiting rules, validate timelines, sort undated asks last

* no-mistakes(review): unify captain identity, keep awaiting owed, validate sidecar fields

* no-mistakes(review): type timeline addresses, drop email-thread mode, widen partner detection

* no-mistakes(review): Widen tech re-scan, keep archived facts, refuse millisecond epochs

* fix(bin): render the to-do page's open tickets live from the intake snapshot (kunchenguid#187)

* fix(bin): render the to-do page's open tickets live from the intake snapshot

The Your open tickets section lived in the hand-written morning detail file,
so every 30-minute re-render repeated the 06:20 read. The page now renders
it from data/channel-intake/tickets.json on every build, stamped with the
snapshot's own read time, labels a snapshot over an hour old as out of date,
says so when it cannot be read, and drops any morning copy of the table.
fm-channel-intake.sh tickets is the validated atomic writer the HubSpot pass
calls each run.

* no-mistakes(review): fix morning-section drop, snapshot validation, and ticket freshness window

* no-mistakes(review): drop emptied wrappers, allow empty subject, document interval key

* no-mistakes(review): take the ticket array on stdin only

* no-mistakes(review): suppress the empty legacy morning reference fold

* no-mistakes(document): Reflow the to-do renderer header's open-tickets prose

* feat(todo): rank partner-facing asks awaiting the captain first

The channel intake assesses a ticket or email-thread timeline passed to
observe --timeline-file: partner-facing when it has an external contact,
company or participant; awaiting the captain when a partner message has no
real reply, a promise naming him or tech has no later outbound, or a
colleague note asking him is unanswered. A send with no EMAIL engagement is
an auto-acknowledgement, and Waiting on contact alone asks nothing of him.

The to-do page, todo, brief and alert order put those asks first, oldest ask
first. HubSpot claims name the Waiting on contact stage and hand out a
bounded periodic re-scan of every owner's tickets naming the captain, and a
timeline re-read counts as verification.

* no-mistakes(review): tighten awaiting rules, validate timelines, sort undated asks last

* no-mistakes(review): unify captain identity, keep awaiting owed, validate sidecar fields

* no-mistakes(review): type timeline addresses, drop email-thread mode, widen partner detection

* no-mistakes(review): Widen tech re-scan, keep archived facts, refuse millisecond epochs

* no-mistakes(review): Count ambiguous promise verbs only when the team or captain acts

* no-mistakes(review): Catch subjectless -ing promises, reject "you" before promise verbs

* no-mistakes(review): Stop counting customer chases as the captain's promises

* no-mistakes(review): Restore actor-anchored follow-up and check-with promise forms

* no-mistakes(document): Clarify that only subjectless check/follow-up forms need third party
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants