Skip to content

feat(bin): automatic Claude seat mode with destination headroom and an extra-usage policy - #11

Merged
max-metaplanet merged 3 commits into
mainfrom
fm/seat-auto-mode
Sep 24, 2026
Merged

max-metaplanet merged 3 commits into
mainfrom
fm/seat-auto-mode

Conversation

@max-metaplanet

@max-metaplanet max-metaplanet commented Sep 24, 2026 •

Copy link
Copy Markdown
Owner

Intent

can there be an automated mode ? e.g. at a configurable threshold auto switch to next seat (if next seat has more than X threshold remaining?) probably need a few controls there e.g. a setting that allows it to switch automatically if next seat has more than X remaning and a setting that controls whether to continue and use api usage if theres any available (configuragle limit) or just stop without dipping into any api usage etc

Context. Claude seat switching today (bin/fm-seat.sh, docs/claude-seats.md) has a trigger threshold plus an arm that runs switch --next when the active seat drops to N percent left. But next_seat picks the next seat in list order that is merely logged in - it never reads that seat's quota, so it can switch onto a seat that is nearly empty - and the watch fires once and must be re-armed by hand. Per-seat spend is observable: quota-axi --provider claude --json --full reports, per seat, a window id extra_usage of kind credits with spentUsd and limitUsd; when a seat's plan quota runs out, work rolls silently into paid extra usage.

The three controls wanted: (1) the trigger threshold, which exists - switch when the ACTIVE seat drops to N percent left; (2) destination headroom - only switch to a seat with more than X percent left, skip seats below X, and if none qualifies do not switch; (3) an extra-usage policy for when no seat has headroom - STOP, holding new Claude dispatch rather than starting workers that would run on paid extra usage, or ALLOW up to a configurable dollar cap and then hold. It keeps watching after a switch instead of firing once.

An honest limit to state in the docs: firstmate controls which seat new work starts on and whether new Claude work is dispatched at all. It cannot stop a worker that is already running from drawing extra usage mid-task - that is the organisation's Claude admin setting. STOP therefore means stop starting new work, plus a loud warning the moment any running worker's seat enters extra usage; it is never described as guaranteeing zero spend.

Also: the usage warner (config/usage-warner) counts percent USED while the seat threshold and the quota viewer ("9% session") count percent REMAINING, so the two read as contradicting each other, and the warner has no setter - an operator must know its file path and format. Make every setting count in percent left, and give the warner a setter matching fm-seat.sh threshold in shape and direction.

What Changed

  • bin/fm-seat.sh has two new settings, destination-min <pct> and extra-usage stop|allow <usd>|off. They are stored in the new config/claude-seat-destination-min and config/claude-seat-extra-usage files, which local secondmate homes inherit. When destination-min is set, rotation reads each candidate seat's quota. It only switches onto a seat with more than that percent left, and a seat whose quota can't be read counts as skipped. It names every skipped seat with its headroom, and it refuses to switch if none qualifies. The armed watch now keeps going after a switch: it fires once per seat crossing and keeps checking for a destination while the active seat stays below its trigger. Every quota read is capped by FM_CHECK_TIMEOUT. status shows all the settings, whether the watch is armed, and whether new dispatch is held right now.
  • bin/fm-spawn.sh now checks the extra-usage policy before a fresh claude spawn. With stop, or once allow <usd> reaches its cap (compared against the seat's reported extra_usage spend), it refuses the spawn and gives the hold reason. A policy that is set also holds dispatch while the quota can't be read. Relaunches are not gated. --ignore-seat-hold pushes a single spawn through without changing any setting. The automatic mode also sends a warning when a seat that a running worker is on enters extra usage.
  • bin/fm-usage-warner.sh thresholds now count percent left and cross downward, matching the seat threshold. Warner output shows both figures (e.g. 8% left (92% used)). There is a new threshold <window> <pct>|off setter, plus a notify action that fm-seat.sh uses so the home keeps a single alert path. The arm/disarm logic for check shims moved into a new shared bin/fm-check-shim-lib.sh. The docs (claude-seats.md, usage-warner.md, configuration.md, AGENTS.md) describe the new controls. They also state that stop only stops new work from starting and does not guarantee zero spend. The seat and warner test suites are extended.

🤖 Generated with Claude Code

Risk Assessment

⚠️ Medium: The fix round correctly resolves all three prior findings with no new defects found. The cmd_auto blocked marker re-checks for a destination on every poll, reports once, and cannot ping-pong between seats. Every quota read goes through one bounded helper, and a timed-out read gives no verdict. The hold-reason wording now lives in one place that both the spawn gate and status use. The fix round also sources fm-quota-axi-lib in fm-spawn, which the dispatch decision's jq filter needs. The change stays medium risk because it can switch accounts automatically and can hold all new Claude dispatch across the fleet.

Testing

I ran fm-seat.sh against real quota-axi in throwaway FM_HOMEs, with no secondmate records, so nothing outside them was touched. The new wake wording showed up live under the stop policy with no qualifying destination, and the repeat poll printed nothing. The watch also switched to a real seat with 97% left, and a rate-limited quota was treated as no verdict. The targeted fm-seat test file passes on the target commit and fails with the old wording restored, but that is a test-suite check, not a live product run. That file stops at its first failure, which is the updated no-headroom test, so the new agreement test itself was not run against the old wording. Once Claude's quota endpoint rate-limited, I could not capture status reporting "allowed" next to the wake line, and I could not get an allow-policy wake. The worktree is clean.

  • Live validation: ✅ go - 4 of 7 scenarios driven live against the product
Scenario Result Live Evidence
Stop policy, trigger crossed, no seat above the destination minimum: the watch says work WILL be held once plan quota runs out, not that it is held now ✅ pass live cli-real-no-headroom-agreement-round2.txt
Repeated poll with nothing changed after a no-headroom crossing stays silent (one wake per crossing) ✅ pass live cli-real-no-headroom-agreement-round2.txt
Active seat at/below trigger switches to a real named seat with headroom (seat-max at 97% left) ✅ pass live cli-real-quota-axi-wording-round2.txt
Adversarial: a rate-limited (unreadable) quota never switches and holds dispatch under a policy without guessing ✅ pass live cli-real-no-headroom-agreement-round2.txt (the final auto and status under allow $25)
The new regression test fails with the old wording and passes with the fix ⏸️ untested no The earlier payload backed this only with runs of the test suite against fake quota (fm-seat.test.round2.log and fm-seat.test.pre-fix-wording.log), not with a live product run, so it did not show a li…
The wake line and status give the same answer while plan quota remains (status: dispatch allowed, some % left) ⏸️ untested no The real Claude quota endpoint rate-limited the reads right after the auto pass, so status reported the quota as unreadable instead of allowed. The test file (fake quota) passes on the fix. To see it…
Allow-policy no-headroom wake says extra usage continues up to the cap once plan quota runs out ⏸️ untested no The active seat's quota read was rate-limited during the allow-policy pass, so it returned no verdict and printed no wake. Re-drive once quota-axi is not rate-limited.
Evidence: Real quota-axi: stop policy, no headroom, new wake wording

Source: Real quota-axi: stop policy, no headroom, new wake wording

claude-seat: default is at 9% left and no seat has enough headroom to switch to; new Claude work will be held once this seat's plan quota runs out, rather than started on paid extra usage. A worker already running is not stopped.

## Round 2 live: real quota-axi, ambient default seat active, real named seat seat-max as the only candidate
## destination-min 99 so seat-max cannot qualify; threshold 100 so the trigger is crossed; plan quota on default is above 0
$ fm-seat.sh threshold 100
auto-switch threshold: 100% left
[exit 0]
$ fm-seat.sh destination-min 99
destination minimum: 99% left
[exit 0]
$ fm-seat.sh extra-usage stop
extra-usage policy: stop
new Claude workers are held once the active seat has no plan quota left.
This stops STARTING new work. It cannot stop a worker already running from
drawing extra usage mid-task, so it is not a guarantee of zero spend.
[exit 0]
$ fm-seat.sh auto
claude-seat: default is at 9% left and no seat has enough headroom to switch to; new Claude work will be held once this seat's plan quota runs out, rather than started on paid extra usage. A worker already running is not stopped.
[exit 0]
$ fm-seat.sh status
active seat for NEW workers: default
active profile: (ambient default login)
login state: unknown
auto-switch trigger: at or below 100% left on the active seat
destination minimum: only switch to a seat above 99% left
extra-usage policy: stop - hold new Claude dispatch rather than start work on paid extra usage
auto-switch watch: not armed
new Claude dispatch: HELD (bin/fm-spawn.sh --ignore-seat-hold starts one task anyway)
  the active Claude seat quota could not be read, so whether this worker would run on paid extra usage is unknown, and the policy makes no guess
  this holds only work not yet started; a worker already running keeps its own seat and can still draw extra usage mid-task

live workers keep the seat they launched with:
  (no task records)

local secondmate homes declining inherited seats:
  (none - every local home takes this seat)
[exit 0]
## repeat poll, nothing changed: expect silence (one wake per crossing)
$ fm-seat.sh auto
[exit 0]
## same crossing under allow $25 (fresh throwaway state so the crossing wakes once)
$ fm-seat.sh extra-usage allow 25
extra-usage policy: allow up to $25, then hold
Measured against the spend the account itself reports for this seat.
[exit 0]
$ fm-seat.sh auto
[exit 0]
$ fm-seat.sh status
active seat for NEW workers: default
active profile: (ambient default login)
login state: unknown
auto-switch trigger: at or below 100% left on the active seat
destination minimum: only switch to a seat above 99% left
extra-usage policy: allow up to $25 of paid extra usage, then hold
auto-switch watch: not armed
new Claude dispatch: HELD (bin/fm-spawn.sh --ignore-seat-hold starts one task anyway)
  the active Claude seat quota could not be read, so whether this worker would run on paid extra usage is unknown, and the policy makes no guess
  this holds only work not yet started; a worker already running keeps its own seat and can still draw extra usage mid-task

live workers keep the seat they launched with:
  (no task records)

local secondmate homes declining inherited seats:
  (none - every local home takes this seat)
[exit 0]
Evidence: Real quota-axi: auto switch to a seat with headroom, then silent repeat poll

Source: Real quota-axi: auto switch to a seat with headroom, then silent repeat poll

claude-seat: switched from default at 9% left to seat-max; new workers launch there

## Round 2: real quota-axi (read-only --no-credential-refresh), ambient default profile, throwaway FM_HOME, target 3e73df4
## threshold 100 guarantees the real seat is at/below trigger; no named seats exist so no destination qualifies
$ fm-seat.sh threshold 100
auto-switch threshold: 100% left
[exit 0]
$ fm-seat.sh extra-usage stop
extra-usage policy: stop
new Claude workers are held once the active seat has no plan quota left.
This stops STARTING new work. It cannot stop a worker already running from
drawing extra usage mid-task, so it is not a guarantee of zero spend.
[exit 0]
$ fm-seat.sh threshold-reached
[exit 0]
$ fm-seat.sh auto
claude-seat: switched from default at 9% left to seat-max; new workers launch there
[exit 0]
$ fm-seat.sh status
active seat for NEW workers: seat-max
active profile: ~/.claude-seats/seat-max
login state: logged-in
auto-switch trigger: at or below 100% left on the active seat
destination minimum: (unset - any logged-in seat is a valid destination)
extra-usage policy: stop - hold new Claude dispatch rather than start work on paid extra usage
auto-switch watch: not armed
new Claude dispatch: allowed
  the active Claude seat still has 97% of its plan quota left

live workers keep the seat they launched with:
  (no task records)

local secondmate homes declining inherited seats:
  (none - every local home takes this seat)
[exit 0]
## repeat poll, nothing changed: expect silence
$ fm-seat.sh auto
[exit 0]
## switch policy to allow $25 and clear the de-dupe record for a fresh crossing
$ fm-seat.sh extra-usage allow 25
extra-usage policy: allow up to $25, then hold
Measured against the spend the account itself reports for this seat.
[exit 0]
$ fm-seat.sh auto
[exit 0]
$ fm-seat.sh status
active seat for NEW workers: seat-max
active profile: ~/.claude-seats/seat-max
login state: unknown
auto-switch trigger: at or below 100% left on the active seat
destination minimum: (unset - any logged-in seat is a valid destination)
extra-usage policy: allow up to $25 of paid extra usage, then hold
auto-switch watch: not armed
new Claude dispatch: HELD (bin/fm-spawn.sh --ignore-seat-hold starts one task anyway)
  the active Claude seat quota could not be read, so whether this worker would run on paid extra usage is unknown, and the policy makes no guess
  this holds only work not yet started; a worker already running keeps its own seat and can still draw extra usage mid-task

live workers keep the seat they launched with:
  (no task records)

local secondmate homes declining inherited seats:
  (none - every local home takes this seat)
[exit 0]
Evidence: fm-seat test file with the fix (passes)

Source: fm-seat test file with the fix (passes)

ok - an unset seat setting is the ambient default and configures no automatic switching
ok - a switch to a logged-in seat records the seat and nothing else
ok - a switch to a profile that is not logged in is refused and changes nothing
ok - --force does not override a seat proven to be logged out
ok - a rate-limited signed-in seat is undecided, and --force switches onto it
ok - an unreadable credential store reads as undecided and --force may cross it
ok - a forced switch refuses a seat whose profile directory does not exist
ok - switching to the default seat clears the setting and restores ambient behaviour
ok - a seat switch reaches running local secondmate homes and reports each one
ok - a failed secondmate push is reported and never undoes the primary switch
ok - a local home that declines keeps its own three seat settings through a switch
ok - one home's decline leaves every other local home taking the switch
ok - status names every local home that declined and the seat it is really on
ok - a decline flag of any type declines and shows in status
ok - seat settings reach local secondmate homes only and never cross to a remote route
ok - a seat switch pushes only local secondmate homes and never waits on a remote route
ok - fm-config-push reaches remote routes by default and skips them only with --local-only
ok - the auto-switch threshold is configurable, validated, clearable, and unset by default
ok - the threshold condition turns true exactly at the configured percent
ok - an unreadable quota never trips an automatic switch
ok - only account-level quota windows count toward the auto-switch threshold
ok - the default seat's probe and threshold read the ambient profile new workers launch with
ok - a home that configures none of the automatic settings behaves exactly as before they existed
ok - the dispatch gate reads no quota at all until an extra-usage policy is configured
ok - the destination minimum is settable by command, validated, clearable, and unset by default
ok - a switch skips a logged-in seat below the destination minimum and lands on one above it
ok - no switch happens when every candidate is below the destination minimum
ok - a candidate whose quota gives no verdict is skipped, never guessed at as headroom
ok - the extra-usage policy is settable by command, validated, clearable, and unset by default
ok - the stop policy holds new dispatch only once the active seat's plan quota is gone
ok - the allow policy dispatches under its dollar cap and holds once the spend reaches it
ok - an unreadable quota holds dispatch instead of guessing, and the hold lifts once it reads again
ok - the watch keeps running after a switch, fires once per crossing, and catches the next seat's own
ok - with no seat qualifying the watch reports the policy consequence once and switches nothing
ok - the watch's wake line and status agree while the seat still has plan quota
ok - after a crossing with nowhere to go, the watch keeps looking and switches once a seat recovers
ok - every quota read one automatic pass makes stays inside the watcher's per-check budget
ok - the watch switches nothing when the active seat's quota gives no verdict
ok - arm registers a repeating watch the watcher can run, and retire removes it cleanly
ok - status reports all three automatic settings, every percentage counting percent left
ok - rotation chooses the next logged-in seat under the root and skips ones with no credentials
ok - rotation never targets the default profile, even when it is the only other logged-in store
ok - rotation never assumes which seats exist and picks up seats added later
ok - rotation refuses rather than pretending to switch when no other seat is usable
ok - adding a seat creates an empty profile directory and prints the owner's login steps
ok - a directory named 'default' is never offered, added, or rotated to
ok - seat names that are not a single safe path component are refused
ok - an unset seat setting leaves the launch and the task record exactly as before
ok - a spawn launches on the active seat and records it in the task's own record
ok - switching seats leaves a running worker's recorded profile unchanged
ok - after a switch new workers get the new seat while existing ones keep theirs
ok - an ambient CLAUDE_CONFIG_DIR still reaches workers and is recorded per task
ok - a configured seat takes precedence over firstmate's own ambient config dir
ok - a non-claude spawn records no Claude seat while a named seat is active
ok - a home configuring both an account pin and an active seat is refused before anything exists
ok - an account pin refuses relaunching a task recorded on a seat before anything is touched
ok - a pin-only home with no seat file still relaunches a claude task under its pin
ok - a pin pointing at a seat directory still relaunches a task recorded on that directory
ok - a stop policy holds a fresh claude spawn, names the override, and changes nothing when overridden
ok - the spawn gate holds at the dollar cap and on an unreadable quota, and dispatches under the cap
ok - the dispatch hold covers fresh claude spawns only and never strands a task already under way
ok - the Claude extra-usage hold never reaches a worker on another harness
# all fm-seat tests passed
Evidence: fm-seat test file with the old wording (fails)

Source: fm-seat test file with the old wording (fails)

not ok - the wake must name the policy consequence, not just the failed switch (missing: 'will be held once this seat's plan quota runs out')

ok - an unset seat setting is the ambient default and configures no automatic switching
ok - a switch to a logged-in seat records the seat and nothing else
ok - a switch to a profile that is not logged in is refused and changes nothing
ok - --force does not override a seat proven to be logged out
ok - a rate-limited signed-in seat is undecided, and --force switches onto it
ok - an unreadable credential store reads as undecided and --force may cross it
ok - a forced switch refuses a seat whose profile directory does not exist
ok - switching to the default seat clears the setting and restores ambient behaviour
ok - a seat switch reaches running local secondmate homes and reports each one
ok - a failed secondmate push is reported and never undoes the primary switch
ok - a local home that declines keeps its own three seat settings through a switch
ok - one home's decline leaves every other local home taking the switch
ok - status names every local home that declined and the seat it is really on
ok - a decline flag of any type declines and shows in status
ok - seat settings reach local secondmate homes only and never cross to a remote route
ok - a seat switch pushes only local secondmate homes and never waits on a remote route
ok - fm-config-push reaches remote routes by default and skips them only with --local-only
ok - the auto-switch threshold is configurable, validated, clearable, and unset by default
ok - the threshold condition turns true exactly at the configured percent
ok - an unreadable quota never trips an automatic switch
ok - only account-level quota windows count toward the auto-switch threshold
ok - the default seat's probe and threshold read the ambient profile new workers launch with
ok - a home that configures none of the automatic settings behaves exactly as before they existed
ok - the dispatch gate reads no quota at all until an extra-usage policy is configured
ok - the destination minimum is settable by command, validated, clearable, and unset by default
ok - a switch skips a logged-in seat below the destination minimum and lands on one above it
ok - no switch happens when every candidate is below the destination minimum
ok - a candidate whose quota gives no verdict is skipped, never guessed at as headroom
ok - the extra-usage policy is settable by command, validated, clearable, and unset by default
ok - the stop policy holds new dispatch only once the active seat's plan quota is gone
ok - the allow policy dispatches under its dollar cap and holds once the spend reaches it
ok - an unreadable quota holds dispatch instead of guessing, and the hold lifts once it reads again
ok - the watch keeps running after a switch, fires once per crossing, and catches the next seat's own
not ok - the wake must name the policy consequence, not just the failed switch (missing: 'will be held once this seat's plan quota runs out')
--- output ---
claude-seat: alpha is at 10% left and no seat has enough headroom to switch to; new Claude work is held rather than started on paid extra usage. A worker already running is not stopped.
- Outcome: 🔧 2 issues found → auto-fixed ✅ across 2 runs (29m59s)

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

🔧 **Review** - 4 issues found → auto-fixed ✅
  • ⚠️ bin/fm-seat.sh:542 - When the trigger is met but next_seat finds no destination, cmd_auto writes fired=<active> and then returns early on every later poll (line 524) until the ACTIVE seat reads back above its threshold. It never calls next_seat again in that time. Example: alpha is at 5% left with threshold 15 and destination-min 30, and beta is at 20%, so there is no destination. Then beta's window resets to 100%. Alpha stays below 15%, so the watch never switches to beta. With extra-usage stop set, every new Claude spawn stays held on alpha even though a seat with headroom exists. This goes against the intent ('keeps watching', 'switch automatically if next seat has more than X remaining'). Fix: in the no-destination case, keep re-evaluating next_seat on each poll without printing again. For example, record a separate blocked=&lt;active&gt; marker that only silences the repeated 'no seat has headroom' line, while fired stays reserved for a switch that actually succeeded or failed. The switch-failed path at line 537 has the same effect.
  • ⚠️ bin/fm-seat.sh:511 - cmd_auto runs one quota-axi read per distinct Claude task seat (warn_extra_usage_entry), then the active seat, then one per candidate in next_seat. These run one after another, none has a time limit, and all of them happen inside the watcher's FM_CHECK_TIMEOUT (default 30s, fm-watch.sh:240). The usage warner caps its own read at min(10s, FM_CHECK_TIMEOUT-3) for this reason. fm_seat_quota_json has no cap. With a policy set, several seats, and a slow network, the watcher can kill the pass before it reaches the switch, on every cycle, so the automatic switch silently never happens. Fix: bound each read with the existing fm-timeout-lib helper using a per-pass deadline, and run the trigger/switch path before the extra-usage warning scan so the warning can't use up the switch's budget.
  • ⚠️ bin/fm-seat.sh:389 - The change adds a public fm-seat.sh dispatch-check [--quiet] subcommand, and its comment says 'The dispatch gate bin/fm-spawn.sh consults'. fm-spawn.sh doesn't use it: it calls fm_seat_dispatch_decision directly and has its own second copy of the hold-reason messages (cmd_seat_dispatch_report, bin/fm-spawn.sh:602). No caller uses --quiet. The intent asks for the gate itself, not a separate on-demand CLI. Either remove dispatch-check and --quiet, or have fm-spawn call it and delete the duplicate renderer, so the reason text is defined in one place. At minimum the comment claiming fm-spawn consults it is wrong.
  • ℹ️ bin/fm-usage-warner.sh:339 - As the intent requires, config/usage-warner values now mean percent LEFT instead of percent USED, and there is no migration. An existing five_hour:80 (previously 'warn at 80% used') now warns as soon as the window drops to 80% left. This is deliberate and documented, and the first warning shows both figures. Noted only so the operator knows any existing home config must be re-set.

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

🔧 **Test** - 2 issues found → auto-fixed ✅
  • ℹ️ bin/fm-seat.sh:719 - When the trigger is crossed with no destination and extra-usage stop is set, the watch says 'new Claude work is held rather than started on paid extra usage' even though plan quota still remains. The real run hit this: the default seat was at 11% left, threshold 15. At the same moment fm-seat.sh status said 'new Claude dispatch: allowed ... still has 11% of its plan quota left', because the hold only starts once plan quota reaches 0. An operator reading the wake line alongside status sees two answers. Consider wording like 'new Claude work will be held once this seat's plan quota runs out'. The allow-policy message has the same shape.
  • ⚠️ live validation verdict: inconclusive (4 of 12 scenarios were driven live against the product); untested: Active seat crosses the trigger: watch skips a seat below destination-min and switches to one with headroom, Watch keeps watching after a switch: the new seat's own crossing fires again with no re-arm, No seat has headroom: no switch, one report of the stop-policy consequence, then silence while nothing changes, Adversarial: after a crossing with nowhere to go, a candidate whose window resets is switched to while the active seat is still below its trigger, Adversarial: an unreadable active quota never counts as reached and never switches, Adversarial: a slow quota endpoint cannot push the auto pass past the watcher's check timeout, Status reports whether new Claude dispatch is held and why (stop at 0% plan quota; allow $25 under vs at the cap), fm-spawn refuses a fresh Claude spawn while held, --ignore-seat-hold gets through, and relaunches and other harnesses are never held
  • Live validation: ⚠️ inconclusive - 4 of 12 scenarios driven live against the product
Scenario Result Live Evidence
Operator sets trigger, destination-min and extra-usage policy in percent left; bad values are rejected and status shows all three ✅ pass live cli-auto-mode-transcript.txt S1: threshold 15, destination-min 30 and extra-usage stop are accepted, and stop prints the not-zero-spend caveat. threshold 150, destination-min abc and allow…
Active seat crosses the trigger: watch skips a seat below destination-min and switches to one with headroom ⏸️ untested no The prior payload did not establish a live result. Per-seat quota levels came from a fake quota-axi because several real logged-in Claude seats at chosen percentages were not available.
Watch keeps watching after a switch: the new seat's own crossing fires again with no re-arm ⏸️ untested no The prior payload did not establish a live result. Seat quota levels came from a fake quota-axi because real multi-seat accounts were not available.
No seat has headroom: no switch, one report of the stop-policy consequence, then silence while nothing changes ⏸️ untested no The prior payload did not establish a live result. Seat quota levels came from a fake quota-axi.
Adversarial: after a crossing with nowhere to go, a candidate whose window resets is switched to while the active seat is still below its trigger ⏸️ untested no The prior payload did not establish a live result. The window reset was simulated with a fake quota-axi. Real seats whose windows reset on demand were not available.
Adversarial: an unreadable active quota never counts as reached and never switches ⏸️ untested no The prior payload did not establish a live result. The unparseable quota report was produced with a fake quota-axi.
Adversarial: a slow quota endpoint cannot push the auto pass past the watcher's check timeout ⏸️ untested no The prior payload did not establish a live result. The slow endpoint was simulated with a fake quota-axi.
Status reports whether new Claude dispatch is held and why (stop at 0% plan quota; allow $25 under vs at the cap) ⏸️ untested no The prior payload did not establish a live result. Zero plan quota and extra-usage spend were simulated with a fake quota-axi. A real seat at 0% plan quota with metered spend was not available.
fm-spawn refuses a fresh Claude spawn while held, --ignore-seat-hold gets through, and relaunches and other harnesses are never held ⏸️ untested no The prior payload did not establish a live result. fm-spawn's guard ('no-mistakes gate agent must not drive the fleet') refused the run, and only the test suite covered the gate. A live proof needs an…
Usage warner has a percent-left setter shaped like fm-seat.sh threshold: print, set, reject, clear ✅ pass live cli-warner-and-arm-transcript.txt S10: threshold five_hour 20 prints '20% left (which is 80% used)'. 150 is rejected. seven_day off clears. config/usage-warner holds 'five_hour:20'.
arm registers a repeating watch, status shows it armed, retire removes it ✅ pass live cli-warner-and-arm-transcript.txt S11: 'armed ... keeps watching after each switch', status shows armed, and after retire status shows not armed
Against the real quota-axi, the trigger reads the real ambient seat, and auto reports rather than switches when no seat qualifies ✅ pass live cli-real-quota-axi-transcript.txt: the real default login at 11% left with threshold 15 makes threshold-reached exit 0. Status shows 11% left and dispatch allowed. Auto reports no destination and sw…
  • bash tests/fm-seat.test.sh (full seat suite, including the auto-watch, headroom, policy, spawn-gate, quota-budget and recovered-candidate regression cases)
  • bash tests/fm-usage-warner.test.sh
  • Manual CLI in a throwaway FM_HOME with a fake quota-axi: fm-seat.sh threshold 15, destination-min 30, extra-usage stop, bad inputs (threshold 150, destination-min abc, extra-usage allow, extra-usage allow -5), switch alpha, status
  • fm-seat.sh auto across a sequence of quota states: quiet pass, crossing that skips a seat below the minimum, repeat poll, second crossing with no re-arm, no destination, silent repeat, candidate recovers, unreadable active quota, 60s endpoint with FM_CHECK_TIMEOUT=8
  • fm-seat.sh status showing HELD vs allowed under stop and under allow 25 at $10 and $25 spent
  • fm-spawn.sh gate-demo-1 ... --harness claude (refused by the gate-agent guard before the seat gate)
  • fm-usage-warner.sh threshold print/set/reject/clear, plus inspecting config/usage-warner
  • fm-seat.sh arm / status / retire, and running the generated state/claude-seat.check.sh shim directly
  • Read-only real quota-axi: fm-seat.sh threshold 15, extra-usage stop, threshold-reached, status, auto on the ambient default login

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

  • Live validation: ✅ go - 4 of 7 scenarios driven live against the product
Scenario Result Live Evidence
Stop policy, trigger crossed, no seat above the destination minimum: the watch says work WILL be held once plan quota runs out, not that it is held now ✅ pass live cli-real-no-headroom-agreement-round2.txt
Repeated poll with nothing changed after a no-headroom crossing stays silent (one wake per crossing) ✅ pass live cli-real-no-headroom-agreement-round2.txt
Active seat at/below trigger switches to a real named seat with headroom (seat-max at 97% left) ✅ pass live cli-real-quota-axi-wording-round2.txt
Adversarial: a rate-limited (unreadable) quota never switches and holds dispatch under a policy without guessing ✅ pass live cli-real-no-headroom-agreement-round2.txt (the final auto and status under allow $25)
The new regression test fails with the old wording and passes with the fix ⏸️ untested no The earlier payload backed this only with runs of the test suite against fake quota (fm-seat.test.round2.log and fm-seat.test.pre-fix-wording.log), not with a live product run, so it did not show a li…
The wake line and status give the same answer while plan quota remains (status: dispatch allowed, some % left) ⏸️ untested no The real Claude quota endpoint rate-limited the reads right after the auto pass, so status reported the quota as unreadable instead of allowed. The test file (fake quota) passes on the fix. To see it…
Allow-policy no-headroom wake says extra usage continues up to the cap once plan quota runs out ⏸️ untested no The active seat's quota read was rate-limited during the allow-policy pass, so it returned no verdict and printed no wake. Re-drive once quota-axi is not rate-limited.
  • FM_HOME=&lt;throwaway&gt; bin/fm-seat.sh threshold 100; extra-usage stop; threshold-reached; auto; status; auto; extra-usage allow 25; auto; status against real quota-axi (--no-credential-refresh), where the watch switched default→seat-max
  • FM_HOME=&lt;throwaway&gt; bin/fm-seat.sh threshold 100; destination-min 99; extra-usage stop; auto; status; auto; extra-usage allow 25; auto; status against real quota-axi, the no-headroom case
  • quota-axi --provider claude --no-credential-refresh --full --json run three times, which showed the upstream rate limit
  • bash tests/fm-seat.test.sh on target commit 3e73df4: all passed
  • bash tests/fm-seat.test.sh with bin/fm-seat.sh from HEAD~1 (old wording): fails with "missing: 'will be held once this seat's plan quota runs out'"; bin/fm-seat.sh restored afterwards
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.


Live validation evidence, and its limits

The automatic mode was exercised end to end in a guarded Herdr lab session against a throwaway FM_HOME with synthetic seats, driven by a scriptable quota-axi shim. No real credential was read, and neither ~/.claude-seats nor ~/.claude was touched: the seats root was redirected into the lab's own tree. The lab session was torn down through the guarded helper with its fleet-state tripwire verified afterwards.

Driven against the real quota-axi (read-only, --no-credential-refresh, against the ambient default login):

  • the three settings and their validation
  • the usage warner's percent-left setter
  • arm / status / retire
  • one read-only quota pass

Driven against the quota-axi shim, because reaching these states on real accounts would mean exhausting two real Claude accounts' quota and spending real extra usage:

  • a switch skips a seat below the destination minimum and lands on one above it
  • no switch when no seat qualifies
  • the watch keeps watching after a switch, and the seat it moved to fires again on its own crossing with nothing re-armed
  • one crossing produces at most one wake and one switch per seat
  • after a crossing with nowhere to go, a candidate whose window later resets is switched to while the active seat is still below its trigger
  • an unreadable active quota never counts as reached and never switches
  • a slow quota endpoint cannot push the automatic pass past the watcher's check timeout
  • status reports whether new Claude dispatch is held and why
  • STOP holds a new dispatch; ALLOW proceeds under its dollar cap and holds once the spend reaches it

Covered by the test suite only: the fm-spawn dispatch hold itself - a fresh Claude spawn refused while held, --ignore-seat-hold getting through, and relaunches and other harnesses never being held. The validation-step agent could not drive fm-spawn directly, because no-mistakes' own gate-agent guard correctly refuses a pipeline agent from driving a pipeline.

tests/fm-seat.test.sh and tests/fm-usage-warner.test.sh both pass, along with the adjacent fm-secondmate-harness, fm-spawn-dispatch-profile and fm-trace-context-lib suites.

Lab transcript

Guarded Herdr lab run, six scenarios
== herdr lab session: fm-lab-seat-auto-mode-96313-23860
name                 status   directory                                        socket
default              running  /Users/max/.config/herdr                         /Users/max/.config/herdr/herdr.sock
fm-lab-fork-sync-63295-1707 stopped  /Users/max/.config/herdr/sessions/fm-lab-fork-sync-63295-1707 /Users/max/.config/herdr/sessions/fm-lab-fork-sync-63295-1707/herdr.sock
fm-lab-seat-auto-mode-96313-23860 running  /Users/max/.config/herdr/sessions/fm-lab-seat-auto-mode-96313-23860 /Users/max/.config/herdr/sessions/fm-lab-seat-auto-mode-96313-23860/herdr.sock

==============================================================
1. A SWITCH SKIPS A SEAT BELOW THE DESTINATION MINIMUM
==============================================================
auto-switch threshold: 15% left
(exit 0)
destination minimum: 25% left
(exit 0)
--- switch --next (beta-lean is at 12% left, zulu-roomy at 70%)
seat beta-lean: skipped, 12% left is not above the 25% destination minimum
switched: alpha -> zulu-roomy
applies to NEW claude workers only; running workers keep their own seat
●━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
●  WORKTREE TANGLE - PRIMARY CHECKOUT IS ON A FEATURE BRANCH
●  /Users/max/.treehouse/firstmate-97638e/4/firstmate is on 'fm/seat-auto-mode', not its default branch 'main'.
●  A crewmate likely branched/committed in the primary instead of its own worktree.
●  The work is SAFE on the 'fm/seat-auto-mode' ref.
●  Restore the primary to 'main':
●      git -C /Users/max/.treehouse/firstmate-97638e/4/firstmate checkout main
●  then re-validate 'fm/seat-auto-mode' in a proper isolated worktree.
●━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
config-push: no live secondmate homes found
(exit 0)
--- active seat now:
zulu-roomy

==============================================================
2. NO SWITCH WHEN NO SEAT QUALIFIES
==============================================================
seat beta-lean: skipped, 12% left is not above the 25% destination minimum
seat zulu-roomy: skipped, 20% left is not above the 25% destination minimum
error: no seat under the seats root qualifies as a destination (each skipped seat and its reason is printed above); add and log into a second seat, or lower 'fm-seat.sh destination-min' (docs/claude-seats.md). The default profile is never a rotation target, so switch to it by name if that is what you want
(exit 1)
--- active seat unchanged:
alpha

==============================================================
3. STOP HOLDS A NEW DISPATCH
==============================================================
extra-usage policy: stop
new Claude workers are held once the active seat has no plan quota left.
This stops STARTING new work. It cannot stop a worker already running from
drawing extra usage mid-task, so it is not a guarantee of zero spend.
(exit 0)
--- plan quota still left (10%): dispatch allowed
dispatch allowed: the active seat still has 10% of its plan quota left
(exit 0)
--- plan quota gone (0%): dispatch held
dispatch HELD: the active seat has no plan quota left and the policy is stop, so no NEW Claude worker is started on paid extra usage
This holds only work not yet STARTED. A worker already running keeps its own
seat and can still draw extra usage mid-task; only the account admin setting
stops that. Clear the hold with: fm-seat.sh extra-usage off
(exit 1)

==============================================================
4. ALLOW PROCEEDS UNTIL THE CAP, THEN HOLDS
==============================================================
extra-usage policy: allow up to $25, then hold
Measured against the spend the account itself reports for this seat.
(exit 0)
--- $10 spent against a $25 cap
dispatch allowed: $10 of extra usage spent, under the $25 cap
(exit 0)
--- $25 spent against a $25 cap
dispatch HELD: $25 of extra usage spent, at or over the $25 cap
This holds only work not yet STARTED. A worker already running keeps its own
seat and can still draw extra usage mid-task; only the account admin setting
stops that. Clear the hold with: fm-seat.sh extra-usage off
(exit 1)

==============================================================
5. THE WATCH FIRES AGAIN ON THE NEXT CROSSING
==============================================================
--- poll 1, alpha at 60% left, above the 15% trigger (silence expected)
(exit 0)
--- poll 2, alpha crosses to 10% left
claude-seat: switched from alpha at 10% left to beta-lean; new workers launch there
(exit 0)
--- active seat:
beta-lean
--- poll 3, same crossing, already acted on (silence expected)
(exit 0)
--- poll 4, the seat it MOVED TO now crosses; nothing was re-armed by hand
claude-seat: switched from beta-lean at 9% left to zulu-roomy; new workers launch there
(exit 0)
--- active seat:
zulu-roomy

==============================================================
6. ARM / RETIRE THE REPEATING WATCH
==============================================================
armed: automatic switch at 15% left on the active seat
keeps watching after each switch; one crossing fires at most once per seat
(exit 0)
claude-seat.check-trust
claude-seat.check.sh
active seat for NEW workers: zulu-roomy
active profile: /var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T//fm-seat-liveproof.Ju9w49/seats/zulu-roomy
login state: logged-in
auto-switch trigger: at or below 15% left on the active seat
destination minimum: only switch to a seat above 25% left
extra-usage policy: (unset - nothing holds Claude dispatch)
auto-switch watch: armed (keeps watching after each switch)

live workers keep the seat they launched with:
  (no task records)

local secondmate homes declining inherited seats:
retired: the automatic Claude seat watch
(exit 0)
(no claude-seat state left)

== live proof complete; tearing the lab down

One migration note for operators

config/usage-warner directives now mean percent left instead of percent used, with no automatic migration. An existing five_hour:80 previously meant "warn at 80% used" and now means "warn at 80% left", so it fires early. The failure direction is safe (it over-warns rather than under-warns) and every warning names both figures, so a carried-over config announces itself the first time it speaks - but it does need re-setting with bin/fm-usage-warner.sh threshold five_hour <percent-left>.

…an extra-usage policy

Seat switching had a trigger but no judgement about where it was switching
to: next_seat picked the next seat that was merely logged in, never reading
its quota, so it could land on a seat that was nearly empty. The watch also
fired once and had to be re-armed by hand, and when a seat's plan quota ran
out, work rolled silently into paid extra usage with nothing to stop it.

Three controls, each off when absent, each counting percent LEFT:

  claude-seat-threshold        trigger: the ACTIVE seat drops to N% left
  claude-seat-destination-min  a DESTINATION must exceed X% left
  claude-seat-extra-usage      `stop`, or `allow <usd>`, when none qualifies

A candidate below the minimum is skipped and named with its measured
headroom; a candidate whose quota gives no verdict is skipped as unknown
rather than guessed at in either direction; if none qualifies, nothing is
switched. With no minimum configured the rotation gate stays login-only and
no candidate quota is read at all.

The extra-usage policy gates NEW claude dispatch through fm-spawn: `stop`
holds once the active seat's plan quota is gone, `allow <usd>` holds once the
seat's extra_usage spend reaches the cap, and an unreadable quota holds rather
than launching on a guess. A relaunch is never held, because that is recovery
of work already under way. --ignore-seat-hold pushes one spawn through
without changing the setting.

State the limit plainly rather than implying a spend guarantee: firstmate
chooses which seat new work starts on and whether it starts, but cannot stop
a worker already running from drawing extra usage mid-task. `stop` therefore
means stop STARTING work, plus a warning the moment a running worker's seat
enters extra usage, sent through the usage warner's notification path.

The watch is now a registered repeating check rather than the one-shot
condition-action primitive: one crossing fires at most once per seat, and the
seat it moves to fires again on its own crossing with nothing re-armed. arm
and retire both clear any older one-shot registration so an upgrading home
ends with one watch.

The usage warner counted percent USED while every seat setting counted
percent REMAINING, so the two read as contradicting each other. It now counts
percent left too, names both figures on every line it prints so a config
carried over from the old reading announces itself, and gains a
`threshold <window-id> <percent-left>` setter matching fm-seat.sh's in shape
and direction, plus a `notify` action that makes it the one owner of this
home's notification path.

fm-check-shim-lib.sh factors out the check-shim write, trust binding, and
rollback that fm-usage-warner.sh already carried, so the seat watch adds a
fourth consumer without a fourth copy.
@max-metaplanet
max-metaplanet merged commit c48332b into main Sep 24, 2026
20 checks passed
max-metaplanet added a commit that referenced this pull request Oct 6, 2026
…n extra-usage policy

Carried from fork commit c48332b (#11).

bin/fm-config-inherit-lib.sh unions the inheritable set again, keeping upstream's
newer items beside the two new seat settings.

AGENTS.md keeps upstream's pointer and the seat entry is updated in the
`operational-home-layout` skill, as for the earlier seat commits.

Two resolutions follow from the approved decision to drop the relaunch-pin
refusal series and wait for upstream's own PR:

docs/configuration.md does not carry this commit's sentence documenting a refused
relaunch when the pin does not select the task's recorded seat, because that
refusal is not implemented here.
Upstream's sentence is kept, with its stale "these three files" corrected to
"these files" now that five drive the behaviour.

tests/fm-seat.test.sh drops `test_account_pin_and_recorded_seat_refuse_the_relaunch`.
The dropped review commits are ancestors of this one, so that test arrived with
this pick's side of the conflict while the code it asserts did not, and it would
have failed against a branch that deliberately has no such refusal.
The two tests asserting a pin-only home and a pin pointing at the seat directory
still relaunch are kept: both pass without the refusal and state the behaviour
this branch does have.
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.

1 participant