Repository navigation
feat(bin): choose a Claude account per ship or scout from a declared list - #7892
omkarbhale wants to merge 4 commits into
Conversation
[Medium impact] The PR appears safe to merge; all previous findings are addressed and no new blocking issue was found. Reviews (2) · Last reviewed commit: "fix(bin): close account-list review gaps..." · Reviewed by Greptile |
|
Speaking as Kun's firstmate: thank you @omkarbhale. This is a careful take on #7638, and the design notes made the diff quick to follow. Holding the quota helper to data only, with no choice of its own, is the right call. What I checked (head Before this can merge, please look at Greptile's three P1s. They match what I see in the code:
On live validation: your body describes live runs against two real subscriptions for spawn, relaunch and the refusals, and that covers the two scenarios the pipeline marked untested. Thank you. After the fixes, a For context, #5444 and #5288 are still open in this area. Your credits section already notes this PR is the narrower, current one, so I'm leaving both as they are. contract-class: opt-in. Everything is gated on a new captain-declared This is waiting on you for the three fixes above plus a re-raise. Thanks again! |
…list Add an opt-in config/claude-accounts list of Claude config directories. When it is present, every Claude ship or scout spawn names one declared entry with --account; that entry passes the same root, raw-command, and stripped-environment `claude auth status` refusals as config/claude-account, and is recorded as account= on the spawn line and in the task record. A relaunch or recovery keeps the recorded account, and only an explicit `fm-control.sh <id> relaunch --account <entry>` moves a task to another declared account. Without the list nothing changes and --account refuses. bin/fm-claude-account-quota.sh measures each declared account in isolation with `quota-axi --provider claude --profile-only` and shows the highest known spendPriority, escalating on a tie or when nothing is rankable, so the existing quota-array-dispatch procedure can rank accounts. Refs kunchenguid#7638
quota-axi exits nonzero when it cannot measure a provider, such as when the Claude quota endpoint rate-limits a burst of reads, but still prints a valid snapshot naming that state. fm-claude-account-quota.sh now keeps that snapshot, so the account is reported unmeasured with the vendor's reason instead of as an unreadable root.
…l chooses account
…condmates - Refuse an --account value holding a control character, and match it against each whole declared entry, so a newline can no longer pass membership on one line or split the account= record. - Print each scope's usableRunwaySeconds and the runway's projectionConfidence in fm-claude-account-quota.sh rows, so the runway floor has the time it needs; confidence was previously always dropped because the snapshot carries it under runway. - Refuse --account on every secondmate spawn before the remote route, which previously accepted and ignored it.
d85f695 to
1f0bcba
Compare
|
Speaking as Kun's firstmate: thank you @omkarbhale. Your four commits landed through #8121, which rebased them onto current main and kept your authorship, so I'm closing this one as superseded. Really appreciate the careful work on #7638. |
Intent
Contribute an implementation of the upstream issue #7638 to firstmate ("Can we contribute here?"). The issue is labelled ready-for-pr.
The issue asks for this. Let Firstmate choose the Claude account per crewmate (ship/scout worker) instead of per home, and pick the account using each account's remaining quota, so several Claude subscriptions can serve one fleet at the same time. Today
config/claude-accountpins oneCLAUDE_CONFIG_DIRfor every Claude worker a home launches. Dispatch profiles andquota-array-dispatchchoose harness, model and effort but not account, andquota-axireports Claude as a single provider.Its sketch:
CLAUDE_CONFIG_DIR) as a list, e.g.config/claude-accounts.quota-axireports each account separately so spendPriority and runway can rank them.claude auth status) per account before launch.The maintainer's triage set what a PR must hold to:
claude auth statuswith the stripped environment, the credential unsetting, and refusal on a malformed or signed-out entry. Never a silent fallback to the ambient account.account=is today), and relaunch and recovery reuse it.quota-axior a deterministic mapping. Ranking stays in the existing dispatch procedure, with no new composite score or daemon.docs/configuration.mdand the skill.The person contributing has two separate Claude subscriptions.
What Changed
config/claude-accounts(a list ofordinaryor absolute Claude config dirs). When it is present, every Claude ship or scout spawn must name a declared entry with--account, and that entry goes through the sameclaude auth statuscheck and credential unsetting as the single pin. A malformed or signed-out entry refuses, and so does a home that has both the list andconfig/claude-account. The chosen account is written to the spawn line and the task meta asaccount=. Without the list, launches behave exactly as before.fm-control.sh <id> relaunch --account <entry>moves a task to another declared account explicitly. A task with no recorded account, or with one that is no longer declared, refuses a plain relaunch.bin/fm-claude-account-quota.sh. It runsquota-axi --profile-onlyunder each declared account's config dir and prints one data-only quota row per account. It does not rank or pick an account. Choosing the account stays in thequota-array-dispatchskill. The change also updatesdocs/configuration.md,AGENTS.md, the related skills, and the tests.🤖 Generated with Claude Code
Risk Assessment
Testing
I ran the three targeted test files for this change: the quota helper, spawn and the account library, and relaunch. All three exited 0. I also drove bin/fm-claude-account-quota.sh live in a throwaway lab home with the real quota-axi and ~/.claude login. With no list or a malformed list it refused with exit 2. With a declared account it printed one row of facts per account (remaining, spendPriority, runway, confidence) and chose nothing. The spawn and relaunch scenarios were covered only by script tests, not live. I could not launch a live worker on a second Claude account because only one login exists on this machine.
Evidence: Live quota helper transcript
Source: Live quota helper transcript
Evidence: worker-account test log
Source: worker-account test log
Evidence: relaunch test log
Source: relaunch test log
Evidence: quota helper test log
Source: quota helper test log
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
✅ No issues found.
✅ **Test** - passed
✅ No issues found.
bash tests/fm-claude-account-quota.test.shbash tests/fm-worker-account.test.shbash tests/fm-control-relaunch.test.shFM_HOME=$LAB bin/fm-claude-account-quota.shin a disposable lab home with no list, a malformed list, and a list naming the real ~/.claude✅ **Document** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.