Skip to content

fix(bin): refresh a remoteless pooled worktree onto its local default branch - #4394

Closed
matixacik-cell wants to merge 1 commit into
kunchenguid:mainfrom
matixacik-cell:fm/fm-spawn-remoteless
Closed

matixacik-cell wants to merge 1 commit into
kunchenguid:mainfrom
matixacik-cell:fm/fm-spawn-remoteless

Conversation

@matixacik-cell

Copy link
Copy Markdown

Intent

Fix bin/fm-spawn.sh so a project with NO configured git remote can be dispatched. freshen_spawn_worktree_base() previously either failed its unconditional 'git fetch origin' (older homes) or, after #3885, skipped the refresh entirely for origin-less repos and launched the pool slot from whatever commit it was last left at. That made mode=local-only self-contradictory: local-only exists for projects with no remote, where the worker stops at a clean ready branch and firstmate lands it with bin/fm-merge-local.sh. Two registered projects (lead-finder, codeza-site-v2) were undispatchable. Required behaviour: (1) detect whether the repository has any configured remote at all using 'git -C remote' returning empty as the signal, not the name origin only; (2) with NO remote, skip the fetch/set-head/origin/ path entirely and refresh the pooled worktree against the LOCAL default branch resolved the same way default_branch() already falls back (main, then master), keeping every other guarantee: still refuse a dirty pooled worktree and never discard uncommitted work, still reset --hard to the resolved target so the slot starts clean, still verify HEAD equals the expected commit afterwards and refuse if not, and refuse with a clear message if no local default branch resolves; (3) a remote that IS configured but unreachable must behave exactly as before: still refuse with the existing 'could not fetch origin ... potentially stale base' message, never silently downgrading into launching from whatever is local; (4) error messages must say which case was hit so a reader can tell 'this repo has no remote' apart from 'your remote is unreachable'. Deliberate decision: a repository that has remotes but none named origin now refuses with a message naming those remotes, because the origin-based fetch cannot verify freshness against a remote it never contacts and the task forbids a silent downgrade to a local base; before this change that shape skipped the refresh and launched as-is. The origin path was extracted unchanged into freshen_spawn_worktree_base_from_origin and the new local path into freshen_spawn_worktree_base_from_local_default; the dirty-worktree refusal runs first on every path. The fm-spawn.sh header paragraph that owns the base-refresh rule was updated to describe the three shapes. Tests in tests/fm-spawn-pool-base-freshen.test.sh: the originless fixture now advances the local default branch past the pool base so the refresh is observable; new cases cover remoteless refresh onto main and onto master, a remoteless repository with no main or master refusing, a repository whose only remote is upstream refusing, and a dirty remoteless slot refusing without refresh or discard; the unreachable-origin and healthy-origin cases are unchanged; the two included-config boundary tests now assert the pool refreshed onto local main instead of asserting HEAD unchanged. Constraints: do NOT change bin/fm-merge-local.sh, bin/fm-backend.sh, or anything under projects/; scope is the freshen path in bin/fm-spawn.sh plus its colocated tests; follow firstmate-coding-guidelines (one sentence per line in prose, plain dash, no agent co-author on commits, shellcheck-clean via bin/fm-lint.sh, colocated tests). Pre-existing unrelated failures in tests/fm-secondmate-liveness.test.sh and tests/fm-muse-harness.test.sh reproduce identically on unchanged main in this environment and are out of scope.

What Changed

  • freshen_spawn_worktree_base() in bin/fm-spawn.sh now tells three repository shapes apart after the dirty-worktree refusal: an origin is fetched and reset to as before (extracted unchanged into freshen_spawn_worktree_base_from_origin); a repository with no remote at all (git remote prints nothing) skips the fetch and resets the pool slot to the local default branch (main, then master) via the new freshen_spawn_worktree_base_from_local_default, verifying HEAD afterwards and refusing if no local default branch resolves; a repository whose remotes exist but include no origin now refuses with a message naming those remotes instead of launching as-is.
  • Every refusal message names which shape was hit (no remote vs. unreachable origin vs. non-origin remotes), and the header paragraph in bin/fm-spawn.sh documenting the base-refresh rule was updated to describe all three shapes.
  • tests/fm-spawn-pool-base-freshen.test.sh advances the originless fixture's local default branch past the pool base so the refresh is observable, and adds cases for remoteless refresh onto main and master, a remoteless repo with no main/master refusing, an upstream-only remote refusing, and a dirty remoteless slot refusing without refresh or discard; the two included-config boundary tests now assert the pool landed on local main. The pipeline Test stage ran this file in full on the target commit (22 cases pass) and confirmed it fails on the base commit.

Risk Assessment

✅ Low: The change is confined to the freshen path and its colocated tests, satisfies every required behaviour in the intent (git remote emptiness as the signal, local main/master reset with dirty refusal first and HEAD verification, unchanged unreachable-origin refusal, distinguishable messages, non-origin remotes refusing by name), and the only findings are a vacuous test assertion and an optional dedup.

Testing

Ran the colocated freshen test suite on the target commit (all pass) and against the base commit (the new remoteless case fails there), then manually dispatched real fm-spawn.sh in --mode local-only across six repository shapes and captured a transcript showing the remoteless slot refreshes onto local main or master without fetching, while no-default, non-origin-remote, unreachable-origin, and dirty-slot cases each refuse with a message naming their case and leave HEAD and uncommitted work untouched. A broad 54-script changed-file sweep was started and stopped early with only passing results; the working tree is clean and temp checkouts were removed.

Evidence: Manual local-only dispatch transcript on target commit (six repository shapes)

== 1. No remote, default branch main, pool slot stale $ git -C pool remote -> '' pool HEAD before spawn -> da5e1ec6... local default tip -> 82906bf8... | spawned lf-main harness=codex kind=ship mode=local-only yolo=off ... exit=0 pool HEAD after spawn -> 82906bf8... pool FETCH_HEAD exists -> no pool has newer.txt -> yes == 3. No remote and no main or master | error: pooled worktree '.../pool' has no git remote and no local default branch (main or master); refusing to launch without a base to refresh from exit=1, HEAD unchanged, task record published -> no == 4. Remote named upstream, not origin | error: pooled worktree '.../pool' has remotes (upstream) but no origin to verify freshness against; refusing to launch from a potentially stale base exit=1, HEAD unchanged == 5. origin configured but unreachable | error: could not fetch origin for pooled worktree '.../pool'; refusing to launch from a potentially stale base exit=1, HEAD unchanged == 6. No remote, slot has uncommitted work | error: pooled worktree '.../pool' is not clean; refusing to discard uncommitted work while refreshing its base exit=1, HEAD unchanged, wip.txt still present -> do not lose me

== 1. No remote, default branch main, pool slot stale (the lead-finder / codeza-site-v2 shape)
  $ git -C pool remote            -> ''
  pool HEAD before spawn          -> da5e1ec6c3cde27b180f92d13576bfc0a1876394
  local default tip               -> 82906bf83d9eb66dc6fd14be38cf591af87ee848
  $ FM_HOME=... bin/fm-spawn.sh lf-main <project> --mode local-only --yolo off
  | warning: /tmp/fm-manual-local-only.gbW2IC/no-remote-main/home/data/lf-main/launch-brief.md records no delivery contract line (scaffolded before ship briefs recorded one); launching on the explicit --mode local-only - confirm its definition of done matches
  | notice: lf-main ships mode=local-only while the standing posture for project is no-mistakes - less rigor than the captain's standing posture; proceed only on a current explicit captain instruction or an intake judgment you can state
  | spawned lf-main harness=codex kind=ship mode=local-only yolo=off window=firstmate:fm-lf-main worktree=/tmp/fm-manual-local-only.gbW2IC/no-remote-main/pool
  exit=0
  pool HEAD after spawn           -> 82906bf83d9eb66dc6fd14be38cf591af87ee848
  pool FETCH_HEAD exists          -> no
  pool has newer.txt              -> yes
  task record published           -> yes

== 2. No remote, default branch master
  $ git -C pool remote            -> ''
  pool HEAD before spawn          -> 0c55abe2539488949ce1d7ab356d002d334175f5
  local default tip               -> 495ced2d73a4487d50444a458bc49c1e8e7902d6
  $ FM_HOME=... bin/fm-spawn.sh lf-master <project> --mode local-only --yolo off
  | warning: /tmp/fm-manual-local-only.gbW2IC/no-remote-master/home/data/lf-master/launch-brief.md records no delivery contract line (scaffolded before ship briefs recorded one); launching on the explicit --mode local-only - confirm its definition of done matches
  | notice: lf-master ships mode=local-only while the standing posture for project is no-mistakes - less rigor than the captain's standing posture; proceed only on a current explicit captain instruction or an intake judgment you can state
  | spawned lf-master harness=codex kind=ship mode=local-only yolo=off window=firstmate:fm-lf-master worktree=/tmp/fm-manual-local-only.gbW2IC/no-remote-master/pool
  exit=0
  pool HEAD after spawn           -> 495ced2d73a4487d50444a458bc49c1e8e7902d6
  pool FETCH_HEAD exists          -> no
  pool has newer.txt              -> yes
  task record published           -> yes

== 3. No remote and no main or master (only trunk) -> must refuse and say so
  $ git -C pool remote            -> ''
  pool HEAD before spawn          -> 8bc0226e075f1c28a64c8a6d15bcd2a087eaef42
  local default tip               -> a54f68446397a2802dad3379a06fd5c9da5a5402
  $ FM_HOME=... bin/fm-spawn.sh lf-trunk <project> --mode local-only --yolo off
  | warning: /tmp/fm-manual-local-only.gbW2IC/no-remote-trunk/home/data/lf-trunk/launch-brief.md records no delivery contract line (scaffolded before ship briefs recorded one); launching on the explicit --mode local-only - confirm its definition of done matches
  | notice: lf-trunk ships mode=local-only while the standing posture for project is no-mistakes - less rigor than the captain's standing posture; proceed only on a current explicit captain instruction or an intake judgment you can state
  | error: pooled worktree '/tmp/fm-manual-local-only.gbW2IC/no-remote-trunk/pool' has no git remote and no local default branch (main or master); refusing to launch without a base to refresh from
  exit=1
  pool HEAD after spawn           -> 8bc0226e075f1c28a64c8a6d15bcd2a087eaef42
  pool FETCH_HEAD exists          -> no
  pool has newer.txt              -> no
  task record published           -> no

== 4. Remote configured but named upstream, not origin -> must refuse naming the remote
  $ git -C pool remote            -> 'upstream '
  pool HEAD before spawn          -> 452a0d393c9b92205d6765d62a47a802fd6acfd0
  local default tip               -> 90ab9ea6fbd758128f905eed0f77a18810c41e0f
  $ FM_HOME=... bin/fm-spawn.sh lf-upstream <project> --mode local-only --yolo off
  | warning: /tmp/fm-manual-local-only.gbW2IC/upstream-only/home/data/lf-upstream/launch-brief.md records no delivery contract line (scaffolded before ship briefs recorded one); launching on the explicit --mode local-only - confirm its definition of done matches
  | notice: lf-upstream ships mode=local-only while the standing posture for project is no-mistakes - less rigor than the captain's standing posture; proceed only on a current explicit captain instruction or an intake judgment you can state
  | error: pooled worktree '/tmp/fm-manual-local-only.gbW2IC/upstream-only/pool' has remotes (upstream) but no origin to verify freshness against; refusing to launch from a potentially stale base
  exit=1
  pool HEAD after spawn           -> 452a0d393c9b92205d6765d62a47a802fd6acfd0
  pool FETCH_HEAD exists          -> no
  pool has newer.txt              -> no
  task record published           -> no

== 5. origin configured but unreachable -> unchanged 'could not fetch origin' refusal, no downgrade to local
  $ git -C pool remote            -> 'origin '
  pool HEAD before spawn          -> a441ce16cdc70ee5f7ace855bc920ea9288dd2c9
  local default tip               -> b13a93d79d98c9363bf1ff4bb694fb45247dfc1b
  $ FM_HOME=... bin/fm-spawn.sh lf-unreach <project> --mode local-only --yolo off
  | warning: /tmp/fm-manual-local-only.gbW2IC/unreachable-origin/home/data/lf-unreach/launch-brief.md records no delivery contract line (scaffolded before ship briefs recorded one); launching on the explicit --mode local-only - confirm its definition of done matches
  | notice: lf-unreach ships mode=local-only while the standing posture for project is no-mistakes - less rigor than the captain's standing posture; proceed only on a current explicit captain instruction or an intake judgment you can state
  | fatal: '/tmp/fm-manual-local-only.gbW2IC/unreachable-origin/missing-origin.git' does not appear to be a git repository
  | fatal: Could not read from remote repository.
  | 
  | Please make sure you have the correct access rights
  | and the repository exists.
  | error: could not fetch origin for pooled worktree '/tmp/fm-manual-local-only.gbW2IC/unreachable-origin/pool'; refusing to launch from a potentially stale base
  exit=1
  pool HEAD after spawn           -> a441ce16cdc70ee5f7ace855bc920ea9288dd2c9
  pool FETCH_HEAD exists          -> no
  pool has newer.txt              -> no
  task record published           -> no

== 6. No remote, slot has uncommitted work -> refuse first, never reset, work kept
  $ git -C pool remote            -> ''
  pool HEAD before spawn          -> 54390f07de1db8feea5d4f8dd97f3afce14c0158
  local default tip               -> 83f81d86218fc86ecc1c4a2ca448812bcd1c2e6f
  $ FM_HOME=... bin/fm-spawn.sh lf-dirty <project> --mode local-only --yolo off
  | warning: /tmp/fm-manual-local-only.gbW2IC/dirty-no-remote/home/data/lf-dirty/launch-brief.md records no delivery contract line (scaffolded before ship briefs recorded one); launching on the explicit --mode local-only - confirm its definition of done matches
  | notice: lf-dirty ships mode=local-only while the standing posture for project is no-mistakes - less rigor than the captain's standing posture; proceed only on a current explicit captain instruction or an intake judgment you can state
  | error: pooled worktree '/tmp/fm-manual-local-only.gbW2IC/dirty-no-remote/pool' is not clean; refusing to discard uncommitted work while refreshing its base
  exit=1
  pool HEAD after spawn           -> 54390f07de1db8feea5d4f8dd97f3afce14c0158
  pool FETCH_HEAD exists          -> no
  pool has newer.txt              -> no
  task record published           -> no
  wip.txt still present           -> do not lose me
Evidence: Same manual scenarios on base commit b182d0f (remoteless slot launched stale, upstream-only launched as-is)

== 1. No remote, default branch main, pool slot stale pool HEAD before spawn -> a3c0134f... local default tip -> a9d6c32c... | spawned lf-main ... mode=local-only ... exit=0 pool HEAD after spawn -> a3c0134f... (still stale) pool has newer.txt -> no == 4. Remote named upstream, not origin | spawned lf-upstream ... mode=local-only ... exit=0 (launched without verifying freshness)

== 1. No remote, default branch main, pool slot stale (the lead-finder / codeza-site-v2 shape)
  $ git -C pool remote            -> ''
  pool HEAD before spawn          -> a3c0134f135fd0a2766e0ab7bb977a19ec3901b7
  local default tip               -> a9d6c32c41e8617dad8df481341f8ec2b76badb0
  $ FM_HOME=... bin/fm-spawn.sh lf-main <project> --mode local-only --yolo off
  | warning: /tmp/fm-manual-local-only.JYKc1V/no-remote-main/home/data/lf-main/launch-brief.md records no delivery contract line (scaffolded before ship briefs recorded one); launching on the explicit --mode local-only - confirm its definition of done matches
  | notice: lf-main ships mode=local-only while the standing posture for project is no-mistakes - less rigor than the captain's standing posture; proceed only on a current explicit captain instruction or an intake judgment you can state
  | spawned lf-main harness=codex kind=ship mode=local-only yolo=off window=firstmate:fm-lf-main worktree=/tmp/fm-manual-local-only.JYKc1V/no-remote-main/pool
  exit=0
  pool HEAD after spawn           -> a3c0134f135fd0a2766e0ab7bb977a19ec3901b7
  pool FETCH_HEAD exists          -> no
  pool has newer.txt              -> no
  task record published           -> yes

== 2. No remote, default branch master
  $ git -C pool remote            -> ''
  pool HEAD before spawn          -> 95e0a35ef8d41314850945876a6e45602609bf67
  local default tip               -> 0dd8170648022d40c373c808c731c6b6557fc034
  $ FM_HOME=... bin/fm-spawn.sh lf-master <project> --mode local-only --yolo off
  | warning: /tmp/fm-manual-local-only.JYKc1V/no-remote-master/home/data/lf-master/launch-brief.md records no delivery contract line (scaffolded before ship briefs recorded one); launching on the explicit --mode local-only - confirm its definition of done matches
  | notice: lf-master ships mode=local-only while the standing posture for project is no-mistakes - less rigor than the captain's standing posture; proceed only on a current explicit captain instruction or an intake judgment you can state
  | spawned lf-master harness=codex kind=ship mode=local-only yolo=off window=firstmate:fm-lf-master worktree=/tmp/fm-manual-local-only.JYKc1V/no-remote-master/pool
  exit=0
  pool HEAD after spawn           -> 95e0a35ef8d41314850945876a6e45602609bf67
  pool FETCH_HEAD exists          -> no
  pool has newer.txt              -> no
  task record published           -> yes

== 3. No remote and no main or master (only trunk) -> must refuse and say so
  $ git -C pool remote            -> ''
  pool HEAD before spawn          -> d3ba1ba0110cf79d4323d15914d74adfb14a4157
  local default tip               -> 831518c230d5bcebfb46b657a952c48962b52dc1
  $ FM_HOME=... bin/fm-spawn.sh lf-trunk <project> --mode local-only --yolo off
  | warning: /tmp/fm-manual-local-only.JYKc1V/no-remote-trunk/home/data/lf-trunk/launch-brief.md records no delivery contract line (scaffolded before ship briefs recorded one); launching on the explicit --mode local-only - confirm its definition of done matches
  | notice: lf-trunk ships mode=local-only while the standing posture for project is no-mistakes - less rigor than the captain's standing posture; proceed only on a current explicit captain instruction or an intake judgment you can state
  | spawned lf-trunk harness=codex kind=ship mode=local-only yolo=off window=firstmate:fm-lf-trunk worktree=/tmp/fm-manual-local-only.JYKc1V/no-remote-trunk/pool
  exit=0
  pool HEAD after spawn           -> d3ba1ba0110cf79d4323d15914d74adfb14a4157
  pool FETCH_HEAD exists          -> no
  pool has newer.txt              -> no
  task record published           -> yes

== 4. Remote configured but named upstream, not origin -> must refuse naming the remote
  $ git -C pool remote            -> 'upstream '
  pool HEAD before spawn          -> d48b394d8969f59a89ab2a5149cb2e969770f202
  local default tip               -> a3d3e4217d3c4b7b784fbcb727673c17afb5420f
  $ FM_HOME=... bin/fm-spawn.sh lf-upstream <project> --mode local-only --yolo off
  | warning: /tmp/fm-manual-local-only.JYKc1V/upstream-only/home/data/lf-upstream/launch-brief.md records no delivery contract line (scaffolded before ship briefs recorded one); launching on the explicit --mode local-only - confirm its definition of done matches
  | notice: lf-upstream ships mode=local-only while the standing posture for project is no-mistakes - less rigor than the captain's standing posture; proceed only on a current explicit captain instruction or an intake judgment you can state
  | spawned lf-upstream harness=codex kind=ship mode=local-only yolo=off window=firstmate:fm-lf-upstream worktree=/tmp/fm-manual-local-only.JYKc1V/upstream-only/pool
  exit=0
  pool HEAD after spawn           -> d48b394d8969f59a89ab2a5149cb2e969770f202
  pool FETCH_HEAD exists          -> no
  pool has newer.txt              -> no
  task record published           -> yes

== 5. origin configured but unreachable -> unchanged 'could not fetch origin' refusal, no downgrade to local
  $ git -C pool remote            -> 'origin '
  pool HEAD before spawn          -> 2a33d53e7fe7fc00ca81be4a95d9cd5efd183f27
  local default tip               -> 107ba548d6bffb231da525737f6faab09dad1aa1
  $ FM_HOME=... bin/fm-spawn.sh lf-unreach <project> --mode local-only --yolo off
  | warning: /tmp/fm-manual-local-only.JYKc1V/unreachable-origin/home/data/lf-unreach/launch-brief.md records no delivery contract line (scaffolded before ship briefs recorded one); launching on the explicit --mode local-only - confirm its definition of done matches
  | notice: lf-unreach ships mode=local-only while the standing posture for project is no-mistakes - less rigor than the captain's standing posture; proceed only on a current explicit captain instruction or an intake judgment you can state
  | fatal: '/tmp/fm-manual-local-only.JYKc1V/unreachable-origin/missing-origin.git' does not appear to be a git repository
  | fatal: Could not read from remote repository.
  | 
  | Please make sure you have the correct access rights
  | and the repository exists.
  | error: could not fetch origin for pooled worktree '/tmp/fm-manual-local-only.JYKc1V/unreachable-origin/pool'; refusing to launch from a potentially stale base
  exit=1
  pool HEAD after spawn           -> 2a33d53e7fe7fc00ca81be4a95d9cd5efd183f27
  pool FETCH_HEAD exists          -> no
  pool has newer.txt              -> no
  task record published           -> no

== 6. No remote, slot has uncommitted work -> refuse first, never reset, work kept
  $ git -C pool remote            -> ''
  pool HEAD before spawn          -> 607bf8c1acb7a021cde04fb9c6fa84b73864364c
  local default tip               -> d4fa7ffb77373e8d71b860c0f0201b6162b827d2
  $ FM_HOME=... bin/fm-spawn.sh lf-dirty <project> --mode local-only --yolo off
  | warning: /tmp/fm-manual-local-only.JYKc1V/dirty-no-remote/home/data/lf-dirty/launch-brief.md records no delivery contract line (scaffolded before ship briefs recorded one); launching on the explicit --mode local-only - confirm its definition of done matches
  | notice: lf-dirty ships mode=local-only while the standing posture for project is no-mistakes - less rigor than the captain's standing posture; proceed only on a current explicit captain instruction or an intake judgment you can state
  | error: pooled worktree '/tmp/fm-manual-local-only.JYKc1V/dirty-no-remote/pool' is not clean; refusing to discard uncommitted work while refreshing its base
  exit=1
  pool HEAD after spawn           -> 607bf8c1acb7a021cde04fb9c6fa84b73864364c
  pool FETCH_HEAD exists          -> no
  pool has newer.txt              -> no
  task record published           -> no
  wip.txt still present           -> do not lose me
Evidence: Colocated freshen test suite on target commit (FM_TEST_EVIDENCE=1)
# remote-seeded Treehouse spawn command
$ FM_HOME=/private/var/folders/sx/97t21t2d30xdp4yq61zj5mkm0000gn/T/fm-spawn-pool-base-freshen.CuPksD/remote-seeded/home bin/fm-spawn.sh pool-remote-seeded-r13 /private/var/folders/sx/97t21t2d30xdp4yq61zj5mkm0000gn/T/fm-spawn-pool-base-freshen.CuPksD/remote-seeded/project --scout
spawned pool-remote-seeded-r13 harness=codex kind=scout window=firstmate:fm-pool-remote-seeded-r13 worktree=/private/var/folders/sx/97t21t2d30xdp4yq61zj5mkm0000gn/T/fm-spawn-pool-base-freshen.CuPksD/remote-seeded/pool
exit=0
published worktree=/private/var/folders/sx/97t21t2d30xdp4yq61zj5mkm0000gn/T/fm-spawn-pool-base-freshen.CuPksD/remote-seeded/pool
resolved project lock=/private/var/folders/sx/97t21t2d30xdp4yq61zj5mkm0000gn/T/fm-spawn-pool-base-freshen.CuPksD/remote-seeded/home/state/.treehouse-project-4d7286cfef179466dc4e9d72a911597ec6a3d4fc.lock
ok - a remote-seeded secondmate home allocates and launches from its Treehouse pool
ok - a Treehouse slot claim names the launched task, refuses when unclaimable, and is dropped by a locked abort
# evidence begin: linked-home spawn, returned=primary
$ bin/fm-spawn.sh pool-linked-primary-r12 /private/var/folders/sx/97t21t2d30xdp4yq61zj5mkm0000gn/T/fm-spawn-pool-base-freshen.CuPksD/linked-primary/secondmate --scout
error: treehouse get did not enter an isolated worktree within 60s (last seen '/private/var/folders/sx/97t21t2d30xdp4yq61zj5mkm0000gn/T/fm-spawn-pool-base-freshen.CuPksD/linked-primary/project': it is the repository's primary checkout (its git dir is the spawning project's common git dir); spawning project '/private/var/folders/sx/97t21t2d30xdp4yq61zj5mkm0000gn/T/fm-spawn-pool-base-freshen.CuPksD/linked-primary/secondmate'); inspect window firstmate:fm-pool-linked-primary-r12
exit=1
primary HEAD before=6f5e826e6390a5aea6b729eace1b774a86cb04e6 after=6f5e826e6390a5aea6b729eace1b774a86cb04e6
primary reflog before:
6f5e826 HEAD@{0}: commit (initial): initial
primary reflog after:
6f5e826 HEAD@{0}: commit (initial): initial
FETCH_HEAD absent
task metadata absent
# evidence end
ok - linked spawning home: primary preserves the primary before any refresh
# evidence begin: linked-home spawn, returned=primary-alias
$ bin/fm-spawn.sh pool-linked-primary-alias-r12 /private/var/folders/sx/97t21t2d30xdp4yq61zj5mkm0000gn/T/fm-spawn-pool-base-freshen.CuPksD/linked-primary-alias/secondmate --scout
error: treehouse get did not enter an isolated worktree within 60s (last seen '/private/var/folders/sx/97t21t2d30xdp4yq61zj5mkm0000gn/T/fm-spawn-pool-base-freshen.CuPksD/linked-primary-alias/primary-alias': it is the repository's primary checkout (its git dir is the spawning project's common git dir); spawning project '/private/var/folders/sx/97t21t2d30xdp4yq61zj5mkm0000gn/T/fm-spawn-pool-base-freshen.CuPksD/linked-primary-alias/secondmate'); inspect window firstmate:fm-pool-linked-primary-alias-r12
exit=1
primary HEAD before=ec98830b0988533a760b4ed18164a80f74d47abd after=ec98830b0988533a760b4ed18164a80f74d47abd
primary reflog before:
ec98830 HEAD@{0}: commit (initial): initial
primary reflog after:
ec98830 HEAD@{0}: commit (initial): initial
FETCH_HEAD absent
task metadata absent
# evidence end
ok - linked spawning home: primary-alias preserves the primary before any refresh
# evidence begin: linked-home spawn, returned=spawning
$ bin/fm-spawn.sh pool-linked-spawning-r12 /private/var/folders/sx/97t21t2d30xdp4yq61zj5mkm0000gn/T/fm-spawn-pool-base-freshen.CuPksD/linked-spawning/secondmate --scout
error: treehouse get did not enter an isolated worktree within 60s (last seen '/private/var/folders/sx/97t21t2d30xdp4yq61zj5mkm0000gn/T/fm-spawn-pool-base-freshen.CuPksD/linked-spawning/secondmate': it is the spawning project itself; spawning project '/private/var/folders/sx/97t21t2d30xdp4yq61zj5mkm0000gn/T/fm-spawn-pool-base-freshen.CuPksD/linked-spawning/secondmate'); inspect window firstmate:fm-pool-linked-spawning-r12
exit=1
primary HEAD before=4dfa0dcd7d99c92a5fe1abb5a1642aba7e7cf3d5 after=4dfa0dcd7d99c92a5fe1abb5a1642aba7e7cf3d5
primary reflog before:
4dfa0dc HEAD@{0}: commit (initial): initial
primary reflog after:
4dfa0dc HEAD@{0}: commit (initial): initial
FETCH_HEAD absent
task metadata absent
# evidence end
ok - linked spawning home: spawning preserves the primary before any refresh
# evidence begin: linked-home spawn, returned=scout
$ bin/fm-spawn.sh pool-linked-scout-r12 /private/var/folders/sx/97t21t2d30xdp4yq61zj5mkm0000gn/T/fm-spawn-pool-base-freshen.CuPksD/linked-scout/secondmate --scout
spawned pool-linked-scout-r12 harness=codex kind=scout window=firstmate:fm-pool-linked-scout-r12 worktree=/private/var/folders/sx/97t21t2d30xdp4yq61zj5mkm0000gn/T/fm-spawn-pool-base-freshen.CuPksD/linked-scout/pool
exit=0
primary HEAD before=718bd0c87b3e7481afc280ea5717fba0cb53f6e2 after=718bd0c87b3e7481afc280ea5717fba0cb53f6e2
primary reflog before:
718bd0c HEAD@{0}: commit (initial): initial
primary reflog after:
718bd0c HEAD@{0}: commit (initial): initial
FETCH_HEAD absent
saved task metadata:
window=firstmate:fm-pool-linked-scout-r12
endpoint_task_id=pool-linked-scout-r12
worktree=/private/var/folders/sx/97t21t2d30xdp4yq61zj5mkm0000gn/T/fm-spawn-pool-base-freshen.CuPksD/linked-scout/pool
project=/private/var/folders/sx/97t21t2d30xdp4yq61zj5mkm0000gn/T/fm-spawn-pool-base-freshen.CuPksD/linked-scout/secondmate
harness=codex
kind=scout
tasktmp=/tmp/fm-pool-linked-scout-r12
model=default
effort=default
spawn_gen=s1789335280.59409.21305
worker HEAD=7ad7f4cec29dc6d39b82bd0034ba6675779c30ba origin/main=7ad7f4cec29dc6d39b82bd0034ba6675779c30ba
# evidence end
ok - linked spawning home: scout preserves the primary before any refresh
# observed spawn: spawned pool-current-base-r1 harness=codex kind=ship mode=no-mistakes yolo=off window=firstmate:fm-pool-current-base-r1 worktree=/private/var/folders/sx/97t21t2d30xdp4yq61zj5mkm0000gn/T/fm-spawn-pool-base-freshen.CuPksD/current-base/pool
# observed base: HEAD=73d8c008f2ec0c7492627adb86fe37abc6f50c5d origin/main=73d8c008f2ec0c7492627adb86fe37abc6f50c5d advanced-main=must survive a newly spawned branch
ok - a stale pooled worktree refreshes to current origin/main before a crew branch is created
ok - a stale pooled worktree resolves and refreshes a non-main default branch
# observed direct-pr spawn: spawned pool-direct-pr-r3 harness=codex kind=ship mode=direct-PR yolo=off window=firstmate:fm-pool-direct-pr-r3 worktree=/private/var/folders/sx/97t21t2d30xdp4yq61zj5mkm0000gn/T/fm-spawn-pool-base-freshen.CuPksD/direct-pr/pool
# observed scout spawn: spawned pool-scout-r3 harness=codex kind=scout window=firstmate:fm-pool-scout-r3 worktree=/private/var/folders/sx/97t21t2d30xdp4yq61zj5mkm0000gn/T/fm-spawn-pool-base-freshen.CuPksD/scout/pool
ok - direct-PR ships and scouts both refresh stale pooled worktrees before launch
# observed dirty refusal: error: pooled worktree '/private/var/folders/sx/97t21t2d30xdp4yq61zj5mkm0000gn/T/fm-spawn-pool-base-freshen.CuPksD/dirty-refusal/pool' is not clean; refusing to discard uncommitted work while refreshing its base; preserved=keep this local work
ok - a dirty pooled worktree is refused without discarding its local work
# observed unresolved-default refusal: error: could not resolve origin's current default branch for pooled worktree '/private/var/folders/sx/97t21t2d30xdp4yq61zj5mkm0000gn/T/fm-spawn-pool-base-freshen.CuPksD/unresolved-default/pool'; refusing to launch from a potentially stale base
ok - an unresolved remote default branch refuses the pooled worktree
# observed unreachable-origin refusal: error: could not fetch origin for pooled worktree '/private/var/folders/sx/97t21t2d30xdp4yq61zj5mkm0000gn/T/fm-spawn-pool-base-freshen.CuPksD/unreachable-origin/pool'; refusing to launch from a potentially stale base
ok - an unreachable origin refuses a potentially stale pooled worktree
# observed remoteless launch (main): spawned pool-remoteless-main-r7 harness=codex kind=ship mode=no-mistakes yolo=off window=firstmate:fm-pool-remoteless-main-r7 worktree=/private/var/folders/sx/97t21t2d30xdp4yq61zj5mkm0000gn/T/fm-spawn-pool-base-freshen.CuPksD/remoteless-main/pool
# observed base: HEAD=10bfaac7050bb82a19f18436ae9e88d7a45e51a8 local main=10bfaac7050bb82a19f18436ae9e88d7a45e51a8
# observed remoteless launch (master): spawned pool-remoteless-master-r7 harness=codex kind=ship mode=no-mistakes yolo=off window=firstmate:fm-pool-remoteless-master-r7 worktree=/private/var/folders/sx/97t21t2d30xdp4yq61zj5mkm0000gn/T/fm-spawn-pool-base-freshen.CuPksD/remoteless-master/pool
# observed base: HEAD=5b5e795b78fedf8724480180dc9b31bf91f256ef local master=5b5e795b78fedf8724480180dc9b31bf91f256ef
ok - a remoteless pooled worktree refreshes onto the local default branch (main, then master) before launch
ok - a remoteless pool with no main or master refuses and names the missing local base
ok - a pool with remotes but no origin refuses rather than launching from an unverified base
ok - a dirty remoteless pooled worktree is refused without refreshing or discarding its local work
ok - an origin configuration without a URL refuses the pooled worktree
ok - an empty origin configuration section refuses the pooled worktree
ok - an empty-only included origin section documents the accepted detection boundary
ok - an inactive conditional origin include leaves the pooled worktree remoteless and refreshed onto local main
# observed stale-pin refusal: error: submodule 'ui' is checked out at f8ce9c51d30b841a64a04495cb822bbd6f599e90, but this base records a0ee5bfdb077de08fc86db473918ff6f1c6ea9bc
ok - an origin-less pool with a stale submodule pin refuses while naming both pins and no remedy
ok - an unpushed submodule commit keeps the uncommitted-work refusal and survives it
ok - work inside a submodule is still refused as uncommitted work, not called stale
ok - a stale pin carrying real work is refused conservatively, never called stale
ok - a stale pin beside other dirt yields the conservative refusal alone, with no stale-pin line
# all fm-spawn-pool-base-freshen tests passed
Evidence: Colocated freshen test suite run against base commit (fails at the remoteless case)
ok - a remote-seeded secondmate home allocates and launches from its Treehouse pool
ok - a Treehouse slot claim names the launched task, refuses when unclaimable, and is dropped by a locked abort
ok - linked spawning home: primary preserves the primary before any refresh
ok - linked spawning home: primary-alias preserves the primary before any refresh
ok - linked spawning home: spawning preserves the primary before any refresh
ok - linked spawning home: scout preserves the primary before any refresh
ok - a stale pooled worktree refreshes to current origin/main before a crew branch is created
ok - a stale pooled worktree resolves and refreshes a non-main default branch
ok - direct-PR ships and scouts both refresh stale pooled worktrees before launch
ok - a dirty pooled worktree is refused without discarding its local work
ok - an unresolved remote default branch refuses the pooled worktree
ok - an unreachable origin refuses a potentially stale pooled worktree
not ok - spawn left the remoteless pool on stale history instead of local main
Evidence: Manual scenario script used for the transcripts
#!/usr/bin/env bash
# Manual end-to-end check: dispatch a project with --mode local-only through the
# real bin/fm-spawn.sh (fake terminal from tests/fixtures.sh) across the
# repository shapes the change tells apart.
set -u
ROOT=$1
. "$ROOT/tests/fixtures.sh"
T=$(mktemp -d /tmp/fm-manual-local-only.XXXXXX)
commit() { git -C "$1" -c user.name='Manual' -c user.email='m@example.invalid' commit -qm "$2"; }

setup() {  # <name> <id> <default-branch>
  local name=$1 id=$2 default=$3
  CASE="$T/$name"; HOME_DIR="$CASE/home"; PROJECT="$CASE/project"; POOL="$CASE/pool"
  FAKEBIN=$(make_spawn_fakebin "$CASE/fake")
  mkdir -p "$HOME_DIR/data/$id" "$HOME_DIR/projects" "$HOME_DIR/state" "$HOME_DIR/config"
  printf 'codex\n' > "$HOME_DIR/config/crew-harness"
  fm_test_spawn_brief "$HOME_DIR" "$id" "manual local-only dispatch"
  touch "$HOME_DIR/state/.last-watcher-beat"
  git init --quiet -b "$default" "$PROJECT"
  printf 'base\n' > "$PROJECT/README.md"; git -C "$PROJECT" add README.md; commit "$PROJECT" initial
  STALE=$(git -C "$PROJECT" rev-parse HEAD)
  git -C "$PROJECT" worktree add --quiet --detach "$POOL" "$STALE"
  printf 'landed after the slot was allocated\n' > "$PROJECT/newer.txt"
  git -C "$PROJECT" add newer.txt; commit "$PROJECT" advance
  TIP=$(git -C "$PROJECT" rev-parse HEAD)
}

report() {  # <id>
  local id=$1
  echo "  \$ git -C pool remote            -> '$(git -C "$POOL" remote | tr '\n' ' ')'"
  echo "  pool HEAD before spawn          -> $STALE"
  echo "  local default tip               -> $TIP"
  echo "  \$ FM_HOME=... bin/fm-spawn.sh $id <project> --mode local-only --yolo off"
  OUT=$(fm_test_run_spawn "$HOME_DIR" "$POOL" "$FAKEBIN" "$id" "$PROJECT" --mode local-only --yolo off); STATUS=$?
  printf '%s\n' "$OUT" | sed 's/^/  | /'
  echo "  exit=$STATUS"
  echo "  pool HEAD after spawn           -> $(git -C "$POOL" rev-parse HEAD)"
  echo "  pool FETCH_HEAD exists          -> $([ -e "$POOL/.git/FETCH_HEAD" ] && echo yes || echo no)"
  echo "  pool has newer.txt              -> $([ -f "$POOL/newer.txt" ] && echo yes || echo no)"
  echo "  task record published           -> $([ -e "$HOME_DIR/state/$id.meta" ] && echo yes || echo no)"
}

echo "== 1. No remote, default branch main, pool slot stale (the lead-finder / codeza-site-v2 shape)"
setup no-remote-main lf-main main; report lf-main; echo

echo "== 2. No remote, default branch master"
setup no-remote-master lf-master master; report lf-master; echo

echo "== 3. No remote and no main or master (only trunk) -> must refuse and say so"
setup no-remote-trunk lf-trunk trunk; report lf-trunk; echo

echo "== 4. Remote configured but named upstream, not origin -> must refuse naming the remote"
setup upstream-only lf-upstream main
git -C "$POOL" remote add upstream "file://$CASE/nowhere.git"
report lf-upstream; echo

echo "== 5. origin configured but unreachable -> unchanged 'could not fetch origin' refusal, no downgrade to local"
setup unreachable-origin lf-unreach main
git -C "$POOL" remote add origin "file://$CASE/missing-origin.git"
report lf-unreach; echo

echo "== 6. No remote, slot has uncommitted work -> refuse first, never reset, work kept"
setup dirty-no-remote lf-dirty main
printf 'do not lose me\n' > "$POOL/wip.txt"
report lf-dirty
echo "  wip.txt still present           -> $([ -f "$POOL/wip.txt" ] && cat "$POOL/wip.txt" || echo MISSING)"
rm -rf "$T"
- Evidence: Partial changed-file test sweep (3 of 54 scripts, stopped early) (local file: /var/folders/sx/97t21t2d30xdp4yq61zj5mkm0000gn/T/no-mistakes-evidence/01M2EAW9WB4PB6NE8EQW15GJ01/changed-run.log) - Outcome: ⚠️ 1 info across 1 run (7m25s)

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

⚠️ **Review** - 2 infos
  • ℹ️ tests/fm-spawn-pool-base-freshen.test.sh:263 - The assertion [ ! -e &#34;$POOL_DIR/.git/FETCH_HEAD&#34; ] can never fail: the pool is a linked worktree, so $POOL_DIR/.git is a gitdir pointer file and $POOL_DIR/.git/FETCH_HEAD is not a real path. FETCH_HEAD for a linked worktree lives under git -C &#34;$POOL_DIR&#34; rev-parse --git-path FETCH_HEAD. The behaviour is still covered by the assert_not_contains ... &#34;could not fetch origin&#34; check on the same case, so this only weakens the evidence rather than hiding a regression. Use --git-path FETCH_HEAD if the fetch-free guarantee is meant to be asserted directly.
  • ℹ️ bin/fm-spawn.sh:2686 - freshen_spawn_worktree_base_from_local_default and freshen_spawn_worktree_base_from_origin repeat the same reset-then-verify tail (rev-parse expected, reset --hard, rev-parse HEAD, compare, refuse). A small shared helper taking the target ref and a shape label for the messages would remove the duplication. The intent explicitly states the origin path was extracted unchanged, so this is a deliberate trade-off; noting it as a possible follow-up only.
⚠️ **Test** - 1 info
  • ℹ️ The broad heuristic sweep (bin/fm-test-run.sh --changed, 54 scripts selected because many suites source bin/fm-spawn.sh) was stopped after 3 of 54 scripts (all passing) because the structured-output deadline arrived. The only test file that references the freshen path is the colocated tests/fm-spawn-pool-base-freshen.test.sh, which passed in full on the target commit; the remaining 51 scripts exercise unrelated behavior and were not run to completion here.
  • FM_TEST_EVIDENCE=1 bash tests/fm-spawn-pool-base-freshen.test.sh on target 8318e4b (all 22 cases pass, including remoteless main/master refresh, no-default refusal, upstream-only refusal, dirty remoteless refusal, unreachable-origin and healthy-origin paths)
  • Same test file run against a git archive of base commit b182d0f: fails at not ok - spawn left the remoteless pool on stale history instead of local main
  • Manual end-to-end script manual-local-only-dispatch.sh driving real bin/fm-spawn.sh &lt;id&gt; &lt;project&gt; --mode local-only --yolo off through the fixtures' fake terminal across six repository shapes: no remote + main, no remote + master, no remote + trunk only, upstream-only remote, unreachable origin, dirty remoteless slot; checked exit code, HEAD before/after, FETCH_HEAD absence, presence of the newer commit's file, task record publication, and preserved uncommitted file
  • Same manual script against the base commit for a before/after contrast (remoteless slot launched stale, upstream-only launched as-is)
  • git diff --name-only b182d0f 8318e4b confirms only bin/fm-spawn.sh and tests/fm-spawn-pool-base-freshen.test.sh changed; git log -1 --format=%B shows no agent co-author trailer
  • bin/fm-test-run.sh --changed --base b182d0f started (3 of 54 scripts completed, all passing) then stopped at the output deadline
✅ **Document** - passed

✅ No issues found.

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

✅ No issues found.

… branch

A local-only project has no remote, so fm-spawn's base refresh either
failed its origin fetch (older homes) or skipped the refresh entirely
and launched the pool slot from whatever commit it was last left at.
Both left mode=local-only projects effectively undispatchable or stale.

freshen_spawn_worktree_base now tells three shapes apart and names
which one it hit in every refusal:
- origin configured: unchanged fetch, set-head, and reset to
  origin/<default>; an unreachable or unusable origin still refuses.
- no remote at all (`git remote` prints nothing): reset the clean pool
  slot to the local default branch (main, then master) with the same
  reset-then-verify guarantee; no resolvable default branch refuses.
- remotes exist but none is origin: refuse rather than launching from
  a base the origin fetch never verified.

The dirty-worktree refusal still runs first in every shape, so no
uncommitted work is discarded on any path.

Tests cover remoteless main and master refresh, a remoteless repository
with no default branch, a non-origin remote, the dirty remoteless slot,
and the unchanged unreachable-origin and healthy-origin paths.

Claude-Session: https://claude.ai/code/session_017ZHa2WVWPpoHhbtbeaZaVD
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate:

First look on main b182d0f908b78d08c7ccb8dce3775bdca8c5d657. Tip 8318e4b1605e57331db6a65e71a38c7400538618. Fork PR (matixacik-cell).

What I inspected (diff vs main)

  • freshen_spawn_worktree_base now distinguishes: origin → fetch/reset; no remotes at all → reset onto local default (main then master) via freshen_spawn_worktree_base_from_local_default; remotes without origin → refuse by name.
  • Dirty pooled worktree still refused first; HEAD verified after reset; unreachable origin unchanged.
  • Colocated tests cover remoteless main/master, no-default refuse, upstream-only refuse, dirty refuse. No workflows.

contract-class: restore — mode=local-only already promised dispatch for remoteless projects; main either failed fetch or skipped refresh and launched stale. Restores refresh onto local default.

Attestation: MISSING (no no-mistakes-pipeline-attestation:v1 head_sha in body). Please re-raise / refresh attestation to tip via no-mistakes so Require no-mistakes can pass.

Checks: first-time fork workflows approved this pass — CI 34784637068, Require no-mistakes 34784637095 (NM expected to fail until attestation MATCH). Waiting-author on attestation.

VISION.md (each rule)

  • One captain, one interface: aligns — spawn freshen stays below deck.
  • Authority is explicit and never inferred: aligns — refuses non-origin remotes rather than silently downgrading.
  • Scripts own the mechanics agents own the judgment: aligns — git remote emptiness / local default in scripts.
  • A restart is a non-event: aligns — remoteless pool refreshes to a deterministic local tip each spawn.
  • Delegation with a spine: aligns — local-only delivery path becomes usable again.
  • The fleet outlives any vendor: aligns — forge-agnostic; remoteless local projects.
  • Scope: aligns — freshen path + colocated tests only.

Security FYI (tip only, not waiting-captain): none material. Attestation missing is an author gate, not a captain security choice.

Merge-eligible N. Waiting-author (attestation). Do not merge. No Firstmate flag.

@matixacik-cell

Copy link
Copy Markdown
Author

Closing: the project this fixed for us now has a remote, so we no longer need it. Feel free to pick the branch up if useful.

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.

3 participants