carry-agent / docs /CARRY_ARCHITECTURE.md
SNAPKITTYWEST's picture
push from SNAPKITTYWEST/carry-agent
80d7559 verified
|
Raw History Blame Contribute Delete
2.9 kB
# CARRY — Adversarial Twin of CARTO
**Architecture:** CURRY_CRYSTAL_C3 Triad
**Memory Model:** Explicit Arena
**Interface:** C ABI Native
**Author:** Ahmad <ahmedparr93@gmail.com>
---
## Relationship to CARTO
CARTO maps the legal terrain with a 5-state fabric FSM (Idle → EnginesAttached → AuditReady → SummonsOpen → MetaLawyerActive → WormSealed).
CARRY is the adversarial twin. Same lineage, different spine:
| Dimension | CARTO | CARRY |
|---|---|---|
| States | 6 (linear fabric) | 7 (DAG-locked pipeline) |
| Layers | Prolog / COBOL / REXX | Curry / Crystal / C3 |
| Memory | implicit | explicit arena (S5) |
| Interface | JS envelope | C ABI native |
| Entropy gate | none | ≤ 0.20 per transition |
| Trust model | engine attach | active ⟹ trusted (NAND-derived) |
| Proof | WORM seal | deterministic compilation proof (V1/V2/V3) |
---
## DAG Pipeline
```
N1 🧠Input (Curry_Strategy)
↓ R1: FFI_C_ABI → layer becomes Crystal
N2 📚Memory (Crystal_Orchestration)
↓ R2: Native_Binding → layer becomes C3
N3 🔍Retrieval (C3_Binding)
↓
N4 ⚙Transform (SIMD_Vectorization)
↓
N5 ⚖Constraint (C_ABI_Verification)
↓
N6 🔐Proof (Deterministic_Latency)
↓
N7 🌐Output (Hardware_Execution) ← terminal
```
Layer transformations fire automatically on the N1→N2 and N2→N3 edges. Every other edge stays on C3.
---
## Entropy Gate
Every transition is blocked if `entropy > 0.20`. This enforces constraints C4 and V2 at the FSM level — not just as documentation. Pass entropy as a float on every event call.
---
## Trust Predicates
- C1: `OR(NOT(active(S1)), trusted(S1))` — Curry layer
- C2: `OR(NOT(active(S2)), trusted(S2))` — Crystal layer
- C3: `OR(NOT(active(S3)), trusted(S3))` — C3 layer
- **V1: `EQUAL(active(S3), trusted(S3))`** — C3 is the only layer where active equals trusted (not merely implied). This is the proof anchor.
---
## Runtime Files
| File | Purpose |
|---|---|
| `runtime/carry-fsm.rs` | Rust FSM — full 7-state DAG with arena, entropy gate, R1/R2 |
| `runtime/carry-engine.mjs` | JS runtime — same logic, CLI smoke-test included |
| `kernels/carry-kernel.pl` | Prolog kernel — declarative transition table + guards |
| `logic/constraint-graph.xml` | Original constraint graph (Ahmad's spec, verbatim) |
| `modules/carry-manifest.json` | Full manifest with layers, DAG, rules, proof conditions |
---
## Smoke Test
```bash
node carry-agent/runtime/carry-engine.mjs
```
Expected output:
```
CARRY FSM — DETERMINISTIC_COMPILATION_COMPLETE
Architecture: CURRY_CRYSTAL_C3_TRIAD
Memory Model: EXPLICIT_ARENA
Interface: C_ABI_NATIVE
[INPUT] e=0.110 layer=crystal → memory CARRY_INIT
R1 curry→crystal via FFI_C_ABI
...
Final state: output
Arena slots: 7
```