Repository navigation
feat: ak usage last known reading, ak ps, and native orchestration (ak run --pick, ak fanout) - #59
Merged
Merged
Conversation
A row that is expired, no_scope, no_login or error kept only a status and a hint. When the usage cache still holds an earlier reading of that account, at most seven days old, ak usage now lists its windows under the status line, dated, and --json carries it as the additive last_known block. A window whose reset time has passed is marked reset and carries no number. The row is still a problem row; ak pick and ak capacity never read a reading that old. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The last known reading comes from a file on disk. A window with a reset time that is not a time, a percentage that is not a number or a missing key made ak usage fail instead of reporting the row. Such a reading is now not shown. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Every interactive ak <kind> [@Profile] now leaves one record in the kit's state directory (sessions/, one 0600 file per launch): the process id and its start time, kind, CLI, provider, profile, working directory, launch time, posture and the Herdr pane id. Best effort: a failed write never changes a launch. A record is live only while its process id is alive with the recorded start time. Nothing reads the records yet; ak ps follows. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
ak ps [--json] lists the interactive sessions ak launched that are still running, oldest first: kind, CLI, provider, profile, directory, launch time, posture, Herdr pane and the account's capacity. Capacity comes from the usage cache alone, with the reading's age: no vendor is queried and no login is touched. Ended records are removed as it reads; of several live sessions naming one Herdr pane only the newest is listed. --json is the new sessions-v1 schema. Interface stays 1. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A process id means nothing on another machine or in another container. With a state directory shared between a host and its containers, ak ps on one side judged the other side's records by its own process table, listed wrong sessions and removed the records of sessions that were alive. Records now name their host, and each side lists, ends and removes only its own. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
ak run <kind> --pick runs on the account ak pick names (one shared choice, pick.select). With --failover N it moves to another account, then to the next --fallback kind, on two triggers only: the attempt never started (exit 3), or it ended with exit 1 or 4 and a fresh usage reading shows the account spent. After a started attempt it moves only when --cwd is a git work tree left exactly as it was; ak run never cleans a workspace. --owner holds a lease for each attempt. The JSON envelope gains attempts and failover with --pick only; without it nothing changes. Interface stays 1. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
ak fanout run takes a task list and runs each task as its own lane: a new git worktree on a new branch (ak/<run-id>/<task-id>) from --base, one ak run --pick child process per lane, in parallel. Lanes start one at a time once the previous lease shows, so ak pick spreads them; an exclusive account carries one lane at a time and a lane that finds every account busy waits its turn. The task list is validated before anything is created. The result is the new fanout-v1 schema; a 0600 run record lists every worktree the run created. It never merges, pushes or rebases. ak fanout ls lists the runs on record. Interface stays 1. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A lane survives a spent account also when the agent had already written: its own worktree is removed and created again from the base and the task runs once more on another account, within --failover; a branch that holds commits is never reset. An account found spent is left out for the rest of the run (ak run gains --exclude @Profile). SIGTERM or SIGINT stops every lane, releases the leases and exits 5. ak fanout clean <run-id> removes a run's worktrees, branches and record: it keeps uncommitted work and branches with commits unless --force, and removes a worktree only when it is in the run's record, where the run puts a lane, a linked worktree of the recorded repository and its own git top level. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…-discard The agentkit-orchestrate skill, its patterns reference and docs/orchestration.md teach ak fanout run for parallel tasks and ak run --pick --failover for one delegate, in place of the loop run by hand. The rules the commands do not enforce stay with the lead: the gate in each worktree, merging only what passes, never an account the user did not offer. The scenarios run the taught commands against fake accounts. ak fanout clean's option to remove uncommitted work and unmerged commits is --discard: the earlier spelling was a CLI's autonomy flag, which no skill may spell (E006). Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Review fixes. A lane's place is <run-id>/<id> or <run-id>/wt/<id> and nothing else under the run id. After a clean, only the run's own --worktrees directory is removed when empty, never the parent of whatever path an edited record names. A run id that is already on record is not reused. A lane that fails inside the kit ends with exit 70 instead of leaving the run without a result. docs/run.md names exit 3 for --pick with no account. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
git worktree remove was called with git's long switch for discarding uncommitted files, which is spelled like a vendor CLI's autonomy flag; no such word may appear in the kit's code. Use git's short switch through a named constant. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
# Conflicts: # CHANGELOG.md # docs/SECURITY.md
…chestration # Conflicts: # AGENTS.md # CHANGELOG.md # docs/SECURITY.md # lib/ak.py # tests/run.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this brings
Three additions, developed on three branches and merged here (they conflict only in shared text files: the changelog, the docs index, the command list). Interface stays 1; every change to an existing surface is additive.
1.
ak usagekeeps showing an account it cannot read nowA row that is
expired,no_scope,no_loginorerrorused to be a status and a hint. When the usage cache still holds an earlier reading of that account, at most seven days old, the table now lists its windows under the status line, dated (last read 3h 0m ago), and--jsoncarries it as the additivelast_knownblock. A window whose reset time has passed is marked reset and carries no number. The row is still a problem row, andak pickandak capacitynever read a reading that old.This makes the account legible. It does not renew a login.
2.
ak ps [--json]— the sessions that are runningEvery interactive
ak <kind> [@profile]leaves one record (best effort; a failed write never changes a launch).ak pslists the sessions still running — kind, profile, posture, Herdr pane — joined to the account's capacity from the usage cache alone, with the reading's age. New schemasessions-v1. A record is live only while its process id is alive with the recorded start time, and belongs to the host that wrote it.3. Native orchestration
ak run <kind> --pickruns on the accountak picknames. With--failover Nit moves to another account, and with--fallback KIND,KINDto another kind, on two triggers only: the attempt never started, or it failed or timed out and a fresh reading shows the account spent. After an attempt that started, it moves only when--cwdis a git work tree left exactly as it was; it never cleans a workspace.--ownerleases the account per attempt;--exclude @profileleaves one out. The envelope gainsattemptsandfailoverwith--pickonly.ak fanout run --tasks FILEruns each task as its own lane: a new git worktree on a new branch, oneak run --pickper lane, in parallel, onefanout-v1result. A lane survives a spent account by starting over from a clean worktree. It never merges, pushes or rebases.ak fanout clean <run-id> [--discard]removes a run's worktrees, branches and record. It keeps uncommitted work and unmerged commits unless--discard, and removes a worktree only when it is provably that run's.agentkit-orchestrateskill anddocs/orchestration.mdteach these commands in place of the loop run by hand.How it was checked
sessions,fanout; new bash-free checkstests/py/sessions_checks.py,tests/py/fanout_checks.py; therun,usageandorchestrate-skillscopes extended.What was not verified
fanoutcheck asserts an upper bound on elapsed time (three 3-second lanes under 8 seconds) and could fail on a very slow runner.Not in this PR
The version bump, the dated changelog section, the tag and the release. A command that renews an expired login through the account's own CLI.
🤖 Generated with Claude Code