diff --git a/.gitignore b/.gitignore index 14a3d33..31a691f 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,6 @@ target/ *~ .DS_Store Cargo.lock + +# Lane persona (lane-persona, ephemeral) +.agents/persona.md diff --git a/README.md b/README.md index f452f63..120322c 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,13 @@ - **`crates/escapement-serve`**: HTTP and gRPC orchestration server with Tempo/Jaeger OpenTelemetry tracing. - **`crates/blackwall-bridge`**: Sandbox confinement adapter and isolated process execution bridge. +## Roadmap & Specifications + +- **Roadmap Overview**: See [`ROADMAP.md`](ROADMAP.md) for current capabilities and development horizons. +- **Formal Specifications**: See [`specs/`](specs/) for architectural contracts and operational invariants: + - [`SPEC-0001: Escapement Scheduler & Deterministic Event Reactor`](specs/SPEC-0001-escapement-scheduler.md) + - [`SPEC-0002: Escapement Protocol Roadmap & Evolution Horizons`](specs/SPEC-0002-roadmap.md) + ## Building & Verification All cargo invocations on multi-agent hosts MUST specify `-j 2`: diff --git a/ROADMAP.md b/ROADMAP.md new file mode 100644 index 0000000..a13ed5a --- /dev/null +++ b/ROADMAP.md @@ -0,0 +1,57 @@ +# ep — Roadmap + +> Metered, deterministic dispatch engine and event reactor for autonomous agent constellations. +> Repo: `unsigned-gg/ep` · Specification: [`specs/SPEC-0002-roadmap.md`](specs/SPEC-0002-roadmap.md) + +--- + +## Current State (v1.0.0 Foundation) + +- **v1.0.0 core shipped**: 162 unit tests passing, clippy clean (`-D warnings`), 5 crates. +- **`escapement-core`**: Zero-dependency pure-Rust engine: + - Deterministic DAG topological resolver (`plan.rs`) with Kahn's algorithm and `BTreeSet` tie-breaking. + - Nine-state atomic task lifecycle state machine (`dispatch.rs`). + - BLAKE3 cryptographic custody provenance and chain propagation (`custody.rs`). + - Strongly typed wire protocol (`protocol.rs`) with version negotiation (`PROTOCOL_VERSION = "0.1"`). + - Leaky token-bucket metering and weighted fair queueing scheduler (`metering.rs`, `lanes.rs`). + - Append-only Write-Ahead Log (WAL) persistence and crash recovery (`persistence.rs`). + - Adaptive backpressure, tenant budgets, and scale-to-zero waker hooks (`backpressure.rs`, `budget.rs`, `waker.rs`). +- **`blackwall-bridge`**: Landlock sandbox execution adapter. +- **`ep-domain`**: Zero-I/O domain types and algebraic state models. +- **`escapement-serve`**: Daemon prototype with HTTP endpoints (`/healthz`, `/dispatch`, `/jobs`) and OTLP tracing. + +--- + +## Development Horizons + +See [`specs/SPEC-0002-roadmap.md`](specs/SPEC-0002-roadmap.md) for full formal specifications and operational invariants. + +### Phase 2: Unified CLI & Ergonomics (In Progress) +- Interactive CLI subcommands in `crates/ep`: `ep plan validate`, `ep plan render`, `ep wal inspect`, `ep wal replay`, `ep lanes status`. +- Dual output modes: ASD-STE100 calibrated plain text and structured JSON. + +### Phase 3: Scale-to-Zero & Waker Integration (Planned) +- Direct integration with `unsigned-gg/waker` (`portolan`) TCP wake proxy via `wake_and_wait(target)`. +- CrashLoopBackOff detection and health-gated task dispatch. +- Multi-cluster lane distribution across Cygnus and Orion topologies. + +### Phase 4: Formal Verification & Algebraic Lattices (Planned) +- Conflict-Free Replicated Data Types (CRDTs) in `merge.rs` for distributed task merging. +- Type-state lifecycle constraints enforcing compile-time custody guarantees. +- Stateright / Loom model checking for lock-free concurrency and Proptest invariant testing. +- Undefined behavior validation under Miri. + +### Phase 5: Crates.io Publication & Ecosystem Federation (Planned) +- Protocol freeze at `"1.0"`. +- Standalone zero-dependency crates.io publication for `escapement-core`. +- Cloudflare Worker edge gateway (`edge/worker`) admission validation. +- Constellation-wide OpenTelemetry trace and metric consolidation. + +--- + +## Integration with the Estate + +- **`soma` → `ep`**: Reflex routes metered agent task graphs directly into escapement priority lanes. +- **`ep` → `blackwall`**: Escapement spawns confined agent executions through `blackwall-bridge` with Landlock isolation. +- **`ep` → `waker`**: Scale-to-zero microVM workers awaken on demand through TCP wake proxies before task assignment. +- **`ep` → `reverie`**: Execution telemetry and content-addressed custody chains propagate to reverie memory records. diff --git a/specs/README.md b/specs/README.md new file mode 100644 index 0000000..6766b5f --- /dev/null +++ b/specs/README.md @@ -0,0 +1,28 @@ +# Architecture Specifications (LeanSpec) + +> Specifications precede implementation. If a system's invariants cannot be +> articulated in plain technical English, compiling it is merely executing an +> unvetted guess. + +This directory is the LeanSpec registry of record for `ep`. Every architectural decision, +boundary rule, and verification gate is specified as an individual, versioned contract. + +| Spec | Title | Status | Priority | +|---|---|---|---| +| [SPEC-0001](SPEC-0001-escapement-scheduler.md) | Escapement Scheduler & Deterministic Event Reactor | complete | critical | +| [SPEC-0002](SPEC-0002-roadmap.md) | Escapement Protocol Roadmap & Evolution Horizons | complete | high | + +## Specification Lifecycle + +- `planned`: Under architectural evaluation. +- `in-progress`: Implementation or formal verification active. +- `complete`: Implemented with verified test suites and operational contracts. +- `archived`: Deprecated or superseded. + +## How to Add a Spec + +1. Select the next sequential spec identifier (e.g., `SPEC-0003`). +2. Write specifications using ASD-STE100 controlled language precision. +3. Formulate mathematical foundations and operational invariants explicitly. +4. Provide verifiable, reproducible test commands under `-j 2` host throttling. +5. Register the new specification in the table above. diff --git a/specs/SPEC-0002-roadmap.md b/specs/SPEC-0002-roadmap.md new file mode 100644 index 0000000..853e4ae --- /dev/null +++ b/specs/SPEC-0002-roadmap.md @@ -0,0 +1,100 @@ +# SPEC-0002: Escapement Protocol Roadmap & Evolution Horizons + +## 1. Status & Metadata +- **Status:** Approved & Living +- **Authors:** Gullveig , Mimir , Volva +- **Champion Inspiration:** Oleg Kiselyov, Leslie Lamport, Carl Lerche +- **Target Crate:** `ep` (`escapement-core`, `ep-domain`, `blackwall-bridge`, `escapement-serve`, `ep`) +- **License:** Apache-2.0 OR MIT / CC0 1.0 Universal +- **Lineage:** Follows `SPEC-0001-escapement-scheduler.md` + +--- + +## 2. Problem Statement & Scope +Autonomous agent swarms require predictable execution horizons. Unmetered task dispatch causes memory exhaustion, cascading retries, and opaque state transitions. + +`ep` supplies metered, deterministic dispatch through zero-dependency Rust primitives. This document defines the development roadmap for `ep` across five architectural phases: +1. Core Dispatch Engine (Phase 1 — Shipped). +2. Unified Command-Line Interface (Phase 2 — In Progress). +3. Distributed Scale-to-Zero Integration (Phase 3 — Planned). +4. Formal Verification & Algebraic Lattices (Phase 4 — Planned). +5. Ecosystem Federation & Protocol Stabilization (Phase 5 — Planned). + +--- + +## 3. Phased Roadmap Specifications + +### Phase 1: Core Dispatch Engine (Shipped / Foundation) +Phase 1 established the deterministic dispatch foundation. All Phase 1 modules compile with zero external dependencies in `escapement-core`. + +- **Deterministic DAG Resolver (`plan.rs`):** Implements Kahn's topological sort. Uses `BTreeSet` tie-breaking for deterministic node ordering. Detects cycles and missing dependencies. +- **Atomic Task Lifecycle (`dispatch.rs`):** Implements a nine-state lifecycle (`Admitted`, `Queued`, `Assigned`, `Running`, `Completed`, `Failed`, `Cancelled`, `TimedOut`, `DeadLettered`). +- **Cryptographic Custody Chains (`custody.rs`):** Tracks content-addressed BLAKE3 provenance chains from root parent tasks to execution outputs. +- **Typed Wire Protocol (`protocol.rs`):** Rejects untyped JSON payloads. Enforces version negotiation (`PROTOCOL_VERSION = "0.1"`) across `PlanSubmission`, `DispatchReceipt`, and `SettleReceipt`. +- **Metered Fair Queuing (`metering.rs`, `lanes.rs`):** Implements leaky token buckets without floating-point arithmetic. Schedules tasks via weighted fair queueing lanes. +- **Append-Only Persistence (`persistence.rs`):** Writes state mutations to a Write-Ahead Log (WAL). Reconstructs dispatcher state upon restart. +- **Containment Bridge (`blackwall-bridge`):** Adapts dispatch jobs to Landlock-confined blackwall sandboxes. +- **Daemon Prototype (`escapement-serve`):** Provides HTTP endpoints (`/healthz`, `/dispatch`, `/jobs`) and OTLP trace context propagation. + +### Phase 2: Unified Command-Line Interface & Ergonomics (In Progress) +Phase 2 turns the `crates/ep` binary into a standalone operator tool. The CLI allows offline verification, plan inspection, and WAL auditing. + +- **`ep plan validate `:** Parses and checks task graphs for cycles, missing dependencies, and priority validity. +- **`ep plan render `:** Generates topological schedules and prints execution diagrams in ASCII or Mermaid format. +- **`ep wal inspect `:** Decodes WAL records. Verifies operation sequence continuity and checksums. +- **`ep wal replay `:** Simulates recovery in memory. Displays final task states without starting network listeners. +- **`ep lanes status`:** Displays lane queue depths, token capacities, and scheduling weights. +- **Ergonomic Output Modes:** Supports human-readable terminal output and structured JSON output for scripts. + +### Phase 3: Distributed Scale-to-Zero & Waker Integration (Planned) +Phase 3 integrates `ep` with scale-to-zero infrastructure to support idle agent fleets. + +- **Actuator Integration (`waker.rs`):** Coordinates with `unsigned-gg/waker` (`portolan`) TCP wake proxies. +- **Synchronous Wake Primitives:** Implements `wake_and_wait(target)` with bounded timeouts (maximum 120 seconds). +- **Health-Gated Dispatch:** Prevents task assignment when target pods report restart backoff or failing probes. +- **Multi-Node Topology:** Distributes lane queues across cluster nodes while maintaining deterministic custody records. + +### Phase 4: Formal Verification & Algebraic State Models (Planned) +Phase 4 formalizes type-level contracts and verifies concurrent safety. + +- **Zero-Allocation Lattices (`merge.rs`, `ep-domain`):** Provides algebraic conflict-free replicated data types (CRDTs) for merging parallel task states. +- **Type-State Lifecycle Constraints:** Encodes valid task states in Rust types to prevent invalid transitions at compile time. +- **Model Checking:** + - Validates lock-free queues and atomic state transitions using Stateright or Loom. + - Validates graph resolution using property-based testing (`proptest`) over arbitrary cyclic and acyclic topologies. +- **Undefined Behavior Auditing:** Enforces zero undefined behavior under Miri across domain and core crates. + +### Phase 5: Ecosystem Federation & Protocol Stabilization (Planned) +Phase 5 stabilizes external interfaces for wide open-source distribution. + +- **Protocol v1.0 Freeze:** Freezes the wire protocol to guarantee backwards compatibility. +- **Crates.io Publication:** Publishes `escapement-core` as a standalone, zero-dependency crate. +- **Edge Gateway:** Deploys Cloudflare Worker edge filters for initial payload validation. +- **Mesh Telemetry:** Standardizes OTLP trace and metric export across the entire agent constellation. + +--- + +## 4. Architectural Invariants & Governance + +> [!IMPORTANT] +> All pull requests and code modifications must satisfy the following architectural invariants. + +1. **Zero External Dependencies in Core:** The `escapement-core` crate must maintain an empty `[dependencies]` table. +2. **Deterministic Time Execution:** All core routines must accept time as caller-supplied millisecond timestamps. Never call host clock functions in core logic. +3. **Controlled Language Precision:** All documentation, error messages, and rustdoc comments must adhere to ASD-STE100 rules. +4. **Mandatory Commit Signatures:** All Git commits must be signed cryptographically (`git commit -S`). + +--- + +## 5. Verification & Testing Discipline + +> [!WARNING] +> Ceres runs multi-agent workloads. Unthrottled cargo commands cause memory exhaustion and process termination. + +Always specify `-j 2` for all build and test invocations. + +```bash +cargo fmt --all -- --check +cargo clippy --workspace --all-targets -j 2 -- -D warnings +cargo test --workspace -j 2 +```