Skip to content

feat(bin): carry local-only projects on secondmate routes and land approved work in the project's own folder - #2700

Open
EternalTime wants to merge 11 commits into
kunchenguid:mainfrom
EternalTime:fm/fm-secondmate-local-only
Open

EternalTime wants to merge 11 commits into
kunchenguid:mainfrom
EternalTime:fm/fm-secondmate-local-only

Conversation

@EternalTime

Copy link
Copy Markdown

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:

  1. Seeding accepts a local-only project. clone_project and validate_seed_project no longer refuse 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 rather than a copy of a copy. That sibling shape is what lets a landing reach the folder in one hop.
  2. Its crewmates already deliver correctly (implement on fm/, stop with a clean ready branch, no push, no PR): bin/fm-brief.sh's local-only contract needed no change, and deliberately got none.
  3. The second mate lands approved work through the existing bin/fm-merge-local.sh under the same merge authority as before.
  4. That landing now continues past the clone into the folder that holds the project. This implements the already-queued firstmate work item fm-landing-pull-into-captain-folder rather than inventing a second mechanism; that item records that every prior session did this by hand as 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.
  5. Backlog handoff for local-only items: bin/fm-backlog-handoff.sh turned out to have NO mechanical mode gate at all - the prohibition existed only as prose in the secondmate-provisioning skill. The prose is gone and a new test pins that no mode gate exists, rather than adding then removing code.

Deliberate decisions a reviewer reading only the diff would not know:

  • The dirty-folder rule is deliberately scoped to PATH OVERLAP, not to any dirtiness. The captain's folder is essentially always dirty (31 uncommitted entries right now), so refusing on any uncommitted work would mean landings never work at all. The landing computes the paths the fast-forward would change and asks git whether any of them is also uncommitted or untracked in the folder, refuses naming those paths, and additionally keeps git's own two-tree ff-only refusal as a backstop. Both layers are intended; the second is not redundant, it catches cases the pathspec check cannot express (for example an untracked file blocking a directory the incoming commit needs).
  • Seeding REFUSES a local-only project whose source clone has no origin, and names the exact 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.
  • The landing REPORTS rather than refuses when origin is absent, bare, or a URL on another host. Those are all legitimate shapes in which the clone genuinely is the endpoint: project-management explicitly supports a local-only project created as a standalone repo under projects/ with no origin. Only a broken origin (a path that is missing, or is not the root of a git work tree) refuses.
  • Stage one's merge stands even when stage two refuses. Stage one is the separately approved merge into the clone; a refused carry is reported with "The change is safe in on " and converges on retry once the folder is ready.
  • The origin folder must be the ROOT of a work tree, not merely inside one, because git answers happily for an enclosing repository and an origin pointing at a subdirectory would otherwise land the change in an unrelated repository.
  • Whole-home REMOTE second mates still refuse local-only projects. That exclusion is kept on purpose (the host can neither clone a folder that exists only on this machine nor receive a landing into it) and its message and docs now state that real reason instead of the old blanket rule.
  • 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.
  • Fleet sync's local-only skip was deliberately NOT changed. It is out of scope, and it is not needed: fm-spawn.sh's freshen_spawn_worktree_base already fetches origin and resets each fresh worker's worktree to origin/, so a worker's base stays current with the folder without touching fleet sync.
  • tests/fm-merge-local.test.sh was placed in the pr-forge family because bin/fm-merge-local.sh already maps to pr-forge for change-based selection.

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:

  • Gitignored files in the origin folder: the collision probe uses --ignored=matching so an ignored file really present at a path the landing would change refuses, because git's own two-tree check refuses an untracked blocker but silently REMOVES an ignored one. A later round extended the same probe to ancestor prefixes of each changed path that exist and are not directories, so an ignored FILE standing where the landing needs a directory also refuses instead of being silently deleted. Both are covered by tests.
  • Over-refusal was deliberately removed: a wholly-ignored directory holding unrelated files must NOT block a landing that only adds a new file beneath it, and there is a test asserting that. The narrow rule is "an entry naming a path that actually exists among the changed paths", not "any dirtiness".
  • Relative and tilde-spelled origins are resolved against the clone before classification, deliberately matching normalize_origin_url, so the two owners agree; the landing prints one advisory line naming the resolved absolute path because a clone spelled that way can receive a landing but cannot have a worker spawned into it. fm_project_origin_safe was deliberately NOT loosened, because bin/fm-remote-home-seed.sh depends on its refusal of relative paths at the host boundary.
  • bin/fm-home-seed.sh now sources bin/fm-project-origin-lib.sh and normalize_origin_url calls fm_project_origin_is_path_form, so the single-owner claim is enforced by construction rather than asserted in a comment.
  • The three # shellcheck disable=SC2088 directives 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.
  • Test-selection comments naming bin/fm-project-origin-lib.sh in tests/fm-merge-local.test.sh and tests/fm-secondmate-safety.test.sh exist so change-based selection reaches those suites; they are load-bearing, not stray comments.

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.sh no 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 exact git -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.sh gains 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.
  • Supporting changes: bin/fm-project-origin-lib.sh gained anchored local-path predicates and bin/fm-home-seed.sh now sources it so both owners of accepted origin forms agree by construction; bin/fm-spawn.sh base 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 suites tests/fm-merge-local.test.sh, tests/fm-project-origin.test.sh and tests/fm-spawn-pool-base-freshen.test.sh were added, with the latter registered in the backend-dispatch family in bin/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>


== ACT 1 - the captain's folder: a git repo with no remote and personal material ==

$ git -C '/private/tmp/fm-e2e-cMRP/JobSearch' remote -v; echo '(no remote at all)'
  (no remote at all)

$ git -C '/private/tmp/fm-e2e-cMRP/JobSearch' status --porcelain
   M CV.tex
  ?? scratch.md

== ACT 2 - the captain's home clone of that folder ==

$ cat '/private/tmp/fm-e2e-cMRP/firstmate-home/data/projects.md'
  - JobSearch [local-only +yolo] - the job search (added 2026-08-20)

$ git -C '/private/tmp/fm-e2e-cMRP/firstmate-home/projects/JobSearch' remote get-url origin
  /private/tmp/fm-e2e-cMRP/JobSearch

== 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 /private/tmp/fm-e2e-cMRP/secondmate-jobs-home JobSearch
  home=/private/tmp/fm-e2e-cMRP/secondmate-jobs-home

  the second mate clone is a SIBLING of the home clone off the same folder:

$ git -C '/private/tmp/fm-e2e-cMRP/firstmate-home/projects/JobSearch' remote get-url origin
  /private/tmp/fm-e2e-cMRP/JobSearch

$ git -C '/private/tmp/fm-e2e-cMRP/secondmate-jobs-home/projects/JobSearch' remote get-url origin
  /private/tmp/fm-e2e-cMRP/JobSearch

== ACT 5 - a crewmate finishes work in the second mate's clone (no push, no PR) ==

$ git -C '/private/tmp/fm-e2e-cMRP/secondmate-jobs-home/projects/JobSearch' log --oneline -1 fm/app-acme
  dd34cd4 answers for the Acme application

$ git -C '/private/tmp/fm-e2e-cMRP/JobSearch' branch --list 'fm/*'; echo '(nothing was pushed into the folder)'
  (nothing was pushed into the folder)

== ACT 6 - the captain approves: bin/fm-merge-local.sh app-acme ==

$ FM_HOME=/private/tmp/fm-e2e-cMRP/secondmate-jobs-home bin/fm-merge-local.sh app-acme
  merged fm/app-acme into local main (16afd1b -> dd34cd4) in /private/tmp/fm-e2e-cMRP/secondmate-jobs-home/projects/JobSearch
  carried main into /private/tmp/fm-e2e-cMRP/JobSearch (16afd1b -> dd34cd4)

== ACT 7 - the change is in the folder the captain actually reads ==

$ git -C '/private/tmp/fm-e2e-cMRP/JobSearch' log --oneline -2
  dd34cd4 answers for the Acme application
  16afd1b cv and first cover letter

$ cat '/private/tmp/fm-e2e-cMRP/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 '/private/tmp/fm-e2e-cMRP/JobSearch/CV.tex'
  Damian Sowinski - 07700 900123 - 12 Harbour Row - edited by hand today

$ cat '/private/tmp/fm-e2e-cMRP/JobSearch/private-notes/referees.txt'
  referee: Dr Vale, 07700 900456

$ git -C '/private/tmp/fm-e2e-cMRP/JobSearch' status --porcelain
   M CV.tex
  ?? scratch.md

== ACT 8 - a landing whose paths collide with his uncommitted work refuses ==

$ FM_HOME=/private/tmp/fm-e2e-cMRP/secondmate-jobs-home bin/fm-merge-local.sh app-beta
  merged fm/app-beta into local main (dd34cd4 -> 4a37998) in /private/tmp/fm-e2e-cMRP/secondmate-jobs-home/projects/JobSearch
  REFUSED: /private/tmp/fm-e2e-cMRP/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 /private/tmp/fm-e2e-cMRP/secondmate-jobs-home/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:

$ cat '/private/tmp/fm-e2e-cMRP/JobSearch/CV.tex'
  Damian Sowinski - 07700 900123 - 12 Harbour Row - edited by hand today

== ACT 9 - he does what the refusal told him: reverts that path, and the landing converges ==

$ git -C '/private/tmp/fm-e2e-cMRP/JobSearch' checkout -- CV.tex

$ FM_HOME=/private/tmp/fm-e2e-cMRP/secondmate-jobs-home bin/fm-merge-local.sh app-beta
  merged fm/app-beta into local main (4a37998 -> 4a37998) in /private/tmp/fm-e2e-cMRP/secondmate-jobs-home/projects/JobSearch
  carried main into /private/tmp/fm-e2e-cMRP/JobSearch (dd34cd4 -> 4a37998)

$ cat '/private/tmp/fm-e2e-cMRP/JobSearch/CV.tex'
  Damian Sowinski - 07700 900123 - 12 Harbour Row - tailored for Beta

$ git -C '/private/tmp/fm-e2e-cMRP/JobSearch' status --porcelain; echo '(his untracked scratch and ignored notes still there)'
  ?? scratch.md
  (his untracked scratch and ignored notes still there)

$ ls '/private/tmp/fm-e2e-cMRP/JobSearch/private-notes'
  referees.txt

== ACT 10 - a gitignored file really sitting where the landing would write refuses ==

$ git -C '/private/tmp/fm-e2e-cMRP/ignored-case/JobSearch' status --porcelain; echo '(git says clean: the file it would destroy is ignored)'
  (git says clean: the file it would destroy is ignored)

$ FM_HOME=/private/tmp/fm-e2e-cMRP/ignored-case/home bin/fm-merge-local.sh app-gamma
  merged fm/app-gamma into local main (55c70bb -> 3678b32) in /private/tmp/fm-e2e-cMRP/ignored-case/home/projects/JobSearch
  REFUSED: /private/tmp/fm-e2e-cMRP/ignored-case/JobSearch has work of its own on paths this landing would change (!! marks a path it ignores):
  !! salary.md
  The change is safe in /private/tmp/fm-e2e-cMRP/ignored-case/home/projects/JobSearch on main; commit, move, or revert those paths yourself, then retry.
  exit=1

$ cat '/private/tmp/fm-e2e-cMRP/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 ==

$ bin/fm-home-seed.sh secondmate-jobs /private/tmp/fm-e2e-cMRP/noorigin/sub JobSearch
  error: project JobSearch is local-only and /private/tmp/fm-e2e-cMRP/noorigin/home/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 /private/tmp/fm-e2e-cMRP/noorigin/home/projects/JobSearch remote add origin <folder>

== ACT 12 - a whole-home REMOTE second mate still refuses a local-only project ==

$ bin/fm-remote-home-seed.sh (local-only project) - refusal text:
  172:    local-only) die "project $project is local-only, so its origin is a folder on this machine that $HOST cannot clone; seed it into a local secondmate home instead" ;;

== DONE ==

== ACT 13 - the crewmate contract inside the seeded second mate home (unchanged by design) ==

$ FM_HOME=/private/tmp/fm-e2e-cMRP/secondmate-jobs-home bin/fm-brief.sh app-delta JobSearch --mode local-only
  scaffolded: .../secondmate-jobs-home/data/app-delta/brief.md (ship, mode=local-only)

$ sed -n 54,59p .../data/app-delta/brief.md
  Delivery contract: mode=local-only
  This task ships **local-only**: no remote, no PR, no pipeline.
  The task is complete only when committed on your branch `fm/app-delta`. Do NOT push, do NOT open a PR, do NOT merge.
  Keep your branch a clean fast-forward onto the current default branch - if `main` has advanced, rebase onto it so the eventual merge stays a fast-forward.
  When it is implemented and committed, append `done: ready in branch fm/app-delta` to the status file and stop.
  The configured merge authority approves the ready branch, then firstmate merges it into local `main` through the guarded fast-forward path.
Evidence: E2E driver script that reproduces the transcript
#!/usr/bin/env bash
# End-to-end walk of the captain's JobSearch case against the real scripts:
# a git folder with NO remote and personal material, a home clone off it, a
# persistent second mate seeded on that local-only project, a crewmate branch,
# and an approved landing that reaches the folder itself.
set -u

ROOT=${ROOT:?set ROOT to the firstmate checkout}
W=${W:?set W to a scratch dir}
export HOME_FAKE="$W/fakehome"
GIT="git -c user.name=Captain -c [email protected]"

say() { printf '\n\033[1m== %s ==\033[0m\n' "$*"; }
run() { printf '\n$ %s\n' "$*"; eval "$@" 2>&1 | sed 's/^/  /'; }

rm -rf "$W"; mkdir -p "$W" "$HOME_FAKE"
W=$(cd "$W" && pwd -P)

say "ACT 1 - the captain's folder: a git repo with no remote and personal material"
FOLDER="$W/JobSearch"
mkdir -p "$FOLDER/cover-letters"
$GIT -C "$W" init -q -b main JobSearch >/dev/null
cat > "$FOLDER/CV.tex" <<'EOF'
Damian Sowinski - 07700 900123 - 12 Harbour Row
EOF
printf 'Dear Acme,\n' > "$FOLDER/cover-letters/acme.md"
printf 'private-notes/\n' > "$FOLDER/.gitignore"
$GIT -C "$FOLDER" add -A >/dev/null && $GIT -C "$FOLDER" commit -qm "cv and first cover letter"
# The folder is dirty the way a folder someone lives in always is.
printf 'Damian Sowinski - 07700 900123 - 12 Harbour Row - edited by hand today\n' > "$FOLDER/CV.tex"
mkdir -p "$FOLDER/private-notes"
printf 'referee: Dr Vale, 07700 900456\n' > "$FOLDER/private-notes/referees.txt"
printf 'salary thoughts\n' > "$FOLDER/scratch.md"
run "git -C '$FOLDER' remote -v; echo '(no remote at all)'"
run "git -C '$FOLDER' status --porcelain"

say "ACT 2 - the captain's home clone of that folder"
HOME_DIR="$W/firstmate-home"
mkdir -p "$HOME_DIR/data" "$HOME_DIR/state" "$HOME_DIR/projects"
git clone --quiet "$FOLDER" "$HOME_DIR/projects/JobSearch"
printf '%s\n' '- JobSearch [local-only +yolo] - the job search (added 2026-08-20)' > "$HOME_DIR/data/projects.md"
run "cat '$HOME_DIR/data/projects.md'"
run "git -C '$HOME_DIR/projects/JobSearch' remote get-url origin"

say "ACT 3 - BEFORE this change: seeding refused the project outright"
BASE="$W/base-checkout"
mkdir -p "$BASE"
git -C "$ROOT" archive "${BASE_COMMIT:?}" | tar -x -C "$BASE"
FM_SECONDMATE_CHARTER='Own the job search: tailor CVs and answer application questions.' \
  FM_HOME="$HOME_DIR" "$ROOT/bin/fm-brief.sh" secondmate-jobs --secondmate JobSearch >/dev/null
printf '\n$ (base commit) bin/fm-home-seed.sh secondmate-jobs <subhome> JobSearch\n'
HOME="$HOME_FAKE" FM_HOME="$HOME_DIR" "$BASE/bin/fm-home-seed.sh" \
  secondmate-jobs "$W/subhome-old" JobSearch 2>&1 | sed 's/^/  /'
rm -rf "$W/subhome-old"

say "ACT 4 - AFTER: the same seed on this branch"
SUB="$W/secondmate-jobs-home"
printf '\n$ bin/fm-home-seed.sh secondmate-jobs %s JobSearch\n' "$SUB"
HOME="$HOME_FAKE" FM_HOME="$HOME_DIR" "$ROOT/bin/fm-home-seed.sh" secondmate-jobs "$SUB" JobSearch 2>&1 | sed 's/^/  /'
printf '\n  the second mate clone is a SIBLING of the home clone off the same folder:\n'
run "git -C '$HOME_DIR/projects/JobSearch' remote get-url origin"
run "git -C '$SUB/projects/JobSearch' remote get-url origin"

say "ACT 5 - a crewmate finishes work in the second mate's clone (no push, no PR)"
CLONE="$SUB/projects/JobSearch"
ID=app-acme
git -C "$CLONE" checkout -q -b "fm/$ID" main
printf 'Q: why us?  A: because your rail telemetry work is the problem I want.\n' \
  > "$CLONE/cover-letters/acme-answers.md"
$GIT -C "$CLONE" add -A >/dev/null && $GIT -C "$CLONE" commit -qm "answers for the Acme application" >/dev/null
git -C "$CLONE" checkout -q main
printf 'project=%s\nmode=local-only\nkind=ship\n' "$CLONE" > "$SUB/state/$ID.meta"
run "git -C '$CLONE' log --oneline -1 fm/$ID"
run "git -C '$FOLDER' branch --list 'fm/*'; echo '(nothing was pushed into the folder)'"

say "ACT 6 - the captain approves: bin/fm-merge-local.sh app-acme"
printf '\n$ FM_HOME=%s bin/fm-merge-local.sh %s\n' "$SUB" "$ID"
FM_HOME="$SUB" "$ROOT/bin/fm-merge-local.sh" "$ID" 2>&1 | grep -v '^●' | grep -v '^WARNING: watcher' | sed 's/^/  /'

say "ACT 7 - the change is in the folder the captain actually reads"
run "git -C '$FOLDER' log --oneline -2"
run "cat '$FOLDER/cover-letters/acme-answers.md'"
printf '\n  and his own uncommitted and ignored material is untouched:\n'
run "cat '$FOLDER/CV.tex'"
run "cat '$FOLDER/private-notes/referees.txt'"
run "git -C '$FOLDER' status --porcelain"

say "ACT 8 - a landing whose paths collide with his uncommitted work refuses"
ID2=app-beta
git -C "$CLONE" checkout -q -b "fm/$ID2" main
printf 'Damian Sowinski - 07700 900123 - 12 Harbour Row - tailored for Beta\n' > "$CLONE/CV.tex"
$GIT -C "$CLONE" add -A >/dev/null && $GIT -C "$CLONE" commit -qm "CV tailored for Beta" >/dev/null
git -C "$CLONE" checkout -q main
printf 'project=%s\nmode=local-only\nkind=ship\n' "$CLONE" > "$SUB/state/$ID2.meta"
before=$($GIT -C "$FOLDER" rev-parse --short HEAD)
printf '\n$ FM_HOME=%s bin/fm-merge-local.sh %s\n' "$SUB" "$ID2"
FM_HOME="$SUB" "$ROOT/bin/fm-merge-local.sh" "$ID2" 2>&1 | grep -v '^●' | grep -v '^WARNING: watcher' | sed 's/^/  /'
printf '  exit=%s\n' "${PIPESTATUS[0]}"
printf '\n  the folder never moved (%s -> %s) and his edit survives:\n' "$before" "$($GIT -C "$FOLDER" rev-parse --short HEAD)"
run "cat '$FOLDER/CV.tex'"

say "ACT 9 - he does what the refusal told him: reverts that path, and the landing converges"
run "git -C '$FOLDER' checkout -- CV.tex"
printf '\n$ FM_HOME=%s bin/fm-merge-local.sh %s\n' "$SUB" "$ID2"
FM_HOME="$SUB" "$ROOT/bin/fm-merge-local.sh" "$ID2" 2>&1 | grep -v '^●' | grep -v '^WARNING: watcher' | sed 's/^/  /'
run "cat '$FOLDER/CV.tex'"
run "git -C '$FOLDER' status --porcelain; echo '(his untracked scratch and ignored notes still there)'"
run "ls '$FOLDER/private-notes'"

say "ACT 10 - a gitignored file really sitting where the landing would write refuses"
W2="$W/ignored-case"
mkdir -p "$W2/home/data" "$W2/home/state" "$W2/home/projects" "$W2/JobSearch"
F2="$W2/JobSearch"; C2="$W2/home/projects/JobSearch"
$GIT -C "$F2" init -q -b main >/dev/null
printf 'cv\n' > "$F2/CV.tex"
printf 'salary.md\n' > "$F2/.gitignore"
$GIT -C "$F2" add -A >/dev/null; $GIT -C "$F2" commit -qm "initial, ignoring my private salary notes" >/dev/null
git clone --quiet "$F2" "$C2"
printf '%s\n' '- JobSearch [local-only] - the job search (added 2026-08-20)' > "$W2/home/data/projects.md"
# The crewmate commits a salary.md of its own in the clone.
git -C "$C2" checkout -q -b fm/app-gamma main
printf 'drafted by the crewmate\n' > "$C2/salary.md"
$GIT -C "$C2" add -f salary.md >/dev/null; $GIT -C "$C2" commit -qm "salary notes" >/dev/null
git -C "$C2" checkout -q main
printf 'project=%s\nmode=local-only\nkind=ship\n' "$C2" > "$W2/home/state/app-gamma.meta"
# The captain's own private file is really there at that path, and ignored.
printf 'MY private salary figures - never share\n' > "$F2/salary.md"
run "git -C '$F2' status --porcelain; echo '(git says clean: the file it would destroy is ignored)'"
printf '\n$ FM_HOME=%s bin/fm-merge-local.sh app-gamma\n' "$W2/home"
FM_HOME="$W2/home" "$ROOT/bin/fm-merge-local.sh" app-gamma 2>&1 | grep -v '^●' | grep -v '^WARNING: watcher' | sed 's/^/  /'
printf '  exit=%s\n' "${PIPESTATUS[0]}"
run "cat '$F2/salary.md'"

say "ACT 11 - seeding refuses a clone that has lost its origin, and names the fix"
W3="$W/noorigin"
mkdir -p "$W3/home/data" "$W3/home/state" "$W3/home/projects"
$GIT -C "$W3/home/projects" init -q -b main JobSearch >/dev/null
printf 'cv\n' > "$W3/home/projects/JobSearch/CV.tex"
$GIT -C "$W3/home/projects/JobSearch" add -A >/dev/null
$GIT -C "$W3/home/projects/JobSearch" commit -qm initial >/dev/null
printf '%s\n' '- JobSearch [local-only] - the job search (added 2026-08-20)' > "$W3/home/data/projects.md"
FM_SECONDMATE_CHARTER='Own the job search.' FM_HOME="$W3/home" \
  "$ROOT/bin/fm-brief.sh" secondmate-jobs --secondmate JobSearch >/dev/null
printf '\n$ bin/fm-home-seed.sh secondmate-jobs %s JobSearch\n' "$W3/sub"
HOME="$HOME_FAKE" FM_HOME="$W3/home" "$ROOT/bin/fm-home-seed.sh" secondmate-jobs "$W3/sub" JobSearch 2>&1 \
  | grep -v '^●' | grep -v '^WARNING: watcher' | sed 's/^/  /'

say "ACT 12 - a whole-home REMOTE second mate still refuses a local-only project"
printf '\n$ bin/fm-remote-home-seed.sh (local-only project) - refusal text:\n'
grep -n 'is local-only, so its origin' "$ROOT/bin/fm-remote-home-seed.sh" | sed 's/^/  /'

say "DONE"
Evidence: Targeted suite case names (landing, origin library, backlog handoff)
ok - an approved landing carries the change into the project's own folder
ok - a repeated landing converges instead of refusing or re-merging
ok - landing refuses when uncommitted work sits on a path it would change
ok - landing refuses when an untracked file would be overwritten
ok - landing refuses a folder that is not on the project's default branch
ok - landing refuses rather than forcing when the folder has its own commits
ok - landing refuses an origin that is not a work-tree root
ok - landing refuses when the origin folder is gone
ok - a local-only project with no origin lands in its clone and says so
ok - a bare origin has no working copy, so the landing ends at the clone and says so
ok - an origin on another host is not a folder to carry into, and the landing says so
ok - the local landing path still refuses any task that is not local-only
ok - landing refuses when a gitignored file sits on a path it would overwrite
ok - an ignored file outside the landing's paths does not refuse the carry
ok - a landing that only adds a file inside a wholly-ignored directory goes through
ok - an ignored file that is really there still refuses, named path and all
ok - an ignored file standing where the landing needs a directory refuses the carry
ok - an origin spelled relative to the clone is anchored and landed into
ok - a tilde-spelled origin expands against the invoking user's home and lands
ok - a path-shaped origin that resolves to nothing refuses instead of reporting
ok - an origin folder whose path holds a space is landed into like any other
ok - an anchored origin that is not a plain absolute path refuses naming the fault
ok - ordinary clone URLs are accepted and clone with the command the remote host runs
ok - executable transports, option-shaped values, and unusable spellings are refused
ok - path-shaped origin spellings are told apart from origins on another host
ok - an origin already anchored on this machine is judged as a local path, spaces and all
ALL TESTS PASSED
ok - a local-only project's queued item hands off to a secondmate
ok - body followed by another item moves intact with no source orphans
ok - body followed by section heading moves intact; section stays
ok - multi-paragraph body with internal blank lines moves whole and is idempotent
ok - body as last lines of the file moves intact
ok - EOF body before a seeded destination section keeps its boundary
ok - untouched EOF line preserves its original terminator
ok - body-carrying handoff is idempotent: re-run changes nothing
ok - noncanonical one-space and tab continuations refuse without changes
ok - indented ## Intent / ## Acceptance are body, not section boundaries
ok - registry home parses when summary has parentheses before (home: ...)
ok - registry entry without (home: ...) fails cleanly with has no home
ok - handoff reports a moved item whose public commitment still binds this home
ok - handoff says nothing about public commitments in a relay-free home
ALL TESTS PASSED
FM_TEST_SUMMARY total=3 failed=0 skipped_gate=0 duration_ms=13675

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

⚠️ **Review** - 1 info
  • ⚠️ 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", and git clone succeeds, 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 - so git clone fails 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 bare cd inside a command substitution. With CDPATH exported (a common interactive-shell setting the script inherits) and an origin spelled as a bare relative name such as JobSearch, 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 treats CDPATH=&#39;&#39; 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 walk bash local-only-secondmate-e2e.sh over real git repos: folder repo with no remote plus dirty personal material -> home clone -> bin/fm-home-seed.sh secondmate-jobs &lt;subhome&gt; JobSearch -> crewmate branch fm/app-acme -> bin/fm-merge-local.sh app-acme -> landed file present in the folder, uncommitted/untracked/ignored material unchanged
  • Manual before/after: ran the base commit's bin/fm-home-seed.sh (extracted with git archive 1cb900c) on the same fixture to capture the old blanket refusal
  • Manual refusal checks: colliding uncommitted CV.tex (refuses naming the path, folder unmoved, stage one reported safe), revert-and-retry convergence, gitignored salary.md really present at a changed path (refuses with !! salary.md), seeding a clone with no origin (refuses and names the git remote add origin fix)
  • Manual crewmate-contract check: FM_HOME=&lt;seeded subhome&gt; bin/fm-brief.sh app-delta JobSearch --mode local-only and 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 whose projects/&lt;name&gt; clone is its only copy and "needs no origin", but bin/fm-spawn.sh runs freshen_spawn_worktree_base on every fresh non-secondmate spawn, whose first step is git 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 to unclassified (bin/fm-test-run.sh:230). A change to bin/fm-spawn.sh selects only the backend-dispatch and pure-contract-unit families (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.

⚠️ **Lint** - 1 warning
  • ⚠️ linter found issues (exit code 127)
✅ **Push** - passed

✅ No issues found.

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate:

Scheduled firstmate-oss pass. Diff reviewed against main (head 8ce911454be35a61e1593cf37307587e6c369c48). No security risk. Approving the pending first-time fork workflow runs. Captain-flag NOW: default-behavior that is otherwise green.

Classification: default-behavior (not opt-in, not unprompted freelance writes).

Landing inspection (the VISION question):

  • Not unprompted: stage two runs only as the second half of bin/fm-merge-local.sh, which is already the captain's merge-authority gate ("the one sanctioned exception" to hard rule 1).
  • Not a separate opt-in flag: after an approved fast-forward into the clone, the script automatically carries that same default branch into origin when origin is a work-tree root on this machine, same branch, ff-only, and no path overlap with uncommitted/untracked/really-present-ignored files. Absent/bare/off-host origins report "landing ended in the clone" instead of writing anything.
  • Captain-approved merge path: yes. Workers still implement in isolated copies under the unchanged local-only brief (no push, no PR, no merge). Stage two is last-mile delivery into the folder that is the project's selected path for folder-backed local-only work, analogous to a GitHub merge landing on the remote. Stage one stands if stage two refuses; retry converges.
  • Also default for local secondmate routes: seeding no longer refuses local-only; remote whole-home routes still refuse, with the real reason (host cannot clone or land into a folder that exists only here). Secondmates remain opt-in as a route type, but carrying local-only is now default for a local seed, not a new config switch.

VISION:

  • One captain, one interface: aligns. The copy the captain actually reads is where approved work lands; refusals name paths; stage-two failure does not hide that the clone merge already happened.
  • Authority is explicit and never inferred: aligns as the selected delivery path, does not align as a new opt-in. "Reads projects but does not change them; delivered through each project's selected path" — this writes the origin folder, which is the project, but only after the captain's merge word and only as that path's last mile. "New capability ships as an option to enable" — landing auto-continues, and local-only on local secondmate routes is assumed rather than flagged. Not a VISION miss of firstmate editing the primary checkout on its own.
  • Scripts own the mechanics, agents own the judgment: aligns. Collision probe, ignored-path probe, work-tree-root check, ff-only, and origin-form predicates are all scripts.
  • A restart is a non-event: aligns. Both stages idempotent; a refused carry is retryable without re-doing a successful clone merge.
  • Delegation with a spine: aligns. Ship vs scout unchanged; workers stay in isolated copies; unlanded work is not discarded; merge still requires configured authority.
  • The fleet outlives any vendor: aligns.
  • Scope: aligns. Command-layer local-only delivery, not workshop.

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 tests/fm-merge-local.test.sh and both patch bin/fm-merge-local.sh — they cannot both merge cleanly. Combine prefix resolution from #2706 with stage-two landing from this PR. Also both this PR and #2705 patch bin/fm-spawn.sh.

@kunchenguid kunchenguid left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

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