aitododocs Coming soonAutonomous delivery

Parallel work

Markdown

What can run in parallel, and how two agents work in two worktrees on one store.

Guideabout 7 min4 commands
On this page

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
  • serial paths run either way through any ticket. review compares each ticket's own location: repo refs (effective repoAnchor.repo) on whole segments (src/api contains src/api/app.py, not src/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 new makes a branch and a worktree and claims the ticket there; tkt worktree done SG-128 --remove releases it and removes the clean worktree.
  • tkt ticket claims shows who works on what, on which branch and worktree; tkt ticket release --stale clears the stale ones (STALE_CLAIM).
Details11 items
  • Counter: keyed by store path; .aitodo/counters.json follows. Outside git or after tkt config set sharedCounter false each worktree counts alone. tkt doctor prints counter: 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 is in_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 get and tkt 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 a live note; its --json live field 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: false or a server store (REST view=brief: always null). tkt board and tkt 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 says N cards live in other worktrees. --watch also redraws when a claim is made or released or a claimed ticket file there changes (claims.json and 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 (base HEAD) different from it ("commit the ticket first"): ERR_NOT_STARTABLE; git refuses (branch or dir exists, bad --base): ERR_GIT_FAILED. worktree add/remove stop after 120 s; half-done work is rolled back.

  • Setup: worktreeSetup (e.g. scripts/worktree.sh + args, no shell) runs in the new worktree with AITODO_TICKET, AITODO_WORKTREE, AITODO_WORKSPACE_DIR, after Setup: <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 like tkt ticket release, in the ticket's worktree (todo there); done/canceled: only --remove. --remove deletes a clean, non-main worktree (commit the claim's status edit too), else ERR_WORKTREE_REFUSED listing changes. The branch stays.

  • tkt worktree new SG-128 slug --base REV --assignee X --no-setup --json: branch off --base (else HEAD) named worktreeBranch (else feat/{id}-{slug}), worktree at worktreeDir (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 --base at another commit than HEAD judges 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} or null next to the committed status; tkt milestone get --json and tkt board --json add liveStatus (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#

Generated from the registry: src/aitodo/api/selfdoc_entries/plan.py, src/aitodo/api/selfdoc_entries/team.py · plan.parallel, team.worktreesv0.1.298