Repository navigation
feat(bin): carry local-only projects on secondmate routes and land approved work in the project's own folder - #2700
EternalTime wants to merge 11 commits into
Conversation
…em back in the folder that holds the project
…local-only landing
|
Speaking as Kun's firstmate: Scheduled firstmate-oss pass. Diff reviewed against main (head Classification: default-behavior (not opt-in, not unprompted freelance writes). Landing inspection (the VISION question):
VISION:
Merge-eligible: YES, with captain flag because this is default-behavior (auto last-mile into the origin folder; local-only now seedable on local secondmate routes). Overlap: this PR and #2706 both add |
kunchenguid
left a comment
There was a problem hiding this comment.
Speaking as Kun's firstmate: reviewed the full diff. No security risk. Default-behavior last-mile of the captain-approved local merge path, not an unprompted primary-checkout write. Captain-flag NOW. Approve pending first-time fork CI.
Intent
Let a persistent second mate own a local-only project whose only copy is a folder on this machine, and make an approved landing reach that folder.
The driving case is the captain's job search: a git repository at /Users/owlshome/JobSearch with no remote at all and about 358 MB of personal material (CVs, cover letters, application answers, his address and phone, his referees' contact details) that he does not want on a forge. Before this change bin/fm-home-seed.sh refused it outright ("project
is local-only; secondmate routes support only no-mistakes and direct-PR projects") and the secondmate-provisioning skill and AGENTS.md said the same in prose. The captain asked for that limitation to be removed, NOT for his job search to be uploaded anywhere.
What was built:
git -C <his folder> pull --ff-only <clone> main. Git refuses a push into a non-bare repository's checked-out branch, so the landing pulls from the clone into the folder instead.Deliberate decisions a reviewer reading only the diff would not know:
git -C <clone> remote add origin <folder>command. It deliberately does NOT fall back to cloning from the local clone path, because that would build a two-hop chain whose landing could never reach the folder. This does mean the captain's existing projects/JobSearch clone, which has lost its origin, must be re-pointed before a second mate can be seeded with it; that is a project write, so it was left for the captain.Documentation followed the one-owner rule from the firstmate-coding-guidelines skill: the landing's stages, guards and refusals are owned by bin/fm-merge-local.sh's header; what a route may carry is owned by the secondmate-provisioning skill; where a local-only project's canonical copy lives is owned by the project-management skill; everything else cross-references. AGENTS.md only lost two lines and gained none, per its size discipline. bin/fm-doc-audience-check.sh passes.
Repo style constraints that were required: one full sentence per line in tracked Markdown, plain dash and never an em dash, no agent co-author, shellcheck-clean bin scripts under the pinned bin/fm-lint.sh, and tests colocated in tests/ as .test.sh extending the existing runner rather than adding a new one.
Known and deliberately out of scope, already reported to the supervisor rather than fixed here: tests/fm-calm-pi-extension.test.sh fails on a clean origin/main checkout in this environment (a live Pi plus tmux end-to-end check), and a local-only project whose clone has no origin cannot be spawned into at all because fm-spawn.sh's base freshening requires a reachable origin.
ALREADY-DECIDED CONTEXT FROM AN EARLIER VALIDATION ATTEMPT ON THIS SAME BRANCH. That attempt completed review, test, document and lint and then failed only at push for lack of repository permissions, so its commits are on this branch and its findings are settled. Please do not re-litigate the following, which were all raised, authorized by the captain, and applied:
# shellcheck disable=SC2088directives are intentional: the tilde is a literal character in a value read from or written to git config, never a path the shell should expand, so expanding it as ShellCheck suggests would delete the feature and its coverage.Delivery note for this attempt: the gate is now configured with the captain's fork as the push target, so the branch goes to that fork and the pull request is raised against the parent repository. An earlier hand-opened pull request from the fork was closed as superseded, because this repository requires every contribution to be raised through the gate and rejects a body missing the signature the gate itself writes.
What Changed
bin/fm-home-seed.shno longer refuses a local-only project on mode, and every mode now seeds from the project's own origin, so a second mate's clone is a sibling of this home's clone off the same folder instead of a copy of a copy; a source clone that has lost its origin refuses and names the exactgit -C <clone> remote add origin <folder>fix rather than falling back to a two-hop clone. Whole-home remote second mates still refuse local-only projects, now stating the real reason (the host can neither clone nor land into a folder that exists only on this machine), and the secondmate-provisioning skill, project-management skill, AGENTS.md and docs were updated to match.bin/fm-merge-local.shgains a guarded second stage: after the approved fast-forward into the clone, it carries that same default branch into the folder the clone names as origin with a fast-forward pull. The carry runs only when origin anchors to the root of a git work tree on this machine sitting on the same default branch, and refuses naming the paths when anything uncommitted, untracked or really-present gitignored overlaps a path the fast-forward would change or stands where it needs a directory, with git's own two-tree refusal kept as a backstop. Absent, bare and off-host origins are reported as "landing ended in the clone" rather than refused, and stage one's merge stands with "The change is safe in on " when stage two refuses, so a retry converges.bin/fm-project-origin-lib.shgained anchored local-path predicates andbin/fm-home-seed.shnow sources it so both owners of accepted origin forms agree by construction;bin/fm-spawn.shbase freshening tolerates an origin-less clone; the prose-only local-only prohibition on backlog handoff was removed with a test pinning that no mechanical mode gate exists; new suitestests/fm-merge-local.test.sh,tests/fm-project-origin.test.shandtests/fm-spawn-pool-base-freshen.test.shwere added, with the latter registered in the backend-dispatch family inbin/fm-test-run.sh.Risk Assessment
✅ Low: The round-2 delta is a pure 48-line deletion of a function that no longer had any caller, with zero remaining references anywhere in the repo and every surviving function in the lib byte-identical, leaving no substantiated defect open across the whole branch.
Testing
I ran the five targeted suites touched by this change (landing, origin library, secondmate safety/seeding, backlog handoff, remote lifecycle) and they all pass, then drove the real scripts through the captain's actual scenario: a git folder with no remote holding personal material and uncommitted work, a home clone off it, a second mate seeded on that local-only project, a crewmate branch, and an approved landing. The transcript shows the base commit refusing the same fixture outright, this branch seeding a clone whose origin is the folder itself (the sibling shape), the landing reporting both stages and reaching the folder, the owner's uncommitted CV edit and untracked and ignored notes surviving untouched, the path-overlap refusal naming CV.tex with the folder left at the same commit, the retry converging after that one path is reverted, the gitignored salary.md refusal that git's own ff-only would have deleted silently, the no-origin seeding refusal naming the exact remote-add command, and the local-only brief still forbidding push or PR. This change has no UI surface, so the reviewer-visible evidence is the CLI transcript rather than a screenshot; nothing failed and the worktree is clean.
Evidence: End-to-end CLI transcript: local-only second mate seeding and landing into the captain's folder
== ACT 3 - BEFORE this change: seeding refused the project outright == $ (base commit) bin/fm-home-seed.sh secondmate-jobs <subhome> JobSearch error: project JobSearch is local-only; secondmate routes support only no-mistakes and direct-PR projects == ACT 4 - AFTER: the same seed on this branch == $ bin/fm-home-seed.sh secondmate-jobs .../secondmate-jobs-home JobSearch home=/private/tmp/fm-e2e/secondmate-jobs-home the second mate clone is a SIBLING of the home clone off the same folder: $ git -C .../firstmate-home/projects/JobSearch remote get-url origin /private/tmp/fm-e2e/JobSearch $ git -C .../secondmate-jobs-home/projects/JobSearch remote get-url origin /private/tmp/fm-e2e/JobSearch == ACT 6 - the captain approves: bin/fm-merge-local.sh app-acme == merged fm/app-acme into local main (16afd1b -> dd34cd4) in .../secondmate-jobs-home/projects/JobSearch carried main into /private/tmp/fm-e2e/JobSearch (16afd1b -> dd34cd4) == ACT 7 - the change is in the folder the captain actually reads == $ cat .../JobSearch/cover-letters/acme-answers.md Q: why us? A: because your rail telemetry work is the problem I want. and his own uncommitted and ignored material is untouched: $ cat .../JobSearch/CV.tex Damian Sowinski - 07700 900123 - 12 Harbour Row - edited by hand today $ cat .../JobSearch/private-notes/referees.txt referee: Dr Vale, 07700 900456 == ACT 8 - a landing whose paths collide with his uncommitted work refuses == merged fm/app-beta into local main (dd34cd4 -> 4a37998) in .../projects/JobSearch REFUSED: .../JobSearch has work of its own on paths this landing would change (!! marks a path it ignores): M CV.tex The change is safe in .../projects/JobSearch on main; commit, move, or revert those paths yourself, then retry. exit=1 the folder never moved (dd34cd4 -> dd34cd4) and his edit survives == ACT 9 - he reverts that path, and the landing converges == carried main into /private/tmp/fm-e2e/JobSearch (dd34cd4 -> 4a37998) == ACT 10 - a gitignored file really sitting where the landing would write refuses == $ git -C .../ignored-case/JobSearch status --porcelain (git says clean: the file it would destroy is ignored) REFUSED: .../ignored-case/JobSearch has work of its own on paths this landing would change (!! marks a path it ignores): !! salary.md $ cat .../ignored-case/JobSearch/salary.md MY private salary figures - never share == ACT 11 - seeding refuses a clone that has lost its origin, and names the fix == error: project JobSearch is local-only and .../projects/JobSearch has no origin remote, so there is no folder to seed from and nowhere for a landing to return to point that clone at the folder holding the project first: git -C .../projects/JobSearch remote add origin <folder>Evidence: E2E driver script that reproduces the transcript
Evidence: Targeted suite case names (landing, origin library, backlog handoff)
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
bin/fm-merge-local.sh:131- An origin folder whose absolute path contains whitespace is accepted by seeding but permanently refused by the landing, with a remedy message that is already satisfied. Scenario: the canonical folder is /Users/owlshome/Job Search (a space is ordinary on macOS). bin/fm-home-seed.sh's normalize_origin_url runs canonical_path_for_check, gets "/Users/owlshome/Job Search", andgit clonesucceeds, so the second mate seeds fine. On the first approved landing, stage one merges into the clone, then line 131 calls fm_project_origin_local_path, which delegates to fm_project_origin_safe; that rejects any value matching [[:space:]] (bin/fm-project-origin-lib.sh:48) and returns 1. fm_project_origin_is_path_form is true, so line 133 prints "origin /Users/owlshome/Job Search is spelled as a path this landing may not follow" and line 134 advises "re-point that origin at the folder's absolute path" - which it already is. Every landing for that project refuses forever with no action that resolves it; the same dead end reaches relative and tilde origins once anchored, since ORIGIN_SPELLING is then the resolved absolute path. This is distinct from the deliberate relative-path refusal recorded in the intent: fm_project_origin_safe's whitespace rule exists for the transported-origin host boundary, not for a path the landing has already anchored on this machine. Marked ask-user because narrowing it means either loosening the single owner or having the landing accept an already-anchored absolute path with spaces, which is the author's design call.bin/fm-merge-local.sh:119- The landing expands a leading tilde against $HOME (lines 118-119) while bin/fm-home-seed.sh's normalize_origin_url does not, so the two owners the header claims agree do not agree for this spelling. With remote.origin.url =/JobSearch the landing carries into$HOME/JobSearch (pinned by test_landing_follows_an_origin_spelled_with_a_tilde), but seeding that same project takes canonical_path_for_check (bin/fm-home-seed.sh:103-108), whose non-slash branch builds "$ (pwd -P)//JobSearch" - a literal '~' directory under the clone - sogit clonefails and the transactional seed rolls back. Git itself also does not expand a tilde in a local-path remote, so such a clone cannot fetch from its own origin either. The comment at lines 108-111 ("so the landing and bin/fm-home-seed.sh agree about the same value") and the matching claim in the file header hold for the relative branch but not the tilde branches. Impact is a loud failure, not a wrong landing.bin/fm-merge-local.sh:121- The relative-origin anchor uses barecdinside a command substitution. With CDPATH exported (a common interactive-shell setting the script inherits) and an origin spelled as a bare relative name such asJobSearch, bash searches CDPATH first - POSIX skips CDPATH only for operands starting with /, ./ or ../ - and on a match prints the resolved directory to stdout. The substitution then captures two lines, fm_project_origin_safe rejects the embedded newline, and line 133 refuses a landing whose origin is actually fine. Line 102's PROJ_ABS=$(cd "$PROJ" && pwd -P) has the same exposure. The repo already treatsCDPATH='' cd --as the convention for this kind of path resolution (bin/fm-remote-file.sh:33, bin/fm-procevent-remote-reply.sh:285); applying it here is mechanical and changes no intended behavior.🔧 Fix: judge an already-anchored landing origin as a local path
1 info still open:
bin/fm-project-origin-lib.sh:197- fm_project_origin_local_path now has no production caller. It was added by this branch (85bd175) for bin/fm-merge-local.sh, and the round-1 fix (c692797) replaced that call site with fm_project_origin_anchored_local_path at bin/fm-merge-local.sh:144 while moving the not-a-local-path report up to the fm_project_origin_is_path_form gate at line 114. Grepping bin/ shows the surviving callers are fm_project_origin_safe (fm-remote-home-seed.sh:97,183; fm-remote-home-provision.sh:221), fm_project_origin_is_path_form (fm-merge-local.sh:114; fm-home-seed.sh:373), and the two anchored helpers; fm_project_origin_local_path is referenced only by its own definition and tests/fm-project-origin.test.sh:115,120. Its rewritten comment asserts it answers "does this TRANSPORTED origin name a repository the receiving machine can reach as a path", yet neither transport boundary calls it - both call fm_project_origin_safe directly - so the comment reads as load-bearing at the host boundary when nothing depends on it. Either delete the function with its dedicated test block, or say in the comment that it is currently uncalled and why it is kept. Marked ask-user because the intent explicitly records adding this function as a deliberate decision, so removing it is the author's call rather than a mechanical cleanup.🔧 Fix: drop the orphaned local-path origin helper and its coverage
1 info still open:
bin/fm-project-origin-lib.sh:189- The intent's deliberate-decisions list still says "fm_project_origin_local_path was added to bin/fm-project-origin-lib.sh, the existing single owner of accepted origin forms, rather than duplicating URL parsing in the landing script", but commit dbd7a98 deletes that function. This is not a behavioral contradiction and needs no change: the substance of the criterion holds, because bin/fm-merge-local.sh parses no origin URLs itself and calls only lib-owned predicates - fm_project_origin_is_path_form at line 114 and fm_project_origin_anchored_local_path/_fault at lines 144-145. The bullet is stale purely because the captain's round-2 instruction in this same run ("Authorized: delete it... It is dead code introduced by this branch") is a later, more specific decision by the same author than the intent text written before it. Recorded as no-op so a later phase composing the PR body or changelog does not carry the obsolete function name forward.✅ **Test** - passed
✅ No issues found.
bin/fm-test-run.sh tests/fm-merge-local.test.sh tests/fm-project-origin.test.sh tests/fm-secondmate-safety.test.sh tests/fm-backlog-handoff.test.sh- all pass (includes local-only seeding, the no-origin refusal, the no-mode-gate handoff and 22 landing cases)bin/fm-test-run.sh tests/fm-remote-secondmate-lifecycle-e2e.test.sh- all pass (the reworded remote local-only refusal)Manual end-to-end walkbash local-only-secondmate-e2e.shover real git repos: folder repo with no remote plus dirty personal material -> home clone ->bin/fm-home-seed.sh secondmate-jobs <subhome> JobSearch-> crewmate branchfm/app-acme->bin/fm-merge-local.sh app-acme-> landed file present in the folder, uncommitted/untracked/ignored material unchangedManual before/after: ran the base commit'sbin/fm-home-seed.sh(extracted withgit archive 1cb900c) on the same fixture to capture the old blanket refusalManual refusal checks: colliding uncommittedCV.tex(refuses naming the path, folder unmoved, stage one reported safe), revert-and-retry convergence, gitignoredsalary.mdreally present at a changed path (refuses with!! salary.md), seeding a clone with no origin (refuses and names thegit remote add originfix)Manual crewmate-contract check:FM_HOME=<seeded subhome> bin/fm-brief.sh app-delta JobSearch --mode local-onlyand inspected the delivery-contract section of the generated brief🔧 **Document** - 1 issue found → auto-fixed (2) ✅
.agents/skills/project-management/SKILL.md:73- The create path documents a local-only project whoseprojects/<name>clone is its only copy and "needs noorigin", butbin/fm-spawn.shrunsfreshen_spawn_worktree_baseon every fresh non-secondmate spawn, whose first step isgit fetch --quiet origin(bin/fm-spawn.sh:1732, gated at bin/fm-spawn.sh:2263). In a repo with no origin that exits 128, so no crewmate can be spawned into such a project at all. This is pre-existing behavior that predates the branch and the intent records it as known and deliberately out of scope, so I did not document a limitation the captain may prefer to fix in code instead. Follow-up: either make base freshening tolerate an origin-less clone, or state the limitation once in its owner (this skill's local-only create path, cross-referencing docs/architecture.md's spawn-base freshening paragraph).🔧 Fix: tolerate an origin-less clone when freshening a spawn base
1 warning still open:
bin/fm-test-run.sh:953- tests/fm-spawn-pool-base-freshen.test.sh is not named in any family case in bin/fm-test-run.sh, so it falls through tounclassified(bin/fm-test-run.sh:230). A change to bin/fm-spawn.sh selects only thebackend-dispatchandpure-contract-unitfamilies (bin/fm-test-run.sh:953-957), neither of which contains that suite. Change-based selection therefore does not run the very suite that owns freshen_spawn_worktree_base's behaviour, including the no-origin coverage added in this round. This is pre-existing (the suite was unclassified before this branch), but this change makes it directly load-bearing: the guard now has two paths and a regression on either would pass change-based selection silently. The fix is a one-line edit adding fm-spawn-pool-base-freshen.test.sh to the backend-dispatch family list at bin/fm-test-run.sh:203-206, which is an executable change outside this documentation phase and outside the code fix the captain authorized, so I did not make it.🔧 Fix: register spawn base-freshen suite in backend-dispatch family
✅ Re-checked - no issues remain.
✅ **Push** - passed
✅ No issues found.