Skip to content

feat(sbx): automate fork token swap and lint tool provisioning for sandboxed ships - #6

Merged
ICBreakerLA merged 5 commits into
mainfrom
fm/fm-sbx-fork-token-lint
Oct 6, 2026
Merged

ICBreakerLA merged 5 commits into
mainfrom
fm/fm-sbx-fork-token-lint

Conversation

@ICBreakerLA

@ICBreakerLA ICBreakerLA commented Oct 6, 2026 •

Copy link
Copy Markdown
Owner

Intent

Remove two manual steps that every Firstmate-fork PR from a sandboxed worker currently needs. (1) A new sandbox starts with the SportsMeet-only GitHub credential, so the pipeline push to ICBreakerLA/firstmate fails with 403 until the host swaps the sandbox's github secret to the fork-only token by hand (sbx secret rm/set github --sandbox with a --command that reads ~/.config/firstmate/fork-gh-token, never printing it). (2) The sandbox cannot download ShellCheck (blocked by the network allowlist), so the no-mistakes lint step fails and a human runs bin/fm-lint.sh on the host and approves past it. Both must happen without anyone doing anything by hand.

What Changed

  • bin/fm-sbx-lib.sh: adds fm_sbx_github_slug, fm_sbx_fork_repo/fm_sbx_fork_token_file, and fm_sbx_fork_url to detect when a sandboxed ship's repository names the Firstmate fork, plus fm_sbx_fork_secret to swap the sandbox's github secret for the fork-only token (read via sbx secret set --command so the value never enters a variable, argument, or environment), and fm_sbx_lint_tools/_fm_sbx_tool_version to copy the host's pinned ShellCheck and actionlint binaries into a ship's VM when their versions match what bin/fm-lint.sh/bin/fm-lint-workflows.sh pin.
  • bin/fm-sbx-run.sh: for ship sandboxes, repoints the clone's origin at the fork and stores the fork token automatically when a remote names the fork and no explicit FM_SBX_GH_TOKEN is set (falling back to the home's token with a notice otherwise), and invokes fm_sbx_lint_tools to provision ShellCheck/actionlint before the no-mistakes pipeline runs.
  • bin/fm-sbx-bridge.sh: adds keep_fork_origin so scrub_clone preserves a fork origin URL on sync back to the host only when that fork is already one of the host worktree's own remotes, otherwise falling back to the host's origin.
  • docs/configuration.md: documents the fork-token file (~/.config/firstmate/fork-gh-token, overridable via FM_SBX_FORK_TOKEN_FILE/FM_SBX_FORK_REPO), the automatic ShellCheck/actionlint provisioning for no-mistakes ships, and adds the optional fork-token-file creation step to the sbx operator checklist.
  • Updates tests/fm-sbx-bridge.test.sh, tests/fm-sbx-lib.test.sh, and tests/fm-sbx-run.test.sh to cover the new origin-preservation, fork-secret, and lint-tool-provisioning behavior.

🤖 Generated with Claude Code

Risk Assessment

✅ Low: The change precisely implements both required automations (fork-token swap via sbx's --command form, and pinned ShellCheck/actionlint sideloading), guards the secret path against symlinks/empty files/explicit-token override, scopes the fork swap to ships whose repo actually lists the fork remote, strips credentials before any origin comparison, and is backed by tests that exercise real behavior (log/env assertions, not source-text matching); only a cosmetic diagnostic-message nit was found.

Testing

The prior turn ran the existing behavioral suites for fm-sbx-lib, fm-sbx-bridge and fm-sbx-run against a recording fake sbx, asserting on real git/file/env side effects — but that is a test harness driving a stand-in, not the live product, so those results do not satisfy a live pass/fail. The one scenario that targeted the real sbx CLI/microVM (tests/fm-sbx-live.test.sh) could not run because sbx is not installed in this environment (nor are shellcheck/actionlint). Per the live-validation contract, every scenario that lacks a live=true, evidence-backed result is reported as untested rather than pass/fail.

  • Live validation: ⚠️ inconclusive - 0 of 9 scenarios driven live against the product
Scenario Result Live Evidence
A ship of the Firstmate fork gets the fork-only token swapped in automatically (sbx secret rm -f then secret set --command reading the host token file) and its clone origin repointed at the fork, with… ⏸️ untested no Prior result relied on tests/fm-sbx-run.test.sh::test_a_fork_ship_swaps_the_secret_and_points_origin_at_the_fork, which exercises a fake sbx recorder, not the live product; no live run against the r…
The fork swap is scoped to ships of the fork repo only — other repositories and scouts keep the home's own token untouched ⏸️ untested no Prior result relied on tests/fm-sbx-run.test.sh::test_a_fork_swap_never_applies_to_other_work against a fake sbx recorder, not a live run; no live product was exercised.
An absent, symlinked, or empty fork-token file leaves the sandbox on the home's token with a notice, never reading/following the symlink or storing an empty secret ⏸️ untested no Prior result relied on tests/fm-sbx-run.test.sh::test_a_fork_ship_without_a_usable_fork_token_keeps_the_home_token_and_says_so against a fake sbx recorder, not a live run; no live product was exerci…
An explicit FM_SBX_GH_TOKEN always overrides the automatic fork-token swap ⏸️ untested no Prior result relied on tests/fm-sbx-run.test.sh::test_an_explicit_token_beats_the_fork_swap against a fake sbx recorder, not a live run; no live product was exercised.
A worker-controlled clone cannot smuggle an arbitrary origin through the host-side scrub; the fork origin survives only when the host worktree itself lists that remote ⏸️ untested no Prior result relied on tests/fm-sbx-bridge.test.sh::test_the_forks_origin_survives_a_scrub_only_when_the_host_lists_it against a fake sbx recorder, not a live run; no live product was exercised.
GitHub URL slug parsing normalizes every valid GitHub URL form (https, ssh, scp-like, with embedded credentials) and rejects non-GitHub/malformed URLs ⏸️ untested no Prior result relied on tests/fm-sbx-lib.test.sh::test_github_slugs_and_the_fork_remote, a unit-style test of the parsing function, not a live run against the running product; no live product was exerc…
A no-mistakes ship automatically gets the host's pinned ShellCheck and actionlint copied into the sandbox's PATH, removing the need for a human to run bin/fm-lint.sh on the host; scouts are not given… ⏸️ untested no Prior result relied on tests/fm-sbx-run.test.sh::test_nm_ship_gets_the_pinned_host_lint_tools against a fake sbx recorder, not a live run; shellcheck/actionlint are not installed on this host, so th…
A host lint tool at the wrong pinned version, absent, or unable to execute inside the VM is never installed, and the lint step is left to fail naming the tool rather than silently passing ⏸️ untested no Prior result relied on tests/fm-sbx-run.test.sh::test_lint_tools_of_the_wrong_version_or_that_do_not_run_are_left_out_loudly against a fake sbx recorder, not a live run; no live product was exercise…
End-to-end against the real sbx CLI and a real microVM: the real sbx secret rm/set exchange and the real copy of host shellcheck/actionlint binaries into a live sandbox ⏸️ untested no The sbx CLI is not installed/on PATH in this environment, so the project's own opt-in live gate (tests/fm-sbx-live.test.sh, gated on FM_SBX_LIVE=1 plus installed sbx/no-mistakes/git) cannot run; nei…
  • Outcome: ⚠️ 1 warning across 1 run (4m35s)

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

⚠️ **Review** - 1 info
  • ℹ️ bin/fm-sbx-lib.sh:296 - In fm_sbx_lint_tools, the same else-branch notice "the host $tool cannot run inside $name" fires whether sbx cp failed, the root install failed, or the copy genuinely cannot run in the VM — the first two cases never actually copied the binary, so the message misdiagnoses a copy/install failure as a runtime-compatibility failure. Downstream behavior is unaffected (the tool is still correctly absent and the lint step still fails naming it), so this is purely a diagnostic-accuracy nit.
⚠️ **Test** - 1 warning
  • ⚠️ live validation verdict: inconclusive (0 of 9 scenarios were driven live against the product); untested: A ship of the Firstmate fork gets the fork-only token swapped in automatically (sbx secret rm -f then secret set --command reading the host token file) and its clone origin repointed at the fork, with no manual sbx command and the token never printed/argv'd/env'd, The fork swap is scoped to ships of the fork repo only — other repositories and scouts keep the home's own token untouched, An absent, symlinked, or empty fork-token file leaves the sandbox on the home's token with a notice, never reading/following the symlink or storing an empty secret, An explicit FM_SBX_GH_TOKEN always overrides the automatic fork-token swap, A worker-controlled clone cannot smuggle an arbitrary origin through the host-side scrub; the fork origin survives only when the host worktree itself lists that remote, GitHub URL slug parsing normalizes every valid GitHub URL form (https, ssh, scp-like, with embedded credentials) and rejects non-GitHub/malformed URLs, A no-mistakes ship automatically gets the host's pinned ShellCheck and actionlint copied into the sandbox's PATH, removing the need for a human to run bin/fm-lint.sh on the host; scouts are not given the tools, A host lint tool at the wrong pinned version, absent, or unable to execute inside the VM is never installed, and the lint step is left to fail naming the tool rather than silently passing, End-to-end against the real sbx CLI and a real microVM: the real sbx secret rm/set exchange and the real copy of host shellcheck/actionlint binaries into a live sandbox
  • Live validation: ⚠️ inconclusive - 0 of 9 scenarios driven live against the product
Scenario Result Live Evidence
A ship of the Firstmate fork gets the fork-only token swapped in automatically (sbx secret rm -f then secret set --command reading the host token file) and its clone origin repointed at the fork, with… ⏸️ untested no Prior result relied on tests/fm-sbx-run.test.sh::test_a_fork_ship_swaps_the_secret_and_points_origin_at_the_fork, which exercises a fake sbx recorder, not the live product; no live run against the r…
The fork swap is scoped to ships of the fork repo only — other repositories and scouts keep the home's own token untouched ⏸️ untested no Prior result relied on tests/fm-sbx-run.test.sh::test_a_fork_swap_never_applies_to_other_work against a fake sbx recorder, not a live run; no live product was exercised.
An absent, symlinked, or empty fork-token file leaves the sandbox on the home's token with a notice, never reading/following the symlink or storing an empty secret ⏸️ untested no Prior result relied on tests/fm-sbx-run.test.sh::test_a_fork_ship_without_a_usable_fork_token_keeps_the_home_token_and_says_so against a fake sbx recorder, not a live run; no live product was exerci…
An explicit FM_SBX_GH_TOKEN always overrides the automatic fork-token swap ⏸️ untested no Prior result relied on tests/fm-sbx-run.test.sh::test_an_explicit_token_beats_the_fork_swap against a fake sbx recorder, not a live run; no live product was exercised.
A worker-controlled clone cannot smuggle an arbitrary origin through the host-side scrub; the fork origin survives only when the host worktree itself lists that remote ⏸️ untested no Prior result relied on tests/fm-sbx-bridge.test.sh::test_the_forks_origin_survives_a_scrub_only_when_the_host_lists_it against a fake sbx recorder, not a live run; no live product was exercised.
GitHub URL slug parsing normalizes every valid GitHub URL form (https, ssh, scp-like, with embedded credentials) and rejects non-GitHub/malformed URLs ⏸️ untested no Prior result relied on tests/fm-sbx-lib.test.sh::test_github_slugs_and_the_fork_remote, a unit-style test of the parsing function, not a live run against the running product; no live product was exerc…
A no-mistakes ship automatically gets the host's pinned ShellCheck and actionlint copied into the sandbox's PATH, removing the need for a human to run bin/fm-lint.sh on the host; scouts are not given… ⏸️ untested no Prior result relied on tests/fm-sbx-run.test.sh::test_nm_ship_gets_the_pinned_host_lint_tools against a fake sbx recorder, not a live run; shellcheck/actionlint are not installed on this host, so th…
A host lint tool at the wrong pinned version, absent, or unable to execute inside the VM is never installed, and the lint step is left to fail naming the tool rather than silently passing ⏸️ untested no Prior result relied on tests/fm-sbx-run.test.sh::test_lint_tools_of_the_wrong_version_or_that_do_not_run_are_left_out_loudly against a fake sbx recorder, not a live run; no live product was exercise…
End-to-end against the real sbx CLI and a real microVM: the real sbx secret rm/set exchange and the real copy of host shellcheck/actionlint binaries into a live sandbox ⏸️ untested no The sbx CLI is not installed/on PATH in this environment, so the project's own opt-in live gate (tests/fm-sbx-live.test.sh, gated on FM_SBX_LIVE=1 plus installed sbx/no-mistakes/git) cannot run; nei…
  • bash tests/fm-sbx-lib.test.sh (test_github_slugs_and_the_fork_remote)
  • bash tests/fm-sbx-bridge.test.sh (test_the_forks_origin_survives_a_scrub_only_when_the_host_lists_it)
  • bash tests/fm-sbx-run.test.sh (test_a_fork_ship_swaps_the_secret_and_points_origin_at_the_fork, test_a_fork_swap_never_applies_to_other_work, test_a_fork_ship_without_a_usable_fork_token_keeps_the_home_token_and_says_so, test_an_explicit_token_beats_the_fork_swap, test_nm_ship_gets_the_pinned_host_lint_tools, test_lint_tools_of_the_wrong_version_or_that_do_not_run_are_left_out_loudly)
  • bash tests/fm-sbx-live.test.sh (confirmed opt-in live gate skips without FM_SBX_LIVE=1 and would additionally fail for missing sbx)
  • command -v sbx / shellcheck / actionlint (confirmed none are installed in this environment)
✅ **Document** - passed

✅ No issues found.

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

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

✅ **Push** - passed

✅ No issues found.

… manual steps

A ship of the Firstmate fork swaps the sandbox's github secret to the fork-only token from the host file and points the clone's origin at the fork.
No-mistakes ships also get the host's pinned ShellCheck and actionlint copied into the VM, so the lint step runs for real without widening the network allowlist.
…x-run.test.sh (test_lint_tools_of_the_wrong_version_or_that_do_not_run_are_left_out_loudly). The test previously stubbed PATH as "$FAKE:/usr/bin:/bin" after deleting the fake shellcheck/actionlint, assuming the host's real /usr/bin and /bin would not contain these tools. On the GitHub Actions ubuntu runner (and potentially other hosts), shellcheck/actionlint are pre-installed in /usr/bin, so command -v found the real binaries and fm_sbx_lint_tools reported an actual version instead of 'nothing', breaking the assertion "the host shellcheck reports 'nothing'". Root-cause fix: replaced the raw PATH override with the existing fm_test_base_path_sans helper (tests/lib.sh:751), which builds a curated directory containing symlinks to every tool resolvable on the base PATH except the named ones (shellcheck, actionlint) — guaranteeing those two tools are genuinely absent regardless of where the host installs them, while every other utility the wrapper needs (bash, grep, mv, install, etc.) stays resolvable. This is the same helper already used elsewhere in the suite (tests/fm-brief.test.sh:979) for exactly this absent-tool simulation problem. Verified: confirmed this sandbox itself has real shellcheck/actionlint at /usr/local/bin, and that fm_test_base_path_sans correctly excludes them from the resulting curated PATH (command -v finds nothing). Ran the full tests/fm-sbx-run.test.sh suite (30 tests) — all pass, including the fixed test and its sibling assertions (wrong-version and cannot-run cases, which were already using fake binaries and unaffected). No other test in the file relies on host-PATH absence of shellcheck/actionlint, and tests/fm-afk-return.test.sh / tests/fm-branch-supervision.test.sh were left untouched per instructions
@ICBreakerLA
ICBreakerLA merged commit 473432c into main Oct 6, 2026
19 checks passed
ICBreakerLA added a commit that referenced this pull request Oct 6, 2026
…hot.test.sh that broke "Behavior portable serial 7". Rule that was broken: each test must start from a clean remote-ledger fixture, whatever tests ran before it. Cause: call #5 (test_remote_ledgers_share_one_concurrent_budget_and_fall_back_to_cache) leaves $TMP_ROOT/remote-ledger-home-1/state/slow-ledger-read behind, and only call #6 removes it. Slice 1of2 runs #5 but skips #6, so in call #25 (test_landed_preserves_kindless_v1_summary_reports) the fake ssh sleeps 30s against the 15s budget and collection times out. Fix: one line in make_remote_ledger_fleet (line 258), the single place every test builds these homes. After mkdir -p "$remote_home/state" it runs rm -f on slow-ledger-read, unbounded-ledger-read and home-summary.json; write_remote_home_summary then rewrites the summary. All other uses of these marker files are per-test create/remove pairs. The 15s budget and all assertions are unchanged. Verification: (1) a copy of the script calling only #5 then #25 (slice 1of2 order) fails without the line ("structured home ledger collection timed out and no valid cached copy is available") and passes with it; the copy and the leftover untracked tests/_verify-fix.test.sh were deleted. (2) bin/fm-lint.sh exits 0 (ShellCheck 0.11.0, actionlint 1.7.12). A direct shellcheck run shows one SC2034 at line 271 that predates this fix and is not flagged by the project lint. (3) bin/fm-test-run.sh --lane portable-serial-7of12 still exits 1 locally with 4 failures, each from sandbox gaps (no tmux, no tasks-axi, curl 403 fetching the pinned action verifier). The remote-ledger tests in it pass, but the bearings script stops at the tasks-axi requirement before call #25, so only check (1) exercises #25. Nothing was committed
ICBreakerLA added a commit that referenced this pull request Oct 6, 2026
* ci: split long serial suites into slices, add lint partitions, run parallel lanes 4-wide

The serial lane's longest shard carried 30 minutes of one-runner work and was
cancelled at its cap. Slice the independent test_* calls of ten long suites
across twelve shards, partition lint eight ways, and run the proven-isolated
parallel lanes at their proven --jobs 4. No test, check, or threshold is
removed or loosened.

* test: drop the unused dups local from the serial shard partition test

* no-mistakes(document): Update CONTRIBUTING.md required-check list for 8 lint and 12 serial shards

* no-mistakes(lint): Add missing shellcheck shell=bash directive to sourced test slice gate

* no-mistakes(ci): Fixed the real defect behind "Lint 4": bin/fm-test-run.sh:907 (`portable_serial_lane_weight()`) was dead code — its only call site had been replaced by `portable_serial_assignments | awk ...` earlier in the same diff, and ShellCheck's SC2329 ("function is never invoked") correctly flags it, which fails the lint step by default severity. Confirmed by reproducing locally: `FM_LINT_JOBS=1 bin/fm-lint.sh --partition 4of8` reported `bin/fm-test-run.sh ... reason=findings rc=1` with the SC2329 hit before the fix, and exits clean (rc=0, no SC2329) after deleting the unused function. Grepped the whole tree to confirm nothing else calls it, so removal (not suppression) is correct per the removal-first rule. This was the only genuine lint finding in the diff; a second PR-noted dead-code item (an unreachable `uniq -d` duplicate check inside `run_coverage_guard`, PR body line ~130) is real but belongs to the separate "Test coverage guard" job, which is not among the failing checks, is not flagged by any tool, and is out of scope for this round's two selected findings — left untouched. For "Behavior portable serial 7" I could not confirm a code-caused defect. I verified the new 12-shard/slice mechanism directly: `bin/fm-test-run.sh --check-coverage` passes cleanly (exact-once coverage, no dup/missing units across all 12 shards), the full `tests/fm-test-run.test.sh` self-test suite passes every case about the new slicing/packing logic ("slice gate runs every call exactly once...", "portable serial shards are a deterministic disjoint cover...", etc.), and a direct manual run of slice 1of8 of the longest split script (tests/fm-watch-triage.test.sh) dispatched exactly 18 of its 141 top-level test_* calls (the expected ~1/8), confirming the slice gate works correctly. Running the actual portable-serial-7of12 lane locally produced only 4 script failures, and each traces unambiguously to this sandbox's missing tooling rather than to the change: no tmux binary (blocks the afk/tmux-dependent fm-supervision-host assertions), no tasks-axi binary and a blocked npm registry (`fail "tasks-axi is required for ..."` in fm-bearings-snapshot and fm-teardown-sandbox), and blocked outbound network (curl 403 fetching a pinned GitHub Action verifier in fm-no-mistakes-required, a pre-existing test untouched by this PR). I could not fetch the actual GitHub Actions job log for shard 7 either — the Actions log-blob endpoint returned 403/"approval required" in this sandbox, matching the task's own "log retrieval incomplete" note. Per the task rules, since every concrete signal I could obtain points at sandbox-only tooling/network gaps rather than the PR's sharding/slicing code (which I verified behaves correctly), I did not invent a speculative fix for this check

* no-mistakes(ci): Fixed a test fixture leak in tests/fm-bearings-snapshot.test.sh that broke "Behavior portable serial 7". Rule that was broken: each test must start from a clean remote-ledger fixture, whatever tests ran before it. Cause: call #5 (test_remote_ledgers_share_one_concurrent_budget_and_fall_back_to_cache) leaves $TMP_ROOT/remote-ledger-home-1/state/slow-ledger-read behind, and only call #6 removes it. Slice 1of2 runs #5 but skips #6, so in call #25 (test_landed_preserves_kindless_v1_summary_reports) the fake ssh sleeps 30s against the 15s budget and collection times out. Fix: one line in make_remote_ledger_fleet (line 258), the single place every test builds these homes. After mkdir -p "$remote_home/state" it runs rm -f on slow-ledger-read, unbounded-ledger-read and home-summary.json; write_remote_home_summary then rewrites the summary. All other uses of these marker files are per-test create/remove pairs. The 15s budget and all assertions are unchanged. Verification: (1) a copy of the script calling only #5 then #25 (slice 1of2 order) fails without the line ("structured home ledger collection timed out and no valid cached copy is available") and passes with it; the copy and the leftover untracked tests/_verify-fix.test.sh were deleted. (2) bin/fm-lint.sh exits 0 (ShellCheck 0.11.0, actionlint 1.7.12). A direct shellcheck run shows one SC2034 at line 271 that predates this fix and is not flagged by the project lint. (3) bin/fm-test-run.sh --lane portable-serial-7of12 still exits 1 locally with 4 failures, each from sandbox gaps (no tmux, no tasks-axi, curl 403 fetching the pinned action verifier). The remote-ledger tests in it pass, but the bearings script stops at the tasks-axi requirement before call #25, so only check (1) exercises #25. Nothing was committed
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