Repository navigation
feat(spawn): neutralize signing and SSH-routing hangs in no-mistakes internal clones - #5
Merged
Merged
Conversation
…edential hangs
The no-mistakes pipeline commits and pushes inside its own internal clone at
~/.no-mistakes/repos/<hash>.git, which fm-sign-lib's per-worktree override never
reaches. That clone inherits the operator's global git config, so on a machine
like the captain's it hits two unattended-hostile settings that block autonomous
validation runs:
- Surface 3: global commit.gpgsign=true drives a GUI signer no autonomous run
can click, hanging every pipeline commit.
- Surface 4: a global url."[email protected]:".insteadOf=https://github.com/
rewrites plain-HTTPS network ops to SSH (same GUI agent), and the default
macOS credential chain (osxkeychain) hangs when the keychain is locked.
Both were recovered manually on ark PR kunchenguid#337 and dotfiles PR #4 with the same
dodge. This automates it: bin/fm-nm-clone-config.sh locates the internal clone via
the project's own no-mistakes remote (hash-independent) and scopes, repo-local to
that clone only, commit/tag.gpgsign=false plus, when SSH routing is detected, the
username-form origin URL + reverse insteadOf + gh credential helper. The operator's
global config, the no-mistakes install, and every project clone are never touched.
Timing: applied at spawn time (fm-spawn.sh, the deterministic firstmate-owned
guarantee, where fm-sign-lib already lives) and re-applied by a ship-brief line
right before /no-mistakes (the internal clone can be created mid-run, after spawn).
Both applications are idempotent. Every piece is a graceful no-op on a machine
without the problem: no no-mistakes remote, no global gpgsign, no insteadOf, or no
gh each shrink the work to nothing without error.
Tests simulate a fake global config + internal clone + project with a curated
PATH-shimmed gh, covering the full dodge, gh-absent username fallback, clean
machine, non-gated repo, no-resolvable-username, and idempotency.
…ellcheck in tests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Intent
Eliminate the two remaining unattended-credential failure surfaces that hang autonomous no-mistakes pipeline runs on the captain's machine. Firstmate PR #1 already scoped commit/tag signing off per task worktree (fm-sign-lib), but the no-mistakes pipeline actually commits and pushes inside its own INTERNAL clone at ~/.no-mistakes/repos/.git, which fm-sign-lib never reaches. That internal clone inherits the operator's global git config and hits two unattended-hostile settings: (surface 3) global commit.gpgsign=true drives a GUI signer no autonomous run can click, hanging every pipeline commit; and (surface 4) a global url."[email protected]:".insteadOf=https://github.com/ rewrites plain-HTTPS git network ops to SSH (needs the same GUI agent), while the default macOS osxkeychain credential helper also hangs when the keychain is locked. Both were recovered manually on ark PR kunchenguid#337 and dotfiles PR #4 with the same dodge. This change adds bin/fm-nm-clone-config.sh, which locates the internal clone via the project's own no-mistakes git remote (deliberately hash-independent, rather than reproducing no-mistakes' sha256(repo-path) hash) and applies, repo-local to that internal clone ONLY: commit.gpgsign=false + tag.gpgsign=false, and when SSH routing is detected (ssh-form origin OR a global github insteadOf rewrite) a username-form origin URL https://@github.com//.git that escapes the global insteadOf, a repo-local reverse insteadOf as a belt, and a credential.helper reset to empty-then-'!gh auth git-credential'. Deliberate design choices a diff-only reviewer would not know: (1) commit.gpgsign=false is set UNCONDITIONALLY on the internal clone, mirroring the sibling fm-sign-lib, because it is effect-equivalent to a no-op when the operator has no global signing and it is robust to global config changing between spawn and validation; (2) the credential-helper and origin-URL dodge are intentionally gated on SSH-routing detection so a clean machine (plain-HTTPS origin, no insteadOf) is left completely untouched - this is why a locked-keychain-without-insteadOf case is deliberately NOT handled, matching the proven manual dodge and avoiding overriding other users' credential setup; (3) the GitHub username is derived at runtime (gh api user, falling back to parsing a user@ from the project origin) because this repo is a shared template that must carry no captain-specific values; (4) every piece is a graceful no-op when there is no no-mistakes remote, no global gpgsign, no insteadOf, or no gh. Timing decision (stated in the commit): applied at spawn time in fm-spawn.sh next to fm-sign-lib as the deterministic firstmate-owned guarantee, AND re-applied by a one-line ship-brief instruction right before /no-mistakes because the internal clone can be created mid-run after spawn; both applications are idempotent. Also: no AGENTS.md change, consistent with the fm-sign-lib PR #1 precedent that this class of automatic config-only infra hardening carries no operating-instruction line. Tests in tests/fm-nm-clone-config.test.sh simulate a fake global config + fake bare internal clone + fake project with a curated PATH-shimmed gh (no real daemon or network), covering the full dodge, gh-absent username fallback, clean machine, non-gated repo, no-resolvable-username, and idempotency. Live dogfood evidence: I ran the new helper against this repo's own previously-unfixed internal clone (bc282c225d8f.git) and it converted [email protected]:7hoenix/firstmate.git to https://[email protected]/7hoenix/firstmate.git, set gpgsign=false, and installed the gh credential helper, with the operator's global config verified untouched - so this very validation run should not hang on signing or credentials.
What Changed
bin/fm-nm-clone-config.sh, which locates the pipeline's internal clone via the project's ownno-mistakesgit remote (hash-independent) and applies, repo-local to that clone only:commit.gpgsign=false/tag.gpgsign=falseunconditionally, plus - when SSH routing is detected (ssh-form origin or a globalgithub.cominsteadOf rewrite) - ahttps://<user>@github.com/...origin that escapes the global insteadOf, a repo-local reverse insteadOf belt, and agh-backed credential helper reset. The GitHub username is resolved at runtime (gh api user, falling back to parsing the project origin) so no captain-specific values are baked in, and every step is a graceful no-op when the remote, global config, orghis absent.bin/fm-spawn.shso it runs at spawn time next to the sign-off logic, and added a one-line ship-brief instruction inbin/fm-brief.shto re-apply it right before/no-mistakes(idempotent) since the internal clone can be created after spawn; documented the script indocs/scripts.md.tests/fm-nm-clone-config.test.shcovering the full dodge, gh-absent username fallback, clean-machine no-op, non-gated repo, no-resolvable-username, and idempotency against a fake global config and bare internal clone with a PATH-shimmedgh; hardened the shared test harness (tests/lib.sh,tests/herdr-test-safety.sh,tests/fm-cd-pretool-check.test.sh) to isolate host git signing config and skip the absent-shellcheck path.Risk Assessment
✅ Low: Purely additive, best-effort, idempotent infra hardening scoped to an internal clone only, with the global config and project clones never touched, backed by thorough hermetic tests covering every branch; the two findings are rare edge cases already mitigated by bootstrap's gh-auth precondition.
Testing
Baseline configured e2e suite ran green before this round; I re-ran the new tests/fm-nm-clone-config.test.sh (all six scenarios ok) and the modified tests/fm-cd-pretool-check.test.sh (all ok), then re-ran a subset of the full suite until the slow e2e tests hit the 2m harness timeout (a speed limit, not a failure). For product-level evidence I built an isolated end-to-end demo — fake HOME carrying the captain's two unattended-hostile global settings, a PATH-shimmed gh, a fake bare internal clone reachable through a project no-mistakes remote — and ran the real helper: it forced commit/tag signing off, rewrote the ssh-form origin to the username-HTTPS form https://[email protected]/7hoenix/firstmate.git that escapes the global insteadOf, added the reverse-insteadOf belt and the gh credential helper, left the operator's global config verifiably untouched, and was a clean no-op on re-run. This CLI transcript (no source changes) directly shows the pipeline-hang fix as an autonomous run would experience it; working tree confirmed clean afterward.
Evidence: End-to-end internal-clone hardening transcript (before/after/idempotent, global config untouched)
BEFORE: internal clone inherits commit.gpgsign=true, ssh-form origin, global insteadOf rewrite. RUN: bin/fm-nm-clone-config.sh <project> -> exit 0 AFTER (repo-local to internal clone ONLY): commit.gpgsign=false ; tag.gpgsign=false origin [email protected]:7hoenix/firstmate.git -> https://[email protected]/7hoenix/firstmate.git repo-local reverse insteadOf belt added credential.helper: [] then [!gh auth git-credential] GLOBAL CONFIG UNTOUCHED (gpgsign still true, insteadOf still present, no gh helper added globally) IDEMPOTENT: second run exit 0, origin + single credential.helper unchangedPipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
bin/fm-nm-clone-config.sh:125- The credential.helper reset+gh block (line 125) is gated only oncommand -v gh, independently of whether USER was resolved and origin was actually rewritten. In the rare case where gh is present butgh api userreturns empty (unauthenticated/API failure) AND the project origin is ssh-form (no user@ to parse), the origin stays SSH (no rewrite) yet credential.helper is still replaced. Result is a spurious config edit on an internal clone whose push still routes over SSH and hangs - a half-applied dodge rather than the clean skip the no-username test asserts for the gh-absent path. In the real firstmate flow this is largely unreachable because bootstrap enforcesNEEDS_GH_AUTH(gh auth good) before any dispatch, sogh api usersucceeds. Consider gating the credential block on USER being resolved (i.e. that the origin was actually moved to HTTPS) so credentials are only touched when they can matter.bin/fm-nm-clone-config.sh:78-global_rewritedetection matches ANY global github.com insteadOf rule regardless of rewrite direction (--get-regexp ... | grep -qi github.com, line 78). A benign global insteadOf that preserves HTTPS (e.g.url.https://github.com/.insteadOf = git://github.com/) would still set global_rewrite=true and trigger the full origin+credential dodge, touching credential.helper on a machine that is effectively HTTPS-clean - diverging slightly from the stated intent to leave clean machines completely untouched. In practice the only common github insteadOf is the HTTPS->SSH one this targets, so the over-trigger is a reasonable simplicity tradeoff and low risk.🔧 **Test** - 1 issue found → auto-fixed ✅
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: isolate host git signing config and skip absent-shellcheck in tests
✅ 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"bash tests/fm-nm-clone-config.test.sh— full dodge, gh-absent username fallback, clean-machine no-op, non-gated repo, no-resolvable-username, idempotency (all ok)bash tests/fm-cd-pretool-check.test.sh— modified test file, all cases pass incl. new absent-shellcheck skipBaseline configured suite (for t in tests/*.test.sh) previously ran green; re-ran a subset (afk-inject e2e passing) before the 2m harness timeout on the slow full e2e setManual E2E: ranbin/fm-nm-clone-config.sh <project>against a fake bare internal clone + PATH-shimmed gh under an isolated HOME simulating global commit.gpgsign=true and url."[email protected]:".insteadOf; verified signing forced off, origin rewritten to https://[email protected]/... , reverse insteadOf belt, gh credential helper, operator global config untouched, and idempotent re-runInspected fm-spawn.sh and fm-brief.sh integration points confirming spawn-time application and ship-brief re-apply-before-/no-mistakes wiring✅ **Document** - passed
✅ No issues found.
🔧 Fix: no lint issues; scripts clean under pinned shellcheck
1 warning still open:
🔧 Fix: no lint issues; scripts clean under pinned shellcheck 0.11.0
1 warning still open:
🔧 Fix: no lint fixes needed; canonical set clean under shellcheck 0.11.0
1 warning still open:
✅ **Push** - passed
✅ No issues found.