Repository navigation
fix(bin): seed remote secondmates from supplied origins - #1836
Merged
kunchenguid merged 7 commits intoAug 7, 2026
Merged
Conversation
Remote seeding required a local projects/<name> clone purely to read `git remote get-url origin` into the provisioning manifest, so setting up a remote second mate forced disposable clones and no-mistakes inits in the primary home for projects that home has no reason to hold. Firstmate now resolves the origin itself and names it as <project>=<origin-url>. The seed validates and transports what it is given, and the receiving host re-validates it rather than trusting the sender; bin/fm-project-origin-lib.sh is the single owner of which URLs are accepted, refusing executable remote-helper transports, option-shaped values, and unusable spellings at both ends. A bare <project> still reads an already-present clone's origin, so nothing that works today has to change. Registry consistency is unchanged: an unregistered or local-only project is still refused. A remote seed therefore creates nothing in the primary home beyond the route, the charter, and its launch record. The lifecycle test now seeds a registered project the primary has never cloned and asserts the primary project tree is byte-identical afterwards, alongside refusals for a missing origin, an unsafe origin, a local-only project, and an unregistered project.
Firstmate is a shared template, so a project origin must be able to name any host: GitHub Enterprise on a private domain, GitLab hosted or self-hosted, Bitbucket, Gitea, Codeberg, sr.ht, a bare IP, an SSH config alias, or a plain server nobody else has heard of. The validator already decided on structure rather than on a forge allowlist, and this makes that guarantee explicit and closes the two gaps that a host-agnostic rule exposed: - a bracketed IPv6 literal in the scp-like form is now accepted, so a host reachable only by address is not excluded - a "/../" traversal inside a local or file: origin is now refused, because that names a path on the cloning host's own filesystem The library is the single owner of the accepted forms, and its header says plainly that there is no host, domain, or forge allowlist and there must never be one. The skill keeps its distinct agent-operating lines (the agent resolves and supplies the origin; a remote seed creates nothing in the primary home beyond the route, the charter, and its launch record) and points at the library for URL acceptance and at the operator doc for the rest. The lifecycle test now drives Bitbucket, a self-hosted enterprise domain, a self-hosted GitLab over ssh with a port, and a bare scp-like custom host through the real seed, manifest, transport, and remote provisioning path in one seed, asserting each URL reaches git unchanged and each clone carries its own origin's content. The unit matrix leads with non-GitHub hosts for the same reason.
Intent
Make remote secondmate seeding create no primary-home side effects beyond registering the remote route, and accept project origins from any host or forge. Firstmate shared, tracked material; captain direction 2026-08-04 after a real seed had to clone 6 repos into the primary home then remove them.
Problem: remote seed required a local projects/ clone only so it could read 'git remote get-url origin' into the provisioning manifest, forcing a disposable primary-side clone and a no-mistakes init during remote setup.
Captain's accepted requirements:
Non-goals ruled out by the captain: copying project trees from primary to remote (the remote still clones from origin), and removing the need for remote host credentials to fetch the origin.
Decisions and tradeoffs:
Delivery note: the previous run for this branch was cancelled because a GitHub Actions outage meant no workflow run was ever created for its pushed head, so its CI monitor could never see checks. That outage has lifted; this run re-pushes a fresh head for a genuine CI result. yolo is off, so the captain merges.
What Changed
<project>=<origin-url>, removing the requirement for a matching project clone in the primary home while retaining the existing-clone fallback for bare project names.Risk Assessment
✅ Low: The change is well-bounded, removes the mandatory primary clone path, validates supplied origins at both transport boundaries, and the authority-validation fix closes the previously identified malformed and option-shaped host paths without introducing a forge allowlist.
Testing
No separate baseline commands were supplied; both targeted executable tests passed, their evidence runs demonstrated forge-agnostic remote cloning and no primary project-tree mutation, and final cleanup verification found no testing changes in the worktree.
Evidence: Project origin validation transcript
Accepted ordinary clone URLs and refused executable, option-shaped, and unsafe forms. All tests passed.Evidence: Remote secondmate lifecycle E2E transcript
Demonstrates supplied-origin remote seeding without primary project-tree changes, receiver-side validation, and unchanged Bitbucket, self-hosted, and scp-like origins reaching remote clones. All tests passed.Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
🔧 **Review** - 1 issue found → auto-fixed ✅
bin/fm-project-origin-lib.sh:50- Required criterion 4 says to “validate STRUCTURE plus SAFETY” and “fail closed on malformed input [and] injection vectors,” but this hunk accepts every non-whitespace value after these scheme prefixes without parsing the authority. Consequently malformed origins such ashttps:///repo.git,ssh://:2222/repo.git, and invalid IPv6 spellings pass; option-shaped SSH hosts can also reach Git. Tighten validation at this shared sender/receiver boundary to require a structurally valid host/authority and reject option-shaped hosts, while retaining host/forge agnosticism.🔧 Fix: Validate project origin authorities safely
✅ Re-checked - no issues remain.
✅ **Test** - passed
✅ No issues found.
tests/fm-project-origin.test.shtests/fm-remote-secondmate-lifecycle-e2e.test.shtests/fm-project-origin.test.sh | tee /var/folders/0k/bf8mwt2n5qddzk24r20gfk0c0000gn/T/no-mistakes-evidence/01KZCM0792QMZQY587JAGF2YXW/project-origin-validation.txttests/fm-remote-secondmate-lifecycle-e2e.test.sh | tee /var/folders/0k/bf8mwt2n5qddzk24r20gfk0c0000gn/T/no-mistakes-evidence/01KZCM0792QMZQY587JAGF2YXW/remote-secondmate-lifecycle.txtgit status --shortconfirmed testing left the worktree unchanged✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.