docs/ARCHITECTURE.md

volante-kit - architecture

Kit version: 0.8.0. Queue format: 3 (docs/FORMAT.md).

1. Goal

One copy of the task-queue skills (spec-prep, spec-batch, spec-run) for every repo and every machine. An improvement found while working in one repo goes into the kit and reaches the others through sync. The kit depends on no orchestrator: it works in a plain Claude Code session.

2. Principles

  1. One source. Skill text lives only in core/. Repos hold copies generated by volante-kit sync, with their hashes in .volante-kit/kit.lock. volante-kit check detects a hand edit of a copy, and sync refuses to overwrite one without --adopt - a change is never lost silently, it has to move into the kit.
  2. A project does not override the core. It has two narrow channels and nothing more:
    • config (.volante-kit/config.json): a closed list of keys from config.schema.json; an unknown key is an error. Config sets data (paths, commands, modes), not steps;
    • addendum (.volante-kit/addendum.md): only the sections Hard rules, Verification, Acceptance, Review, at most 60 lines each. The text is APPENDED at a fixed place in the core; it never replaces a step.

    There are no hooks on steps and no custom templates. When a project needs different behavior, the core changes (a new key or a new rule) and every repo gets it.

  3. Logic-free templates. Conditions in templates are flags computed in lib/context.mjs; a template never compares values. Every new variation goes through the schema, the context and a test.
  4. The format is a contract (docs/FORMAT.md): the skills, the validator and any importer read the same format. A format change is a new version plus a migration (volante-kit migrate).
  5. Determinism in code, not in prose. Whatever a script can check or decide (queue format, the next task, unverified work, running the gates, finding the culprit of a red gate, freshness of the copies) is done by a script (queue.mjs, gates.mjs, check); the skill only says to run it.
  6. State is data, open work is a task. Where a queue stands is one YAML file the tools validate and rewrite; anything open - work, a decision, something to check by hand, a red gate - is an entry in it, never prose in another file.

3. Layout

core/                       the core: *.tmpl templates and files copied 1:1
  skills/spec-prep/         SKILL.md.tmpl, templates/*.tmpl, queue.mjs (state.yaml: lint, next, pending, set,
                            show, changes),
                            gates.mjs (the gate runner) - both copied 1:1, no dependencies
  skills/spec-batch/        SKILL.md.tmpl, references/review.md.tmpl
  skills/spec-run/          SKILL.md.tmpl, spec-run-loop.sh.tmpl
  agents/spec-run.md.tmpl   subagent with a fixed tool list
config.schema.json          the closed list of project settings
lib/                        template (engine), config (validation + addendum), context (flags, gates.json),
                            generate (sync, lock), init (gate detection), migrate, legacy (format 1-2 tables)
bin/volante-kit.mjs         CLI: init, diff, sync, check, lint, migrate, render
examples/                   example configs and addenda, used by the tests
ui/                         the dashboard: a separate package (React, Vite, TypeScript), never generated into a
                            repo; reads queues through core/skills/spec-prep/queue.mjs (ui/README.md)
test/                       node --test, no dependencies

A project repo after sync:

.volante-kit/config.json    config (edited by a human, committed)
.volante-kit/addendum.md    addendum (edited by a human, committed, optional)
.volante-kit/kit.lock       kit version and hashes of the copies (generated, committed)
<paths.skills>/spec-*/      copies (generated, committed, never edited), incl. spec-prep/gates.json
<paths.agents>/spec-run.md  copy (generated, committed)

4. How the skills work together

 spec-prep            spec-batch (main session)                spec-run (fresh context per task)
 ---------            -------------------------                ---------------------------------
 doc/plan  -->  NN-*.md + state.yaml -->  queue.mjs next  -->  queue.mjs show: its task in one call
                                         dispatch subagent     code + tests, no gates (deferred)
                                         accept the result <-- record state, ONE commit
                                         (scope, criteria,     4-line report
                                          commits, lint),
                                         record the hash
                                         ... until no task is ready ...
                                         gates.mjs --record --> green: verified
                                                            --> red: fix tasks after the culprits,
                                                                back to the loop (max 2 rounds)
  • state.yaml is the only queue and the only memory between runs; a run reads only its task’s definition, which queue.mjs show prints in one call (the entry, its definition, the notes of its dependencies, sections 1-4 of the spec). The spec-run subagent carries the skill in its own instructions, so a dispatched run reads no SKILL.md.
  • A dispatched run makes ONE commit. The orchestrator (spec-batch, the loop) records its hash in state.yaml afterwards; that change rides along with the next task commit or the gate commit, or is committed once at the end of the run (queue.mjs changes tells such a hash-only change from any other). A run used to commit the hash separately: two commits and two or three agent turns per task (measured: 53 of 79 commits in one repo).
  • Work found along the way becomes derived tasks (T05-01a, defined inline), decisions and actions become user tasks (decision, action, session), things the user must look at become check tasks, and a red gate becomes a fix task.
  • spec-batch never writes task code; it keeps its context for acceptance of the whole queue. Without spec-batch, the same spec-run works by hand (/spec-run <queue>) or headless (spec-run-loop.sh, one claude -p per task).

5. Verification: the factory model

A coding agent that runs typecheck, lint and the test suite after every task pays for the slowest part of the loop N times; in a measured run of this kit that was 43% of the loop time. The kit treats a spec-batch run (or the headless loop) as a production line, the way a merge queue treats a batch of pull requests:

  1. Produce. Each task writes its code and its tests, commits, and runs no gate (verify.mode: run). The cheap, deterministic structure check - queue.mjs lint, milliseconds - still runs after every task, because a broken queue would hand out the wrong next task.
  2. Verify once. When the run has no ready task left (or stops for a limit), gates.mjs runs every gate once on the whole tree. <base> in a command scopes change-aware tools (nx affected, turbo --filter) to the unverified work, from the last green run.
  3. Attribute. For a red gate the runner finds the culprit the way a merge queue does after a red batch, but without bisecting: it takes the files the failing output names, keeps those changed since the base, and maps each to the task whose recorded commit is the most recent commit that touched it (by hash: ids repeat across queues, hashes do not). Without such a file it blames the last task of the range; with no task commit in the range the gate was already red.
  4. Repair through the queue. Each suspect gets a fix task right after it - the gate, the suspect files, the command that shows the error and a “never weaken the check” rule inline. No gate output goes into the queue: whatever a test printed (a token, a password in a URL, user data) would otherwise be committed with state.yaml, and redacting it is a losing game (below). The loop takes fix tasks like any other task; a fix task, unlike a normal one, runs its own gates (--only) as a tight inner loop. Then the gates run again: at most two repair rounds, and only fix tasks run past the task limit.
  5. Record. verification in state.yaml says green or red at which commit. Any task committed after the last green run is pending (queue.mjs pending), so an interrupted run is verified by the next one - unverified work is never reported as finished.

verify.mode: spec adds a verification point at every spec boundary (a checkpoint for long queues); verify.mode: task keeps the classic per-task verification. verify.final holds heavier gates (pre-PR script, e2e, build) that run once after the gates are green. verify.parallel runs independent gates at the same time. volante-kit init detects the gates of the repo’s stack: Node (scripts, tsc, nx affected --base=<base>), Python (mypy/pyright, ruff, pytest, through uv run/poetry run), Rust (fmt, clippy, test), Go (gofmt, vet, test), a Makefile as the fallback.

What this is based on

  • Merge queues (GitHub merge queue, Mergify, Trunk, Bors): batch many changes, test once, and on a red batch isolate the culprit (bisection, or - cheaper - using which tests failed, as in failure-informed batch testing). The kit uses the cheaper variant because every task is its own commit, recorded in state.yaml.
  • Long-running agent harnesses (Anthropic, “Effective harnesses for long-running agents”, 2025): one task per fresh context, state in a structured file instead of Markdown (agents are less likely to rewrite structured data inappropriately), git history as memory, a task is not passing until it is verified end to end.
  • Software factories (StrongDM, 2026; Osmani, “Software Factories, Light and Dark”, 2026): autonomy is bounded by what can be verified cheaply and reliably, and tests written by the generating agent can be gamed. Hence the hard rule for fix tasks (fix the code, never delete, skip or weaken a test, an assertion, a type or a lint rule) and the acceptance check of it.
  • The counter-argument - check at every transition so errors do not compound (stage-gate loops) - is met in part: the deterministic queue check runs at every step, spec mode adds checkpoints, fix tasks have a tight inner loop, and the attribution keeps a late failure cheap to route.

Sources: Anthropic, Mergify batching, Trunk batching, parallel batch testing (arXiv 2308.13129), StrongDM software factory (Simon Willison), Osmani, stage-gate loops.

Build or use a ready tool

The kit writes its own code only for closed problems it defines itself: the queue format and its YAML subset, choosing the next task, attributing a red gate to a task of the queue. Their scope is finite, fully testable and changes only with the kit. For open problems - ones the outside world keeps changing - it delegates through a gate command instead of reimplementing:

  • secret scanning: gitleaks, TruffleHog or detect-secrets maintain hundreds of rules; three rounds of security review on a home-grown redaction each found a new gap. So the queue never holds gate output, and a repo that wants scanning adds a gate (init proposes gitleaks git --redact --log-opts="<base>..HEAD" when the repo has a gitleaks config) - it then checks the agents’ own commits too,
  • affected detection and caching: nx, turbo, Bazel - through <base>, never a cache of the kit’s own,
  • test reporting: if path-based attribution is ever too coarse, the standard is JUnit XML (pytest, jest, Go, nextest), not a parser per tool.

Why YAML and a strict subset

The state is read by scripts (the loop, the gate runner, a dashboard) and edited by agents. A Markdown table broke on a | in a note and on a wrong cell count, and checks.md was a second, unstructured place for open work. YAML keeps one entry per task with optional fields (an inline scope, gates, things to check) and stays readable in a diff. Full YAML has traps for agents and for other readers (no read as false, 1e5 as a number, a plain value continued on the next line, anchors), so queue.mjs reads a strict subset, in the spirit of StrictYAML: whatever it accepts, any YAML parser reads the same way, and everything else is an error with a line number. queue.mjs set changes simple fields without hand-editing; the canonical layout keeps diffs stable.

6. Distribution and many machines

  • Consumption: the copies are committed in each project repo, so a new machine only needs git pull of the project - nothing to install to use the skills.
  • Producing copies (init, sync, check, migrate) needs the kit: npx volante-kit@X.Y.Z from npm (a bin, no dependencies), npm install -g volante-kit, or a clone plus npm link to change the kit.
  • The dashboard is its own npm package, volante-kit-ui, with one dependency: volante-kit of the same release. It imports only the kit’s exports (volante-kit/queue = core/skills/spec-prep/queue.mjs, volante-kit/config = lib/config.mjs), so moving either file is a change of exports too. Release: the kit first, then ui.
  • Changing the kit: edit core/ -> npm test -> volante-kit diff <repo> on real repos (or diff --config <draft>) -> bump the version and docs/CHANGELOG.md -> npm publish -> in every repo sync and a commit chore(volante-kit): X.Y.Z.
  • An improvement found in a project goes into the kit, never into a copy: either right away, or as a user task (kind: action) “change in volante-kit: …” in the queue. A hand edit of a copy stops check and sync anyway.
  • Guarding: volante-kit check in the project’s pre-commit hook (a hand edit or a config change without sync = error), check --strict from time to time (copies older than the kit = error).

Why generated copies, not a plugin or user-level skills

A Claude Code plugin or ~/.claude/skills would share one static text across repos, so every per-repo difference (queue location, commit rules, verification commands, local vs committed queue) would have to be prose branches the model reads at runtime (“if the queue is committed, …”). Generated copies contain only the branch that applies, with real paths and commands, and they travel with the repo: any clone on any machine, and a reviewer sees exactly what the agent sees. The cost is a sync per repo after a kit change, which check makes visible.

There is deliberately no global (per-user) config: the copies must be reproducible from what is committed in the repo, otherwise check would fail on another machine. Shared defaults live in config.schema.json.

7. Risks and open decisions

  1. A formatter in the project repo (e.g. prettier) reformats the Markdown copies and the lock hashes stop matching. Recommended: put the generated paths into the formatter’s ignore file (copies are never edited anyway). Alternative: sync runs the project’s formatter and hashes the result.
  2. Two sessions on one local queue - git cannot see them; today only spec-batch’s copy of state.yaml catches it.
  3. Pre-commit hooks that run the gates (lefthook, husky running lint or tests on every commit) undo the batching: every task commit pays for them again. --no-verify stays forbidden; the fix is in the repo - keep the hook to fast, staged-file checks and let the gates (or verify.final) hold the full suite.
  4. Attribution is a heuristic. A failure whose output names no changed file (a broken fixture, a global type) goes to the last task of the run; the fix task’s subagent then finds the real cause. A bisecting fallback (git bisect run in a worktree) is possible, but costs one gate run per step.
  5. Flaky gates. A red gate runs once more (verify.retry); green the second time is reported as flaky and gets no fix task. That doubles the time of a really red gate - turn it off for slow suites that are never flaky. A gate flaky beyond one retry still becomes a fix task for the wrong task; the second repair round stops the line, and a gate that is red without a suspect is reported, not “fixed”.
  6. Plugin channel - the same core/ could also ship as a Claude Code plugin (.claude-plugin/) for repos that cannot hold copies (e.g. a public repo with .claude/ ignored). Skills would then be namespaced (/volante-kit:spec-run).
  7. The headless loop and permissions - spec-run-loop.sh runs claude -p --permission-mode acceptEdits, which approves edits only; the project must allow the Bash commands a run needs (git, node, the gates).

docs/ARCHITECTURE.md on GitHub