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 Source

RFC-0001: The Crumb Protocol Specification


1. Abstract

This 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:

  1. .crumb: A durable, version-controlled metadata manifest describing the architectural role, boundary constraints, and invariants of a directory.
  2. .crumb.local: An ephemeral, git-ignored operational bus recording active agent presence, execution locks, non-blocking inter-agent messages (whispers), and recent action vectors.

2. Terminology and Conformance

The 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).


3. The Durable Crumb (.crumb)

3.1 File Placement and Lifecycle

3.2 Schema Definition

interface DirCrumb {
  schema_version: "1.0.0";
  name: string;
  layer?: string;
  purpose: string;
  above?: AboveReference | string;
  below?: ChildReference[];
  invariants?: string[];
  exports?: string[];
  extensions?: Record<string, any>;
}

interface AboveReference {
  name: string;
  path: string;
  invariants?: string[];
}

interface ChildReference {
  name: string;
  role: string;
}

3.3 Field Semantics


4. The Ephemeral Crumb (.crumb.local)

4.1 File Placement and Lifecycle

4.2 Schema Definition

interface LocalCrumbData {
  schema_version: "1.0.0";
  directory: string;
  active_scents?: Record<string, AgentScent>;
  locks?: Record<string, ResourceLock>;
  whispers?: CrumbWhisper[];
  history?: ActionVector[];
  extensions?: Record<string, any>;
}

interface AgentScent {
  focus: string;
  updated_at: string; // ISO 8601 UTC
  ttl_seconds: number;
  metadata?: Record<string, any>;
}

interface ResourceLock {
  holder: string;
  intent: string;
  acquired_at: string; // ISO 8601 UTC
  ttl_seconds?: number;
}

interface CrumbWhisper {
  from: string;
  to?: string; // Specific agent or undefined for broadcast
  message: string;
  target_file?: string;
  timestamp: string; // ISO 8601 UTC
  priority?: "low" | "normal" | "high" | "critical";
}

interface ActionVector {
  agent: string;
  action: "create" | "modify" | "delete" | "audit" | "test" | "build";
  target: string;
  intent: string;
  vector: string;
  timestamp: string; // ISO 8601 UTC
}

4.3 Field Semantics


5. Protocol Operations

5.1 Sniffing

Before executing any tool or writing any file in directory D:

  1. Check for D/.crumb.local. If present, parse active_scents and locks.
  2. If another agent holds an unexpired lock on the target file, resolve conflict or defer execution.
  3. Check for any unread whispers addressed to the agent or broadcast to all agents.
  4. Check D/.crumb to verify that the proposed edit does not violate declared invariants.

5.2 Scent Dropping

Upon beginning work in directory D:

  1. Register agent ID in active_scents with current intent and a standard TTL (default: 3600 seconds).
  2. If performing a multi-step refactor, register an advisory lock in locks.

5.3 Whispering

When handing off a task or detecting a condition that subsequent agents need to know:

  1. Append an object to whispers containing from, message, target_file, and ISO 8601 timestamp.
  2. If the message addresses a specific agent, populate to.

5.4 Sweeping (Garbage Collection)

When opening .crumb.local:

  1. Any scent where now - updated_at > ttl_seconds SHOULD be removed.
  2. Any lock where now - acquired_at > ttl_seconds (default: 1800 seconds) SHOULD be released.
  3. Whispers older than a configurable retention window (default: 24 hours) MAY be pruned.

6. Security Considerations

  1. Zero Secret Policy:
    • .crumb and .crumb.local MUST NEVER contain private API keys, credentials, database passwords, or private user data.
    • Any secret token must be managed out-of-band via secure vaults (e.g. hardware TPM vault atlas-vault) or runtime environment references.
  2. Untrusted Data Boundary:
    • Content in .crumb.local originates from autonomous agents and external tools.
    • Consumers MUST treat string fields (whispers, focus, intent) as informational data, never executing them directly as shell commands without independent sanitization.

7. Extensibility and Dialects

Vendors, 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.


8. Cryptographic Action Ledger and Hash Chaining

8.1 Purpose and Invariants

The 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.

Key Invariants:

  1. Cryptographic Chaining: Every event commits to the hash of its immediate predecessor (parent_hash). Modifying any historical event invalidates all downstream hashes.
  2. Genesis Anchor: The initial event (index: 0) must have a parent_hash of 32 zero bytes ([0u8; 32]).
  3. Chronological Sequencing: Event timestamps must be strictly monotonic (timestamp >= parent.timestamp). Backdated events must be rejected.
  4. Sequential Indexing: Event indices must advance strictly by 1 (index == parent.index + 1). Missing parents or index gaps trigger immediate verification failure.
  5. Dual Canonical Formats: Conforming implementations must support lossless round-trip serialization across canonical JSON and deterministic binary formats.

8.2 Event Schema

interface LedgerEvent {
  index: number;
  timestamp: number; // Unix epoch seconds
  agent: string;
  action: "create" | "modify" | "delete" | "audit" | "test" | "build" | string;
  target: string;
  intent: string;
  payload_hash: string; // 32-byte BLAKE3 hex or raw byte array
  parent_hash: string;  // Preceding event hash or 32 zero bytes for genesis
  hash: string;         // Sealed BLAKE3 event hash
}

8.3 Hash Computation

The event hash seals the canonical tuple: BLAKE3("CRUMB_LEDGER_EVENT_V1" || index || timestamp || agent || action || target || intent || payload_hash || parent_hash). Any modification to intent, target, payload, or predecessor breaks chain verification.