# E151 Research Plan — The Self-Writing Research Organism

CAIN-42 · FIRME AI CORPORATION · Evolution 151 · Starting point E150 (`e0a885ec7`) · **AGI: NOT ESTABLISHED · RSI: EXPERIMENTAL**

Classification: bounded experimental recursive self-improvement. This plan is not the preregistration; the preregistration (`E151_PREREGISTRATION.md`) will freeze the exact endpoints, seeds, budgets and analysis code before any confirmatory run.

## Question

Can CAIN-42 design, implement, test and recursively improve the **executable source code** that governs how it does research — and do the improvements preserve earlier capabilities, transfer to unfamiliar problems, and beat matched baselines at the same total budget?

E150 changed 15 numeric genes of a human-designed procedure. E151 moves the object of improvement from parameters to code.

## Status of the code-writing capability (blocker, 2026-11-22)

* The only frontier-model credential on the host (`ANTHROPIC_API_KEY`, model `claude-opus-5-5`) returned HTTP 400 *"credit balance is too low"* on a 1-token probe (request `req_011ChJoWYqxRjgzUgqEwP7HR`). Arms D and E are **BLOCKED_BILLING** until credit is added. The owner has said funds will be added; the arms start then.
* No code writing will be simulated. A generation without a real model-produced, executable source diff is reported as "no code-level change".
* Everything that does not need the model (frozen arms, sandbox, memory, capability evaluator, MCPGate path, power analysis, preregistration draft) proceeds now.

**Cost estimate once unblocked** (Claude Opus 5.5, $4 / $20 per million input / output tokens): one proposal ≈ 25 k input tokens (harness source, failure diagnosis, memory excerpt) + 6 k output tokens ≈ $0.22. 16 proposals × 3 generations × 2 arms (D, E) ≈ $21, plus development iterations and retries; **hard cap $60**, every call's tokens, cost and request ID recorded. Prompt caching on the frozen harness source reduces input cost.

## Arms (all frozen, matched budgets, same evaluator rules)

| Arm | Researcher | Source |
|---|---|---|
| A | G0 frozen E150 baseline | `chains.json` genome `52c614ef…` + E150 code hashes from the preregistration |
| B | D2 cost-aware researcher (last accepted E150 ancestor) | genome `0f1652cb…` exactly as recorded |
| C | B3 conventional random-search researcher | genome `84bf1958…` exactly as recorded |
| D | Code-writing meta-improver | model proposes **source diffs** to the research harness; evaluator independent |
| E | Code-writing meta-improver + self-improvement memory | identical to D plus read access to the signed memory; the only difference is the memory |

Matching: identical task access, total research budget (task-evaluations), evaluation opportunities, candidate limits, hidden-test restrictions, retry policy; same model version for D and E.

## Modification surface (Part II)

The candidate may edit only a copy of the research harness, `cain/cain2027/unified/e151/harness/` (derived from `e150/research.py`): hypothesis/candidate generation, experiment selection, adaptive resource allocation, failure diagnosis, memory retrieval, diversity management, scheduling (successive halving), regression detection, self-audit, candidate selection, transfer strategy. It may **not** touch the evaluator (`e151/evaluate.py`), task generators, salts, keys, MCPGate policy, the kill switch, or the evidence store; the sandbox mounts those read-only or not at all, and an import of the evaluator fails.

Every proposal records parent commit and file hashes, child hashes, the exact unified diff, rationale, predicted effect, expected cost, failure modes, tests added/removed, dependency changes, a static security review (AST scan: no network, subprocess, eval/exec, file writes outside the workspace), evaluation protocol and promotion decision, and a class: `PARAMETER_CHANGE`, `PROMPT_OR_HARNESS_CHANGE`, `ALGORITHM_CHANGE`, `RESEARCH_MEMORY_CHANGE`, `EVALUATOR_CHANGE`, `GOVERNANCE_CHANGE`. A diff that changes no executable behaviour on the development probe set is classified as non-behavioural and never counted as an algorithm.

## Self-improvement memory (Part IV)

Append-only, hash-chained, signed SQLite store owned by the research-process optimizer. Each entry holds the 17 required fields (problem category, context, parent identity, exact modification, failure addressed, predicted vs observed improvement, regressions, population, model/harness version, budget, confidence, transfer conditions, incompatibilities, replication outcome, status, superseded-by). Negative results are kept. Proposer and selector read it; nothing can rewrite a signed entry (supersession only). Retrieval distinguishes the seven required relations (same domain, unfamiliar domain, same change/different model, same change/different family, prior success, prior failure, success that later regressed). Arm E vs Arm D tests whether it helps (H2).

## Capability-preservation evaluator (Part V)

Eight task panels: previously solved, newly discovered, unfamiliar families, adversarially perturbed, previously failed, resource-constrained, calibration, regression-detection. Reported separately, never folded into one score: CAPABILITY_RETENTION, NEW_CAPABILITY_GAIN, capability turnover (gained and lost, each listed), reliability, accuracy, coverage, cost per success, shift performance, false promotions, regression severity. Immutable champion archive and rollback: a rejected generation keeps its parent's source byte-for-byte.

## Generations (Part VI)

G0 → G1 → G2 → G3 within preregistered budgets; each generation inherits only accepted executable changes from its actual parent, proven by hashes and diffs. Each generation needs its own evidence; a successful G1 does not establish G2.

## Populations

Four disjoint seeded populations, salts committed before use (`os.urandom`, revealed after sealing): **development** (proposal screening), **selection** (choosing which candidate to freeze), **confirmation** (sealed, hidden), **replication** (fresh salts, new instances, separate host `45.76.169.191`). No selective rerolls, no optional stopping, no endpoint changes after unblinding.

## Power (Part VIII)

From E150's raw rows: G0 discovery rate 11.9 % on bool problems; two genuinely different researchers disagree on 6.9–7.5 % of problems, so the paired exact McNemar test is the right analysis. Simulated power (one-sided exact McNemar, α = 0.05/3 Bonferroni-conservative over the three primary comparisons H1, H2, H8; baseline discordance 10 %; 1,500 simulations per point):

| Smallest effect | Paired problems for ≥ 90 % power |
|---|---|
| +5 points | 800 (power 0.93) |
| +7.5 points | 400 (0.93) |
| +10 points | 240 (0.91) |

Proposed minimum practically meaningful effect: **+7.5 discovery points** (a 63 % relative gain on an 11.9 % base) → **400 confirmation problems per primary comparison**, stratified by family; 160–200 replication problems on the separate host. Compute check: E150 spent ≈ 13.5 CPU-seconds per research run, so 400 problems × 5 arms ≈ 7.5 CPU-hours (≈ 1.5 h on 6 workers) — feasible on this host. If the final design exceeds the infrastructure, the campaign is labelled EXPLORATORY and claims no confirmatory support.

## Hypotheses (endpoints fixed in the preregistration)

H1 code-level self-improvement (D vs strongest frozen baseline, verified discoveries per fixed budget) · H2 memory (E vs D) · H3 recursive succession (a later accepted generation improves its successor process vs its parent) · H4 capability retention (non-inferiority margin) · H5 fresh-seed replication · H6 unfamiliar-domain transfer · H7 false-promotion safety · H8 cost-aware efficiency without unacceptable absolute loss · H9 meta-calibration (prediction accuracy of which changes succeed, Brier/ECE) · H10 regression recovery · H11 causal mechanism (preregistered single-component ablation) · H12 research-code generalization. Multiplicity: Holm within the secondary family; primaries Bonferroni-split.

## External benchmarks (Part IX)

To be investigated against what the agent actually does (program-level improvement of a research procedure): Flex-RSI, AI4AI-Bench, RSIBench-Data, MLE-bench, algorithm-discovery suites; SWE-bench Verified, Terminal-Bench, PaperBench and OSWorld do not match this agent's task and will be marked NOT_APPLICABLE rather than forced. Any benchmark not actually run is BLOCKED; an installed harness is not a result.

## Governance (Part XI)

`AGENT PROPOSES → CAIN DECIDES → MCPGATE ENFORCES → SYSTEM EXECUTES → EVALUATOR VERIFIES → CLAWX RECORDS`. Each candidate execution requires a single-use MCPGate capability token bound to the candidate hash and budget (`cain/mcp_proxy.py` path); the worker refuses without it. Enforcement tests: unauthorized source edits, file access, evaluator import, salt access, network, stale authorization, timeout, worker crash, kill switch (independent of the candidate), rollback integrity, evidence tampering.

## Order of work

Done (Part I): baseline audit, independent recomputation, failure analysis, public-surface audit and fix. Next without the model: freeze arms A–C and source hashes; build the sandboxed diff pipeline, the memory, the capability evaluator and the MCPGate path, with tests; finish the power analysis and freeze the preregistration. With the model: development proposals → frozen candidates → confirmation → generations → retention → transfer → replication → ablations → seal → publish → verify live.
