Skip to content

feat(bin): add crewmate launch resume infrastructure - #220

Closed
JJ22007 wants to merge 10 commits into
kunchenguid:mainfrom
JJ22007:fm/fm-infra-fixes
Closed

JJ22007 wants to merge 10 commits into
kunchenguid:mainfrom
JJ22007:fm/fm-infra-fixes

Conversation

@JJ22007

@JJ22007 JJ22007 commented Jul 3, 2026

Copy link
Copy Markdown

What Changed

  • Captain, extracted shared launch handling into bin/fm-launch-lib.sh, added fm-resume-worktree.sh, and updated spawn/resume behavior for default crewmate models, proxy passthrough, task temp cleanup, and worktree recovery.
  • Promoted the loopd and loopds skills with autogrow, backoff, drive, and visual-check helpers, including tests for queue growth, visual gates, proxy handling, and resume flows.
  • Updated firstmate docs and contributor/script references to cover the new launch, resume, recovery, and loop workflows.

Risk Assessment

⚠️ Medium: Captain, the remaining reviewed changes are non-trivial fleet infrastructure and long-running skill automation, but I did not find additional substantiated defects beyond previously ignored items.

Testing

Completed 1 recorded test check.

  • Outcome: 🔧 1 issue found → auto-fixed ✅ across 2 runs (15m25s)

Pipeline

Updates from git push no-mistakes

⏭️ **intent** - skipped

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

🔧 **Review** - 5 issues found → auto-fixed (5) ✅
  • ⚠️ bin/fm-spawn.sh:573 - Proxy values are typed directly into the child pane via an export ... command and again as a launch-command prefix, so credentialed proxy URLs such as http://user:token@proxy will be left in pane scrollback and any captured send logs. Preserve proxy propagation, but avoid echoing raw secret-bearing values into the interactive command stream, or redact known credential portions before anything is visible/captured.
  • ⚠️ AGENTS.md:314 - Recovery now says to resume both kind=ship and kind=scout tasks whenever their worktree still exists. That conflicts with the scout lifecycle where data/<id>/report.md is the terminal deliverable: after a restart that kills the endpoint after the report was written, this instruction would relaunch an already-finished scout instead of reading the report and tearing it down. Clarify whether scouts with an existing report should bypass fm-resume-worktree.sh.
  • ⚠️ .agents/skills/loopds/autogrow.mjs:54 - ingest() deduplicates only against explored and queue, but drive.mjs pick removes the current facet from queue and recordRound() does not add it to explored until after ingest() runs. If a workflow proposes the same current facet as a next facet or blind spot, it can be requeued and picked again, defeating the no-repeat/autogrow contract. Include state.current?.facet in the duplicate set or record the current facet before ingesting new directions.
  • ⚠️ .agents/skills/loopds/vischeck.mjs:35 - nonblankVerdict() treats any image with dimensions and at least 1024 bytes as nonblank. A normal full-page white Chrome screenshot can easily exceed that byte floor, so the Tier-0 visual gate can pass a blank render. Add a deterministic pixel/content check, or rename this to a weaker existence check and keep real nonblank detection separate.
  • ⚠️ bin/fm-resume-worktree.sh:104 - Resume creates /tmp/fm-$ID/gotmp and exports it, but it only rewrites window= in meta. For older tasks whose meta predates tasktmp=, teardown will not remove this resumed temp root, because cleanup is keyed off tasktmp=. When resuming a meta without tasktmp=, append or preserve that field so cleanup remains deterministic.

🔧 Fix: Fix selected review findings
3 warnings still open:

  • ⚠️ bin/fm-spawn.sh:574 - Proxy values are written to $TASK_TMP/proxy-env.sh before treehouse get succeeds and before state/<id>.meta records tasktmp=, so a timeout or isolation-guard failure exits with a credential-bearing temp file that teardown cannot discover. Add pre-meta failure cleanup, or delay durable proxy-file creation until meta cleanup is guaranteed.
  • ⚠️ .agents/skills/loopds/SKILL.md:344 - The new loopds instructions make sync-surface.mjs a required cleanup step, but this change does not add that script under .agents/skills/loopds. A user following the skill will fail at the required final sync unless the script is included or this Lorevik-specific step is made conditional.
  • ⚠️ .agents/skills/loopds/vischeck.mjs:256 - --min parsing splits on every =, so common DOM substrings like <div class="row"=3 produce n=NaN; the comparison then silently passes instead of enforcing the minimum count. Split at the last = and reject missing or non-numeric counts.

🔧 Fix: Fix proxy cleanup and min parsing
1 warning still open:

  • ⚠️ .agents/skills/loopds/vischeck.mjs:241 - compare exits non-zero for both real image differences and fatal tool errors, but this catch parses the first number from any stderr. A missing reference image or size/format error can yield a tiny arbitrary AE value and pass the pixel-diff gate. Require real numeric AE output, and fail loudly on non-metric stderr/tool errors.

🔧 Fix: Captain, harden vischeck diff error handling
1 warning still open:

  • ⚠️ bin/fm-resume-worktree.sh:103 - Resume creates the replacement tmux window before rewriting meta with the new window/tasktmp, and only updates meta after sending the launch command. If any later command fails or the script is interrupted, the new endpoint is orphaned from state; for older metas without tasktmp=, a credential-bearing proxy-env.sh can also be left where teardown cannot discover it. Update meta or install a cleanup trap immediately after creating the endpoint and before writing/sourcing proxy env.

🔧 Fix: Captain, fix resume meta ordering
2 warnings still open:

  • ⚠️ bin/fm-spawn.sh:585 - Proxy env is sourced into the new pane before treehouse get, but pre-meta failure cleanup only removes the temp file and never kills the just-created endpoint. A timeout or isolation-guard failure can leave an untracked pane whose shell still has credentialed proxy variables loaded, so teardown cannot discover or clean it. Extend the pre-meta cleanup to kill $T until meta records the endpoint, or record cleanup-discoverable meta before sourcing the proxy env.
  • ⚠️ .agents/skills/loopds/vischeck.mjs:263 - parseFlags() silently ignores unknown tokens and does not fail loudly for missing --inc or --exc values, so a typo like --incl '<canvas' can leave domcheck with no assertions and pass any DOM. Reject unknown flags and require values for every flag so malformed visual gates fail closed.

🔧 Fix: Captain, harden proxy cleanup and vischeck flags
✅ Re-checked - no issues remain.

🔧 **Test** - 1 issue found → auto-fixed ✅
  • 🚨 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: Fix fm-pr-merge extra args
✅ 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"
✅ **Document** - passed

✅ No issues found.

⏭️ **Lint** - skipped
  • ⚠️ .github/workflows/ci.yml:18 - Configured shellcheck lint could not be run because shellcheck is not installed on PATH, and installing tools outside the worktree is disallowed.
✅ **Push** - passed

✅ No issues found.

@JJ22007
JJ22007 force-pushed the fm/fm-infra-fixes branch 2 times, most recently from 941173a to 6da91b3 Compare July 3, 2026 18:41
@kunchenguid

Copy link
Copy Markdown
Owner

Thanks for the PR! It looks like this branch has a merge conflict with the base branch right now. When you get a chance, could you rebase onto (or merge in) the latest base branch, resolve the conflict, and push? Once GitHub shows the PR as mergeable again, it'll be picked back up for review.

Noted for firstmate#220 at 6da91b3e.

@JJ22007
JJ22007 force-pushed the fm/fm-infra-fixes branch from 6da91b3 to 314bd9b Compare July 4, 2026 05:26
JJ22007 added 10 commits July 4, 2026 14:36
…; promote loopds/loopd

- fm-spawn.sh: default claude crewmate launches to claude-sonnet-5 (overridable),
  record tier=default|override|none in meta.
- fm-spawn.sh: propagate firstmate's proxy env (HTTP_PROXY etc.) into the
  treehouse-get window and the final launch command, so a spawned crewmate
  takes the same route as firstmate on a restricted network.
- Extract launch-command construction (shell_quote, proxy_env_prefix,
  model/effort flag builders, launch_template) into bin/fm-launch-lib.sh,
  shared by fm-spawn.sh and the new bin/fm-resume-worktree.sh.
- Add bin/fm-resume-worktree.sh: formalizes resuming a crewmate/scout task in
  its existing worktree (tmux backend only) after its runtime endpoint dies,
  without provisioning a fresh worktree via treehouse get.
- Promote the loopds/loopd skills from ~/.claude/skills into
  .agents/skills/, adopting two gnhf-derived mechanisms (backoff.mjs +
  drive.mjs backoff subcommand for infra-error exponential backoff; a
  unified run-id run directory convention documented in SKILL.md).
  autogrow.mjs is copied verbatim, unchanged.

fm-brief.sh's heredoc apostrophe bug (originally scoped as part of this
bundle) turned out to already be fixed and tested on main (PR kunchenguid#173);
nothing left to do there.
@JJ22007
JJ22007 force-pushed the fm/fm-infra-fixes branch from 314bd9b to 0c1a021 Compare July 4, 2026 06:37
@JJ22007

JJ22007 commented Jul 4, 2026

Copy link
Copy Markdown
Author

Closing this upstream contribution for now - applying the fix locally instead rather than continuing to require review from the template maintainer. Thanks for looking at it.

@JJ22007 JJ22007 closed this Jul 4, 2026
@i098 i098 mentioned this pull request Oct 21, 2026
fritznoff pushed a commit to fritznoff/starship that referenced this pull request Nov 2, 2026
…y instead of after the last one relabelled (kunchenguid#220)

Label a Herdr workspace shared by several projects neutrally.
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.

2 participants