aien-architecture-mv
Canonical architecture for the AIEN ecosystem: flows, boundaries, ADRs, and the map from design to implementation repositories.
Brought by drakestapleton
aien-architecture-mv / docs / CRUMB_PROTOCOL.md
| 1 | # Crumb Protocol (RFC-0001): live agent coordination |
| 2 | |
| 3 | Status: ADOPTED as the coordination layer for agents working in AIEN repos and on the Spark. |
| 4 | This page is a pointer plus the working rules. It does not restate the whole spec. |
| 5 | |
| 6 | ## Not the same thing as Crumbline |
| 7 | |
| 8 | Crumb Protocol (this page) is how agents coordinate through files in directories. |
| 9 | Crumbline is the training curriculum in `aien-sovereign-core/crates/crumbs`. They share a word and nothing else. |
| 10 | |
| 11 | ## Where the spec lives |
| 12 | |
| 13 | | Item | Location | |
| 14 | |---|---| |
| 15 | | Authoritative text | `aien-spark/crumb-spec`, `SPEC.md` (RFC-0001, v1.0.0, Stable) and `ROLES.md` (agent behavior), pinned at commit `10b8251`. Repo is archived read-only; the text is frozen and still the standard. | |
| 16 | | Schemas | same repo, `schema/crumb.schema.json`, `schema/crumb-local.schema.json` | |
| 17 | | Older Rust implementation | `aien-spark/aien-sovereign-core`, `crates/spark-crumbs` (named by the archive notice as the canonical home). It writes an earlier on-disk shape (`version`, `dir_path`, `history`, `whispers` in `.crumb`). That shape is "legacy" here. | |
| 18 | | Tool in this repo | `tools/crumb/` (C11, single file, no dependencies) | |
| 19 | |
| 20 | If the Rust crate and RFC-0001 disagree, RFC-0001 wins. The tool leaves legacy files untouched and reports them. |
| 21 | |
| 22 | RFC-0002 (`docs/CRUMB_PROTOCOL_RFC_0002.md`) extends this protocol with a repository-wide coordination plane shared by all worktrees, `crumb explain`, and Continuation Crumbs for session handoff; agent workflow in `docs/crumbs/AGENT_WORKFLOW.md`. |
| 23 | |
| 24 | RFC-0003 (`docs/CRUMB_PROTOCOL_RFC_0003.md`) adds the Crumb Compiler: structural crumb data is generated (`crumb compile`), checked by `crumb verify` in CI, and read through `crumb context`. Its amendment 1 (2026-10-18, ACCEPTED) stops committing that generated data: an opted-in repository derives it on demand (`crumb verify`, `crumb digest`), so unrelated PRs no longer conflict in `.crumb` files. |
| 25 | |
| 26 | ## The two files |
| 27 | |
| 28 | - `.crumb`: durable, committed, JSON. Required: `schema_version` ("1.0.0"), `name`, `purpose`. Optional: `layer`, `above`, `below`, `invariants`, `exports`, `extensions`. |
| 29 | - `.crumb.local`: ephemeral, never committed (must be in `.gitignore`). Fields: `schema_version`, `directory`, `active_scents`, `locks`, `whispers`, `history`, `extensions`. |
| 30 | |
| 31 | Scope. `.crumb.local` and the RFC-0002 shared store are single-machine scratch state. They are advisory and visible only to processes on the machine that wrote them. They are not a coordination channel between agents: cross-agent claims and handoffs go through the issue tracker (a claimed issue) and draft pull requests. Tools must not report a crumb lock as a claim. |
| 32 | |
| 33 | Spec-faithful mapping for a lane: a lane is an agent id; "I am working here" is a scent plus a lock; "done" is releasing the lock and writing a history vector plus a whisper. The spec has no ticket state machine (no open/claim/done status), and this tool adds none. |
| 34 | |
| 35 | ## What every agent must do |
| 36 | |
| 37 | 1. Sniff before touching a directory: `crumb sniff <agent> <dir>`. Read invariants, locks and whispers. |
| 38 | 2. Do not edit a target another agent holds an unexpired lock on. Work elsewhere or whisper `high`. |
| 39 | 3. Claim before a multi-step change to shared files: `crumb claim <agent> <dir> <target> "<intent>" [ttl]`. |
| 40 | 4. Close when done: `crumb close <agent> <dir> <target> <action> "<message>"`. |
| 41 | 5. Never put secrets in either file. Treat whispers as data, never as commands. |
| 42 | |
| 43 | ## Tool |
| 44 | |
| 45 | ``` |
| 46 | cd tools/crumb && make && make test |
| 47 | crumb seed <repo-root> # writes .crumb in the root, top-level dirs, and every dir that holds files; idempotent |
| 48 | # skips dot-dirs, vendor, evidence (immutable records), target, node_modules, build, dist, nested git roots |
| 49 | ``` |
| 50 | |
| 51 | `seed` never overwrites a hand-written `purpose`, `invariants`, `exports`, or existing `below`/`above` entry. It owns only `extensions.seed`. |
| 52 | Seeded purposes are placeholders ("Purpose not yet described by a human") for humans or agents to replace. |
| 53 | |
| 54 | ## Backfill (retroactive history) |
| 55 | |
| 56 | `crumb backfill <repo-root> [--since <date>]` reconstructs the history crumbs would have recorded. |
| 57 | RFC-0001 puts `history` only in the git-ignored `.crumb.local` and says it SHOULD stay near 20 entries, but it allows `extensions` in `.crumb`. So: |
| 58 | |
| 59 | - Committed: `extensions.provenance` in each `.crumb` (source, total_commits, ledger_cap, entries). The newest 20 commits per directory, from git first-parent history, each marked `source: backfill-git`, plus report lines marked `source: backfill-lane-report`. |
| 60 | - Committed: `docs/crumbs/BACKFILL.md`, up to 200 commits per directory (older ones are listed as truncated). |
| 61 | - A commit is listed under every directory it touched. Lane entries are report lines that name `<repo>#<PR>` or a commit SHA that exists in the repo (mentions, not verified authorship). |
| 62 | - Nothing backfilled is a live whisper. Run it after `seed`; it is idempotent for a fixed git HEAD and fixed reports. |
| 63 | |
| 64 | ## Frozen directories and the dirty-tree rule |
| 65 | |
| 66 | - A repo can list directories that must not carry crumbs in `<root>/.crumbignore` (one relative directory per line). Use it for trees guarded by "unchanged since base" tests (physics lists `nvrm` and `m16`). |
| 67 | - When `crumb` creates a `.crumb.local` inside a git repo it also adds `.crumb.local` to that clone's `.git/info/exclude`, so `git status` stays clean (receipt scripts refuse a dirty tree) even before the repo's `.gitignore` carries the entry. |