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
LineageArchive::recordstores each generation as{ id, parent_id, patches, valid, score }.ParentSelectionchooses the next breeding parent:LatestBest(highest score)ScoreProportional(sigmoid-weighted sampling with an over-use penalty)
WorkingCopy::createscratch-copies a target repo, excluding protected paths.WorkingCopy::apply_patchesrunsgit applyover the reconstructed patch chain.WorkingCopy::finalize_diffforce-resets protected paths and filters the resulting diff.StagedGateruns aValidityCheck, then a subsetEvaluator::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 applyandgit 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
> 0bar.
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/*.txttools/builtins/*.txtsession/limit.tssession/guardrail-defaults.ts
Allowlist and protected suite
A patch is valid only if it passes all of these:- It touches only allowlisted files.
- The two
.tsfiles change numbers only, within bounds. - The guard tests pass: byte caps, vendor ban, injection wording, context breakdown and guardrails.
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.