Parallel work
What can run in parallel, and how two agents work in two worktrees on one store.
What can run in parallel#
tkt plan parallel SG-127 SG-159 [--json] judges each pair: serial (a blockedBy path between them, transitive), review (a shared repo path or a shared risky pattern: parallelRiskPaths), unknown (one of them has no own repo refs: no_repo_refs, the overlap cannot be judged), else parallel. The worst pair wins (serial > review > unknown > parallel). Read-only, no AI; exit 0 all parallel, 1 a review, 2 a serial, 3 unknown, 4 could not run.
Details4 items
-
serialpaths run either way through any ticket.reviewcompares each ticket's ownlocation: reporefs (effectiverepoAnchor.repo) on whole segments (src/apicontainssrc/api/app.py, notsrc/apix, not two files of one folder); no file read, no Stage 2. Patterns:**/migrations/**,**/schema*(tkt config set parallelRiskPaths '["**/db/**"]'); a shared path matching one is "higher risk". -
Info only: a shared epic (
same_parent), milestone (same_milestone), group (shared_group) unless it is either ticket's primary group (groups[0]). -
A ticket without repo refs: its pairs are
unknown, plus a note; judge the overlap yourself (shared groups, bodies, migrations). -
tkt plan parallel --json:{pairs: [{a, b, verdict, reasons: [{kind, detail}]}], notes: [{ticket, message}]},verdict:serial|review|unknown|parallel,kind:blocked_by|shared_path|risky_pattern|no_repo_refs|same_parent|same_milestone|shared_group.
Parallel worktrees#
In a git repo every worktree shares one id counter ($(git-common-dir)/aitodo/counters.json) and one claim record ($(git-common-dir)/aitodo/claims.json): parallel worktrees never mint the same id or start the same ticket (one ticket, one worktree).
tkt worktree newmakes a branch and a worktree and claims the ticket there;tkt worktree done SG-128 --removereleases it and removes the clean worktree.tkt ticket claimsshows who works on what, on which branch and worktree;tkt ticket release --staleclears the stale ones (STALE_CLAIM).
Details11 items
-
Counter: keyed by store path;
.aitodo/counters.jsonfollows. Outside git or aftertkt config set sharedCounter falseeach worktree counts alone.tkt doctorprintscounter: store/counter: git: <path>. -
Claims: every worktree sees the record; rules: Claiming and giving back. A claim is stale when its worktree is not in
git worktree list. Renumber and move keep it; outside git a claim isin_progress+ assignee. -
Live state: a ticket claimed in another worktree shows its state there (status, AC, last note) next to the committed status in
tkt ticket get --brief,tkt tree,tkt milestone getandtkt ticket list:in_review (worktree feat/x).tkt ticket get(the Context Bundle) prints it in the header,status: todo (live: in_review in worktree feat/x, 1/2 AC)and alive note; its--jsonlivefield is--brief's. It is read from the ticket file in the claim's worktree store, working copy (an uncommitted edit counts). Nothing is written. None for your own claim, a stale claim, equal state (e.g. after the merge), an unreadable file, outside git,sharedCounter: falseor a server store (RESTview=brief: alwaysnull).tkt boardandtkt graph(every format) mark it too: a card stays in its committed column (the columns agree with the progress; unmerged work is not done) and the board saysN cards live in other worktrees.--watchalso redraws when a claim is made or released or a claimed ticket file there changes (claims.jsonand those files' mtime). Status filters use the committed status;--live(tkt ticket list,tkt tree,tkt graph) the live one. -
Refused, nothing created: already claimed (
ERR_ALREADY_CLAIMED, checked first); not startable, or the ticket file missing at the base or (baseHEAD) different from it ("commit the ticket first"):ERR_NOT_STARTABLE; git refuses (branch or dir exists, bad--base):ERR_GIT_FAILED.worktree add/removestop after 120 s; half-done work is rolled back. -
Setup:
worktreeSetup(e.g.scripts/worktree.sh+ args, no shell) runs in the new worktree withAITODO_TICKET,AITODO_WORKTREE,AITODO_WORKSPACE_DIR, afterSetup: <command>; a failure is a warning (exit 0, worktree kept). The hook's output goes to stderr. -
tkt worktree done SG-128 --remove --assignee X --force --json: releases liketkt ticket release, in the ticket's worktree (todothere);done/canceled: only--remove.--removedeletes a clean, non-main worktree (commit the claim's status edit too), elseERR_WORKTREE_REFUSEDlisting changes. The branch stays. -
tkt worktree new SG-128 slug --base REV --assignee X --no-setup --json: branch off--base(elseHEAD) namedworktreeBranch(elsefeat/{id}-{slug}), worktree atworktreeDir(default../{repo}-{id}, beside the main worktree;{repo}its dir name,{id}lower case,{slug}from the title, ASCII,--joined, at most 40 characters); only these three; quote a template starting with{(YAML). It claims in the new store. A--baseat another commit thanHEADjudges the ticket as it is there (status and blockers in the new worktree); this tree's copy, even an uncommitted edit, does not count, and the refusal names the ref ("on main"). -
Live state in JSON:
live: {status, acDone, acTotal, lastNote, branch, worktree}ornullnext to the committedstatus;tkt milestone get --jsonandtkt board --jsonaddliveStatus(count by status). No shared git-ignored overlay (rejected: every write would have to keep it in step, stale entries need a cleanup). -
tkt ticket claims --json:{claims: [{id, ulid, assignee, branch, worktree, claimedAt, ageSeconds, here, stale}]}. -
tkt worktree new --json:{path, branch, ticket, base, store, setup: {command, exitCode, error} | null}. -
tkt worktree done --json:{path, branch, ticket, released, removed}.
Commands on this page#
tkt plan parallelCan these tickets run in parallel worktrees?→
tkt worktree newBranch (worktreeBranch, default feat/{id}-{slug}) + worktree (worktreeDir, default ../{repo}-{id}) + the claim there, in one step; then the worktreeSetup script→
tkt worktree doneGive the ticket's claim back (from any worktree); --remove also removes its worktree once clean, else refuses (ERR_WORKTREE_REFUSED) and says why→
tkt ticket claimsList the claims: assignee, branch, worktree and age; stale when the worktree is gone→