diff --git a/skills/crumb-protocol/SKILL.md b/skills/crumb-protocol/SKILL.md index 9045456..36d06f8 100644 --- a/skills/crumb-protocol/SKILL.md +++ b/skills/crumb-protocol/SKILL.md @@ -5,7 +5,7 @@ description: Work with the AIEN Crumb Protocol correctly. Use before editing, cr # Crumb Protocol: coordinate through the repository, not the chat log -Crumbs are how agents in AIEN repositories find out what a directory is for, who is already working in it, and what changed under it, without anyone handing over the whole architecture. The doctrine calls this spatial grounding and provenance; the rules below are what is enforced. Do not confuse the Crumb Protocol with Crumbline, the training curriculum in `aien-sovereign-core/crates/crumbs`, which shares a word and nothing else. +Crumbs are how agents in AIEN repositories find out what a directory is for, who is already working in it, and what changed under it, without anyone handing over the whole architecture. The doctrine calls this spatial grounding and provenance. Verify which commands and runtime hooks enforce each rule; prose and advisory notices alone do not enforce exclusion. Do not confuse the Crumb Protocol with Crumbline, the training curriculum in `aien-sovereign-core/crates/crumbs`, which shares a word and nothing else. Sources, read 2026-10-25: the protocol page https://github.com/aien-dev/aien-architecture-mv/blob/main/docs/CRUMB_PROTOCOL.md, the agent workflow https://github.com/aien-dev/aien-architecture-mv/blob/main/docs/crumbs/AGENT_WORKFLOW.md, and the tool itself https://github.com/aien-dev/aien-architecture-mv/blob/909f8094b644c490a0ed49503ef5f294787886a7/tools/crumb/crumb.c, whose usage and exit codes are the truth where documents disagree. The frozen normative text is RFC-0001 in https://github.com/aien-dev/crumb-spec-mv (`SPEC.md`, `ROLES.md`, `schema/crumb.schema.json`) at commit `10b8251`; that repository was renamed from `aien-spark/crumb-spec` and is archived read-only, so old links still name the previous owner. @@ -22,7 +22,13 @@ Two writers, one file. Humans and agents own the semantic kernel: `purpose`, `la A repository's root crumb names where the repository hangs in the org graph under `extensions.map` (PENDING with `synapse-map`, 2026-10-27): `{"parent": "owner/repo@" or null, "parent_status": "CONFIRMED"}`, next to the ordinary top-level `purpose` and `layer`. The parent cannot be a top-level key because of `additionalProperties: false`. `synapse-map import` treats a parent without this crumb entry as INFERRED. `crumb claim` locks directories inside one checkout's shared store; leases that must be visible across repositories, sessions and outside targets (PRs, branches, email recipients) go through `synapse-claims`. -Inside a git repository, live coordination no longer lives in `.crumb.local`: new writes go to the shared store under `/crumb/v1/{dirs,agents,continuations,ledger}`. The old file is a read path, merged in with provenance when present. So do not write `.crumb.local` by hand, and never delete or edit the store to clear a state you do not like; the tool keeps it transactionally consistent for a reason. +For the C `crumb` tool, repository operations use `CRUMB_COORD_ROOT`, then `git config crumb.coordinationRoot`, then `/crumb/v1`. Linked worktrees share the default store; independent clones and other machines do not. Confirm the resolved store and expected STORE_ID for each worker before claiming shared coordination. Use a registered identity and strict checking supported by the deployed tool. An identical copied marker does not prove two paths reach the same live store. + +Keep stores separated by repository unless the chosen interface explicitly namespaces repository identities. The C tool keys paths relative to a repository, so pointing unrelated repositories at one unnamespaced root can create false conflicts. Remote workers must reach the same authority through a verified supported transport, not independent synchronized copies. + +The older Rust CLI and spark-crumbs still write `.crumb.local` as directory-local telemetry. They are a different implementation from the transactional C store. Treat their history and whispers as advisory; they establish neither an exclusive claim nor delivery into another model session. Never delete a store to silence a conflict. + +Source audit, 2026-11-06: C tool at aien-architecture-mv `12ad0141b41ec67ef5aa51cb4e1815894c1083bb`; CLI and spark-crumbs at aien-sovereign-core-mv `dffdbd195edcbe1ec3bd2fa255355b15c530f31e`. Track runtime integration in [core #924](https://github.com/aien-dev/aien-sovereign-core-mv/issues/924) and existing [session delivery #587](https://github.com/aien-dev/aien-sovereign-core-mv/issues/587). Installed versions and cross-machine behavior remain to be measured. Legacy warning: the older Rust implementation wrote `version`, `dir_path`, `history` and `whispers` into `.crumb`. Those files still exist in some repositories. The tool leaves them untouched and reports them as legacy. Do not copy that shape into a new crumb. @@ -37,7 +43,7 @@ crumb list path/to/dir Read the nearest crumb's `purpose` and `invariants`, and the ancestors it points at. They are the directory's contract, not decoration. Follow the references that matter (`git show `, the receipt, the related `.crumb`) instead of reading everything, and do not carry assumptions from an earlier session into a new one. -`` is one stable session id you pick once, for example `claude-l6b-7f32`. Never a process id, which changes; the tool falls back to `CRUMB_SESSION` or `agent@host` if you omit it. +`` is one stable session id you pick once, for example `claude-l6b-7f32`. Never a process id, which changes. The positional agent is required; the tool records the session that holds the lease separately, from `CRUMB_SESSION`, else `@`. In a repository gated by the session bridge (section 12) you do not pick it: use the identity the bridge prints. ## 3. While you work @@ -49,7 +55,7 @@ crumb close "" # release, history ``` - Claim before a multi-step change to shared files, and for any path another agent could pick up. Defaults are a 3600 s scent and an 1800 s lock; state a longer ttl when the work needs it. -- Targets are repository relative, so a claim from any worktree protects that path in all of them. +- Targets are repository relative. Claims contend only when workers use the same authoritative store and compatible key interpretation. Verify contention from two independent clones as well as two linked worktrees. The lock is advisory: the actual writing tool must check ownership and lease validity before its effect. - Exit 2 on `claim` means another agent holds it, and the tool prints the holder, worktree and intent. Stop, work elsewhere, or whisper at `high` priority to coordinate. Do not treat it as a tool bug and do not work anyway. The same code is returned by `crumb create` on a directory that already has a crumb, so read the message. - Whisper the seam you found, the trap you hit, the state you left. Not a status report and not the conversation. - Close after the branch is pushed, naming what landed. @@ -76,7 +82,7 @@ crumb migrate [root] # strip committed generated data and mark the root on- crumb validate [path] # RFC-0001 required-field check; exit 1 if any file is invalid ``` -What makes a crumb stale: verify rebuilds every crumb from the tracked blobs in the working tree and compares content digests, ignoring stamps, bottom up. A crumb is current when the tree and the last commits beneath it match what compile would write now. In practice: finish the content change, compile, then commit the crumbs in the same commit as the work. +First read the root's `extensions.generated_policy`. In legacy mode, verify compares generated content digests and compile refreshes committed generated data. In `on-demand` mode, committed `extensions.generated` is stale; compile strips it and digest derives it when requested. Do not regenerate and commit roll-up data in an on-demand repository. Core main at `dffdbd195edcbe1ec3bd2fa255355b15c530f31e` already selects on-demand mode. Preserve handwritten purpose, exports and invariants when reconciling old branches. Measured 2026-10-25 in a scratch git repository with the pinned tool: `compile` then `commit` then `verify` gave `OK`; adding one file afterwards gave `STALE` for both crumbs and `verify` exit 1 with `run: crumb compile`; recompiling and committing restored `OK`, and a further compile rewrote nothing. In a repository that has been migrated to on-demand generated data, a committed `extensions.generated` block is itself stale by design and compile strips it. @@ -98,9 +104,9 @@ tests/gates/run.sh crumb-verify # needs the ../aien-architecture sibling; wi That step archives the aien-architecture commit named in `crumb.lock`, builds `tools/crumb/crumb` from it, and runs `crumb verify .`. The readiness path is the same judgement: `aien-local-ci verify ` prints the pinned tool and a CURRENT or STALE status, and a repository is READY only when its crumbs are CURRENT. That gate step runs inside the untrusted candidate check; the trusted readiness path does not take its checker from the candidate (below). -Failure means the committed crumb text lost its fixed point with the tree at that commit: source changed after the last compile, someone hand-edited generated data, or the layout moved. It is never "the gate is noisy". +Classify the actual error before repair: missing repository/tool/dependency, invalid JSON, legacy stale generated data, or generated data forbidden by on-demand mode. A failed wrapper is not proof of stale content. `crumb verify` does not execute invariant checks or prove peer coordination. -Tool skew is the usual cause of a disagreement, because four paths can pick four different builds: the repository gate from `crumb.lock`, the hosted workflow from its own pin, a worker's readiness check, and your own compile. On this machine `omega-mv` pins `d0f0b95d`, while `aien-sovereign-core-mv`, the hosted workflow and the sandbox install pin `94fffbcf`. Use the pin the repository names. +Compare the repository gate, hosted workflow, trusted readiness checker and worker tool identities. Core source at `dffdbd195edcbe1ec3bd2fa255355b15c530f31e` pins `12ad0141b41ec67ef5aa51cb4e1815894c1083bb`; this is not evidence of the installed worker or hosted checker version. Read each actual pin and binary identity instead of treating old machine-specific values in a guide as current. Which tree may choose the checker changed in aien-sovereign-core-mv main `2369d7c834971eb91b8a20bab40b6ca7692064f5` (PR #771, fixing issue #770, merged 2026-10-26). That state is MERGED in source and NOT_DEPLOYED: no trusted verifier, local-CI helper, shim or doctor from it was installed or restarted, so an operator install that predates the cutover still follows the older rule (the candidate tree's `crumb.lock`, else the in-tree tool when the tree is aien-architecture, else the sandbox build). Check the installed copy before relying on either rule. The merged rule: @@ -142,7 +148,7 @@ Starting again is SNIFF, RESOLVE, REVALIDATE, LEASE, RESUME: `crumb sniff` the r 1. A new directory is invisible until it holds a crumb. Membership is "directories that already hold one", so adding files under `src/new/` leaves `verify` green and the directory unenrolled. Run `crumb seed .`. 2. Hand-writing `extensions.generated`, or compiling with a different build than the gate uses, produces crumbs that verify locally and fail in CI. -3. Writing `.crumb.local` inside a repository, or deleting the shared store, corrupts the live coordination layer. Use the commands. +3. Editing `.crumb.local` or the shared store by hand, or deleting the store, corrupts the live coordination layer. Use the commands (the C tool for leases; `aien-cli`/`spark-crumbs` write `.crumb.local` telemetry themselves). 4. Treating exit 2 as a broken tool instead of a locked target, or guessing `CRUMB_EXPECT_STORE_ID` to silence exit 3, which hides split or unregistered stores rather than fixing them. 5. Putting secrets, tokens, credentials or private machine detail in either file. Crumbs are public. 6. Claiming that `extensions.provenance` proves authorship. It records mentions from git history, and the backfill marks its own entries as reconstructed. @@ -164,8 +170,34 @@ State what you ran and what it returned. A crumb change is part of the change un Merged to core main on 2026-10-31 as `b7f2250a` (core#887, DRA-95). The merge came from the `ready-to-merge` label with no review; a post-merge review found no reason to revert. Every invariant in a shipped-path `.crumb` ends with `Check: `, naming the test or script that enforces it, for example `"A reused KV block never exposes the previous sequence's KV. Check: cargo test -p aien-kv-cache --test kv_lifecycle_qualification -- --exact freed_block_reuse_never_exposes_previous_sequence_kv"`. An invariant with no check you can name and run does not go in the crumb; list it in the PR as unenforced instead. -These crumbs are hand-written and do not parse as the `DirCrumb` struct that `spark-crumbs` and the `aien` CLI read. Until a loader fix merges, `spark-crumbs show`, `sniff` or `record`, and `aien` nest, sniff or show, run in such a directory, overwrite its `.crumb` with an auto-sensed one, and `crumb verify` still passes. Do not run them there; if one ran, restore the file with `git checkout -- /.crumb` before committing. +The source at core `dffdbd195edcbe1ec3bd2fa255355b15c530f31e` now treats foreign handwritten crumbs as read-only and includes preservation tests in both implementations. Verify the installed binary before assuming that fix is deployed. Inspect and preserve valid uncommitted semantic edits when recovering an old overwrite; do not blindly restore a whole file. The separate telemetry race, hidden I/O errors and hard-coded CLI worker identity remain tracked in core #924. `om/crumb-coverage/run.sh` (Omega, omc pinned in `om/crumb-coverage/omega.pin`, omega-mv `b3346c2e`) counts tracked directories, directories with a `.crumb`, and directories with at least one invariant whose `Check:` resolves to an existing test function or repository script, and lists every check that does not resolve. Without `AIEN_OMC` hashing to the pin it exits 77 NOT_RUN. Measured 2026-10-31 on core main `b7f2250a`: `tracked_dirs 780`, `crumb_dirs 41`, `enforced_dirs 28`, `invariants 46 resolved 46 unresolved 0`; `--self-test` PASS. Before the merge, main `43495111` had 17 of 780 directories with a crumb and 0 enforced. The coverage report is advisory: no gate runs it, and `CRUMB-VERIFY` checks only that crumbs are current, not that their checks pass. Resolving a check proves the named test exists, not that it passes; run it. The `.crumb.local` wording in section 1 and the binding-rules change are tracked in aien-dev/omega-harness#158 pending DRA-97 and DRA-98. + +## 12. Enforced repositories, `crumb check` and the session bridge (crumb924, core#924, core#587) + +Status, 2026-11-07: IMPLEMENTED and EXERCISED on branches, PENDING merge, NOT deployed. Heads and receipts: aien-architecture-mv `fix/crumb-924-crumb-c` @ `8261a731` (the C tool; `make -C tools/crumb test` 343 PASS 0 FAIL), aien-sovereign-core-mv `fix/crumb-924-bridge` @ `9116c98c` (`swarm-bridge`, its Hermes shell hooks and the OMP extension, with the board crate re-vendored from aien-dev/synapse `fix/crumb-924-coord-durability` @ `62d00170`; `cargo test -p swarm-bridge` 136 passed 0 failed, `cargo test -p synapse-coord` 83 passed 0 failed, OMP bun tests 59 pass 0 fail) and `fix/crumb-924-telemetry` @ `20d81340` (`aien-cli`, `spark-crumbs`; `cargo test -p aien-cli -p spark-crumbs` 345 passed 0 failed). The pull requests carry the receipts. A repository is enforced only when the deployed gate is active in your runtime and the repository opts in. The first-turn notice and recorded binary hashes do not prove the hooks are installed; a write refused in an enforced scratch repository does. Otherwise every lock is advisory. Check `crumb check` exists in the build you run (`crumb` with no arguments prints its usage) before relying on this section. + +What enforcement is. A repository opts in with `git config crumb.enforce true`. In it, the runtime's write gate (Hermes `pre_tool_call` shell hook, OMP `tool_call` extension) runs `crumb check ` before each `write_file`, `patch` and terminal write it can see, and blocks the call on anything but exit 0. Paths outside enforced repositories are not gated. + +Your identity is `.`: the agent name (`AIEN_AGENT_NAME`, else the Hermes profile, else the runtime) and the runtime's own session id, never a constant. Every subagent has its own. Use the exact string the bridge prints in its first-turn notice and in its lease-refusal block messages, verbatim (some refusals, such as a store error or a malformed HELD line, carry no claim command). The C tool uses ids matching `^[A-Za-z0-9][A-Za-z0-9_.@-]{0,159}$` verbatim (no aliases) and, in enforcement mode, refuses a claim, renew or close of a live lease from a different session (`CRUMB_SESSION`). Adapters differ in how they build the id: Hermes uses its session id with surrounding whitespace trimmed; the OMP extension refuses a session id outside that alphabet (it never rewrites one), appends `.` when two in-process sessions report the same session id (the agent id is validated when it is used as that suffix), and refuses an identity another agent in the same process already holds. The board binds one live session per tag; it does not refuse a second process presenting the same identity. + +```sh +crumb claim . "" # prints ... generation ; a directory lease covers what is below it +crumb check . [--key K] [--generation N] # HELD by key generation expires