interplane.Get Omega
Read in your language

crumb-spec

Crumb Protocol specification and filesystem standard for sovereign AI agents

Brought by drakestapleton

branch main Branches Tags History

crumb-spec / SPEC.md

219 lines · 10030 bytes Raw Blame History Rendered
1# RFC-0001: The Crumb Protocol Specification
2
3- **Status**: Stable / Standard
4- **Version**: 1.0.0
5- **Author**: AIEN <aien.atlas@proton.me>
6- **Published**: September 2026
7
8---
9
10## 1. Abstract
11
12This specification defines the Crumb Protocol, a file-system-native architecture for spatial grounding, structural hierarchy declaration, and peer agent coordination across multi-agent AI coding systems. The protocol establishes two decoupled layers:
131. `.crumb`: A durable, version-controlled metadata manifest describing the architectural role, boundary constraints, and invariants of a directory.
142. `.crumb.local`: An ephemeral, git-ignored operational bus recording active agent presence, execution locks, non-blocking inter-agent messages (whispers), and recent action vectors.
15
16---
17
18## 2. Terminology and Conformance
19
20The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in BCP 14 (RFC 2119, RFC 8174).
21
22- **Agent**: An autonomous software entity (LLM, neural graph, rule engine, or human collaborator) reading or modifying files in a repository.
23- **Topography**: The structural hierarchy of directories and their declared architectural purposes.
24- **Scent**: An ephemeral record of an agent's current or recent presence and intent.
25- **Whisper**: An asynchronous, non-blocking message left by one agent for subsequent or peer agents.
26- **Lock**: A non-blocking advisory claim over a file or directory indicating ongoing mutation.
27- **Invariant**: A non-negotiable architectural or operational rule that all agents must satisfy within a directory tree.
28
29---
30
31## 3. The Durable Crumb (`.crumb`)
32
33### 3.1 File Placement and Lifecycle
34- The `.crumb` file MUST be placed directly inside the directory it describes.
35- The `.crumb` file MUST be encoded in UTF-8 JSON.
36- The `.crumb` file MUST be tracked in version control (git).
37- The `.crumb` file SHOULD only be modified when the architectural purpose, exported interface, or invariant set of a directory changes.
38
39### 3.2 Schema Definition
40
41```typescript
42interface DirCrumb {
43 schema_version: "1.0.0";
44 name: string;
45 layer?: string;
46 purpose: string;
47 above?: AboveReference | string;
48 below?: ChildReference[];
49 invariants?: string[];
50 exports?: string[];
51 extensions?: Record<string, any>;
52}
53
54interface AboveReference {
55 name: string;
56 path: string;
57 invariants?: string[];
58}
59
60interface ChildReference {
61 name: string;
62 role: string;
63}
64```
65
66### 3.3 Field Semantics
67
68- **`schema_version`** (REQUIRED, string): Semantic version string of the specification. Must be `"1.0.0"`.
69- **`name`** (REQUIRED, string): Human-readable identifier for the module or directory.
70- **`layer`** (OPTIONAL, string): Architectural layer identifier (e.g. `"core/runtime"`, `"ui/web"`, `"infra/db"`).
71- **`purpose`** (REQUIRED, string): Concise summary of what this directory contains and what responsibilities it fulfills.
72- **`above`** (OPTIONAL, object or string): Relative or canonical pointer to the parent architectural boundary. When expressed as an object, it provides the parent name, path, and inherited invariants.
73- **`below`** (OPTIONAL, array of objects): Declarations of significant subdirectories and their specific functional roles.
74- **`invariants`** (OPTIONAL, array of strings): Explicit engineering constraints that MUST NOT be violated within this directory.
75- **`exports`** (OPTIONAL, array of strings): Key public API symbols, CLI commands, or services provided by this directory.
76- **`extensions`** (OPTIONAL, object): Arbitrary domain-specific metadata.
77
78---
79
80## 4. The Ephemeral Crumb (`.crumb.local`)
81
82### 4.1 File Placement and Lifecycle
83- The `.crumb.local` file MUST be placed alongside `.crumb` in the same directory.
84- The `.crumb.local` file MUST be listed in `.gitignore` and NEVER committed to version control.
85- Agents MAY create or update `.crumb.local` upon entering or mutating a directory.
86- Stale scents and expired whispers MUST be pruned periodically or during directory traversal.
87
88### 4.2 Schema Definition
89
90```typescript
91interface LocalCrumbData {
92 schema_version: "1.0.0";
93 directory: string;
94 active_scents?: Record<string, AgentScent>;
95 locks?: Record<string, ResourceLock>;
96 whispers?: CrumbWhisper[];
97 history?: ActionVector[];
98 extensions?: Record<string, any>;
99}
100
101interface AgentScent {
102 focus: string;
103 updated_at: string; // ISO 8601 UTC
104 ttl_seconds: number;
105 metadata?: Record<string, any>;
106}
107
108interface ResourceLock {
109 holder: string;
110 intent: string;
111 acquired_at: string; // ISO 8601 UTC
112 ttl_seconds?: number;
113}
114
115interface CrumbWhisper {
116 from: string;
117 to?: string; // Specific agent or undefined for broadcast
118 message: string;
119 target_file?: string;
120 timestamp: string; // ISO 8601 UTC
121 priority?: "low" | "normal" | "high" | "critical";
122}
123
124interface ActionVector {
125 agent: string;
126 action: "create" | "modify" | "delete" | "audit" | "test" | "build";
127 target: string;
128 intent: string;
129 vector: string;
130 timestamp: string; // ISO 8601 UTC
131}
132```
133
134### 4.3 Field Semantics
135
136- **`active_scents`**: Map of agent identifiers to their current focus and TTL. A scent whose `updated_at + ttl_seconds < now` is considered expired and SHOULD be pruned.
137- **`locks`**: Advisory claims on specific files or the directory itself. An agent detecting an unexpired lock held by another agent SHOULD pause, consult the lock holder, or proceed only on non-conflicting targets.
138- **`whispers`**: Non-blocking asynchronous message bus. Whispers allow an agent leaving a directory to pass critical context, warnings, or reminders to whoever visits next.
139- **`history`**: Rolling buffer of recent operational vectors. Implementations SHOULD cap history at a reasonable limit (e.g. 20 entries) to maintain minimal file size.
140
141---
142
143## 5. Protocol Operations
144
145### 5.1 Sniffing
146Before executing any tool or writing any file in directory `D`:
1471. Check for `D/.crumb.local`. If present, parse `active_scents` and `locks`.
1482. If another agent holds an unexpired lock on the target file, resolve conflict or defer execution.
1493. Check for any unread `whispers` addressed to the agent or broadcast to all agents.
1504. Check `D/.crumb` to verify that the proposed edit does not violate declared `invariants`.
151
152### 5.2 Scent Dropping
153Upon beginning work in directory `D`:
1541. Register agent ID in `active_scents` with current intent and a standard TTL (default: 3600 seconds).
1552. If performing a multi-step refactor, register an advisory lock in `locks`.
156
157### 5.3 Whispering
158When handing off a task or detecting a condition that subsequent agents need to know:
1591. Append an object to `whispers` containing `from`, `message`, `target_file`, and ISO 8601 timestamp.
1602. If the message addresses a specific agent, populate `to`.
161
162### 5.4 Sweeping (Garbage Collection)
163When opening `.crumb.local`:
1641. Any scent where `now - updated_at > ttl_seconds` SHOULD be removed.
1652. Any lock where `now - acquired_at > ttl_seconds` (default: 1800 seconds) SHOULD be released.
1663. Whispers older than a configurable retention window (default: 24 hours) MAY be pruned.
167
168---
169
170## 6. Security Considerations
171
1721. **Zero Secret Policy**:
173 - `.crumb` and `.crumb.local` MUST NEVER contain private API keys, credentials, database passwords, or private user data.
174 - Any secret token must be managed out-of-band via secure vaults (e.g. hardware TPM vault `atlas-vault`) or runtime environment references.
1752. **Untrusted Data Boundary**:
176 - Content in `.crumb.local` originates from autonomous agents and external tools.
177 - Consumers MUST treat string fields (whispers, focus, intent) as informational data, never executing them directly as shell commands without independent sanitization.
178
179---
180
181## 7. Extensibility and Dialects
182
183Vendors, open-source communities, and agent teams MAY add custom fields under the top-level `extensions` object or introduce custom sub-objects prefixed with `x_`. Implementations conforming to RFC-0001 MUST preserve unrecognized extension fields during read-modify-write cycles.
184
185---
186
187## 8. Cryptographic Action Ledger and Hash Chaining
188
189### 8.1 Purpose and Invariants
190The Crumb Ledger provides an immutable, cryptographically verifiable record of operational action vectors executed across repositories by autonomous agents. Each event seals the physical mutation or audit with BLAKE3 cryptographic hashes, forming an unbroken tamper-evident hash chain.
191
192Key Invariants:
1931. **Cryptographic Chaining**: Every event commits to the hash of its immediate predecessor (`parent_hash`). Modifying any historical event invalidates all downstream hashes.
1942. **Genesis Anchor**: The initial event (`index: 0`) must have a `parent_hash` of 32 zero bytes (`[0u8; 32]`).
1953. **Chronological Sequencing**: Event timestamps must be strictly monotonic (`timestamp >= parent.timestamp`). Backdated events must be rejected.
1964. **Sequential Indexing**: Event indices must advance strictly by 1 (`index == parent.index + 1`). Missing parents or index gaps trigger immediate verification failure.
1975. **Dual Canonical Formats**: Conforming implementations must support lossless round-trip serialization across canonical JSON and deterministic binary formats.
198
199### 8.2 Event Schema
200
201```typescript
202interface LedgerEvent {
203 index: number;
204 timestamp: number; // Unix epoch seconds
205 agent: string;
206 action: "create" | "modify" | "delete" | "audit" | "test" | "build" | string;
207 target: string;
208 intent: string;
209 payload_hash: string; // 32-byte BLAKE3 hex or raw byte array
210 parent_hash: string; // Preceding event hash or 32 zero bytes for genesis
211 hash: string; // Sealed BLAKE3 event hash
212}
213```
214
215### 8.3 Hash Computation
216The event hash seals the canonical tuple:
217`BLAKE3("CRUMB_LEDGER_EVENT_V1" || index || timestamp || agent || action || target || intent || payload_hash || parent_hash)`.
218Any modification to intent, target, payload, or predecessor breaks chain verification.
219