tasks
Specification

Directory layout

How a tree is discovered, what it contains, and how writes, locking, and working copies are handled.

Discovery

An implementation MUST locate the tree by walking from a starting directory toward the filesystem root, testing each ancestor for a directory named .tasks. The first match is the tree; the search MUST stop there. An implementation MUST NOT merge a discovered tree with any tree found further up. If no ancestor contains .tasks/, the operation MUST fail as not found. An implementation SHOULD let the caller name the starting directory (-C <dir>), and take it literally. Run without one inside a linked git worktree — a checkout whose .git is a file pointing into the repository's .git/worktrees/ — discovery SHOULD start at the same place in the main checkout (or the nearest place that exists there), so the tree of the main checkout is found and the worktree's own copy, a snapshot committed on its branch, is passed over; the worktree's own tree is taken only when the main checkout has none. Code lives in worktrees, the tasks about it do not.

Contents

.tasks/
  config.yml            REQUIRED, carries `version: 2`
  README.md             OPTIONAL human-facing description
  .gitignore            OPTIONAL, SHOULD ignore .locks/
  index.md              OPTIONAL derived overview
  <segment>/            a group or a task, at any depth
    task.md             present ⇒ this directory is a task
    state.md            OPTIONAL workspace files, see Workspace files
    design.md
    plan.md
    log.md
    <anything else>     workspace content, ignored by the scanner
    <segment>/          a child task, or a group, or workspace content
  .archive/             OPTIONAL archived tasks, mirroring live paths
  .locks/               OPTIONAL transient lock and session files

Segments, groups and tasks

A directory name that participates in the tree — a group or a task — MUST match:

^[a-z0-9][a-z0-9-]*$

When enumerating, an implementation MUST descend into every directory whose name matches that pattern, except .archive/, .locks/ and any other name beginning with a dot, and MUST NOT descend into directories whose name does not match.

  • A directory that contains a file named task.md is a task. task.md is a reserved filename anywhere under .tasks/; a file with that name MUST be parsed as a task manifest, and one that cannot be parsed MUST be reported as malformed rather than skipped.
  • A matching directory without task.md is a group. Groups carry no manifest and no status; they MAY appear at any depth, including inside a task. A group that contains no tasks is ordinary workspace content and needs no special treatment.
  • The parent of a task is the nearest ancestor directory that is a task; a task with no task ancestor has the root as its parent. Intermediate groups do not break parenthood.
  • Every other file in a task directory is workspace content. An implementation MUST NOT parse it as a task and MUST NOT rewrite it, except for the files the workspace vocabulary assigns to the tooling.

An implementation MUST create a group directory on demand when placing a task under it, and SHOULD remove a group directory it empties.

Creating a task at the path of an existing group turns the group into a task: the tasks beneath it become its children and its finish gate applies to them from then on. An implementation MUST allow this (the new task is open, so no invariant can break — except a task created in BACKLOG over a group that holds scheduled open tasks, which would break the BACKLOG invariant and MUST be refused) and MUST refuse to create a task at the path of an existing task as a conflict.

Non-normative

Reserving one filename is what makes the rule uniform: any directory can be a group, any task can hold sub-groups of children, and a screenshots/ folder inside a task is harmless because it holds no task.md. There is no need for a separate "phase" concept: a v1 phase is just a top-level group.

.archive/

An archived task lives at .tasks/.archive/<its former path>/, with its whole directory — manifest, workspace files, and any archived descendants — moved as a subtree. When the destination already exists because a descendant was archived earlier, the subtree is merged into it; a task.md present on both sides is the duplicate error of Writes, never a silent choice. A directory under .archive/ without a task.md is not an archived task; it only carries a former path.

An implementation:

  • MUST exclude archived tasks from every default query.
  • MUST treat an archived task as not satisfying any gate.
  • MAY let a query reach archived tasks on request, saying so: a show of one by its former path, the log of one, a history query that includes the archive.
  • MUST treat an archived task's path as reserved: creating or moving a live task to a path at which .archive/ holds a task.md MUST fail until that entry is purged. A directory under .archive/ without task.md reserves nothing.
  • MUST refuse to archive a task that is not resolved, or that has live open descendants, or that open tasks reference through depends_on or finishes_after — in the local tree and in the trees reachable through projects: — naming the dependents, unless explicitly overridden.
  • MAY archive in one command every resolved subtree whose root was resolved before a given time, applying the refusals above to each root and naming the roots it skipped.
  • MUST offer a way to purge an archive entry: remove it permanently and release its path. A purge MUST name the live tasks that still reference the entry; it is the explicit decision that a task recreated at that path may be reached by those references.
  • MAY offer a delete that removes a live task without archiving it, only when the task has no log entry other than its creation, no state.md, nothing beneath it (no child task and no segment-named directory that could hold one), no live task references it, and the caller is authorized as for a transition of it. Everything else is archived.

.locks/

.tasks/.locks/ holds the tree lock and the session registry (see Concurrency and Sessions and liveness). It MUST NOT be committed to version control; an implementation that scaffolds a tree SHOULD write a .tasks/.gitignore containing .locks/.

index.md

index.md at the root of .tasks/ is a derived view of the tree; the name is reserved there and nowhere else. An implementation MUST NOT treat it as a source of truth and MUST NOT read it to answer any query. A Writer SHOULD regenerate it after every mutation when the file exists, so the committed rendering follows the tree without a separate step. Its content is not specified; an implementation that detects it is out of date MUST report that as a warning, never an error.

Writes

Every write of a manifest, a tool-owned workspace file, config.yml or index.md MUST be atomic: write a temporary file in the same directory, then rename it into place; log.md, whose existing bytes are never rewritten, is appended in place instead. Serialization MUST be canonical (see Serialization).

Relocating a task or a group MUST be performed as a single atomic directory rename when source and destination are on the same filesystem. Across filesystems an implementation MAY copy the subtree and then remove the source; interrupted, this leaves the task present twice, which validation MUST report as a duplicate rather than silently choosing one.

Concurrency

Every mutation of a tree MUST be performed under one tree-wide exclusive lock, .tasks/.locks/tree.lock, acquired with an operation that atomically fails if the file exists (O_EXCL or equivalent). The implementation MUST re-read every task whose state the mutation depends on inside the lock before deciding. A lock older than a documented staleness threshold MUST be reclaimable; the reference threshold is 10 seconds. A holder SHOULD keep a lock it holds younger than that threshold while it works, so a long write is not reclaimed under it; the reference implementation touches its lock every 2.5 seconds.

Each tree has its own lock. A command that writes several trees MUST write them one at a time, each under its own lock; there are no cross-tree transactions, and every intermediate state is one that gates treat as blocking and validation reports.

Non-normative

v1 locked per task. v2's gates read other tasks (children, dependencies) while deciding a transition, so per-task locks would either need ordered multi-lock acquisition or accept races between a parent closing and a child reopening. Writes to a local tracker are rare and short; one lock is simpler and correct. The lock serializes processes on one filesystem only — two clones of a repository still discover conflicting claims at merge.

Working copies and branches

The tree is versioned with the code, so a task's state is the state in one checkout on one branch: a claim, a transition or a state.md written in one working copy is invisible to every other until merged, and .locks/ is private to each working copy, so sessions in two checkouts never see each other's heartbeats. This specification assumes that task state is mutated in a single working copy on the project's integration branch. Changing .tasks/ on a feature branch is a merge hazard: log.md merges mechanically (see log.md), the frontmatter of task.md does not — which status survives is a person's decision — and validate MUST be run after any merge that touched the tree.

Non-normative

Code may live on branches and in worktrees; the tasks about it should not. A session working in a secondary worktree reaches the main checkout's tree by discovery, records the branch under Open in state.md, and the transitions land on the integration branch as the work does. A tree carried along in a pull request still works, but its reviewer sees every state.md rewrite and log entry in the diff.

Non-normative — several machines

Claims, heartbeats and the tree lock are atomic within one filesystem only. Agents on several machines that share a repository through git share no .locks/ and no tree state until they push and pull; two clones can claim the same task and discover it at merge. v2 does not arbitrate between machines. The direction that keeps the filesystem authoritative is to make the integration branch the arbiter: a claim is a commit pushed to it, a rejected push is the conflict, and liveness is the age of the last pushed heartbeat. That is a possible later revision, not part of this one; until then a swarm runs on one machine against one checkout per repository, each agent in its own worktree, whose commands reach the main checkout's trees by discovery.

On this page