Overview

The Allternit Self-Improve crate provides scaffolding for an evolutionary self-improvement loop in the agents-as-diffs pattern. A meta-agent rewrites a task-agent’s code, and every generation is stored as a diff from its parent. A protected evaluation surface can never appear in a produced diff, and a staged evaluation gate runs a cheap subset before paying for a full evaluation.

Base URL

The crate is consumed as a Rust library. It does not expose HTTP endpoints directly.

Components

The pattern

  1. LineageArchive::record stores each generation as { id, parent_id, patches, valid, score }.
  2. ParentSelection chooses the next breeding parent:
    • Latest
    • Best (highest score)
    • ScoreProportional (sigmoid-weighted sampling with an over-use penalty)
  3. WorkingCopy::create scratch-copies a target repo, excluding protected paths.
  4. WorkingCopy::apply_patches runs git apply over the reconstructed patch chain.
  5. WorkingCopy::finalize_diff force-resets protected paths and filters the resulting diff.
  6. StagedGate runs a ValidityCheck, then a subset Evaluator::eval_subset, then the full evaluation if all staged scores are positive.

Safety rules

  • Protected paths can never appear in a produced diff. Filtering is verified by re-scanning the diff for the protected path string.
  • No network assumptions. The crate only invokes local git apply and git diff.
  • Validity before evaluation. A generation that does not compile or typecheck never reaches an evaluator.
  • Staged before full. Full evaluation only runs after every staged score clears the > 0 bar.

Configuration

JSON examples

Record a generation

Reconstruct a working copy

Run staged evaluation

Error codes

Harness improve loop

Coming in the next release. harness-improve is a repo tool, not part of an installed app.
harness-improve (crate services/self-improve-gizzi) uses this scaffolding to propose changes to Gizzi’s own prompts and limits. It runs on your own model access. A person approves every change.

Harness view

Only the editable files are copied into a temp dir:
  • session/prompt/*.txt
  • tools/builtins/*.txt
  • session/limit.ts
  • session/guardrail-defaults.ts
The suite, the graders and the tests are never in the view. The proposer sees the failed dev cases, not hidden tests.

Allowlist and protected suite

A patch is valid only if it passes all of these:
  • It touches only allowlisted files.
  • The two .ts files change numbers only, within bounds.
  • The guard tests pass: byte caps, vendor ban, injection wording, context breakdown and guardrails.
The shared suite in domains/agent-evals/gizzi/ is protected. See Gizzi evals.

Staged gate, then full gate

The candidate runs the protected suite live. The staged gate runs a fraction of the dev split. The full gate adds the holdout split. Staged results are cached.

Accept rule

A candidate is accepted when the gate is valid, the report comparison is ok, and at least one more case passes than in the baseline. The tool shows the price first. --max-usd is a hard stop. --max-generations defaults to 1.

Output

The output is a patch, report.md and a lineage record. --open-pr opens a draft pull request and is opt-in. The tool never merges.