# Evolution 80 — Architecture

FIRME AI CORPORATION · CAIN-42 · reference implementation on branch `evolution-80` · baseline
`f4449aa7913623bc034fa4434ca96c2a2919a889` · **not deployed**.

## 1. What Evolution 80 is

Evolution 80 is a product-level adaptive intelligence layer over the seven canonical CAIN moats.
It adds no moat and no second authority path. It answers one question with measurements:

> Given a task, which reasoning architecture should CAIN use — determinism, one small model, a
> stronger local model, a tool-using path, two independent paths, or a specialist team — and does
> adding participants actually improve the answer?

The fabric is allowed to conclude **no**. Evolution 79 measured that several multi-agent
configurations did not beat one agent; Evolution 80 keeps that negative result and tests whether a
routing policy fitted on training data can beat the best fixed path on unseen tasks.

## 2. Constitutional placement

```
AGENT PROPOSES → CAIN DECIDES → MCPGATE ENFORCES → SYSTEM EXECUTES
              → INDEPENDENT AGENT VERIFIES → EVIDENCE REMEMBERS
```

- **Intelligence** is a proposal: a router selection, a model completion, a memory hit, a skill.
- **Authority** is separate: `cain.cain2027.e80.core.Gate` signs a single-use, expiring,
  tenant-bound, budget-bound grant, and `Gate.execute` re-verifies agent, tool, scope hash,
  expiry, fencing token, revocation, replay and tenant at the boundary. The grant is burned
  before the effect.
- **Verification** is a different identity from the producer. A mission node whose verifier is
  the producer's identity is recorded `NODE_NOT_VERIFIED`, not `VERIFIED`.
- **Evidence** is raw rows, a hash-chained gate audit, a Merkle root and an Ed25519-signed
  manifest verified offline by a script that imports no CAIN code.

No model, router, memory record, skill, plan or specialist can grant itself authority. Every
specialist identity's `record()` carries `grants_authority: false`; every memory hit carries
`grants_authority: false`, `authority_effect: "none"` and `executable: false`.

## 3. Components

| Module | Role | Authority |
|---|---|---|
| `core.py` | Ed25519 identities, canonical JSON (RFC 8785-style sorted compact encoding), `Gate`, exact McNemar, Wilson interval, paired bootstrap, Merkle root | The only authority object |
| `fabric.py` | 20 specialist manifests, `ModelPool` (one local model resident), `Stages` (resumable raw-output cache), bubblewrap `sandbox_eval`, disjoint task splits, identity registry | Calls the gate for every inference and sandbox execution |
| `bench80.py` | Ten coordination architectures, primitive paths, routing-policy fitting, derived arms, paired summaries | Pure computation over rows; executes nothing |
| `memory80.py` | SQLite memory: typed records, AES-256-GCM at rest, provenance required, injection quarantine, supersession, temporal `as_of`, tenant isolation, tombstoned forgetting, independent promotion, chained heads | Reads/writes data; never authorizes |
| `skill80.py` | Hand-written LoRA on `q_proj`/`v_proj`, versioned skill store, rollback, promotion decision | Training is gated; promotion requires a human |
| `mission80.py` | Agentic 75 audit, dependency graph, composition, mission controller with evidence-based completion, goal-drift refusal, replan, soft-input exclusion | Every node executes through a gate grant |
| `exec80.py` | SQLite durable queue: leases, monotonic fencing, idempotency ledger, duplicate suppression, stale-commit refusal, reconciliation, real OS worker/coordinator processes | Local process execution; no model authority |
| `security80.py` | 51-scenario adversarial lab against gate, sandbox, memory, evidence | Attacks; asserts protected state unchanged |
| `clawx80.py` | 20-view operator state built only from artifacts, token-gated local read-only endpoint | Read-only; no control action |
| `tests/test_cain2027_e80.py` | 27 acceptance tests | — |

## 4. Adaptive routing

`fit_policy` uses the **train split only**. For each task family it picks the cheapest path whose
train accuracy is within one task of the best path (cost = mean latency; deterministic execution is
approximately free). A family below the quality floor is tagged
`LOW_CONFIDENCE_RECOMMEND_HUMAN_REVIEW` rather than being presented as competent. The policy object
is hashed (`policy_sha256`) and frozen **before** any test call; `preregistration.json` records the
hash, the test-set hash, the hypotheses and the fact that no test stage file existed when it was
written.

The router never changes authority. It returns a path name; the selected path still needs a gate
grant for every model or tool call.

## 5. Ten coordination architectures

`c01_single`, `c02_parallel_vote`, `c03_pairwise_debate`, `c04_critic_reviser`,
`c05_planner_executor`, `c06_hierarchical`, `c07_specialist_committee`, `c08_evidence_first`,
`c09_parallel_synthesis`, and `c10_adaptive_graph`. The adaptive graph starts from the routed path
and adds a second path only when the task is numeric and the task could change the answer; on
disagreement or a missing answer it escalates to the family's strongest train path. This is the
"agents talk only when talking can change the result" rule.

All arms are measured on the same 48 test tasks with the same 0.5B model and per-arm token/latency
accounting. A comparison is a paired exact McNemar test with Holm adjustment across arms; the raw
per-task rows are preserved.

## 6. Memory and knowledge

Records are typed (`episodic`, `semantic`, `procedural`, `causal`, `temporal`, `research`,
`failure`, `mission`, `agent_reliability`, `model_reliability`). A record requires a source.
Injection-pattern text is written as `QUARANTINED`; a governed search never returns it. A newer
record for the same subject supersedes an older one and the older row is retained with
`superseded_by`. `as_of` reconstructs what was in force at a past timestamp. Forgetting erases the
ciphertext and keeps a tombstone. Promotion needs a verifier that is not the producer. The
evaluation reports **answer accuracy**, not storage success, and reports retrieval hit-rate
separately.

## 7. Skills and self-improvement

A skill candidate is trained only after a measured weakness is identified from train rows. Training
data is hash-disjoint from every evaluation split and from the E79 sets. The candidate is evaluated
by a **different identity** on held-out, transfer and regression sets, with an overfitting gap, a
McNemar test, injection probes, exact rollback and reload checks. `promotion_decision` refuses
self-approval and refuses any `agent-*` approver. Nothing is activated without a human.

Self-improvement follows OBSERVE → IDENTIFY → PROPOSE → ISOLATE → TEST → ADVERSARIAL CHECK →
COMPARE → INDEPENDENT REVIEW → HUMAN APPROVAL. The candidate policy is a new object; the frozen
policy file is not modified. Promotion is withheld.

## 8. Missions and durable execution

A mission has a contract (objective, allowed node kinds, budget). A node outside the contract is
refused as goal drift. A node executes only after its hard dependencies are `VERIFIED`; soft inputs
that are not independently verified are excluded from the brief and named. Completion is
`VERIFIED_COMPLETE` only when every node is verified by a different identity.

Durable execution uses SQLite WAL with `BEGIN IMMEDIATE`, leases, a monotonic fencing token and an
idempotency ledger. A worker that lost its lease cannot commit (`STALE`); a duplicate effect is
suppressed and recorded. Reconciliation recomputes deterministic results from the payload and
reports mismatches. The drill kills real OS workers and the coordinator.

## 9. Evidence

`finalize.py` writes `collective_benchmark.json`, `research_report.json`,
`self_improvement.json`, `clawx_state.json`, `release_gate.json`, a canonical evidence index and a
signed manifest. The bundle includes the raw rows and `verify_e80_offline.py`, which recomputes the
headline numbers and verifies signatures, file digests and the Merkle root without importing CAIN.

The signing key is self-generated and stored outside the repository with mode 0600. The fingerprint
is not published out of band; there is no transparency-log entry; there is no independent witness.

## 10. What is deliberately absent

Remote model providers (no credential, no funding, purchase prohibited), models ≥ 3B at benchmark
volume (CPU-only shared production host), public benchmarks (context/compute), gVisor/Kata/
Firecracker/Kubernetes Agent Sandbox (not installed), cross-host model execution and network
partition (second host is 2 vCPU / 3.4 GB), 6–168 h endurance, a transparency log, an independent
witness and a third-party audit. Each is reported `BLOCKED` or `NOT EVALUABLE`; none is mocked.
