Skip to content

feat(bin): enforce an opt-in concurrent Sol session ceiling - #7433

Open
kesslerio wants to merge 54 commits into
kunchenguid:mainfrom
kesslerio:fm/sol61-ceiling-enforcement
Open

kesslerio wants to merge 54 commits into
kunchenguid:mainfrom
kesslerio:fm/sol61-ceiling-enforcement

Conversation

@kesslerio

@kesslerio kesslerio commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

What Changed

  • Adds bin/fm-sol-cap-lib.sh, which owns admission, counting, and claim reconciliation for a captain-declared config/sol-cap ceiling on concurrent covered-model sessions: inert when undeclared, refusing at the ceiling instead of queueing, with a per-home state/sol-sessions.tsv registry counted across local homes.
  • Wires the guard into bin/fm-spawn.sh (local and remote secondmate launches), bin/fm-teardown.sh, and bin/fm-remote-secondmate-relaunch.sh, so occupancy is reserved before launch, reconciled from the endpoint-reported model, matched per home's own declaration, and released only after a confirmed endpoint close or retirement.
  • Adds fm_backend_kill_confirmed with per-backend absence proofs (tmux, herdr, zellij, cmux, orca, paseo, rex, t3code, tern, hc) while ordinary teardown keeps the unchanged best-effort close, and adds covering tests plus documentation for the ceiling, the confirmed-close contract, and the superseded-row rules.

Risk Assessment

⚠️ Medium: The normal spawn paths carry effective configuration, but the operator CLI can produce an incorrect admission decision with an explicitly supplied redirected configuration.

Testing

Live-validated the change with a disposable marked lab home plus a registered secondmate lab home, driving the real bin/fm-spawn.sh and bin/fm-sol-cap-lib.sh entrypoints. A worker admitted through the product into the secondmate's own state root made a primary-home dispatch refuse at max=1, naming that session and its separate state root and creating no task record; stopping it freed the slot. With a separate state override and a redirected config, admission claimed the slot and the spawn's staged handoff (which carries both overrides) was executed in a real tmux pane on the lab's private socket, promoting the reservation onto a live worker while the config inferred from the state path was malformed. Adversarially, a malformed effective declaration refused loudly with no reservation, and a permissive declaration sitting at the state path's inferred config was never consulted (the second dispatch still refused at max=1) while switching the effective config to that permissive file admitted, proving the trap reachable. The three focused suites covering this feature also pass. No UI surface exists in this change, so no visual artifact applies; the evidence is transcripts, the staged handoff, the real-pane capture, and the resulting registry row.

  • Live validation: ✅ go - 4 of 4 scenarios driven live against the product
Scenario Result Live Evidence
A dispatch from the primary lab home (max=1) is refused because a covered worker occupies a registered secondmate home's separate state root, and the refusal names that session and its state root with… ✅ pass live live-sol-cap.log lines 5-19; sol-cap-cross-root-refusal.txt: real bin/fm-spawn.sh exits 1 with 'Sol ceiling reached: ... sm-task (gpt-6.1-sol, age 3s) in <lab>/sm/state' and no <id>.meta; after that w…
A dispatch with FM_STATE_OVERRIDE plus a redirected FM_CONFIG_OVERRIDE is admitted, its staged handoff carries both overrides, and that handoff promotes the delivery reservation and runs the worker in… ✅ pass live live-sol-cap.log lines 21-84; sol-cap-live-handoff.txt; sol-cap-live-pane.txt ('live worker reachable, argv: probe-ran'); sol-cap-live-registry.tsv row promoted from pid 0 to the live worker pid; cont…
Adversarial: a malformed effective declaration refuses the dispatch loudly, naming the file and the bad max, with no reservation row and no task record left behind ✅ pass live live-sol-cap.log lines 86-96; sol-cap-malformed-effective-refusal.txt: 'Sol ceiling unavailable: <cfg>/sol-cap must declare max as a positive integer ...'; no sol-sessions.tsv and no task-three.meta
Adversarial: a permissive declaration placed at the state path's inferred config is never consulted - the second dispatch at max=1 is refused naming the first occupant, while switching the effective c… ✅ pass live live-sol-cap.log lines 98-110; sol-cap-inferred-config-ignored-refusal.txt ('Sol ceiling reached ... task-four-a (gpt-6.1-sol ...)') and the control admission 'claimed' under the permissive declaratio…
Evidence: Live Sol-ceiling driver transcript (S1-S4, all checks passing)

Source: Live Sol-ceiling driver transcript (S1-S4, all checks passing)

lab primary home : /tmp/fm-lab.gn4pu7
lab secondmate   : /tmp/fm-lab.gn4pu7/sm
lab tmux socket  : /tmp/fml.kKUgv5/fm-lab.sock

== S1  registered secondmate home's separate state root holds the slot
   secondmate admission: claimed
   secondmate registry: sm-task	gpt-6.1-sol	1794296344	3333610
PASS the secondmate home holds a live covered session (pid 3333610)

== S1  dispatch from the primary lab home at that machine-wide ceiling (rc=1)
   | error: Sol ceiling reached: 1 concurrent capped session(s) already active and this ceiling is 1 (declared in config/sol-cap); the dispatch of task task-one (codex, gpt-6.1-sol) was refused. Active sessions: sm-task (gpt-6.1-sol, age 3s) in /tmp/fm-lab.gn4pu7/sm/state. A session frees its slot when its worker's process ends; the dispatch contract refuses at the ceiling instead of queueing
PASS the dispatch was refused
PASS the refusal names the ceiling
PASS the refusal names the secondmate's session
PASS the refusal names the separate state root it counted
PASS the refused dispatch published no task record
   ceiling still declared after the secondmate worker exited: 1
   dispatch after the secondmate session stopped: claimed
PASS the stopped session freed the machine-wide slot

== S2  separate state override reads the effective redirected configuration

== S2  dispatch under separate state + redirected config (rc=0)
   | warning: /tmp/fm-lab.gn4pu7/data/task-two/launch-brief.md records no ship branch; defaulting to legacy branch fm/task-two
   | spawned task-two harness=codex kind=ship mode=no-mistakes yolo=off window=firstmate:fm-task-two worktree=/tmp/fm-lab.gn4pu7/cases/s2/wt-task-two
PASS admission accepted the dispatch
   state override registry after admission: task-two	gpt-6.1-sol	1794296349	0
   spawn tmux calls:
     t| display-message -p -t $0 #S
     t| list-windows -t firstmate -F #{window_name}
     t| new-window -dP -F #{window_id} -t firstmate: -n fm-task-two -c /tmp/fm-lab.gn4pu7/proj
     t| set-window-option -t  automatic-rename off
     t| set-window-option -t  allow-rename off
     t| send-keys -t firstmate:fm-task-two treehouse get Enter
     t| display-message -p -t firstmate:fm-task-two #{pane_current_path}
     t| display-message -p -t firstmate:fm-task-two #{pane_current_path}
     t| send-keys -t firstmate:fm-task-two cd -- '/tmp/fm-lab.gn4pu7/cases/s2/wt-task-two' Enter
     t| display-message -p -t firstmate:fm-task-two #{pane_current_path}
     t| list-windows -t =firstmate -F #{window_name}
     t| list-windows -t =firstmate -F #{window_name}
     t| capture-pane -p -t firstmate:fm-task-two -S -40
     t| send-keys -t firstmate:fm-task-two export GOTMPDIR=/tmp/fm-task-two/gotmp Enter
     t| send-keys -t firstmate:fm-task-two export COMPACT_ADVISER_DISABLE=1 Enter
     t| send-keys -t firstmate:fm-task-two export FM_TASK_ID=task-two Enter
     t| send-keys -t firstmate:fm-task-two -l . '/tmp/fm-task-two+3cea1f415b0eceefe7ba6653c42203df2aedfeacaf37c77ce84e5a74df90e682/launch.s1794296353.3336715.10563.sh'
     t| list-windows -t =firstmate -F #{window_name}
     t| send-keys -t firstmate:fm-task-two Enter
   staged launch files under the state root:
   staged handoff file: /tmp/fm-task-two+3cea1f415b0eceefe7ba6653c42203df2aedfeacaf37c77ce84e5a74df90e682/launch.s1794296353.3336715.10563.sh
PASS the spawn staged a launch handoff
   handoff: FM_HOME='/tmp/fm-lab.gn4pu7' FM_STATE_OVERRIDE='/tmp/fm-lab.gn4pu7/runtime/state' FM_CONFIG_OVERRIDE='/tmp/fm-lab.gn4pu7/redir-config' bash '{run-worktree}/bin/fm-sol-cap-lib.sh' run-launch 'task-two' '/tmp/fm-lab.gn4pu7/runtime/state' 'export COMPACT_ADVISER_DISABLE=1; export FM_TASK_INBOX='\''/tmp/fm-lab.gn4pu7/runtime/state/task-two.inbox'\''; '\''{run-worktree}/bin/fm-osc7501.sh'\'' arm --task '\''task-two'\'' --harness '\''codex'\'' --backend '\''tmux'\'' --kind '\''ship'\'' --state '\''/tmp/fm-lab.gn4pu7/runtime/state'\'' --config '\''/tmp/fm-lab.gn4pu7/redir-config'\'' --target '\''firstmate:fm-task-two'\'' --agent-bin '\''/tmp/fm-lab.gn4pu7/fakebin/codex'\'' >/dev/null || true
'\''{run-worktree}/bin/fm-git-strip-ai-trailers.sh'\'' env-file '\''/tmp/fm-lab.gn4pu7/runtime/state/task-two.git-hooks'\'' '\''/tmp/fm-task-two+3cea1f415b0eceefe7ba6653c42203df2aedfeacaf37c77ce84e5a74df90e682/git-config.s1794296353.3336715.10563.sh'\'' && . '\''/tmp/fm-task-two+3cea1f415b0eceefe7ba6653c42203df2aedfeacaf37c77ce84e5a74df90e682/git-config.s1794296353.3336715.10563.sh'\'' || return 1 2>/dev/null || exit 1; export FM_HOME='\''/tmp/fm-lab.gn4pu7'\''; env -u CURSOR_AGENT -u CURSOR_INVOKED_AS -u GEMINI_CLI /tmp/fm-lab.gn4pu7/fakebin/codex '\''/tmp/fm-lab.gn4pu7/cases/s2/invocation.argv'\''
'\''{run-worktree}/bin/fm-osc7501.sh'\'' disarm --state '\''/tmp/fm-lab.gn4pu7/runtime/state'\'' >/dev/null 2>/dev/null || true'
PASS the handoff passes the resolved config override
PASS the handoff passes the resolved state override
PASS the worker launched in the real pane: probe-ran
   real pane after the launch:
     p| . '/tmp/fm-task-two+3cea1f415b0eceefe7ba6653c42203df2aedfeacaf37c77ce84e5a74df90e682/launch.s1794296353.3336715.10563.sh'
     p| 
     p| [art@zeppola:/tmp/fm-lab.gn4pu7/cases/s2/wt-task-two]$ . '/tmp/fm-task-two+3cea1f415b0eceefe7ba6653c42203df2aedfeacaf37c77ce84e5a74df90e682/launch.s1794296353.3336715.10563.sh'
     p| live worker reachable, argv: probe-ran
     p| 
     p| 
     p| 
     p| 
     p| 
     p| 
     p| 
     p| 
     p| 
     p| 
     p| 
     p| 
     p| 
     p| 
     p| 
     p| 
   state override registry after launch: task-two	gpt-6.1-sol	1794296349	3340321
PASS the reservation was promoted onto the live worker process (pid 3340321)

== S2 control: same state root, path-inferred malformed declaration, no effective override (rc=1)
   | error: Sol ceiling unavailable: /tmp/fm-lab.gn4pu7/runtime/config/sol-cap must declare max as a positive integer of at most nine digits, not 'invalid'; task task-ctl with model gpt-6.1-sol was not dispatched rather than launched against an undeclared ceiling
PASS the path-inferred malformed declaration refuses
PASS the refusal names the malformed declaration

== S3  adversarial: a malformed effective declaration refuses and reserves nothing

== S3  dispatch under a malformed effective declaration (rc=1)
   | error: Sol ceiling unavailable: /tmp/fm-lab.gn4pu7/cases/s3/bad-config/sol-cap must declare max as a positive integer of at most nine digits, not 'invalid'; task task-three with model gpt-6.1-sol was not dispatched rather than launched against an undeclared ceiling
PASS the dispatch was refused
PASS the refusal names the ceiling as unavailable
PASS the refusal names the malformed max
PASS the refusal names the offending file
PASS no reservation was written for the refused dispatch
PASS no task record was published for the refused dispatch

== S4  adversarial: a permissive declaration at the inferred config path is not consulted
PASS the first covered worker is live in the redirected state root (pid 3341143)

== S4  first admission under max=1: rc=0 claimed

== S4  second admission, permissive trap present at the inferred path: rc=1
   | error: Sol ceiling reached: 1 concurrent capped session(s) already active and this ceiling is 1 (declared in config/sol-cap); the dispatch of task task-four-b (codex, gpt-6.1-sol) was refused. Active sessions: task-four-a (gpt-6.1-sol, age 2s). A session frees its slot when its worker's process ends; the dispatch contract refuses at the ceiling instead of queueing
PASS the first admission claimed the only slot
PASS the second admission was refused at the ceiling
PASS the refusal names the ceiling
PASS the refusal names the occupying session

== S4 control: same state, effective config switched to the permissive one: rc=0 claimed
PASS the permissive declaration admits, so the trap is genuinely reachable

== evidence
   wrote evidence under ~/.no-mistakes/evidence/01M725HG5Q50ECNGF4V37CVFN8

== teardown

lab homes and socket removed: /tmp/fm-lab.gn4pu7

RESULT: all live scenarios passed
Evidence: Live validation driver script (all scenarios, disposable lab homes)

Source: Live validation driver script (all scenarios, disposable lab homes)

#!/usr/bin/env bash
# Live validation driver for the Sol ceiling change under test
# (fm/sol61-ceiling-enforcement): "Enforce Sol ceiling across separate state
# roots and resolve state override against effective configuration".
#
# It stands up a disposable, marked fm-lab home (bin/fm-lab-home.sh) plus a
# registered local secondmate lab home, then drives the REAL product entrypoints
# (bin/fm-spawn.sh and bin/fm-sol-cap-lib.sh) against them:
#
#   S1  a capped worker occupying a registered secondmate home's separate state
#       root makes a dispatch from the primary lab home refuse at the ceiling.
#   S2  redirected config + separate state override: admission claims, the
#       staged handoff promotes the reservation and runs the worker in a REAL
#       tmux pane on the lab's private socket, even though the config inferred
#       from the state path is malformed.
#   S3  adversarial: a malformed *effective* declaration refuses loudly and
#       leaves no reservation and no task record.
#   S4  adversarial: a permissive declaration sitting at the state path's
#       inferred config must not be consulted when the effective config is
#       max=1 - the second dispatch refuses; switching the effective config to
#       the permissive one admits it (control proving the trap is reachable).
set -u

ROOT=${FM_LIVE_ROOT:?set FM_LIVE_ROOT to the run worktree}
EVID=${FM_LIVE_EVIDENCE:?set FM_LIVE_EVIDENCE to the evidence dir}
TMUX_BIN=$(command -v tmux) || { echo "tmux is not on PATH; the live pane launch cannot run"; exit 1; }
LAB=$(mktemp -d "${TMPDIR:-/tmp}/fm-lab.XXXXXX") || exit 1
SOCK=
TMUX_SESS=fm-lab-launch
FAILS=0

cleanup() {
  if [ -n "$SOCK" ]; then
    "$TMUX_BIN" -S "$SOCK/fm-lab.sock" kill-server 2>/dev/null || true
    rm -rf "$SOCK" 2>/dev/null || true
  fi
  # Stop any worker the launcher left running in the lab.
  pkill -f "$LAB/" 2>/dev/null || true
  [ -z "${STAGED_DIR:-}" ] || rm -rf "$STAGED_DIR" 2>/dev/null || true
  chmod -R u+w "$LAB" 2>/dev/null || true
  rm -rf "$LAB" 2>/dev/null || true
}
trap cleanup EXIT INT TERM

say() { printf '\n== %s\n' "$*"; }
note() { printf '   %s\n' "$*"; }
ok() { printf 'PASS %s\n' "$*"; }
bad() { printf 'FAIL %s\n' "$*"; FAILS=$((FAILS + 1)); }
check() {  # <description> <expected-substring> <actual>
  case "$3" in
    *"$2"*) ok "$1" ;;
    *) bad "$1 (missing: $2)"; printf '%s\n' "$3" | sed 's/^/     | /' ;;
  esac
}
check_absent() {  # <description> <file>
  if [ -e "$2" ]; then bad "$1 ($2 exists)"; else ok "$1"; fi
}

# --- disposable lab homes ---------------------------------------------------
# Minted by the supported writer, which only marks a fresh empty directory and
# is the one authorization a gate agent may use for fleet lifecycle.
H=$("$ROOT/bin/fm-lab-home.sh" create "$LAB") || { echo "cannot mint lab home"; exit 1; }
M=$("$ROOT/bin/fm-lab-home.sh" create "$LAB/sm") || { echo "cannot mint secondmate lab home"; exit 1; }
SOCK=$("$ROOT/bin/fm-lab-home.sh" tmux-dir "$H") || { echo "cannot mint lab tmux dir"; exit 1; }
printf 'lab primary home : %s\nlab secondmate   : %s\nlab tmux socket  : %s/fm-lab.sock\n' "$H" "$M" "$SOCK"

# Both homes declare the same ceiling and cover the same Sol model, so the
# machine-wide count is one declaration's worth across two state roots.
printf 'max=1\nmodels=gpt-6.1-sol\n' > "$H/config/sol-cap"
printf 'max=1\nmodels=gpt-6.1-sol\n' > "$M/config/sol-cap"

# Register the secondmate as a LOCAL home the way a real captain's
# data/secondmates.md does, so machine-local state enumeration discovers it.
cat > "$H/data/secondmates.md" <<EOF
# Secondmates

- sm - disposable lab secondmate (home: $M/; scope: repo; projects: all; added 2026-01-01)
EOF

# --- project fixture an end user dispatches from ---------------------------
PROJ=$LAB/proj
mkdir -p "$PROJ"
git -C "$PROJ" init -q -b main
git -C "$PROJ" -c user.email=lab@example.invalid -c user.name=Lab commit -q --allow-empty -m init
git init -q --bare "$PROJ.origin.git"
git -C "$PROJ" remote add origin "$PROJ.origin.git"
git --git-dir="$PROJ.origin.git" symbolic-ref HEAD refs/heads/main
git -C "$PROJ" -c user.email=lab@example.invalid -c user.name=Lab push -q -u origin main 2>/dev/null || true

# --- external tools the spawn/launch shells call (not firstmate itself) ----
FAKE=$LAB/fakebin
mkdir -p "$FAKE"
for tool in treehouse gh gh-axi no-mistakes; do
  printf '#!/usr/bin/env bash\nexit 0\n' > "$FAKE/$tool"
  chmod +x "$FAKE/$tool"
done
# The worker the launch must actually run: records the argv it received and
# whether it was reached at all.
cat > "$FAKE/codex" <<'SH'
#!/usr/bin/env bash
# The probe the launch must actually run; <log> is baked into the raw launch
# command so the pane never depends on PATH lookup.
log=$1
shift
printf '%s\n' "${*:-probe-ran}" >> "$log"
printf 'live worker reachable, argv: %s\n' "${*:-probe-ran}"
sleep 30
SH
chmod +x "$FAKE/codex"

# tmux stand-in for the spawn's window bookkeeping only. The launch handoff
# itself is executed in a REAL tmux pane below.
cat > "$FAKE/tmux" <<'SH'
#!/usr/bin/env bash
printf '%s\n' "$*" >> "$FM_LIVE_CALL_LOG"
case "${1:-}" in
  display-message)
    case "$*" in
      *pane_current_path*) printf '%s\n' "${FM_LIVE_PANE_PATH:-}" ;;
      *) printf 'firstmate\n' ;;
    esac ;;
  list-windows) [ ! -s "$FM_LIVE_CALL_LOG.w" ] || cat "$FM_LIVE_CALL_LOG.w" ;;
  list-panes) printf '%s\n' "${FM_LIVE_PANE_PID:-0}" ;;
  new-window)
    prev=; name=
    for a in "$@"; do [ "$prev" = -n ] && name=$a; prev=$a; done
    grep -Fqx -- "$name" "$FM_LIVE_CALL_LOG.w" 2>/dev/null || printf '%s\n' "$name" >> "$FM_LIVE_CALL_LOG.w" ;;
  kill-window) : ;;
  send-keys)
    # Record the launch text the spawn hands the pane so the same handoff can
    # be executed in a real tmux pane below.
    prev=
    for a in "$@"; do
      if [ "$prev" = -l ]; then
        case "$a" in
          ". '"*"'")
            staged=${a#". '"}
            staged=${staged%"'"}
            if [ -f "$staged" ]; then
              cat "$staged" >> "$FM_LIVE_CALL_LOG.launch"
              printf '%s\n' "$staged" >> "$FM_LIVE_CALL_LOG.launchpath"
            fi ;;
        esac
      fi
      prev=$a
    done ;;
  *) : ;;
esac
exit 0
SH
chmod +x "$FAKE/tmux"

task_fixture() {  # <home> <id>
  mkdir -p "$1/data/$2"
  cat > "$1/data/$2/brief.md" <<EOF
# Task
## Captain's intent
Live Sol-ceiling check for $2.

## Firstmate spec
Drive the real ceiling admission path.

# Definition of done
Delivery contract: mode=no-mistakes
EOF
  printf '{"task":"%s","status":"off","profile":null}\n' "$2" > "$1/data/$2/dispatch-resolution.json"
}

# The real dispatch entrypoint, run from the lab (not a gate worktree) with the
# marked lab home so the product's own gate boundary permits it.
unset NO_MISTAKES_GATE FM_GATE_REFUSE_BYPASS
cd "$LAB" || exit 1

run_spawn() {  # <case-dir> <pane-path> <args...>
  local case_dir=$1 pane=$2
  shift 2
  env -u FM_ROOT_OVERRIDE FM_HOME="$H" FM_SPAWN_NO_GUARD=1 \
    TMUX="fake,1,0" FM_BACKEND=tmux FM_LIVE_PANE_PID="$$" \
    FM_LIVE_PANE_PATH="$pane" FM_LIVE_CALL_LOG="$case_dir/calls.log" \
    FM_LIVE_INVOCATION_LOG="$case_dir/invocation" \
    PATH="$FAKE:$PATH" \
    "$ROOT/bin/fm-spawn.sh" "$@" 2>&1
}

new_worktree() {  # <case-dir> <name>
  git -C "$PROJ" worktree add --quiet -b "wt-$2" "$1/wt-$2" >/dev/null 2>&1
  printf '%s\n' "$1/wt-$2"
}

CASES=$LAB/cases
mkdir -p "$CASES"

# =========================================================================
say "S1  registered secondmate home's separate state root holds the slot"
# The secondmate dispatch is admitted through the real product: admission
# reserves, then the reservation is promoted onto a real long-running worker
# process inside the secondmate's own state root. Nothing here is hand-written
# registry data.
task_fixture "$M" sm-task
(
  cd "$LAB" || exit 1
  env -u FM_ROOT_OVERRIDE FM_HOME="$M" PATH="$FAKE:$PATH" \
    "$ROOT/bin/fm-sol-cap-lib.sh" refuse-claim sm-task ship codex gpt-6.1-sol \
    "$M/config" "$M/state" >"$CASES/sm-admit.out" 2>&1 || exit 1
  exec env -u FM_ROOT_OVERRIDE FM_HOME="$M" \
    "$ROOT/bin/fm-sol-cap-lib.sh" run sm-task "$M/state" sleep 120
) &
SM_PID=$!
sleep 1.5
note "sec

... [4559 bytes truncated] ...

ly as an operator's shell would carry its PATH.
  env FM_LIVE_INVOCATION_LOG="$S2/invocation" \
    "$TMUX_BIN" -S "$SOCK/fm-lab.sock" new-session -d -s "$TMUX_SESS" -x 200 -y 50 -c "$S2_PANE"
  "$TMUX_BIN" -S "$SOCK/fm-lab.sock" send-keys -t "$TMUX_SESS" ". '$STAGED'" Enter
  i=0
  while [ "$i" -lt 40 ]; do
    [ -s "$S2/invocation.argv" ] && break
    i=$((i + 1))
    sleep 0.25
  done
  if [ -s "$S2/invocation.argv" ]; then
    ok "the worker launched in the real pane: $(cat "$S2/invocation.argv")"
  else
    bad "the worker never ran in the real pane"
    "$TMUX_BIN" -S "$SOCK/fm-lab.sock" capture-pane -p -t "$TMUX_SESS" | sed 's/^/     p| /'
  fi
  "$TMUX_BIN" -S "$SOCK/fm-lab.sock" capture-pane -p -t "$TMUX_SESS" > "$S2/pane.txt" 2>/dev/null || true
  note "real pane after the launch:"; sed 's/^/     p| /' "$S2/pane.txt" 2>/dev/null | head -20
  S2_PROMOTED=$(awk -F'\t' '$1 == "task-two" {print $4}' "$S2_STATE/sol-sessions.tsv" 2>/dev/null || true)
  note "state override registry after launch: $(cat "$S2_STATE/sol-sessions.tsv" 2>/dev/null || echo '<none>')"
  case "$S2_PROMOTED" in
    '' | 0) bad "the reservation was not promoted to the worker (pid '${S2_PROMOTED:-none}')" ;;
    *)
      if kill -0 "$S2_PROMOTED" 2>/dev/null; then
        ok "the reservation was promoted onto the live worker process (pid $S2_PROMOTED)"
      else
        bad "the promoted pid $S2_PROMOTED is not alive"
      fi ;;
  esac
else
  bad "the spawn staged no launch handoff"
fi

# Control: the malformed declaration inferred from the state path really does
# refuse, proving S2 resolved the override rather than a harmless path.
S2C_OUT=$(cd "$LAB" && env -u FM_ROOT_OVERRIDE FM_HOME="$H" FM_STATE_OVERRIDE="$S2_STATE" \
  "$ROOT/bin/fm-sol-cap-lib.sh" refuse-claim task-ctl ship codex gpt-6.1-sol \
  "$RUNTIME/config" "$S2_STATE" 2>&1)
S2C_RC=$?
say "S2 control: same state root, path-inferred malformed declaration, no effective override (rc=$S2C_RC)"
printf '%s\n' "$S2C_OUT" | sed 's/^/   | /'
[ "$S2C_RC" -eq 1 ] && ok "the path-inferred malformed declaration refuses" ||
  bad "the path-inferred malformed declaration was accepted (rc=$S2C_RC)"
check "the refusal names the malformed declaration" "must declare max as a positive integer" "$S2C_OUT"

# =========================================================================
say "S3  adversarial: a malformed effective declaration refuses and reserves nothing"
S3=$CASES/s3
mkdir -p "$S3"
S3_STATE=$S3/state
S3_CFG=$S3/bad-config
mkdir -p "$S3_STATE" "$S3_CFG"
touch "$S3_STATE/.last-watcher-beat"
printf 'max=invalid\nmodels=gpt-6.1-sol\n' > "$S3_CFG/sol-cap"
task_fixture "$H" task-three
S3_PANE=$(new_worktree "$S3" task-three)
S3_OUT=$(FM_STATE_OVERRIDE="$S3_STATE" FM_CONFIG_OVERRIDE="$S3_CFG" \
  run_spawn "$S3" "$S3_PANE" task-three "$PROJ" --harness codex --model gpt-6.1-sol --mode no-mistakes --yolo off)
S3_RC=$?
say "S3  dispatch under a malformed effective declaration (rc=$S3_RC)"
printf '%s\n' "$S3_OUT" | sed 's/^/   | /'
[ "$S3_RC" -eq 1 ] && ok "the dispatch was refused" || bad "the dispatch was not refused (rc=$S3_RC)"
check "the refusal names the ceiling as unavailable" "Sol ceiling unavailable" "$S3_OUT"
check "the refusal names the malformed max" "must declare max as a positive integer" "$S3_OUT"
check "the refusal names the offending file" "$S3_CFG/sol-cap" "$S3_OUT"
check_absent "no reservation was written for the refused dispatch" "$S3_STATE/sol-sessions.tsv"
check_absent "no task record was published for the refused dispatch" "$H/state/task-three.meta"

# =========================================================================
say "S4  adversarial: a permissive declaration at the inferred config path is not consulted"
S4=$CASES/s4
mkdir -p "$S4"
S4_ROOT=$S4/runtime
S4_STATE=$S4_ROOT/state
S4_CFG=$S4/effective-config
mkdir -p "$S4_STATE" "$S4_ROOT/config" "$S4_CFG"
touch "$S4_STATE/.last-watcher-beat"
# The trap: the declaration a state-path guess would find is permissive.
printf 'max=99\nmodels=gpt-6.1-sol\n' > "$S4_ROOT/config/sol-cap"
printf 'max=1\nmodels=gpt-6.1-sol\n' > "$S4_CFG/sol-cap"
# The primary lab home declares nothing here, so only the overrides can speak.
rm -f "$H/config/sol-cap"

admit() {  # <id> <config-dir> <state-dir>
  (cd "$LAB" && env -u FM_ROOT_OVERRIDE FM_HOME="$H" FM_STATE_OVERRIDE="$3" \
    FM_CONFIG_OVERRIDE="$2" "$ROOT/bin/fm-sol-cap-lib.sh" refuse-claim \
    "$1" ship codex gpt-6.1-sol "$2" "$3" 2>&1)
}
# The first dispatch really holds its slot: admission reserves, then the
# reservation is promoted onto a live worker process, both through the product.
(
  cd "$LAB" || exit 1
  env -u FM_ROOT_OVERRIDE FM_HOME="$H" FM_STATE_OVERRIDE="$S4_STATE" \
    FM_CONFIG_OVERRIDE="$S4_CFG" "$ROOT/bin/fm-sol-cap-lib.sh" refuse-claim \
    task-four-a ship codex gpt-6.1-sol "$S4_CFG" "$S4_STATE" \
    >"$S4/first-admit.out" 2>&1 || exit 1
  exec env -u FM_ROOT_OVERRIDE FM_HOME="$H" FM_STATE_OVERRIDE="$S4_STATE" \
    FM_CONFIG_OVERRIDE="$S4_CFG" \
    "$ROOT/bin/fm-sol-cap-lib.sh" run task-four-a "$S4_STATE" sleep 120
) &
S4_PID=$!
sleep 1.5
S4_A=$(cat "$S4/first-admit.out")
S4_A_RC=0
S4_ROW_PID=$(awk -F'\t' '$1 == "task-four-a" {print $4}' "$S4_STATE/sol-sessions.tsv" 2>/dev/null)
if kill -0 "${S4_ROW_PID:-0}" 2>/dev/null; then
  ok "the first covered worker is live in the redirected state root (pid $S4_ROW_PID)"
else
  bad "the first covered worker is not live (row pid ${S4_ROW_PID:-none})"
fi
S4_B=$(admit task-four-b "$S4_CFG" "$S4_STATE"); S4_B_RC=$?
say "S4  first admission under max=1: rc=$S4_A_RC ${S4_A}"
say "S4  second admission, permissive trap present at the inferred path: rc=$S4_B_RC"
printf '%s\n' "$S4_B" | sed 's/^/   | /'
[ "$S4_A_RC" -eq 0 ] && ok "the first admission claimed the only slot" || bad "the first admission failed"
[ "$S4_B_RC" -eq 1 ] && ok "the second admission was refused at the ceiling" ||
  bad "the second admission was admitted (rc=$S4_B_RC)"
check "the refusal names the ceiling" "Sol ceiling reached" "$S4_B"
check "the refusal names the occupying session" "task-four-a (gpt-6.1-sol" "$S4_B"
# Control: the trap declaration is reachable and does admit, so the refusal
# above is the effective configuration's decision, not an inert file.
S4_C=$(admit task-four-c "$S4_ROOT/config" "$S4_STATE"); S4_C_RC=$?
say "S4 control: same state, effective config switched to the permissive one: rc=$S4_C_RC ${S4_C}"
[ "$S4_C_RC" -eq 0 ] && ok "the permissive declaration admits, so the trap is genuinely reachable" ||
  bad "the control admission failed (rc=$S4_C_RC): ${S4_C}"

# =========================================================================
say "evidence"
printf '%s\n' "$S1_OUT" > "$EVID/sol-cap-cross-root-refusal.txt"
printf '%s\n' "$S2C_OUT" > "$EVID/sol-cap-effective-config-refusal.txt"
printf '%s\n' "$S3_OUT" > "$EVID/sol-cap-malformed-effective-refusal.txt"
printf '%s\n' "$S4_B" > "$EVID/sol-cap-inferred-config-ignored-refusal.txt"
{
  printf 'cross-root refusal:\n%s\n\n' "$S1_OUT"
  printf 'effective-config refusal:\n%s\n\n' "$S2C_OUT"
  printf 'malformed effective declaration refusal:\n%s\n\n' "$S3_OUT"
  printf 'inferred-config-ignored refusal:\n%s\n\n' "$S4_B"
  printf 'permissive control admission:\n%s\n' "$S4_C"
} > "$EVID/sol-cap-live-refusals.txt"
if [ -n "${STAGED:-}" ] && [ -f "$STAGED" ]; then
  cat "$STAGED" > "$EVID/sol-cap-live-handoff.txt"
fi
[ ! -f "$S2/pane.txt" ] || cp "$S2/pane.txt" "$EVID/sol-cap-live-pane.txt"
cp "$S2_STATE/sol-sessions.tsv" "$EVID/sol-cap-live-registry.tsv" 2>/dev/null || true
note "wrote evidence under $EVID"

say "teardown"
[ -z "${SM_PID:-}" ] || { kill "$SM_PID" 2>/dev/null || true; wait "$SM_PID" 2>/dev/null || true; }
[ -z "${S4_PID:-}" ] || { kill "$S4_PID" 2>/dev/null || true; wait "$S4_PID" 2>/dev/null || true; }
"$TMUX_BIN" -S "$SOCK/fm-lab.sock" kill-server 2>/dev/null || true
rm -rf "$SOCK"
SOCK=
[ -z "${STAGED_DIR:-}" ] || rm -rf "$STAGED_DIR"
chmod -R u+w "$LAB" 2>/dev/null || true
rm -rf "$LAB"
printf '\nlab homes and socket removed: %s\n' "$LAB"
if [ "$FAILS" -eq 0 ]; then
  printf '\nRESULT: all live scenarios passed\n'
  exit 0
fi
printf '\nRESULT: %d live check(s) failed\n' "$FAILS"
exit 1
Evidence: Cross-root ceiling refusal naming the secondmate session and its state root

Source: Cross-root ceiling refusal naming the secondmate session and its state root

error: Sol ceiling reached: 1 concurrent capped session(s) already active and this ceiling is 1 (declared in config/sol-cap); the dispatch of task task-one (codex, gpt-6.1-sol) was refused. Active sessions: sm-task (gpt-6.1-sol, age 3s) in <lab>/sm/state.

error: Sol ceiling reached: 1 concurrent capped session(s) already active and this ceiling is 1 (declared in config/sol-cap); the dispatch of task task-one (codex, gpt-6.1-sol) was refused. Active sessions: sm-task (gpt-6.1-sol, age 3s) in /tmp/fm-lab.gn4pu7/sm/state. A session frees its slot when its worker's process ends; the dispatch contract refuses at the ceiling instead of queueing
Evidence: Real tmux pane running the staged capped handoff (promotion + worker reachable)

Source: Real tmux pane running the staged capped handoff (promotion + worker reachable)

. '/tmp/fm-task-two+.../launch.s...sh' live worker reachable, argv: probe-ran

. '/tmp/fm-task-two+3cea1f415b0eceefe7ba6653c42203df2aedfeacaf37c77ce84e5a74df90e682/launch.s1794296353.3336715.10563.sh'

[art@zeppola:/tmp/fm-lab.gn4pu7/cases/s2/wt-task-two]$ . '/tmp/fm-task-two+3cea1f415b0eceefe7ba6653c42203df2aedfeacaf37c77ce84e5a74df90e682/launch.s1794296353.3336715.10563.sh'
live worker reachable, argv: probe-ran
Evidence: Staged capped handoff carrying the resolved config and state overrides

Source: Staged capped handoff carrying the resolved config and state overrides

FM_HOME='/tmp/fm-lab.gn4pu7' FM_STATE_OVERRIDE='/tmp/fm-lab.gn4pu7/runtime/state' FM_CONFIG_OVERRIDE='/tmp/fm-lab.gn4pu7/redir-config' bash '{run-worktree}/bin/fm-sol-cap-lib.sh' run-launch 'task-two' '/tmp/fm-lab.gn4pu7/runtime/state' 'export COMPACT_ADVISER_DISABLE=1; export FM_TASK_INBOX='\''/tmp/fm-lab.gn4pu7/runtime/state/task-two.inbox'\''; '\''{run-worktree}/bin/fm-osc7501.sh'\'' arm --task '\''task-two'\'' --harness '\''codex'\'' --backend '\''tmux'\'' --kind '\''ship'\'' --state '\''/tmp/fm-lab.gn4pu7/runtime/state'\'' --config '\''/tmp/fm-lab.gn4pu7/redir-config'\'' --target '\''firstmate:fm-task-two'\'' --agent-bin '\''/tmp/fm-lab.gn4pu7/fakebin/codex'\'' >/dev/null || true
'\''{run-worktree}/bin/fm-git-strip-ai-trailers.sh'\'' env-file '\''/tmp/fm-lab.gn4pu7/runtime/state/task-two.git-hooks'\'' '\''/tmp/fm-task-two+3cea1f415b0eceefe7ba6653c42203df2aedfeacaf37c77ce84e5a74df90e682/git-config.s1794296353.3336715.10563.sh'\'' && . '\''/tmp/fm-task-two+3cea1f415b0eceefe7ba6653c42203df2aedfeacaf37c77ce84e5a74df90e682/git-config.s1794296353.3336715.10563.sh'\'' || return 1 2>/dev/null || exit 1; export FM_HOME='\''/tmp/fm-lab.gn4pu7'\''; env -u CURSOR_AGENT -u CURSOR_INVOKED_AS -u GEMINI_CLI /tmp/fm-lab.gn4pu7/fakebin/codex '\''/tmp/fm-lab.gn4pu7/cases/s2/invocation.argv'\''
'\''{run-worktree}/bin/fm-osc7501.sh'\'' disarm --state '\''/tmp/fm-lab.gn4pu7/runtime/state'\'' >/dev/null 2>/dev/null || true'
Evidence: State-override registry after the launch (reservation promoted to the live worker pid)

Source: State-override registry after the launch (reservation promoted to the live worker pid)

task-two gpt-6.1-sol <start> <worker-pid>

task-two	gpt-6.1-sol	1794296349	3340321
Evidence: Combined refusals: cross-root, effective-config, malformed declaration, inferred-config-ignored

Source: Combined refusals: cross-root, effective-config, malformed declaration, inferred-config-ignored

cross-root refusal:
error: Sol ceiling reached: 1 concurrent capped session(s) already active and this ceiling is 1 (declared in config/sol-cap); the dispatch of task task-one (codex, gpt-6.1-sol) was refused. Active sessions: sm-task (gpt-6.1-sol, age 3s) in /tmp/fm-lab.gn4pu7/sm/state. A session frees its slot when its worker's process ends; the dispatch contract refuses at the ceiling instead of queueing

effective-config refusal:
error: Sol ceiling unavailable: /tmp/fm-lab.gn4pu7/runtime/config/sol-cap must declare max as a positive integer of at most nine digits, not 'invalid'; task task-ctl with model gpt-6.1-sol was not dispatched rather than launched against an undeclared ceiling

malformed effective declaration refusal:
error: Sol ceiling unavailable: /tmp/fm-lab.gn4pu7/cases/s3/bad-config/sol-cap must declare max as a positive integer of at most nine digits, not 'invalid'; task task-three with model gpt-6.1-sol was not dispatched rather than launched against an undeclared ceiling

inferred-config-ignored refusal:
error: Sol ceiling reached: 1 concurrent capped session(s) already active and this ceiling is 1 (declared in config/sol-cap); the dispatch of task task-four-b (codex, gpt-6.1-sol) was refused. Active sessions: task-four-a (gpt-6.1-sol, age 2s). A session frees its slot when its worker's process ends; the dispatch contract refuses at the ceiling instead of queueing

permissive control admission:
claimed
Evidence: tests/fm-sol-cap.test.sh transcript (49 ok)

Source: tests/fm-sol-cap.test.sh transcript (49 ok)

ok - queued delivery retains occupancy after spawning process exits
ok - adopted exits free capacity while uncertain and in-flight claims remain
ok - confirmed-stop paths remember legacy workers with missing registries or rows
ok - pruning and explicit release preserve stop evidence while metadata survives
ok - unpinned workers remain exempt during broad-pattern and explicit-list adoption
ok - admission adopts preserved live or uncertain Sol workers without duplicating or counting stopped/non-Sol workers
ok - proven local stops and unpublished remote recovery release conservative occupancy
ok - remote parent-route ownership shares the ceiling and recovery preserves uncertain claims
ok - retries preserve occupancy and only confirmed teardown releases it
ok - local homes share admission lock and preserve distinct task identities
/tmp/fm-sol-cap.PlHTjx/review/home/config/sol-cap must declare ceiling as an integer from 1 through 4, not '5'
ok - exact identities, worker lifetime, live age, bounded declarations and non-Sol isolation
ok - a Sol delivery under the ceiling retains a conservative claim
ok - a capped launch runs the uncapped command unchanged under the pane shell
skip: fish not found (fish pane launch); only a static handoff check ran
ok - the capped launch handoff carries no syntax fish rejects
ok - an unnamed pane shell falls back to a shell that runs the launch line
ok - redirected-config spawn launches and promotes when home declaration is malformed
ok - redirected-config spawn with malformed declaration fails admission without reservation
ok - a dispatch at the ceiling is refused, naming sessions and ages, and creates nothing
ok - separate state override ending in /state counts against the declared ceiling
ok - separate-state staged launch retains effective configuration
ok - dead workers are pruned regardless of age
ok - a non-Sol model dispatch passes a full ceiling and touches no registry row
ok - config/sol-cap declares the ceiling the guard enforces
ok - a home that declared no ceiling has no ceiling, no reservation, and no registry row
ok - only the models the captain declared are capped, by exact id or by declared pattern
ok - the declaration documented in docs/configuration.md parses as written
ok - a home that dropped its declaration owns no occupancy and keeps its rows as evidence
ok - a reused row follows the current declaration and its model is reconciled
ok - a row whose model the declaration dropped holds no occupancy
ok - a replacement while the guard is off marks the prior incarnation's row superseded
ok - a replacement on an excluded model marks the prior incarnation's row superseded
ok - the adoption resolves a superseded row into the live incarnation it names
ok - an uncapped incarnation resolves the superseded row it replaced
ok - an abandoned replacement leaves no capacity behind
ok - a live row is not superseded by a dispatch that displaced no session
ok - a busy admission boundary keeps the invalidation pending and the next admission supersedes the prior row
ok - admission cannot consume marker staging before atomic publication
ok - failed marker publication reports the unavailable count
ok - a concurrent admission preserves its claim while applying a pending invalidation
ok - a busy-boundary replacement holds its slot at the next ceiling decision
ok - a relaunched task id replaces its own registry row instead of counting itself
ok - a reused live Sol endpoint's reported model claims its occupancy
ok - a non-Sol reported model releases the task's stale Sol claim
ok - a confirmed Sol report preserves an adopted uncertain claim's reconciliation
ok - a Sol report under an existing claim keeps the claim and reconciles the model
ok - a malformed registry row refuses every Sol dispatch and names the row
ok - a malformed declaration refuses loudly instead of falling back to a default
ok - an unresolvable parent binding refuses admission, promotion, and reconciliation loudly
ok - non-Sol reports bypass admission only without owned Sol occupancy
Evidence: tests/fm-sol-cap-rex.test.sh transcript

Source: tests/fm-sol-cap-rex.test.sh transcript

ok - Rex adoption and reconciliation prove absence on the recorded server

Pipeline

Updates from git push no-mistakes

✅ **Intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

⚠️ **Review** - 1 warning
  • ⚠️ bin/fm-sol-cap-lib.sh:830 - The public refuse-claim CLI can ignore existing occupancy when given a redirected config directory. With FM_HOME=H, H/config/sol-cap absent, C/sol-cap declaring max=1, and a live covered claim in H/state, invoke refuse-claim with C and H/state without FM_CONFIG_OVERRIDE. Admission loads C, but counting resolves H/config, excludes the existing claim, and incorrectly returns 'claimed'. Bind the supplied config directory to the supplied state directory throughout admission. Related sites: bin/fm-sol-cap-lib.sh:98 (configuration resolution), :407 (adoption), :551 (row classification), and :1289 (CLI forwards explicit directories without establishing their association).
✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 4 of 4 scenarios driven live against the product
Scenario Result Live Evidence
A dispatch from the primary lab home (max=1) is refused because a covered worker occupies a registered secondmate home's separate state root, and the refusal names that session and its state root with… ✅ pass live live-sol-cap.log lines 5-19; sol-cap-cross-root-refusal.txt: real bin/fm-spawn.sh exits 1 with 'Sol ceiling reached: ... sm-task (gpt-6.1-sol, age 3s) in <lab>/sm/state' and no <id>.meta; after that w…
A dispatch with FM_STATE_OVERRIDE plus a redirected FM_CONFIG_OVERRIDE is admitted, its staged handoff carries both overrides, and that handoff promotes the delivery reservation and runs the worker in… ✅ pass live live-sol-cap.log lines 21-84; sol-cap-live-handoff.txt; sol-cap-live-pane.txt ('live worker reachable, argv: probe-ran'); sol-cap-live-registry.tsv row promoted from pid 0 to the live worker pid; cont…
Adversarial: a malformed effective declaration refuses the dispatch loudly, naming the file and the bad max, with no reservation row and no task record left behind ✅ pass live live-sol-cap.log lines 86-96; sol-cap-malformed-effective-refusal.txt: 'Sol ceiling unavailable: <cfg>/sol-cap must declare max as a positive integer ...'; no sol-sessions.tsv and no task-three.meta
Adversarial: a permissive declaration placed at the state path's inferred config is never consulted - the second dispatch at max=1 is refused naming the first occupant, while switching the effective c… ✅ pass live live-sol-cap.log lines 98-110; sol-cap-inferred-config-ignored-refusal.txt ('Sol ceiling reached ... task-four-a (gpt-6.1-sol ...)') and the control admission 'claimed' under the permissive declaratio…
  • bash ~/.no-mistakes/evidence/01M725HG5Q50ECNGF4V37CVFN8/live-sol-cap-driver.sh (S1 cross-root ceiling, S2 separate state + redirected config launch in a real tmux pane, S3 malformed effective declaration, S4 inferred-config trap) with FM_LIVE_ROOT=&lt;run worktree&gt;
  • bin/fm-lab-home.sh create / tmux-dir minted and tore down the disposable lab homes and private tmux socket
  • bin/fm-spawn.sh task-one ... refused at max=1 because a live covered worker occupied the registered secondmate home's state (S1)
  • bin/fm-sol-cap-lib.sh refuse-claim + run minted the live secondmate occupancy and the S4 first occupant (real product, no hand-written registry rows)
  • bin/fm-spawn.sh task-two ... with FM_STATE_OVERRIDE + FM_CONFIG_OVERRIDE, then the staged handoff executed in a real tmux pane on the lab socket (S2)
  • bash tests/fm-sol-cap.test.sh (49 ok)
  • bash tests/fm-sol-cap-rex.test.sh
  • bash tests/fm-remote-secondmate-relaunch.test.sh (9 ok)
⚠️ **Document** - 1 info
  • ℹ️ docs/fm-test-portable-shards.md:31 - The recorded provisional serial hint for tests/fm-sol-cap.test.sh (25000 ms) is now far below a fresh sample: bin/fm-test-run.sh --json tests/fm-sol-cap.test.sh measured duration_ms=165766 on this Linux host after this branch's later commits added the lock-contention and refusal tests. The other two values in that sentence still match their suites (fm-backend-close 543 ms, fm-sol-cap-rex 930 ms). Refreshing this needs the hint table in bin/fm-test-run.sh (executable configuration outside this phase) together with this evidence line, so I left both untouched rather than desynchronizing the doc from the table.
✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

@kesslerio kesslerio changed the title feat: enforce a shared concurrent Sol session ceiling feat: enforce shared Sol session limits across worker lifecycles Oct 17, 2026
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate:

Thanks @kesslerio. This is careful work: the no-mistakes review rounds clearly hardened the locking, adoption and confirmed-stop paths, and the live admission transcripts are good evidence. I read the tip against main 15ad1bd6. It doesn't yet match the shape #7429 was marked ready-for-pr for, so this is waiting on you.

contract-class: new-default (my own read of the diff, not the PR's framing):

  • FM_SOL_CAP_DEFAULT=4 applies whenever config/crew-dispatch.json names any model matching ^gpt-[0-9.]+-sol$. A home that never declared a cap gets one, and config/sol-cap can only lower it (1–4). Higher values are refused. Feature: mechanical concurrency cap for quota-limited model sessions (spawn-hook refusal with named active sessions) #7429 was accepted as off unless declared: no default cap value, no hard-coded models.
  • The model regex and the plan limit of 4 sit in tracked code. VISION ("The fleet outlives any vendor"; quota stays captain-owned) needs both to come from the captain's own config.
  • The cmux, Zellij and Orca close-return changes (bin/backends/*.sh, plus the fm-teardown consumers) change teardown for every task, Sol or not. The documented contract in docs/verification/runtime-backends.md said those arms report 0. Nonzero on an unconfirmed close may well be the right direction, but it's a separate default-behavior change. It has no live run on cmux or Orca (your table marks those untested).

VISION.md, rule by rule:

State: CI run 38991109830 was cancelled again, with Behavior portable serial 2 at the 30-minute ceiling (known repo-wide issue #7255, not your code). The empty ci: regenerate hosted checks commit 45cd620b moved the head, so "PR must be raised via no-mistakes" now fails: the attestation names 94089f15, and the head is 45cd620b.

What would move this forward:

  1. Make it opt-in: no cap and no model set unless the captain declares both in config (for example the cap value and the model ids or pattern in config/sol-cap or the dispatch table). Missing config should mean the guard is inert, and malformed config should refuse loudly. Please drop FM_SOL_CAP_DEFAULT and the gpt-*-sol regex from tracked code.
  2. Either split the cmux/Zellij/Orca close-return change into its own PR, or limit it to the Sol release decision so other teardowns stay unchanged. If you keep it, please add live evidence on the backends it changes.
  3. Say how this composes with feat(fleet-seats): cap shared model routes with fleet-wide seat pools #6238: fold one into the other, or build feat(fleet-seats): cap shared model routes with fleet-wide seat pools #6238 on this slice, so only one capacity path lands.
  4. Re-raise through git push no-mistakes so the attestation binds the real head. Please don't push empty commits to re-trigger CI; the serial-2 timeout is ours to handle.
  5. If you can, add live evidence for an authenticated worker launch under the cap (still marked untested).

Kun keeps the final merge call on any capacity guard. After this is opt-in, CI is green and the attestation matches, I'll take it from there.

@kesslerio kesslerio changed the title feat: enforce shared Sol session limits across worker lifecycles feat: enforce the concurrent Sol session ceiling Oct 17, 2026
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate:

Thanks for the follow-up rounds, @kesslerio. Some things improved. The no-mistakes attestation now binds the head (28825e67), and CI run 39007139158 is fully green. Live coverage is now 13 of 16, including an authenticated Sol launch.

I re-read the tip against main d20196ae. The points from my last comment are still open, so this is still waiting on you:

  1. Still new-default. bin/fm-sol-cap-lib.sh still ships FM_SOL_CAP_DEFAULT=4 and the ^gpt-[0-9.]+-sol$ regex in tracked code. A home that never declared anything still gets a ceiling as soon as its dispatch table names a matching model. Feature: mechanical concurrency cap for quota-limited model sessions (spawn-hook refusal with named active sessions) #7429 was accepted as off-unless-declared: the captain declares the cap value and the model ids or pattern in config, a missing config leaves the guard inert, and a malformed config refuses loudly.
  2. The cmux/Zellij/Orca close-return change still changes teardown for every task. cmux and Orca closure are still marked untested. Please split it out, or limit it to the Sol release decision.
  3. feat(fleet-seats): cap shared model routes with fleet-wide seat pools #6238: please say how the two compose, so only one capacity path lands.
  4. New since last time: the branch now also changes CI sharding: a 10th serial shard in .github/workflows/ci.yml, a refreshed bin/fm-test-run.sh weight table, and the fm-supervision-host helper split. That may be a real help for the serial-2 timeout (fix(pi): keep the Pi watcher armed after a successor or arm child dies #7255). But it's a separate concern from a Sol guard, so please move it to its own PR. That keeps both reviewable, and a workflow-file change can't ride along with this one.

When 1–3 are addressed, please re-raise through git push no-mistakes again. Kun keeps the final merge call on any capacity guard.

@kesslerio
kesslerio force-pushed the fm/sol61-ceiling-enforcement branch from 28825e6 to 03f0eee Compare October 19, 2026 12:46
@kesslerio kesslerio changed the title feat: enforce the concurrent Sol session ceiling feat: enforce concurrent Sol session limits Oct 19, 2026
@kesslerio

Copy link
Copy Markdown
Contributor Author

@kunchenguid - re-review of the hardened tip, please.

Since your last comment (at 28825e67): four more review rounds landed through 223fd356. The occupancy races are closed (the admission lock now spans remote publication and reconcile, dead-worker records bypass the lock), confirmed-stop evidence is preserved per backend, and CI is fully green 20/20 after the serial-shard regeneration. The 11th live scenario remains blocked at the hook-trust boundary, unchanged.

Your four structural points stand as you left them: the default cap and the Sol pattern still ship in bin/fm-sol-cap-lib.sh, the close-return change still rides this PR, the #6238 compose note is not written, and the CI-shard work is not split out. I left them for your call rather than restructuring unilaterally - happy to split or rewrite on your word; otherwise please re-review the hardening as it stands.

@kesslerio
kesslerio force-pushed the fm/sol61-ceiling-enforcement branch from 223fd35 to ef41b8a Compare October 20, 2026 22:05
@kesslerio kesslerio changed the title feat: enforce concurrent Sol session limits feat(spawn): enforce a captain-declared concurrent session ceiling Oct 20, 2026
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate:

Thank you @kesslerio. This is a real rework, and it reads much closer to what #7429 asked for. I re-read the new tip ef41b8ae against main 9d76aa8e:

This is still waiting on you for two things:

  1. no-mistakes is red. "PR must be raised via no-mistakes" fails on this head (run 39506030560: "This PR was not raised through no-mistakes"). The rewritten body has no ## Pipeline section. Please re-raise this head with git push no-mistakes so the attestation binds ef41b8ae. CI run 39505442741 was still pending when I looked.
  2. One change still reaches homes without a declaration. In spawn_remote_secondmate, the meta line goes from echo "model=${model#-}" (the requested model, empty for -) to echo "model=$remote_model" (what the remote reports, which is default for -). The feat: add per-task trace context propagation #995 comment block explaining that recording is also replaced. That runs for every remote secondmate, whether or not a ceiling is declared. Please either keep the old recording when no ceiling is declared, or explain in the PR why this is a fix to an existing promised behavior, with a test. Until then I can't call the whole diff opt-in. That's why this stamp says cannot-tell rather than opt-in.

Live validation is 10/11. The untested scenario is fine to leave as a stated gap if it's still blocked at the hook-trust boundary.

Once both are cleared and CI is green, this goes to Kun for the merge call. As said before, Kun keeps the final call on any capacity guard. Nothing else is needed from you after that.

@kesslerio
kesslerio force-pushed the fm/sol61-ceiling-enforcement branch from 5b84df9 to 0165daa Compare October 21, 2026 01:22
@kesslerio kesslerio changed the title feat(spawn): enforce a captain-declared concurrent session ceiling feat: enforce configurable Sol session ceilings Oct 21, 2026
@kesslerio kesslerio changed the title feat: enforce configurable Sol session ceilings feat(spawn): enforce a captain-declared concurrent session ceiling Oct 21, 2026
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate:

Thank you @kesslerio. The re-raise worked. "PR must be raised via no-mistakes" passes on 0165daad, the body now carries the ## Pipeline attestation for this head, and 18 of 19 CI checks are green.

Where it stands:

  • CI: the only red is Behavior portable serial 2, which was cancelled at the 30-minute ceiling (fix(pi): keep the Pi watcher armed after a successor or arm child dies #7255). That's the known infra limit your ci: add a tenth portable serial shard and split the supervision host suite #7587 addresses, not this diff. I re-ran the failed job once (run 39526969771).
  • Still waiting on you, for one thing: the remote-secondmate model recording I raised last time is unchanged. spawn_remote_secondmate still writes model=$remote_model (what the remote endpoint reports) instead of model=${model#-} (the requested model), and the feat: add per-task trace context propagation #995 comment is still replaced. That line runs for every remote secondmate whether or not config/sol-cap exists. Commit 44ac5a38 ("reconcile a remote replacement's registry row with its model") reconciles the row's model when a ceiling is declared, but it doesn't address the undeclared path. The body says an undeclared home is "byte-for-byte unaffected", and for this line that isn't the case. Please do one of two things:
    1. Keep the old model=${model#-} recording when no ceiling is declared, and use the reported model only for capped reconciliation.
    2. Explain in the PR why recording the reported model is a fix to an already-promised behavior. Name the doc or test that promised it, and add a regression test for the undeclared case.
  • Until then this stays cannot-tell rather than opt-in. VISION: One captain, Scripts/judgment, Restart, Spine and Vendor align. Authority aligns now that the ceiling is captain-declared. Scope can't be confirmed until the undeclared-path line is settled.

Once that's settled and CI is green, this goes to Kun for the merge call. Kun keeps the final word on any capacity guard. Nothing else is needed from you after that.

@kesslerio

Copy link
Copy Markdown
Contributor Author

@kunchenguid — the four structural points are addressed and the branch is published at 0165daad. One red job remains and it belongs to #7587, not to this PR. Two decisions are yours.

Point 1 — still new-default, now off unless declared. FM_SOL_CAP_DEFAULT=4 and the ^gpt-[0-9.]+-sol$ regex are gone from tracked code. The declaration now lives in the captain's own config/sol-cap, which carries a declared max, an optional ceiling that may only lower it, and either models (exact ids) or model-pattern. No file → the guard is inert: no ceiling, no reservation, no registry row, no dispatch change. A malformed file → it refuses loudly, naming the file and the problem, never falling back to a default. The regex survives only as an example in the header comment of what a captain might write in their own config. docs/configuration.md is rewritten for this contract.

Point 2 — the close-return change no longer touches every task. fm_backend_kill keeps main's contract byte-for-byte (cmux and Zellij best-effort; Orca only reports a close its missing CLI never attempted), so no non-Sol task's teardown changes. A new fm_backend_kill_confirmed closes and proves absence, and it is used only by the capped-occupancy release decision; tmux, Herdr, cmux, Zellij, Orca and Paseo each have one, and a backend without one is refused rather than assumed.

Point 3 — how this composes with #6238 is written into the body: the fleet seat ledger is authoritative for a model in a declared pool, this guard defers instead of double-counting, a model declared in both is refused, and this PR lands first, after which #6238 must make the fleet seat ledger the single authority. The cross-check itself is deliberately not implemented here, because it needs #6238's pool-declaration key to be stable.

Point 4 — the CI-shard work is its own PR, #7587. This branch's diff against main touches no workflow file, no bin/fm-test-run.sh weight table and no supervision-host test.

CI on 0165daad: 18 of 19 pass. The only red is Behavior portable serial 2, the 30-minute job ceiling — the shard that carries tests/fm-supervision-host.test.sh alone, hinted at 734 024 ms and really running 19–28 minutes. #7587 splits that suite and brings the shard to ~16 minutes. It was cancelled at the same ceiling on 5 of the last 12 origin/main runs, so this is not this branch's doing, and nothing needs re-running here beyond what #7587 fixes.

The live admission, spawn and shared-home evidence was re-run under the new contract rather than relabelled — the old transcripts exercised a shipped default, so they no longer stood.

Two decisions that are yours.

  1. Prior-incarnation invalidation is best effort. A replacement dispatched while another admission holds the admission boundary for longer than the brief wait can return without invalidating the old row, so restoring a narrowed or disabled declaration after that leaves the live replacement uncounted. The review names the remedy as durable incarnation evidence in the registry state contract — a state-contract change needing authorisation, so this branch does not extend that contract on its own. The window needs a declaration change around a relaunch plus boundary contention. Authorise the durable incarnation evidence, or accept the narrow best-effort window as documented.
  2. The malformed-declaration blast radius. A declaration the guard cannot read leaves it unable to know its own scope, so it refuses every dispatch through the guard, not only a capped model. That is deliberate, and it is the one behaviour on this branch I would most want a second opinion on.

The authenticated-worker lifecycle scenario is still untested: the earlier attempt stopped at "Hooks need review" (Codex) and at workspace trust (Claude), and continuing needs a trust decision that persists outside the permitted workspace.

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thanks @kesslerio for the detailed write-up.

The head is still 0165daad, so nothing in the code has changed since my last stamp. Points 1–4 are addressed, as I said on 10-20, and thanks again for that.

This is still waiting on you, for the same one thing: spawn_remote_secondmate still writes model=$remote_model instead of model=${model#-}, and the #995 comment is still replaced. That line runs for every remote secondmate, whether or not config/sol-cap exists, so the unconfigured path still changes. Your note didn't mention it, so here are the two ways forward again:

  1. Keep model=${model#-} when no ceiling is declared, and use the reported model only for capped reconciliation.
  2. Or show in the PR why recording the reported model fixes behavior that was already promised: name the doc or test that promised it, and add a regression test for the undeclared case.

Until then this stays cannot-tell rather than opt-in.

On your two decisions (the best-effort prior-incarnation window, and a malformed declaration refusing every guarded dispatch): those are fair questions for Kun. They'll go to him together with the merge call once the line above is settled and CI is green. I'm not deciding them here.

CI: the re-run of Behavior portable serial 2 hit the 30-minute ceiling again (#7255). As you said, that's the shard #7587 addresses, not this diff, so I haven't re-run it again.

@kesslerio
kesslerio force-pushed the fm/sol61-ceiling-enforcement branch from 0165daa to d0e99bc Compare October 22, 2026 10:37
@kesslerio kesslerio changed the title feat(spawn): enforce a captain-declared concurrent session ceiling feat(bin): enforce a configurable ceiling on concurrent Sol sessions Oct 22, 2026
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thank you @kesslerio. The remote-secondmate model line is settled. I re-read the new head d0e99bc2 against main 9fe25bca.

  • Undeclared path: with no config/sol-cap, fm_sol_cap_state_model_capped returns "not capped", so spawn_remote_secondmate records model=${model#-} exactly as main does, and the feat: add per-task trace context propagation #995 comment is back. The reported model is used only when the declaration covers it. I also traced fm_sol_cap_refuse_and_claim, fm_sol_cap_reconcile_remote, fm_sol_cap_promote ... remove and the teardown teardown_sol_claim_held branch. With no declaration, each one returns before it touches a lock or the registry, and teardown keeps the plain fm_backend_kill path.
  • Contract class (my own read): opt-in. This replaces the earlier cannot-tell.
  • VISION, rule by rule: One captain aligns (a refusal names the sessions it is waiting on). Authority aligns (no ceiling unless the captain declares one). Scripts/judgment aligns. Restart aligns (counts come from the registry plus live state). Spine aligns (live 4 of 6, and the gaps are stated). Vendor aligns (no model names in tracked code). Scope aligns now that the undeclared path is untouched.
  • no-mistakes: the attestation binds this head, and "PR must be raised via no-mistakes" passes.

This is waiting on you, for one CI fix. Lint 2 fails on a real finding in this diff (run 39764521408). bin/fm-teardown.sh sources fm-sol-cap-lib.sh at lines 516 and 3243 without a # shellcheck source=bin/fm-sol-cap-lib.sh directive, so ShellCheck reports SC1091 on both. The line at 3243 has also lost its indentation inside the if. Adding the directive next to each source line, the way the fm-wake-lib.sh line above it does, should clear it. Please push the fix through no-mistakes so the attestation follows the new head. Behavior portable serial 2 was cancelled at the 30-minute limit again (#7255). That isn't your diff, and I'll rerun it on the next head if it happens again.

Once Lint is green, this goes to Kun with your two open questions (the best-effort prior-incarnation window, and a malformed declaration refusing every guarded dispatch). He keeps the final word on capacity guards, so it won't auto-merge. After that fix, nothing more is needed from you.

@kesslerio
kesslerio force-pushed the fm/sol61-ceiling-enforcement branch from d0e99bc to d515458 Compare October 25, 2026 02:03
@kesslerio kesslerio changed the title feat(bin): enforce a configurable ceiling on concurrent Sol sessions feat: enforce per-home Sol session ceilings Oct 25, 2026
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thank you @kesslerio. The Lint 2 fix looks right. I re-read the new head d515458a against main 842eab16:

  • Lint: bin/fm-teardown.sh now has the # shellcheck source=bin/fm-sol-cap-lib.sh directive on the top-level source, and the redundant second source in the Herdr lock-recovery fallback is gone. You're right that it was also resetting the parsed FM_SOL_CAP_* state.
  • Undeclared path: unchanged from 10-22. With no config/sol-cap, spawn_remote_secondmate still records model=${model#-}, and the guard stays inert. Contract class (my own read): opt-in, the same as last time.
  • no-mistakes: the attestation binds d515458a, and "PR must be raised via no-mistakes" passes. CI run 40153000061 was still running when I looked.

This is waiting on you, for one thing: live evidence. The re-raise on this head reports live validation as 0 of 4 scenarios ("no isolated authenticated Sol endpoint/session was established"). The earlier head reported 4 of 6. When you get a chance, could you drive the ceiling live in a disposable lab home and post the transcripts here? The four scenarios in the body are the right ones: admission below the ceiling, refusal at the ceiling naming the active sessions, stale/dead sessions not counting, and a non-Sol model not being blocked. Re-raising with git push no-mistakes once a live session is available works too.

Once live evidence is in and CI is green, this goes to Kun together with your two open questions (the best-effort prior-incarnation window, and a malformed declaration refusing every guarded dispatch), as promised. I'm not deciding those here.

@kesslerio
kesslerio force-pushed the fm/sol61-ceiling-enforcement branch from d515458 to 650bb98 Compare October 30, 2026 22:56
@kesslerio kesslerio changed the title feat: enforce per-home Sol session ceilings feat: enforce configurable Sol session ceilings Oct 30, 2026
@greptile-apps

greptile-apps Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; the numbered previous finding is fixed and no new actionable issues were established.

Reviews (14) · Last reviewed commit: "no-mistakes(document): Document Sol stat..." · Reviewed by Greptile

Comment thread bin/backends/zellij.sh Resolved
@greptile-apps

This comment has been minimized.

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thank you @kesslerio. The re-raise on 650bb98c answers my last ask. Live validation is now 4 of 4: admission below the ceiling, refusal at the ceiling naming the active session and its age, a dead row pruned before admission, and a non-Sol model passing a full ceiling. The attestation binds this head, and the quick checks pass (coverage guard, repo invariants, no-mistakes).

I re-read the tip against main 095db3bc. The undeclared path still looks inert. With no config/sol-cap, fm_sol_cap_state_model_capped reports "not capped", so spawn_remote_secondmate records model=${model#-} as main does, and the ordinary fm_backend_kill contracts are unchanged. One small thing I noticed, which you don't need to change: bin/fm-remote-secondmate-relaunch.sh now takes the task's .spawn-<id>.lock for every remote runtime switch, declared or not. That's the same lock fm-spawn.sh already holds, so it reads as a stricter refusal of a concurrent spawn and switch. I'll mention it to Kun as part of the diff. A sentence in the body saying it's intended would help.

This is waiting on you, for two review findings Greptile raised on this head:

  1. P1, refused switches keep capacity (bin/fm-remote-secondmate-relaunch.sh around line 69, posted outside the diff). Say a remote secondmate on an uncapped model is switched to a capped one. The claim is created and promoted to pid 0 before the host call. If the host refuses before it changes the worker, that claim is never released. Adoption skips pid-0 rows, and reconcile keeps the row because the original worker is still alive. A failed switch could then block later capped dispatches. Releasing or restoring the claim on a confirmed pre-launch refusal, with a regression test, would close it. If you think it can't happen, a reason on the PR is enough.
  2. P2, Zellij skips the absence check (open thread on bin/backends/zellij.sh). fm_backend_zellij_kill_confirmed trusts a zero exit from the close, but the adapter already says Zellij exit codes don't prove the close reached its target. The test also accepts confirmation while the pane is still listed. Always checking fm_backend_zellij_target_absent would make the confirmed release safe. Please fix it or reply on the thread.

Please push through git push no-mistakes so the attestation follows the new head. The red Full suite row is our label gate, not your code. Once these two are settled, we run the full suite, and then it goes to Kun with your two open questions (the best-effort prior-incarnation window, and a malformed declaration refusing every guarded dispatch). He keeps the final word on capacity guards.

Contract-class (my own read): opt-in, unchanged. VISION: unchanged from 10-22. All seven rules align, with Spine now backed by 4 of 4 live scenarios.

A remote runtime switch promotes its new reservation to pid 0 before
delivery, and a switch the host refuses before the control plane starts
left that reservation behind. Reconcile only drops a row for a dead or
missing remote, so the still-live uncapped worker kept the slot and later
capped dispatches were refused against capacity nothing was using.

The host now proves the phase: fm-remote-secondmate-control.sh relaunch
prints relaunch_refused_before_control=<id> on any exit before the
fm-control call, which is the window in which nothing was started,
stopped, or replaced. The parent releases the reservation it created only
on that proof and only when the route held no capped occupancy before the
switch, so a worker that already owns a slot keeps it, and a transport or
control failure keeps the claim because a replacement may be running.

Regression coverage drives all four outcomes: a confirmed pre-control
refusal releases the new reservation, and an unproven failure, an
uncertain delivery, and a proof naming another task each keep it.
…mantics

A capped launch walked the whole launch line through `/bin/sh -c`, so the
ceiling changed how a command was parsed rather than only whether it was
admitted. An uncapped launch is a line the pane shell sources, so a raw
launch command that relied on that shell - process substitution, arrays, a
here-string - started uncapped and failed capped, which is a launch
regression, not an admission decision.

The handoff now takes the pane shell's own report of itself (`$0`, expanded
by the shell that sources the staged line) and execs the launch line
unchanged under it, so an uncapped and a capped launch run the same bytes
with the same interpreter. An unusable report falls back to $SHELL and then
/bin/sh, which still runs every Firstmate-generated launch line, and the
reservation still transfers to the worker's own process.

Regression coverage spawns one raw command carrying process substitution
twice, once under a declared ceiling and once with the guard inert: both
staged lines carry the same command bytes, both drive the worker with the
same argv, and the capped one runs under a pane-shell stand-in that names
itself as the interpreter, so a substituted shell fails the test even where
/bin/sh happens to be bash. A second case proves the unresolvable-report
fallback still runs the line.
…ompatible $0

The staged capped launch carried a literal `"$0"` for the pane shell to expand,
but fish has no `$0`: fish 4.x expands it away and leaves the handoff without an
identity, so a capped launch in a fish pane fell back to $SHELL or /bin/sh and
reinterpreted the pane's command under an interpreter that cannot parse it.

The staged line now names no shell expression of its own, so every supported
pane shell parses it unchanged. run-launch reads the sourcing shell from the
process tree instead, where the parent's executable name is the same shell
identity `$0` gave POSIX panes, and the explicit report remains as the operator
and test seam. A fish pane now runs the identical command the uncapped launch
would have run, and the reservation still transfers to that shell's process.

Regression: the staged file is sourced by real fish with a fish-only payload,
capped against an uncapped control, comparing worker argv, the interpreter that
ran it and the transferred reservation. Without fish the handoff is checked for
tokens fish cannot parse and the live case reports a skip.
…lacement path in bin/fm-sol-cap-lib.sh gave up on its row invalidation whenever the admission lock stayed busy past the brief wait, so a live replacement could sit behind a -1/dead-pid row that the count reads as claiming no slot, letting a later capped dispatch run above the declared ceiling. The invalidation is now durable instead of dropped: when the brief attempt fails, the dispatch still continues unrefused and writes a per-task pending marker (atomic tmp+mv, no registry rewrite outside the boundary) into the task's state directory, naming the row it invalidates; the next admission applies and clears pending markers under the admission lock, before counting, in every local state directory it walks (fm_sol_cap_active_count), so no later admission can count above the ceiling. The live-occupancy guard is preserved at both points: a row holding live occupancy is never superseded at write time or at apply time, and a row that changed since the marker was recorded (a newer incarnation or its stop marker) is left alone and the marker cleared. Unreadable markers or a registry that cannot be rewritten fail the count loudly, consistent with the module's existing stance, leaving the marker for the next admission. Sibling paths checked: covered replacement (unchanged, under lock), reuse (keeps its row by recorded decision), another task's concurrent admitted row (supersede only rewrites the matching id, verified by test), multi-home counts (each counted state dir applies its own markers), and teardown/ownership predicates (a -1 row still owns no occupancy, unchanged). Added three regressions in tests/fm-sol-cap.test.sh driving real processes: the test holds the admission lock in a live process while a fresh CLI process performs the uncapped replacement (asserting the dispatch continues, the prior row is untouched, and the marker lands, then that the next admission supersedes it), a sibling test asserting another admitted claim's row survives the sequence, and a test asserting a capped dispatch is refused at the ceiling afterward. Updated the bin/fm-sol-cap-lib.sh header and the docs/configuration.md superseded-row bullet. Verified: bash tests/fm-sol-cap.test.sh (42 ok, only the pre-existing fish-absent skip), tests/fm-remote-secondmate-relaunch.test.sh, tests/fm-sol-cap-rex.test.sh, tests/fm-gotmp.test.sh, and bin/fm-lint.sh (pinned ShellCheck 0.11.0 plus workflow actionlint) all pass
The lock-hold case wrote its holder pid from BASHPID, which stock macOS Bash 3.2 does not define.
Under the suite's `set -u` the holder exited before creating `held`, so the case failed on a supported shell.
The pid now comes from fm_current_pid, the portable owner of that probe, and the holder unsets BASHPID so every host exercises the Bash 3.2 path rather than only macOS.
The case also asserts the recorded holder is a live process other than the test shell, so it still proves a real holder rather than any live pid.
When a spawn uses a valid redirected config while the home's normal
sol-cap declaration is malformed, admission succeeds but run-launch
dropped FM_CONFIG_OVERRIDE, reading the malformed declaration and failing
before worker launch. Passing FM_CONFIG_OVERRIDE into the handoff ensures
admission and launch read the same declaration. Added regression coverage
verifying redirected config launches and promotes cleanly, and malformed
redirected declarations fail admission without leaving a reservation.
@kesslerio
kesslerio force-pushed the fm/sol61-ceiling-enforcement branch from 95e3ba1 to 7701a29 Compare November 10, 2026 07:58
@kesslerio kesslerio changed the title feat(bin): enforce an opt-in ceiling on concurrent Sol sessions feat(bin): enforce an opt-in concurrent Sol session ceiling Nov 10, 2026
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thanks @kesslerio, both asks from my last note are done. On 7701a295 the attestation binds the head with every step completed (intent included). Greptile's P1 "Separate state bypasses the ceiling" is fixed and resolved: fm_sol_cap_config_dir now resolves a redirected state root against the dispatch's effective configuration, and Greptile's re-review on this head is 5/5. The quick checks and the no-mistakes check pass, every review thread is resolved, and live validation is go (4 of 4). I re-checked the unconfigured path on this head. With no config/sol-cap, admission covers nothing, fm_sol_cap_has_owned_occupancy returns "not owned", and the confirmed close only runs for a task holding a claim, so contract class stays opt-in (my own read). VISION.md: every rule aligns.

One item is waiting on you before we run the full suite. Your own no-mistakes Review step left an open warning on this head, and your Risk Assessment rates it Medium. At bin/fm-sol-cap-lib.sh:830, the public refuse-claim CLI can be given a config directory C and the state H/state without FM_CONFIG_OVERRIDE. Admission then reads C/sol-cap, but row classification goes through fm_sol_cap_config_dir, which resolves H/config. So a live covered claim in H/state isn't counted, and a second dispatch is "claimed" over a max=1 ceiling. This is the same config/state binding class as the P1 you just fixed. The spawn paths are safe because they always pass the effective config. Please either bind the supplied config directory to the supplied state for the whole admission, or reply here explaining why the CLI-only path is acceptable. Then re-raise once through git push no-mistakes.

Optional, while you're in there: the Document step notes that the provisional hint for tests/fm-sol-cap.test.sh (25000 ms) is now far below a fresh Linux sample (about 166 s). Refreshing the hint in bin/fm-test-run.sh and its line in docs/fm-test-portable-shards.md would keep the serial shards balanced.

I'll mention one edge to Kun, and you don't need to change it: on a home with no ceiling declared, fm_sol_cap_refuse_and_claim resolves the root home before it checks coverage. So a home whose .fm-secondmate-parent binding can't be resolved now refuses every spawn loudly. Main already refuses Treehouse spawns in that state.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants