Skip to content

feat(bin): add Polytoken crewmate/scout worker adapter - #7321

Merged
kunchenguid merged 38 commits into
kunchenguid:mainfrom
sjennings:fm/fm-polytoken-worker-adapter-v2
Oct 17, 2026
Merged

kunchenguid merged 38 commits into
kunchenguid:mainfrom
sjennings:fm/fm-polytoken-worker-adapter-v2

Conversation

@sjennings

@sjennings sjennings commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Intent

have firstmate grant Polytoken access to that folder at launch.

also have the launch script clean up after itself if we are making changes

Context for those words. "That folder" is the firstmate task directory, <FM_HOME>/data/<task-id>/, where every worker brief tells the worker to keep proof, scratch output, evidence and landing-gate results. Polytoken workers' file tools (file_read, file_write and similar) are scoped to the worker's worktree and refuse paths in that directory, while shell commands reach it; two AugustStorm Polytoken workers hit this on 2026-10-15 and had to be told to fall back to shell.

"The launch script clean up after itself": on 2026-10-15 a bin/fm-spawn.sh launch on polytoken was refused after it had claimed a treehouse pool slot (refusal: the project tracked its own .polytoken/hooks.json). A retry of the same task on claude then launched into that slot, but the pool afterwards still treated the slot as free, so the next spawn of a different task was handed the same worktree, and two task records claimed one copy (teardown then refused both until one record was retired). A refused or failed launch must leave the pool and task records exactly as before it started.

and add them to the pr if ci has not already run

"The pr" is #7321 ("feat(bin): add Polytoken crewmate/scout worker adapter", head branch fm/fm-polytoken-worker-adapter-v2 on the fork sjennings/firstmate, currently at 5da1709 after a metadata-only re-push that corrected commit author emails). Its CI has not run on that head: both workflows are waiting for maintainer approval (action_required).

do we need to split it? just change it to polytoken-only as the pr comment suggests

Context for that line: the maintainer reclassified the PR as new-default because spawn_abort_cleanup in bin/fm-spawn.sh (closing the endpoint, clearing wiring, removing temp root and staged launch file, dropping the late Treehouse slot claim after a failed pre-launch spawn) and the added "Running for s" match in FM_DELIVERY_BUSY_REGEX_DEFAULT apply to every harness; a Polytoken-only change keeps the PR opt-in.

What Changed

  • Adds polytoken as an opt-in crewmate/scout harness, refused for --secondmate. The new bin/fm-polytoken-lib.sh generates the per-task artifacts: a config dir that copies the operator's config and forces default_permission_matcher: bypass, a sessions dir, the firstmate-worker facet, and a worktree .polytoken/hooks.json busy wiring with a no-argv writer. bin/fm-spawn.sh launches the TUI with --prompt, folds effort into the model ref, never passes --accept-license-terms, clears foreign ORCA_*/FM_* and harness-identity env vars, and records the session port and credential in task metadata. Detection is wired into fm-harness.sh, fm-busy-lib.sh (polytoken-hook), fm-tmux-lib.sh, and fm-composer-lib.sh, and fm-control.sh interrupts over the daemon's POST /turn/cancel, writing the busy close itself. Relaunch refuses a bad Polytoken profile or a hook layer Firstmate didn't generate before it stops the old worker.
  • Polytoken 0.9.0 has no launch-time path grant, so the worker facet tells workers to reach the task directory with file_read/file_write directly or the shell, not tool_flow. The live evidence is in docs/verification/polytoken.md.
  • Polytoken-only cleanup: when a fresh Polytoken spawn fails and leaves no task record, it closes the endpoint it opened if no launch was sent yet. Under the per-id spawn lock it removes its wiring, task temp root, and staged launch file, then retakes the Treehouse project lock to drop its slot claim, so the pool is left as it was. Teardown and relaunch remove only untracked, Firstmate-generated Polytoken wiring and state dirs. Adds the harness-adapters reference, docs updates, and tests (fm-polytoken-harness, live signals e2e, relaunch, teardown, pool-freshen).

🤖 Generated with Claude Code

Risk Assessment

✅ Low: The round-1 fix (0099856) correctly mirrors the GIT_HOOKS_DIR pattern: the Polytoken-only abort deletions now run only after retaking SPAWN_TASK_LOCK (set globally at bin/fm-spawn.sh:2037, before any flagged path is created, and already released at :1553 so the retake succeeds uncontended) with a meta re-check, skip with a warning on contention, keep endpoint close and slot release outside the lock, and leave non-polytoken paths untouched; the new test drives a real contended lock through the spawn and the existing test at line 868 still covers the uncontended removal.

Testing

I drove six live scenarios against the real product, each in a disposable lab home with a private tmux socket and a real Treehouse pool, plus a real Polytoken 0.9.0 worker where needed. All six passed. I also ran the two targeted test files that cover the changed code, and both passed. A refused Polytoken spawn returned its slot, closed its window, and published no record. A same-id retry and a second task then each got their own slot, with no double claim. An adversarial run raced a holder onto the per-id spawn lock during the abort. The abort printed the contention warning, kept /tmp/fm-<id>, and still closed the window and returned the slot. The full live worker lifecycle passed: launch, brief, busy hooks, fm-send steer and acknowledgement, REST interrupt, relaunch, exit and teardown. The worker read and wrote proof in the task directory with its file tools. The harness-less busy union is unchanged from base. A seventh scenario, the non-Polytoken refused launch, is covered only by a fixture-driven unit test, so it is marked untested. The labs were torn down and the worktree is clean. This is a CLI/TUI change with no rendered UI surface, so the evidence is CLI transcripts and logs.

  • Live validation: ✅ go - 6 of 7 scenarios driven live against the product
Scenario Result Live Evidence
Operator spawns a polytoken task into a project that tracks its own .polytoken/hooks.json: the spawn is refused, its window is closed, no task record is published, the real Treehouse slot reads availa… ✅ pass live refused-spawn-pool-lab.log (checks 1-8)
After that refusal, a same-id retry on another harness and then a different task each launch into their own slot, and each slot's claim names its own task ✅ pass live refused-spawn-pool-lab.log (checks 9-14, treehouse status at end)
Adversarial: a concurrent retry holds the per-id spawn lock while the refused polytoken abort runs. The abort warns and leaves /tmp/fm-<id> in place, and still closes the window and returns the slot;… ✅ pass live contended-lock-pool-lab.log (warning line; temp root kept; slot 'available'; retry exit 0)
A real Polytoken worker runs the full lifecycle: launch with model/effort pin, brief runs, busy hooks open and close, fm-send steer is acknowledged, REST interrupt, relaunch rebinds the session, exit,… ✅ pass live polytoken-signals-live-e2e.log (all ok)
A real Polytoken worker writes and reads back proof in $FM_HOME/data/<task-id>/ with its file tools, and the generated facet carries the task-directory guidance (the settled implementation of the acce… ✅ pass live polytoken-taskdir-live.log
Polytoken-only scoping: the harness-less delivery busy union is byte-identical to base, and a real pane rendering 'Running for 3.03s' reads idle harness-less and under claude but busy under polytoken ✅ pass live busy-union-scope-live.log
Non-polytoken refused launch keeps main's behavior (window stays open, pre-publication claim dropped) ⏸️ untested no The prior payload did not establish a live result for this scenario. Its only coverage was the fixture-driven unit test test_non_polytoken_refused_launch_keeps_its_window in tests/fm-spawn-pool-base-f…
Evidence: Refused Polytoken spawn leaves the real Treehouse pool clean (lab log)

Source: Refused Polytoken spawn leaves the real Treehouse pool clean (lab log)


=== pool before anything (treehouse status)
base  main  (repository default)

=== 1. fm-spawn pt1 --harness polytoken (project tracks .polytoken/hooks.json)
fm-gate-refuse: gate agent lifecycle permitted only against lab home /private/var/folders/qw/fh5wf_hn25x4f712lv79r_480000gn/T/fm-lab.WVSGYV/fm
warning: /private/var/folders/qw/fh5wf_hn25x4f712lv79r_480000gn/T/fm-lab.WVSGYV/fm/data/pt1/launch-brief.md records no ship branch; defaulting to legacy branch fm/pt1
warning: /private/var/folders/qw/fh5wf_hn25x4f712lv79r_480000gn/T/fm-lab.WVSGYV/fm/data/pt1/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: pt1 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: /private/var/folders/qw/fh5wf_hn25x4f712lv79r_480000gn/T/fm-lab.WVSGYV/pool/.treehouse/project-6fd4a1/1/project/.polytoken/hooks.json already exists; a project's own polytoken hook layer is not firstmate's to clobber, so this task cannot be launched on polytoken into this worktree. Select another harness for this task.
exit=1
PASS: refused spawn exits non-zero
PASS: refusal names the project hook layer
PASS: refusal does not point at a window to inspect
PASS: no task record published
PASS: tmux window fm-pt1 closed
slot claims in pool after refusal: 0
PASS: no slot claim left anywhere in the pool
PASS: treehouse reports every pool slot available (none leased or in use)
PASS: task temp root /tmp/fm-pt1 removed
refused spawn had acquired slot: /private/var/folders/qw/fh5wf_hn25x4f712lv79r_480000gn/T/fm-lab.WVSGYV/pool/.treehouse/project-6fd4a1/1/project

=== pool after refusal (treehouse status)
base  main  (repository default)
1     available    /private/var/folders/qw/fh5wf_hn25x4f712lv79r_480000gn/T/fm-lab.WVSGYV/pool/.treehouse/project-6fd4a1/1/project  (detached)
lab tmux windows:
lab

=== 2. retry pt1 on another harness (raw bash launch)
fm-gate-refuse: gate agent lifecycle permitted only against lab home /private/var/folders/qw/fh5wf_hn25x4f712lv79r_480000gn/T/fm-lab.WVSGYV/fm
warning: /private/var/folders/qw/fh5wf_hn25x4f712lv79r_480000gn/T/fm-lab.WVSGYV/fm/data/pt1/launch-brief.md records no ship branch; defaulting to legacy branch fm/pt1
warning: /private/var/folders/qw/fh5wf_hn25x4f712lv79r_480000gn/T/fm-lab.WVSGYV/fm/data/pt1/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: pt1 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 pt1 harness=bash kind=ship mode=local-only yolo=off window=firstmate:fm-pt1 worktree=/private/var/folders/qw/fh5wf_hn25x4f712lv79r_480000gn/T/fm-lab.WVSGYV/pool/.treehouse/project-6fd4a1/1/project
exit=0
PASS: retry launches
pt1 worktree=/private/var/folders/qw/fh5wf_hn25x4f712lv79r_480000gn/T/fm-lab.WVSGYV/pool/.treehouse/project-6fd4a1/1/project

=== 3. spawn a different task pt2 (raw bash launch)
fm-gate-refuse: gate agent lifecycle permitted only against lab home /private/var/folders/qw/fh5wf_hn25x4f712lv79r_480000gn/T/fm-lab.WVSGYV/fm
warning: /private/var/folders/qw/fh5wf_hn25x4f712lv79r_480000gn/T/fm-lab.WVSGYV/fm/data/pt2/launch-brief.md records no ship branch; defaulting to legacy branch fm/pt2
warning: /private/var/folders/qw/fh5wf_hn25x4f712lv79r_480000gn/T/fm-lab.WVSGYV/fm/data/pt2/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: pt2 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 pt2 harness=bash kind=ship mode=local-only yolo=off window=firstmate:fm-pt2 worktree=/private/var/folders/qw/fh5wf_hn25x4f712lv79r_480000gn/T/fm-lab.WVSGYV/pool/.treehouse/project-6fd4a1/2/project
exit=0
PASS: second task launches
pt2 worktree=/private/var/folders/qw/fh5wf_hn25x4f712lv79r_480000gn/T/fm-lab.WVSGYV/pool/.treehouse/project-6fd4a1/2/project
PASS: retry reused the slot the refused spawn returned
PASS: the two task records name different worktrees
claim /private/var/folders/qw/fh5wf_hn25x4f712lv79r_480000gn/T/fm-lab.WVSGYV/pool/.treehouse/project-6fd4a1/1/.fm-slot-owner:
task=pt1
home=/private/var/folders/qw/fh5wf_hn25x4f712lv79r_480000gn/T/fm-lab.WVSGYV/fm
claim /private/var/folders/qw/fh5wf_hn25x4f712lv79r_480000gn/T/fm-lab.WVSGYV/pool/.treehouse/project-6fd4a1/2/.fm-slot-owner:
task=pt2
home=/private/var/folders/qw/fh5wf_hn25x4f712lv79r_480000gn/T/fm-lab.WVSGYV/fm
PASS: pt1's slot is claimed by pt1
PASS: pt2's slot is claimed by pt2

=== pool at end (treehouse status)
base  main  (repository default)
1     in-use       /private/var/folders/qw/fh5wf_hn25x4f712lv79r_480000gn/T/fm-lab.WVSGYV/pool/.treehouse/project-6fd4a1/1/project  (detached)
                   zsh (94137), bash (95415)
2     in-use       /private/var/folders/qw/fh5wf_hn25x4f712lv79r_480000gn/T/fm-lab.WVSGYV/pool/.treehouse/project-6fd4a1/2/project  (detached)
                   zsh (95807), bash (97261)
lab tmux windows:
lab
fm-pt1
fm-pt2

=== RESULT: 0 failing checks
Evidence: Refused-spawn pool lab script

Source: Refused-spawn pool lab script

#!/usr/bin/env bash
# Live lab: a polytoken spawn refused after it claimed a REAL Treehouse pool
# slot must leave the pool and task records as it found them, so a retry of the
# same task and a second task each land on their own slot.
# Real: bin/fm-spawn.sh, treehouse, tmux (private socket), git. Retries use a
# raw `bash` launch so no model login is needed for the pool proof.
set -u
ROOT=${1:?worktree}
REAL_TMUX=$(command -v tmux)
REAL_TREEHOUSE=$(command -v treehouse)
LAB=$(mktemp -d "${TMPDIR:-/tmp}/fm-lab.XXXXXX"); LAB=$(cd "$LAB" && pwd -P)
H="$LAB/fm"; U="$LAB/user-home"; ORIGIN="$LAB/origin.git"; PROJ="$LAB/project"; POOL="$LAB/pool"
LAB_TMUX_DIR=
cleanup() {
  [ -z "$LAB_TMUX_DIR" ] || { TMUX_TMPDIR="$LAB_TMUX_DIR" "$REAL_TMUX" kill-server >/dev/null 2>&1; "$ROOT/bin/fm-lab-home.sh" teardown "$H" >/dev/null 2>&1; }
  rm -rf /tmp/fm-pt1 /tmp/fm-pt2 /tmp/fm-pt1+* /tmp/fm-pt2+* 2>/dev/null
  chmod -R u+w "$LAB" 2>/dev/null; rm -rf -- "$LAB"
}
trap cleanup EXIT
say() { printf '\n=== %s\n' "$*"; }
fails=0
check() { if eval "$2"; then echo "PASS: $1"; else echo "FAIL: $1"; fails=$((fails+1)); fi; }

"$ROOT/bin/fm-lab-home.sh" create "$H" >/dev/null || exit 1
LAB_TMUX_DIR=$("$ROOT/bin/fm-lab-home.sh" tmux-dir "$H") || exit 1
mkdir -p "$H/data" "$H/projects" "$U" "$POOL"; touch "$H/state/.last-watcher-beat"
printf 'tmux\n' > "$H/config/backend"; printf 'manual\n' > "$H/config/backlog-backend"
for id in pt1 pt2; do
  mkdir -p "$H/data/$id"
  printf '# Task\n## Captain'"'"'s intent\nlab %s\n\n## Firstmate spec\nPool lab.\n' "$id" > "$H/data/$id/brief.md"
done

# Stage a copy of the operator's polytoken config (minus MCP servers) and
# license acceptance so model validation passes and the refusal under test is
# the hook-layer one that fires after the slot claim. Never modifies the source.
mkdir -p "$U/.config/polytoken" "$U/.local/share/polytoken"
awk '/^[^[:space:]#][^:]*:/ {skip=($0 ~ /^mcp_servers:/)} !skip {print}' \
  "$HOME/.config/polytoken/config.yaml" > "$U/.config/polytoken/config.yaml"
chmod 600 "$U/.config/polytoken/config.yaml"
cp "$HOME/.local/share/polytoken/license-acceptance.json" "$U/.local/share/polytoken/"
git init -q --bare "$ORIGIN"
git -c init.defaultBranch=main init -q "$PROJ"
git -C "$PROJ" -c user.name=lab -c [email protected] commit -q --allow-empty -m init
mkdir -p "$PROJ/.polytoken"; printf '[]\n' > "$PROJ/.polytoken/hooks.json"
printf 'root = "%s"\n' "$POOL" > "$PROJ/treehouse.toml"
git -C "$PROJ" add -A
git -C "$PROJ" -c user.name=lab -c [email protected] commit -q -m "project tracks its own .polytoken/hooks.json"
git -C "$PROJ" remote add origin "$ORIGIN"; git -C "$PROJ" push -q -u origin main

export FM_HOME="$H" HOME="$U" TMUX_TMPDIR="$LAB_TMUX_DIR" TREEHOUSE_ROOT="$POOL"
unset TMUX NO_MISTAKES_GATE FM_GATE_REFUSE_BYPASS FM_ROOT_OVERRIDE FM_STATE_OVERRIDE FM_DATA_OVERRIDE FM_CONFIG_OVERRIDE FM_PROJECTS_OVERRIDE
"$REAL_TMUX" -f /dev/null new-session -d -s firstmate -n lab -x 160 -y 50 "/bin/bash --noprofile --norc"
"$REAL_TMUX" set-option -g default-command "/bin/bash --noprofile --norc" >/dev/null

claims() { find "$POOL" -name .fm-slot-owner -print 2>/dev/null; }
say "pool before anything (treehouse status)"; (cd "$PROJ" && "$REAL_TREEHOUSE" status 2>/dev/null)

say "1. fm-spawn pt1 --harness polytoken (project tracks .polytoken/hooks.json)"
out=$(FM_SPAWN_NO_GUARD=1 "$ROOT/bin/fm-spawn.sh" pt1 "$PROJ" --mode local-only --yolo off --harness polytoken --model zai/glm-5.3-flash --effort low 2>&1); st=$?
printf '%s\nexit=%s\n' "$out" "$st"
check "refused spawn exits non-zero" '[ "$st" -ne 0 ]'
check "refusal names the project hook layer" 'case "$out" in *"not firstmate'"'"'s to clobber"*) true;; *) false;; esac'
check "refusal does not point at a window to inspect" 'case "$out" in *"inspect window"*) false;; *) true;; esac'
check "no task record published" '[ ! -e "$H/state/pt1.meta" ]'
check "tmux window fm-pt1 closed" '! "$REAL_TMUX" list-windows -a -F "#{window_name}" | grep -qx fm-pt1'
sleep 2
echo "slot claims in pool after refusal: $(claims | wc -l | tr -d " ")"
check "no slot claim left anywhere in the pool" '[ -z "$(claims)" ]'
check "treehouse reports every pool slot available (none leased or in use)" '! (cd "$PROJ" && "$REAL_TREEHOUSE" status 2>/dev/null) | grep -Eq "in-use|leased"'
check "task temp root /tmp/fm-pt1 removed" '[ ! -e /tmp/fm-pt1 ]'
REFUSED_SLOT=$(printf "%s\n" "$out" | sed -n "s|.*error: \(.*\)/.polytoken/hooks.json already exists.*|\1|p")
echo "refused spawn had acquired slot: $REFUSED_SLOT"
sleep 2
say "pool after refusal (treehouse status)"; (cd "$PROJ" && "$REAL_TREEHOUSE" status 2>/dev/null)
echo "lab tmux windows:"; "$REAL_TMUX" list-windows -a -F '#{window_name}'

say "2. retry pt1 on another harness (raw bash launch)"
out=$(FM_SPAWN_NO_GUARD=1 "$ROOT/bin/fm-spawn.sh" pt1 "$PROJ" --mode local-only --yolo off --harness 'bash --noprofile --norc' 2>&1); st=$?
printf '%s\nexit=%s\n' "$out" "$st"
check "retry launches" '[ "$st" -eq 0 ]'
W1=$(awk -F= '$1=="worktree"{print substr($0,index($0,"=")+1)}' "$H/state/pt1.meta" 2>/dev/null); echo "pt1 worktree=$W1"

say "3. spawn a different task pt2 (raw bash launch)"
out=$(FM_SPAWN_NO_GUARD=1 "$ROOT/bin/fm-spawn.sh" pt2 "$PROJ" --mode local-only --yolo off --harness 'bash --noprofile --norc' 2>&1); st=$?
printf '%s\nexit=%s\n' "$out" "$st"
check "second task launches" '[ "$st" -eq 0 ]'
W2=$(awk -F= '$1=="worktree"{print substr($0,index($0,"=")+1)}' "$H/state/pt2.meta" 2>/dev/null); echo "pt2 worktree=$W2"
check "retry reused the slot the refused spawn returned" '[ "$W1" = "$REFUSED_SLOT" ]'
check "the two task records name different worktrees" '[ -n "$W1" ] && [ -n "$W2" ] && [ "$W1" != "$W2" ]'
for w in "$W1" "$W2"; do echo "claim $(dirname "$w")/.fm-slot-owner:"; cat "$(dirname "$w")/.fm-slot-owner" 2>/dev/null; done
check "pt1's slot is claimed by pt1" 'grep -qx "task=pt1" "$(dirname "$W1")/.fm-slot-owner"'
check "pt2's slot is claimed by pt2" 'grep -qx "task=pt2" "$(dirname "$W2")/.fm-slot-owner"'
say "pool at end (treehouse status)"; (cd "$PROJ" && "$REAL_TREEHOUSE" status 2>/dev/null)
echo "lab tmux windows:"; "$REAL_TMUX" list-windows -a -F '#{window_name}'
say "RESULT: $fails failing checks"
exit "$fails"
Evidence: Contended per-id spawn lock: abort spares per-id paths, still returns the slot (lab log)

Source: Contended per-id spawn lock: abort spares per-id paths, still returns the slot (lab log)


=== 1. fm-spawn pt1 --harness polytoken; a stand-in retry takes the pt1 spawn lock as the abort closes the window
fm-gate-refuse: gate agent lifecycle permitted only against lab home /private/var/folders/qw/fh5wf_hn25x4f712lv79r_480000gn/T/fm-lab.zylmnm/fm
warning: /private/var/folders/qw/fh5wf_hn25x4f712lv79r_480000gn/T/fm-lab.zylmnm/fm/data/pt1/launch-brief.md records no ship branch; defaulting to legacy branch fm/pt1
warning: /private/var/folders/qw/fh5wf_hn25x4f712lv79r_480000gn/T/fm-lab.zylmnm/fm/data/pt1/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: pt1 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: /private/var/folders/qw/fh5wf_hn25x4f712lv79r_480000gn/T/fm-lab.zylmnm/pool/.treehouse/project-0dd67d/1/project/.polytoken/hooks.json already exists; a project's own polytoken hook layer is not firstmate's to clobber, so this task cannot be launched on polytoken into this worktree. Select another harness for this task.
warning: another spawn of pt1 holds its spawn lock; leaving its polytoken wiring, temp root, and staged launch file in place
exit=1
PASS: refused spawn exits non-zero
PASS: stand-in retry really held the per-id spawn lock
PASS: abort reports it skipped per-id cleanup under contention
PASS: task temp root /tmp/fm-pt1 left for the lock holder
PASS: no task record published
PASS: tmux window fm-pt1 still closed
PASS: slot claim still dropped

=== pool after contended refusal (treehouse status)
base  main  (repository default)
1     available    /private/var/folders/qw/fh5wf_hn25x4f712lv79r_480000gn/T/fm-lab.zylmnm/pool/.treehouse/project-0dd67d/1/project  (detached)
PASS: treehouse reports the slot returned

=== 2. after the holder exits, retry pt1 on raw bash
fm-gate-refuse: gate agent lifecycle permitted only against lab home /private/var/folders/qw/fh5wf_hn25x4f712lv79r_480000gn/T/fm-lab.zylmnm/fm
warning: /private/var/folders/qw/fh5wf_hn25x4f712lv79r_480000gn/T/fm-lab.zylmnm/fm/data/pt1/launch-brief.md records no ship branch; defaulting to legacy branch fm/pt1
warning: /private/var/folders/qw/fh5wf_hn25x4f712lv79r_480000gn/T/fm-lab.zylmnm/fm/data/pt1/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: pt1 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 pt1 harness=bash kind=ship mode=local-only yolo=off window=firstmate:fm-pt1 worktree=/private/var/folders/qw/fh5wf_hn25x4f712lv79r_480000gn/T/fm-lab.zylmnm/pool/.treehouse/project-0dd67d/1/project
exit=0
PASS: retry launches
PASS: retry record exists

=== pool at end
base  main  (repository default)
1     in-use       /private/var/folders/qw/fh5wf_hn25x4f712lv79r_480000gn/T/fm-lab.zylmnm/pool/.treehouse/project-0dd67d/1/project  (detached)
                   zsh (10362), bash (11596)

=== RESULT: 0 failing checks
Evidence: Contended-lock lab script

Source: Contended-lock lab script

#!/usr/bin/env bash
# Live lab (adversarial): a polytoken spawn refused after claiming a REAL Treehouse
# pool slot, while a concurrent retry of the same id grabs the per-id spawn lock
# at the moment the abort closes its window. The abort must still close the window
# and return the slot, but must NOT delete per-id paths (task temp root) the retry
# may be reusing. A PATH tmux shim injects the race on kill-window, then execs real tmux.
# Real: bin/fm-spawn.sh, treehouse, tmux (private socket), git. Retries use a
# raw `bash` launch so no model login is needed for the pool proof.
set -u
ROOT=${1:?worktree}
REAL_TMUX=$(command -v tmux)
REAL_TREEHOUSE=$(command -v treehouse)
LAB=$(mktemp -d "${TMPDIR:-/tmp}/fm-lab.XXXXXX"); LAB=$(cd "$LAB" && pwd -P)
H="$LAB/fm"; U="$LAB/user-home"; ORIGIN="$LAB/origin.git"; PROJ="$LAB/project"; POOL="$LAB/pool"
LAB_TMUX_DIR=
cleanup() {
  [ -e "$LAB/holder.pid" ] && kill "$(cat "$LAB/holder.pid")" 2>/dev/null
  [ -z "$LAB_TMUX_DIR" ] || { TMUX_TMPDIR="$LAB_TMUX_DIR" "$REAL_TMUX" kill-server >/dev/null 2>&1; "$ROOT/bin/fm-lab-home.sh" teardown "$H" >/dev/null 2>&1; }
  rm -rf /tmp/fm-pt1 /tmp/fm-pt2 /tmp/fm-pt1+* /tmp/fm-pt2+* 2>/dev/null
  chmod -R u+w "$LAB" 2>/dev/null; rm -rf -- "$LAB"
}
trap cleanup EXIT
say() { printf '\n=== %s\n' "$*"; }
fails=0
check() { if eval "$2"; then echo "PASS: $1"; else echo "FAIL: $1"; fails=$((fails+1)); fi; }

"$ROOT/bin/fm-lab-home.sh" create "$H" >/dev/null || exit 1
LAB_TMUX_DIR=$("$ROOT/bin/fm-lab-home.sh" tmux-dir "$H") || exit 1
mkdir -p "$H/data" "$H/projects" "$U" "$POOL"; touch "$H/state/.last-watcher-beat"
printf 'tmux\n' > "$H/config/backend"; printf 'manual\n' > "$H/config/backlog-backend"
for id in pt1 pt2; do
  mkdir -p "$H/data/$id"
  printf '# Task\n## Captain'"'"'s intent\nlab %s\n\n## Firstmate spec\nPool lab.\n' "$id" > "$H/data/$id/brief.md"
done

# Stage a copy of the operator's polytoken config (minus MCP servers) and
# license acceptance so model validation passes and the refusal under test is
# the hook-layer one that fires after the slot claim. Never modifies the source.
mkdir -p "$U/.config/polytoken" "$U/.local/share/polytoken"
awk '/^[^[:space:]#][^:]*:/ {skip=($0 ~ /^mcp_servers:/)} !skip {print}' \
  "$HOME/.config/polytoken/config.yaml" > "$U/.config/polytoken/config.yaml"
chmod 600 "$U/.config/polytoken/config.yaml"
cp "$HOME/.local/share/polytoken/license-acceptance.json" "$U/.local/share/polytoken/"
git init -q --bare "$ORIGIN"
git -c init.defaultBranch=main init -q "$PROJ"
git -C "$PROJ" -c user.name=lab -c [email protected] commit -q --allow-empty -m init
mkdir -p "$PROJ/.polytoken"; printf '[]\n' > "$PROJ/.polytoken/hooks.json"
printf 'root = "%s"\n' "$POOL" > "$PROJ/treehouse.toml"
git -C "$PROJ" add -A
git -C "$PROJ" -c user.name=lab -c [email protected] commit -q -m "project tracks its own .polytoken/hooks.json"
git -C "$PROJ" remote add origin "$ORIGIN"; git -C "$PROJ" push -q -u origin main

export FM_HOME="$H" HOME="$U" TMUX_TMPDIR="$LAB_TMUX_DIR" TREEHOUSE_ROOT="$POOL"
unset TMUX NO_MISTAKES_GATE FM_GATE_REFUSE_BYPASS FM_ROOT_OVERRIDE FM_STATE_OVERRIDE FM_DATA_OVERRIDE FM_CONFIG_OVERRIDE FM_PROJECTS_OVERRIDE
"$REAL_TMUX" -f /dev/null new-session -d -s firstmate -n lab -x 160 -y 50 "/bin/bash --noprofile --norc"
"$REAL_TMUX" set-option -g default-command "/bin/bash --noprofile --norc" >/dev/null


SHIMBIN="$LAB/shimbin"; mkdir -p "$SHIMBIN"
cat > "$SHIMBIN/tmux" <<SH
#!/usr/bin/env bash
if [ "\${1:-}" = kill-window ] && [ ! -e '$LAB/holder.pid' ]; then
  FM_HOME='$H' nohup bash -c '. "\$1"; fm_lock_try_acquire "\$2" || exit 1; : > "\$3"; exec /bin/sleep 120' _ \\
    '$ROOT/bin/fm-wake-lib.sh' '$H/state/.spawn-pt1.lock' '$LAB/holder.ready' >/dev/null 2>&1 &
  printf '%s\n' "\$!" > '$LAB/holder.pid'
  n=0; while [ ! -e '$LAB/holder.ready' ] && [ "\$n" -lt 100 ]; do /bin/sleep 0.05; n=\$((n + 1)); done
fi
exec '$REAL_TMUX' "\$@"
SH
chmod +x "$SHIMBIN/tmux"
claims() { find "$POOL" -name .fm-slot-owner -print 2>/dev/null; }
say "1. fm-spawn pt1 --harness polytoken; a stand-in retry takes the pt1 spawn lock as the abort closes the window"
out=$(PATH="$SHIMBIN:$PATH" FM_SPAWN_NO_GUARD=1 "$ROOT/bin/fm-spawn.sh" pt1 "$PROJ" --mode local-only --yolo off --harness polytoken --model zai/glm-5.3-flash --effort low 2>&1); st=$?
printf '%s\nexit=%s\n' "$out" "$st"
check "refused spawn exits non-zero" '[ "$st" -ne 0 ]'
check "stand-in retry really held the per-id spawn lock" '[ -e "$LAB/holder.ready" ]'
check "abort reports it skipped per-id cleanup under contention" 'case "$out" in *"another spawn of pt1 holds its spawn lock"*) true;; *) false;; esac'
check "task temp root /tmp/fm-pt1 left for the lock holder" '[ -d /tmp/fm-pt1 ]'
check "no task record published" '[ ! -e "$H/state/pt1.meta" ]'
check "tmux window fm-pt1 still closed" '! "$REAL_TMUX" list-windows -a -F "#{window_name}" | grep -qx fm-pt1'
sleep 2
check "slot claim still dropped" '[ -z "$(claims)" ]'
say "pool after contended refusal (treehouse status)"; (cd "$PROJ" && "$REAL_TREEHOUSE" status 2>/dev/null)
check "treehouse reports the slot returned" '! (cd "$PROJ" && "$REAL_TREEHOUSE" status 2>/dev/null) | grep -Eq "in-use|leased"'
kill "$(cat "$LAB/holder.pid")" 2>/dev/null; sleep 0.5
say "2. after the holder exits, retry pt1 on raw bash"
out=$(FM_SPAWN_NO_GUARD=1 "$ROOT/bin/fm-spawn.sh" pt1 "$PROJ" --mode local-only --yolo off --harness 'bash --noprofile --norc' 2>&1); st=$?
printf '%s\nexit=%s\n' "$out" "$st"
check "retry launches" '[ "$st" -eq 0 ]'
check "retry record exists" '[ -e "$H/state/pt1.meta" ]'
say "pool at end"; (cd "$PROJ" && "$REAL_TREEHOUSE" status 2>/dev/null)
say "RESULT: $fails failing checks"
exit "$fails"
Evidence: Real Polytoken worker lifecycle e2e

Source: Real Polytoken worker lifecycle e2e

ok - polytoken 0.9.0: the live model catalog still lists the cheap low-effort reference
ok - polytoken 0.9.0: generated launch starts a bound worker; daemon state and retained selection prove the model and effort pin
ok - polytoken 0.9.0: the brief ran and fm-harness.sh detects polytoken from a real tool subprocess
ok - polytoken 0.9.0: the stop hook closes the busy record and touches the turn-ended marker
ok - polytoken 0.9.0: fm-send's durable message is read, acted on, and acknowledged
ok - polytoken 0.9.0: fm-send steers a real turn that opens the busy record and renders the busy row
ok - polytoken 0.9.0: fm-control interrupt cancels the real turn over REST and leaves the worker alive
ok - polytoken 0.9.0: fm-control relaunch replaces the worker through the generated launch and rebinds its session
ok - polytoken 0.9.0: fm-control exit stops the real worker and the backend reads it dead
ok - polytoken 0.9.0: teardown retires the task and its generated Polytoken artifacts
Evidence: Real Polytoken worker file tools reach the task directory

Source: Real Polytoken worker file tools reach the task directory

ok - polytoken 0.9.0: the live model catalog still lists the cheap low-effort reference
--- generated worker facet(s) delivered to the worker (task-dir guidance lines):
The tool_flow tool cannot read the Firstmate task directory your brief names for proof and scratch output, because it is outside this worktree; for paths there, call file_read and file_write directly or use the shell.
ok - generated worker facet carries the task-directory guidance
--- $LAB/fm/data/pttaskdir/proof.txt:
taskdir-ok
--- worktree readback.txt:
taskdir-ok
--- tool calls touching the task dir in the retained session log (name + path):
["file_read","{\"path\":\"$LAB/fm/data/pttaskdir/proof.txt\"}"]
["file_read","{\"value\":{\"path\":\"$LAB/fm/data/pttaskdir/proof.txt\"},\"truncated\":false}"]
["file_write","{\"content\":\"taskdir-ok\",\"path\":\"$LAB/fm/data/pttaskdir/proof.txt\"}"]
["file_write","{\"content\":\"taskdir-ok\",\"path\":\"readback.txt\"}"]
["file_write","{\"value\":{\"content\":\"taskdir-ok\",\"path\":\"$LAB/fm/data/pttaskdir/proof.txt\"},\"truncated\":false}"]
["file_write","{\"value\":{\"content\":\"taskdir-ok\",\"path\":\"readback.txt\"},\"truncated\":false}"]
ok - a real polytoken worker wrote and read back proof in $FM_HOME/data/<task-id>/ with its file tools
ok - lab worker exited and torn down
Evidence: Busy union scoped to polytoken on a real tmux pane

Source: Busy union scoped to polytoken on a real tmux pane

union line main vs head: identical harness-less fm_pane_busy_state: idle polytoken fm_pane_busy_state: busy claude fm_pane_busy_state: idle

union line main vs head:
  identical
pane:
  ⠋ thinking
  Running for 3.03s
harness-less fm_pane_busy_state: idle
polytoken    fm_pane_busy_state: busy
claude       fm_pane_busy_state: idle
Evidence: fm-spawn-pool-base-freshen test log

Source: fm-spawn-pool-base-freshen test log

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 - a launch refused after its slot claim leaves the pool for a retry and a second task
ok - a refused polytoken launch leaves its per-id paths alone while another spawn holds the per-id lock
ok - a non-polytoken launch refused after its slot claim keeps main's abort behavior
ok - the treehouse-get isolation refusal points only at what survives the 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 - --base-branch picks the copy's starting point and is recorded; a missing or local-only base refuses
ok - a spawn refuses when --base-branch and the brief's Base branch lines disagree
ok - a Base branch line in the captain's intent neither blocks nor redirects a spawn
ok - a based scout on a forge=gerrit project is refused at spawn
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
ok - an origin-less pooled worktree launches as-is, skipping the freshness gate
ok - a dirty origin-less pooled worktree is refused without 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 origin-less
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: fm-polytoken-harness test log

Source: fm-polytoken-harness test log

ok - fm-harness.sh: ancestry detects a natively-named polytoken command
ok - fm-harness.sh: ancestry rejects unrelated polytoken mentions
ok - fm-harness.sh: no inherited launcher marker claims the polytoken identity
ok - fm-control-lib: polytoken mechanics are REST interrupt, /quit exit, no secondmates
ok - fm-control-lib: polytoken wiring tables name every generated artifact and no project file
ok - bin/fm-agent-process-lib.sh: polytoken is an agent, fragments are not
ok - fm-busy-lib: the polytoken-hook source is scoped to polytoken tasks
ok - fm-composer-lib: only the pinned Running-for row carries the polytoken busy verdict
ok - fm-composer-lib: the polytoken separated shape reads empty, pending, and unknown exactly
ok - fm-composer-lib: the queued-Enter conversion covers polytoken's verified queue behavior
ok - fm-tmux-lib: only a polytoken-identity pane confirms a submit from its Running-for row
ok - fm-polytoken-lib: the config mirror enforces the unattended posture
ok - fm-polytoken-lib: the worker facet carries the role contract and no model pin
ok - fm-polytoken-lib: the no-argv busy writer opens, closes, and never fails
ok - fm-polytoken-lib: the hook layer binds the three events and refuses to clobber
ok - fm-polytoken-lib: the model ref composes the effort axis and refuses unlisted models
ok - fm-polytoken-lib: an unreachable listing refuses an unprovable pin
ok - fm-polytoken-lib: the REST interrupt reports cancelled, not-running, and refuses unauthorized
ok - fm-polytoken-lib: the interrupt close lands after mid-turn rewrites and spares a reopened or running turn
ok - fm-polytoken-lib: the typed settle postcondition follows GET /sync
ok - fm-spawn: the polytoken launch carries the hybrid contract end to end
ok - fm-spawn: polytoken maps an unlisted effort and retains the requested axis
ok - fm-spawn: polytoken requires explicit model and effort axes
ok - fm-spawn: an unlisted polytoken model refuses before pane creation
ok - fm-spawn: polytoken cannot be launched as a secondmate
ok - fm-spawn: a project's own polytoken hook layer is refused, not clobbered
ok - fm-spawn: a whitespace-bearing state dir refuses polytoken wiring before writing any
ok - fm-spawn: a failed readiness gate fails loudly, reaps, and retires its wiring
ok - fm-spawn: a gate failure after publication drops the slot claim with the record
ok - fm-spawn: the polytoken busy contract arms and advances through the generated writer

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

🔧 **Review** - 1 issue found → auto-fixed ✅
  • ⚠️ bin/fm-spawn.sh:1593 - The Polytoken abort branch in spawn_abort_cleanup deletes per-task-id paths without holding the per-id spawn lock, which this trap releases earlier, at bin/fm-spawn.sh:1553. The paths are rm -rf $TASK_TMP (/tmp/fm-$ID, which the comment at ~5108 calls a shared per-id root), the $STATE/$ID.polytoken-config, -sessions and -sessions-v1 dirs plus $ID.polytoken-busy.sh via clear_relaunch_harness_wiring (1590), and the staged launch file (1597). Concrete sequence: a refused Polytoken spawn prints its error before the EXIT trap runs, and the trap then spends time in fm_backend_kill. The intent's own scenario is an immediate retry of the same task id on another harness. That retry takes the per-id lock, finds /tmp/fm-$ID already present and owned by the same user, and reuses it (the mkdir-else branch at ~5111). The first process's trap then runs rm -rf /tmp/fm-$ID and deletes the retry's temp root. The same trap already guards against exactly this race for the git-hooks strip dir at bin/fm-spawn.sh:1660-1668, where it retakes SPAWN_TASK_LOCK with fm_lock_try_acquire and re-checks that $STATE/$ID.meta is absent. Fix: put the Polytoken removals (TASK_TMP, the clear_relaunch_harness_wiring call, the staged launch file) under the same retaken SPAWN_TASK_LOCK and meta re-check, and skip them on contention. Endpoint close and slot release can stay where they are.

🔧 Fix applied.
✅ Re-checked - no issues remain.

✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 6 of 7 scenarios driven live against the product
Scenario Result Live Evidence
Operator spawns a polytoken task into a project that tracks its own .polytoken/hooks.json: the spawn is refused, its window is closed, no task record is published, the real Treehouse slot reads availa… ✅ pass live refused-spawn-pool-lab.log (checks 1-8)
After that refusal, a same-id retry on another harness and then a different task each launch into their own slot, and each slot's claim names its own task ✅ pass live refused-spawn-pool-lab.log (checks 9-14, treehouse status at end)
Adversarial: a concurrent retry holds the per-id spawn lock while the refused polytoken abort runs. The abort warns and leaves /tmp/fm-<id> in place, and still closes the window and returns the slot;… ✅ pass live contended-lock-pool-lab.log (warning line; temp root kept; slot 'available'; retry exit 0)
A real Polytoken worker runs the full lifecycle: launch with model/effort pin, brief runs, busy hooks open and close, fm-send steer is acknowledged, REST interrupt, relaunch rebinds the session, exit,… ✅ pass live polytoken-signals-live-e2e.log (all ok)
A real Polytoken worker writes and reads back proof in $FM_HOME/data/<task-id>/ with its file tools, and the generated facet carries the task-directory guidance (the settled implementation of the acce… ✅ pass live polytoken-taskdir-live.log
Polytoken-only scoping: the harness-less delivery busy union is byte-identical to base, and a real pane rendering 'Running for 3.03s' reads idle harness-less and under claude but busy under polytoken ✅ pass live busy-union-scope-live.log
Non-polytoken refused launch keeps main's behavior (window stays open, pre-publication claim dropped) ⏸️ untested no The prior payload did not establish a live result for this scenario. Its only coverage was the fixture-driven unit test test_non_polytoken_refused_launch_keeps_its_window in tests/fm-spawn-pool-base-f…
  • bash refused-spawn-pool-lab.sh &lt;worktree&gt;: real bin/fm-spawn.sh + real treehouse pool + private tmux socket; refused polytoken spawn, then same-id retry on raw bash, then a second task
  • bash contended-lock-pool-lab.sh &lt;worktree&gt;: same real lab, with a PATH tmux shim that takes $FM_HOME/state/.spawn-pt1.lock at kill-window to stand in for a concurrent retry
  • FM_POLYTOKEN_SIGNALS_LIVE=1 bash tests/fm-polytoken-signals-live-e2e.test.sh (real polytoken 0.9.0 worker, zai/glm-5.3-flash low)
  • WT_ROOT=$PWD FM_POLYTOKEN_SIGNALS_LIVE=1 bash polytoken-taskdir-live.sh (real worker file_read/file_write into $FM_HOME/data/<id>/)
  • bash busy-union-scope-live.sh &lt;worktree&gt; (real tmux pane rendering 'Running for 3.03s'; union diffed against base ce697402)
  • bash tests/fm-spawn-pool-base-freshen.test.sh (includes the new contended-lock test and the non-polytoken keeps-its-window test)
  • bash tests/fm-polytoken-harness.test.sh (submit-core ack and stale-hint coverage)
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

Add polytoken 0.8.19 as a verified crewmate/scout adapter on the
captain-approved TUI-pane-plus-REST hybrid: the pane keeps inspection
and backend parity while the control verbs ride the session daemon's
typed REST API.

Detection is ancestry alone on the anchored polytoken comm (a tool
subprocess's parent is the session daemon, verified live), with the
launch boundary clearing every foreign ORCA_/FM_ marker plus the fixed
harness-identity set. The launch generates the per-task worker config
dir (mirrored operator config with the unattended permission posture
enforced, because a project config.yaml fully replaces the global
config), the worker role-contract facet (no model pin, delegation and
facet switching denied at the tool registry), and the worktree hook
layer binding the verified busy pair - pre_user_prompt and
pre_model_turn open, stop closes - to a no-argv generated writer. The
readiness gate binds the session id, port, and credential into task
metadata through sessions --format json and fails loudly on any
first-start dialog, because the license terms are a blocker by captain
decision and --accept-license-terms is never passed.

Interrupt is POST /turn/cancel with its typed settle (the TUI has no
interrupt chord, so no key is ever improvised), exit is /quit, and a
cancelled turn's busy close is written by the control plane because no
stop hook fires. The composer is the verified separated shape with
polytoken as its second owner, and Enter mid-turn queues, so the
busy-queued conversion applies. Crewmate and scout only: a secondmate
launch is refused, and a project's own .polytoken/hooks.json is refused
rather than clobbered.
The refused relaunch onto polytoken resolves the polytoken binary before
its hook-layer refusal, so the case failed on CI hosts without the real
CLI installed. A no-op stub on the fixture PATH stands in; it is never
launched.
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thank you @sjennings for bringing Polytoken back on current main without a version pin, and for re-validating live on 0.9.0. The adversarial relaunch-refusal runs, where the worker, session and daemon profile survive every bad profile, are exactly the evidence that makes a new adapter easy to trust.

Diff review and CI: I read the full diff against main 33503ab3. There are no .github/workflow changes, and the REST control stays on loopback with the token on stdin. The per-task config is a private mirror of the operator's own config, rm -rf is scoped to state/<id>.polytoken-*, and --accept-license-terms is never passed. I approved the fork runs for this tip (CI 38660376452, Require no-mistakes 38660605101 / 38660532898 / 38660376372). The attestation matches 4178eb38.

Contract-class (my own read of the unconfigured path): new-default. The Polytoken lane itself is opt-in. But two changes reach every home's existing harnesses, even when Polytoken is never dispatched:

  1. fm-teardown.sh now runs remove_harness_worktree_wiring for every task's recorded harness. On the non-Orca return, that newly deletes OpenCode's .opencode/plugins/fm-busy-state.js, which main leaves in place.
  2. clear_relaunch_harness_wiring now skips git-tracked worktree wiring for all harnesses on relaunch, where main removes it unconditionally.

Both look sensible and protective, but they change existing default paths, so this can't take the auto-merge lane as-is. Once CI is green, it goes to Kun as a merge-or-leave decision. If you'd rather keep it on the auto-merge path, scoping those two changes to polytoken (or splitting them into their own PR) would make this purely opt-in. Either way works, and it's your call. (The harness-less delivery-union addition follows the agy/Devin precedent, and I'm not counting it against the class.)

VISION.md: all seven rules align. Scope is noted only because of the two fleet-wide deltas above.

Status: waiting on the approved CI. Nothing is required from you unless you want to make the scoping change.

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: a quick heads-up, @sjennings. #6679 (the Command Code adapter) just landed on main, and it edits the same harness lists, so GitHub now reports this PR as conflicting. When you rebase onto current main, a fresh git push no-mistakes will refresh the attestation for the new head. That's also a natural point to scope the two fleet-wide teardown/relaunch changes from my note above, if you want to. This is waiting on you for the rebase; everything else in my earlier note still stands.