carry-agent / README.md
SNAPKITTYWEST's picture
Metadata: discovery tags (collection, languages)
c29b25a verified
|
Raw History Blame Contribute Delete
19.9 kB
---
license: agpl-3.0
tags:
- snapkitty
- agents
- python
---
> Source: [github.com/SNAPKITTYWEST/carry-agent](https://github.com/SNAPKITTYWEST/carry-agent)
<p align="center">
<img src="docs/firecarry.png" alt="CARRY β€” CARTO's Evil Twin Made of Curry" width="360px" />
</p>
<h1 align="center">CARRY</h1>
<h3 align="center">Adversarial Twin of CARTO</h3>
<p align="center">
<strong>CURRY_CRYSTAL_C3 Triad + Braid Topology + Sovereign Quantum Simulator</strong><br />
7-state DAG-locked pipeline Β· Entropy-gated transitions Β· Tau-Prolog logic kernel<br />
Fibonacci anyons Β· ICP governance Β· BLAKE3 WORM audit chain<br />
<em>The FSM tells you WHERE you are. The braid tells you WHETHER you got there honestly.</em>
</p>
<p align="center">
<img src="https://img.shields.io/badge/lang-Rust-orange?style=flat-square" />
<img src="https://img.shields.io/badge/logic-Tau--Prolog-blue?style=flat-square" />
<img src="https://img.shields.io/badge/proof-Braid_B₃-purple?style=flat-square" />
<img src="https://img.shields.io/badge/quantum-Fibonacci_Anyons-cyan?style=flat-square" />
<img src="https://img.shields.io/badge/formal-Lean_4_%2B_Agda-blueviolet?style=flat-square" />
<img src="https://img.shields.io/badge/tests-14%2F14_PASS-brightgreen?style=flat-square" />
<img src="https://img.shields.io/badge/sorry-0-brightgreen?style=flat-square" />
<img src="https://img.shields.io/badge/license-AGPL--3.0-green?style=flat-square" />
</p>
---
<p align="center">
<img src="docs/carry_brand_banner.png" alt="CARRY FSM β€” Adversarial Twin System + Deterministic Compiler Engine" width="100%" />
</p>
---
```
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ•— β–ˆβ–ˆβ•—
β–ˆβ–ˆβ•”β•β•β•β•β•β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β•šβ–ˆβ–ˆβ•— β–ˆβ–ˆβ•”β•
β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β• β•šβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•
β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•— β•šβ–ˆβ–ˆβ•”β•
β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘
β•šβ•β•β•β•β•β•β•šβ•β• β•šβ•β•β•šβ•β• β•šβ•β•β•šβ•β• β•šβ•β• β•šβ•β•
╔═══════════════════════════════════════════════╗
β•‘ B R A I D T O P O L O G Y R U N T I M E β•‘
β•‘ σ₁ Β· Οƒβ‚‚ Β· σ₁ = Οƒβ‚‚ Β· σ₁ Β· Οƒβ‚‚ β•‘
β•‘ Yang-Baxter holds. The chain is honest. β•‘
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
strand 0 ──╲ ╱── Οƒβ‚‚ crossing
strand 1 β•²β•±
β•±β•²
strand 2 ──╱ ╲── σ₁ crossing
β”‚
β–Ό
[C3 at pos 0]
writhe = +2
INVARIANT HOLDS
```
---
## What Is CARRY?
CARRY is the **adversarial twin** of [CARTO](https://github.com/SNAPKITTYWEST/cartographer-agent).
**CARTO** is the sovereign mapping agent β€” it models terrain, constructs pipelines, and produces outputs it claims are valid.
**CARRY** attacks those outputs. If CARRY cannot break CARTO's pipeline, the pipeline is honest. CARRY is the red team that never sleeps β€” a formal adversary baked into the architecture itself rather than run as a separate audit process.
The relationship:
```
CARTO CARRY
───── ─────
Maps terrain ←→ Attacks the map
Claims pipeline is valid ←→ Tries to falsify the claim
Produces WORM output ←→ Verifies the WORM seal
GOTO (push semantics) ←→ COME-FROM (pull semantics)
Forward evolution (U) ←→ Reversed evolution (U†)
```
The braid topology encodes this duality formally: every GOTO crossing has a matching COME-FROM crossing. The writhe invariant proves that authority was transferred through the correct sequence of crossings β€” not just that it arrived at the right place, but that it took the right path.
If the path is wrong, the braid is wrong. If the braid is wrong, the proof is rejected. No exceptions.
---
## Braid Authority Transfer
```
INITIAL: Curry ──── Crystal ──── C3
[0] [1] [2] (authority = pos 0)
After Οƒβ‚‚: Curry ──── C3 ──── Crystal
[0] [1] [2] (C3 crosses OVER Crystal)
After σ₁: C3 ──── Curry ──── Crystal
[0] [1] [2] (C3 crosses OVER Curry)
Writhe W(Ξ²) = (+1) + (+1) = +2
C3 at position 0 β†’ AUTHORITY TRANSFERRED
INVARIANT HOLDS βœ“
```
```
BRAID WORD: Οƒβ‚‚ Β· σ₁
─────────────────────
Curry ────\────────────────
\
Crystal ────X──\────────── Οƒβ‚‚: C3 over Crystal
/ \
C3 ─────── /────X──────── σ₁: C3 over Curry
\
β–Ό
C3 at pos 0
W = +2 βœ“
```
---
## Architecture
```
╔══════════════════════════════════════════════════════════════╗
β•‘ CARRY STACK β•‘
╠══════════════════════════════════════════════════════════════╣
β•‘ FORMAL LAYER Lean 4 + Agda β•‘
β•‘ 13 invariants Β· 0 sorry β•‘
β•‘ state_preservation proved β•‘
β•‘ duality_involution proved β•‘
╠══════════════════════════════════════════════════════════════╣
β•‘ QUANTUM LAYER Fibonacci Anyon Simulator β•‘
β•‘ B₃ braid group Β· Ο† = 1.6180 β•‘
β•‘ StateVector + DensityMatrix engines β•‘
β•‘ ICP 6-stage governance pipeline β•‘
β•‘ ASP declarative constraint solver β•‘
β•‘ 6052 cycle-accurate emulator β•‘
╠══════════════════════════════════════════════════════════════╣
β•‘ GOVERNANCE LAYER Conditional Dual DAG β•‘
β•‘ GOTO ↔ COME-FROM duality β•‘
β•‘ state preserved across ALL transitions β•‘
β•‘ BLAKE3 WORM audit chain β•‘
╠══════════════════════════════════════════════════════════════╣
β•‘ RUNTIME LAYER Rust (carry-fsm crate) β•‘
β•‘ 7-state DAG-locked FSM β•‘
β•‘ Entropy ≀ 0.20 gate β•‘
β•‘ Tau-Prolog logic kernel β•‘
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
```
---
## 7-State Quantum FSM
```
β”Œβ”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ INIT │───▢│ PREPARE │───▢│ ENTANGLE │───▢│ COMPUTE β”‚
β””β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜
β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚ COMMIT │◀───│ VERIFY │◀───│MEASURE β”‚β—€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β””β”€β”€β”€β”¬β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”‚
└──▢ PREPARE (loop) ─── or ─── COMMIT (terminal)
Any state ──▢ HALTED (emergency)
Any state ──▢ CYCLE_LIMIT (budget exhausted, absorbing)
Theorem (Lean 4, zero sorry):
Halted and CYCLE_LIMIT are ABSORBING STATES.
No transition exits them. Ever.
```
---
## The Quantum Module
CARRY ships a full first-principles quantum simulator:
```
runtime/quantum/
β”œβ”€β”€ core.rs StateVector |ψ⟩ + DensityMatrix ρ engines
β”‚ Born rule measurement Β· noise models
β”‚ H X Y Z S T Rx Ry Rz CNOT CZ SWAP
β”œβ”€β”€ fsm.rs 7-state governance FSM (proved absorbing terminals)
β”œβ”€β”€ agents.rs Primary + Partner agent pairs
β”‚ Qubit ownership: pairwise disjoint (proved INV-7)
β”œβ”€β”€ dag.rs Execution DAG + provenance hash chain
β”œβ”€β”€ icp.rs Integrity Constraint Protocol
│ 6 stages: Setup→Observe→Validate→Check→Execute→Verify
β”‚ HALT on any constraint breach
β”œβ”€β”€ asp.rs Answer Set Programming constraint solver
β”‚ QubitControl Β· Entangled Β· AgentControls rules
β”œβ”€β”€ topological.rs Fibonacci anyon simulator
β”‚ B₃: σ₁ Οƒβ‚‚ σ₁⁻¹ σ₂⁻¹ Β· Ο† β‰ˆ 1.6180 (golden ratio)
β”‚ Fusion rules: tauβŠ—tau β†’ {vacuum, tau}
β”œβ”€β”€ ftb.rs Fibonacci-Taylor Braid synthesis [RESEARCH_HYPOTHESIS]
β”œβ”€β”€ gitc.rs Governance Invariant Topological Cycle
β”œβ”€β”€ emulator_6052.rs Cycle-accurate 6052 emulator Β· MAX_CYCLE hard budget
└── benchmarks.rs Bell Β· GHZ Β· Teleportation Β· Deutsch Β· Grover Β· QFT
```
Reference circuits:
```
Circuit Qubits Gates Expected state
──────────── ────── ───── ──────────────────────────
Bell 2 2 (|00⟩ + |11⟩) / √2
GHZ-3 3 3 (|000⟩ + |111⟩) / √2
Teleportation 3 7 State transfer protocol
Deutsch-Jozsa 2 5 Constant/balanced oracle
Grover-2Q 2 12 Amplitude amplification
QFT-3Q 3 10 Quantum Fourier Transform
────────────────────────────────────────────────────────
14/14 tests PASS Β· all circuits SUCCESS
```
---
## Formal Verification Layer
```
runtime/quantum/
β”œβ”€β”€ QuantumSpec.agda Dependent-type specification
β”‚ Transition s s' encoded in the TYPE
β”‚ Illegal transitions: unrepresentable
β”‚
β”œβ”€β”€ QuantumInvariants.lean 13 machine-checked invariants
β”‚ INV-1: norm preserved by unitary gates
β”‚ INV-3: cycle counter strictly monotone
β”‚ INV-4: FSM confined to DAG edges
β”‚ INV-5: Halted/CycleLimit absorbing βœ“
β”‚ INV-7: agent qubit ownership disjoint
β”‚ INV-9: Fibonacci fusion rules correct
β”‚ INV-12: GITC invariant_holds iff all checks pass
β”‚ ... 13 total Β· 0 sorry
β”‚
└── QuantumReference.fs F# executable reference backend
7 conformance tests
Bell state Β· FSM terminal Β· ownership
```
The key post-quantum security property (ADR-002):
```
theorem state_preservation :
Step P (l₁, s₁) (lβ‚‚, sβ‚‚) β†’ s₁ = sβ‚‚
The governance layer is FORMALLY INERT with respect to state.
A quantum adversary with full control of the navigator
CANNOT touch the cryptographic state.
Not policy. TYPE.
```
---
## Trust Gate Invariants
```
╔═══════════════════════════════════════════════════════════╗
β•‘ GATE RULE BLOCKS β•‘
╠═══════════════════════════════════════════════════════════╣
β•‘ Entropy entropy ≀ 0.20 Acting on noise β•‘
β•‘ Writhe W(Ξ²) β‰₯ 2 Incomplete transfer β•‘
β•‘ Reidemeister σ·σ⁻¹ rejected Fake crossings β•‘
β•‘ V1 Trust active ≑ trusted Untrusted execution β•‘
β•‘ Absorbing Halted stays Halted Re-entry after HALT β•‘
β•‘ Cycle cycle ≀ max_cycle Infinite loops β•‘
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
```
---
## Repository Structure
```
carry-agent/
β”‚
β”œβ”€β”€ Cargo.toml carry-fsm crate (AGPL-3.0)
β”‚
β”œβ”€β”€ runtime/
β”‚ β”œβ”€β”€ carry-fsm.rs Core FSM library (7-state DAG)
β”‚ β”œβ”€β”€ braid.rs B₃ braid topology module
β”‚ β”œβ”€β”€ main.rs carry-cli binary
β”‚ β”‚
β”‚ └── quantum/ β—€ SOVEREIGN QUANTUM SIMULATOR
β”‚ β”œβ”€β”€ core.rs StateVector + DensityMatrix + gates
β”‚ β”œβ”€β”€ fsm.rs Quantum governance FSM
β”‚ β”œβ”€β”€ agents.rs Primary/partner agent pairs
β”‚ β”œβ”€β”€ dag.rs Execution DAG + provenance
β”‚ β”œβ”€β”€ icp.rs Integrity Constraint Protocol
β”‚ β”œβ”€β”€ asp.rs ASP constraint solver
β”‚ β”œβ”€β”€ topological.rs Fibonacci anyon simulator
β”‚ β”œβ”€β”€ ftb.rs Fibonacci-Taylor Braids [HYPOTHESIS]
β”‚ β”œβ”€β”€ gitc.rs Governance Invariant Topological Cycle
β”‚ β”œβ”€β”€ emulator_6052.rs Cycle-accurate 6052 emulator
β”‚ β”œβ”€β”€ benchmarks.rs Reference circuit suite
β”‚ β”œβ”€β”€ mod.rs Module root
β”‚ β”‚
β”‚ β”œβ”€β”€ QuantumSpec.agda β—€ Dependent-type spec (Agda)
β”‚ β”œβ”€β”€ QuantumInvariants.lean β—€ 13 invariants, 0 sorry (Lean 4)
β”‚ └── QuantumReference.fs β—€ F# conformance backend
β”‚
β”œβ”€β”€ kernels/
β”‚ β”œβ”€β”€ carry-kernel.pl Original Prolog transition table
β”‚ └── tau-prolog/
β”‚ β”œβ”€β”€ braid_kernel.pl Braid logic engine (ISO Prolog)
β”‚ └── crossing_table.pl Crossing-to-DAG lookup
β”‚
β”œβ”€β”€ logic/
β”‚ └── constraint-graph.xml Constraint graph specification
β”‚
β”œβ”€β”€ modules/
β”‚ └── carry-manifest.json Full manifest (layers, DAG, rules)
β”‚
└── docs/
β”œβ”€β”€ firecarry.png Avatar
β”œβ”€β”€ carry_brand_banner.png Architecture diagram
β”œβ”€β”€ braid_animation.svg Animated braid crossing proof
└── CARRY_ARCHITECTURE.md Architecture specification
```
---
## Run It
```bash
# Full pipeline (FSM + braid proof)
cargo run --bin carry-cli
# Quantum benchmark suite
cargo run --bin carry-cli -- quantum benchmark
# Quantum governance verification (ICP + ASP)
cargo run --bin carry-cli -- quantum verify
# Fibonacci anyon topological simulation
cargo run --bin carry-cli -- quantum topology
# All 14 tests
cargo test
# Inspect FSM state
cargo run --bin carry-cli -- quantum inspect
```
Expected output:
```
═══════════════════════════════════════════════════════════════
CARRY PIPELINE: BOTH PROOFS DISCHARGE
FSM: DETERMINISTIC_COMPILATION_COMPLETE
BRAID: INVARIANT_HOLDS (writhe=2, C3 at pos 0)
═══════════════════════════════════════════════════════════════
β”Œβ”€ QUANTUM BENCHMARK SUITE ──────────────────────────────────┐
Circuit: Bell Qubits: 2 | Gates: 2 | Status: SUCCESS
Circuit: GHZ-3 Qubits: 3 | Gates: 3 | Status: SUCCESS
Circuit: Teleportation Qubits: 3 | Gates: 7 | Status: SUCCESS
Circuit: Deutsch Qubits: 2 | Gates: 5 | Status: SUCCESS
Circuit: Grover-2Q Qubits: 2 | Gates: 12 | Status: SUCCESS
Circuit: QFT-3Q Qubits: 3 | Gates: 10 | Status: SUCCESS
═══════════════════════════════════════════════════════════════
```
---
## The Math
**B₃ braid group** β€” generators σ₁, Οƒβ‚‚, Yang-Baxter:
```
σ₁ Β· Οƒβ‚‚ Β· σ₁ = Οƒβ‚‚ Β· σ₁ Β· Οƒβ‚‚
```
**Writhe invariant** for canonical pipeline Ξ² = Οƒβ‚‚ Β· σ₁:
```
W(Ξ²) = (+1) + (+1) = +2
Ο€(Ξ²): C3 β†’ position 0
Invariant: W(Ξ²) β‰₯ 2 ∧ Ο€(Ξ²)(C3) = 0
```
**Fibonacci anyons** β€” golden ratio quantum dimension:
```
Ο† = (1 + √5) / 2 β‰ˆ 1.6180
tau βŠ— tau β†’ vacuum w.p. 1/φ² β‰ˆ 0.382
tau βŠ— tau β†’ tau w.p. 1 - 1/φ² β‰ˆ 0.618
```
**Zβ‚‚ duality** (proved in Lean 4 + Agda, from order-of-symmetry):
```
D ∘ D = id (duality is an involution)
D(P) β‰  P (no fixed points β€” orbit size exactly 2)
GOTO ↔ COME-FROM (structural mirrors, Zβ‚‚ group of order 2)
```
**State preservation** (proved, 0 sorry):
```
Step P (l₁, s₁) (lβ‚‚, sβ‚‚) β†’ s₁ = sβ‚‚
The navigator cannot touch the payload. By type. Not by policy.
```
---
```
╔═════════════════════════════════════════════╗
β•‘ CARRY: The adversarial twin that proves β•‘
β•‘ your pipeline is honest. β•‘
β•‘ β•‘
β•‘ The compiler says it runs. β•‘
β•‘ The braid says it's real. β•‘
β•‘ The Lean proof says it stays real. β•‘
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
```
---
## License
AGPL-3.0-only
Copyright (C) 2026 Ahmad Ali Parr, Jessica L. Williams / SNAPKITTYWEST
<p align="center">
<img src="docs/firecarry.png" alt="Firecarry" width="80px" />
</p>
### πŸ’Ό Commercial License
Snapkitty code is free and open under **AGPL-3.0** for open-source use. Building a commercial product or service? A **proprietary commercial license** from Snapkitty Collective LLC lets you ship this code without the AGPL's source-sharing and network-use obligations.
**[β†’ Get a commercial license](mailto:A.parr@belespritdaccord.uk?subject=Commercial%20license:%20carry-agent)** Β· A.parr@belespritdaccord.uk