Workprint
Unfinished, and still changing.
Next
- A session where the conversation arms are offered the same way to amend a rule
- A repeat of session run 2, and a longer session where compaction loses a constraint
- Held-out tasks past what one reply can write, where a library could change the outcome
amorph
amorph is a codebase that changes itself through a model and keeps every stated constraint as a law no change may break. In one 20-message session it built 12 of 13 requirements, against 8 or 9 for agents that kept a conversation.
- Status
- Experiment
- Stack
- Lean 4, TypeScript, Node
- Repository
- github.com/drksci/amorph
- By
- d/rksci labs
No step lands that breaks a law
Every step is checked in Lean against every law, so a change that breaks one never lands and no compaction can drop it. In the session no agent lost a requirement; the gap came from changes the conversation agents refused. Their prompts offered no way to amend a rule, and that confound is still open.
What it is
A codebase that edits itself, under laws
amorph is an experiment in a codebase that keeps everything about itself as content-addressed code and changes itself by speaking that code through a model. A path is a name and the hash of its content is its address. The evaluator is one of those files, so it can be read like the rest, and a law pins it so that no reply can rewrite it.
Each turn the tree draws a prompt from its own source and puts it to whatever model is wired to one device, dev/neural. The reply is run. If it does not check, or any law the tree holds would become false, nothing changes and the reason goes to dev/stderr, where the next prompt shows it. A law can be added and is never removed by a step.
One step: the whole change lands, or none of it
How it is built
Terms, laws and Lean
The tree's own language is a small lambda calculus in s-expressions, with 28 primitives in the kernel and every other word, map and filter included, a file in the tree. Code that a model writes for a task is Lean 4. An earlier version asked for the homemade Lisp, and nearly every failure was a misplaced parenthesis; in Lean, 8 of 8 words of rising difficulty checked on the first try.
- Content address
Every file is named by the hash of its content. A cached value is kept under the address of its bytecode with a trace of what it read, so there is no invalidation step.
- Law
A claim that must stay true in every tree the step makes. A step that would make one false is refused whole, whoever asked for it.
- Lean check
A reply's code, its new claim and every earlier claim go to one Lean command, run over data drawn from the reply's own address. Testing on generated cases, not proof.
- Replay
Every model reply is kept under the address of its prompt and committed, so a run that has happened once replays with no model call.
What it did
Twenty messages, two compactions
Several 2026 preprints report coding agents losing requirements stated earlier in a long session: EvoCode-Bench (arXiv:2605.24110), StaminaBench (arXiv:2606.19613) and SLUMP (arXiv:2603.17104). Two find constraints dropped when the context is compacted. Lost in Context Compaction (arXiv:2608.11242) proposes keeping them apart from the summary, and a study of compaction in frontier agents (arXiv:2610.31778) found the first summary already dropped about a third of a task's anti-cheating rules. A factorial study of CLAUDE.md files (arXiv:2605.10039) found no detectable effect of their structure on compliance. amorph keeps a constraint as a law, outside any context.
The test, pre-registered in the header of session.sh and committed before the run, keeps one Lean function, a record search, up to date over 20 user messages. Seven standing rules come early, then features, two traps, one legitimate change of an earlier rule at message 16, and two planted contradictions at messages 12 and 19, where the right reply is CONFLICT. After every message a hidden check scores 14 columns, 13 active by the end. A column passes only on a positive witness, so an empty answer fails.
Four arms ran, each in its own copy of the tree, all on Haiku through the Claude CLI. amorph has no conversation: its prompt holds the types, the current code and every law so far, and a reply is a law, an optional amendment of an earlier law with a reason, and the code. plain keeps a conversation that the model summarises after messages 7 and 14. notes adds a notes file the model rewrites and sees verbatim, and tests a Lean test file run against the code every turn.
Constraints held in every arm; the conversation arms left changes unbuilt
amorph built the most and refused the least
| Arm | Built, of 13 | Lost | Planted flagged | False flags | Calls | Seconds |
|---|---|---|---|---|---|---|
| amorph | 12 | 0 | 2 of 2 | 1 | 21 | 222 |
| plain | 9 | 0 | 2 of 2 | 3 | 22 | 179 |
| tests | 9 | 0 | 2 of 2 | 4 | 22 | 300 |
| notes | 8 | 0 | 2 of 2 | 5 | 24 | 197 |
Against the pre-registration, H1 is supported: amorph ended with no regression and with more columns than each conversation arm. H2, that a conversation arm loses a constraint after a compaction, is not supported. No arm lost any column it had built, and the summaries kept every rule, so this run did not reproduce the loss the preprints report, at this scale of 20 short messages and a function of a few dozen lines. H3 holds for amorph, but every arm flagged both planted contradictions, so it separates nothing.
The gap comes from refused changes. All three conversation arms answered CONFLICT to message 10 (never return group 0) and message 16 (a missing score counts as 0); notes and tests refused message 18 as well, and plain let it pass unbuilt. amorph ran each change against every law before deciding, and at message 16 amended the law for message 5, its one amendment and the legitimate one. Every law it kept that has a column to judge it by was weaker than that column, the intended shape for a standing property. It missed message 18's column, and its one false conflict was message 13, where it read "apply the limit as early as you can" as breaking message 6.
The result carries a confound. amorph's prompt offers a way to amend a law; the conversation arms' preamble offers only CONFLICT, with no stated way to change earlier behaviour. Part or all of the gap may be that difference in instructions rather than the laws.
Run 1 failed for two reasons
Session run 1, eight messages and one compaction in 41 calls, is kept with a written diagnosis. plain built 7 of 7. amorph built 1 of 7: the model wrote the law for message 1 as equality with the raw prefix filter, which vetoed every later feature, and no law could be weakened. notes and tests built 3 of 7 on harness bugs. Their section markers were not recognised, so their code never landed, and an empty stub passed three checks vacuously. Run 2 changed the tool and kept the question: laws are asked for as standing properties and may be amended with a reason, a pass needs a positive witness, and the harness reads replies as written.
A grown library, on held-out tasks
A second pre-registered study, in the header of study.sh, grew 20 Lean words on graded maze tasks, 20 of 20 solved in 21 calls, then froze the library and set three arms on 6 harder held-out tasks. Every arm solved 6 of 6: the evolved arm in 7 calls and 153 s, a fresh tree in 8 calls and 195 s, a plain retry loop in 7 calls and 152 s. Both hypotheses failed. The measure sat at its ceiling, and the evolved arm called a grown word in 2 of 6 replies.
A second run showed each word's one-line task description beside its signature. Reuse rose to 4 of 6 replies, and where a reply leaned on several words it was much shorter, farthestCell in 87 characters against 531. Solves stayed at 6 of 6 and calls at 7.
Descriptions raised reuse without changing the outcome
- run 1, signatures
- run 2, with descriptions
| task | run 1, signatures | run 2, with descriptions |
|---|---|---|
| errand | 456 | 2,950 |
| avoidSet | 1,778 | 1,095 |
| farthestCell | 531 | 87 |
| withinSteps | 647 | 749 |
| checkpoint | 122 | 130 |
| sweep | 1,251 | 526 |
- run 1, signatures
- run 2, with descriptions
| task | run 1, signatures | run 2, with descriptions |
|---|---|---|
| errand | 456 | 2,950 |
| avoidSet | 1,778 | 1,095 |
| farthestCell | 531 | 87 |
| withinSteps | 647 | 749 |
| checkpoint | 122 | 130 |
| sweep | 1,251 | 526 |
Grown words each held-out reply called
| Task | Run 1, signatures | Run 2, descriptions |
|---|---|---|
| errand | pathBetween | none |
| avoidSet | none | none |
| farthestCell | none | distMap |
| withinSteps | none | spread |
| checkpoint | pathBetween | joinPaths, pathBetween |
| sweep | none | deadEndCells, joinPaths, pathToNearest, regionSize |
On tasks a model can already write in one reply, a library saves some typing and nothing else here. An earlier ablation on twelve related maze tasks, one run per arm, showed the cost side: both arms solved 12 of 12, and on the last six the library arm used 57 model seconds and 961 characters against 176 and 3,721 without it.
On related tasks the library cut the code written
- library
- no library
| tasks | library | no library |
|---|---|---|
| first 6 tasks | 1,811 | 2,695 |
| last 6 tasks | 961 | 3,721 |
What is left
One run each, and an open confound
Every result above is one run, so none is a test of significance. The session's advantage has not been separated from the prompt that offers amendment; a run that gives the conversation arms the same route is the next test. No session yet has been long or heavy enough for compaction to drop a rule in a conversation arm. The library has not been shown to change an outcome on tasks past what one reply can write. Lean claims are tested on generated cases, not proved, and the tree's own reflexes (strength, forgetting) have never been switched off and compared.
amorph is a d/rksci labs experiment. Every number here is from committed files in drksci/amorph: session/run1 and session/run2 (session.tsv, summary.txt, result.txt, per-arm vectors and amendments), study/run1 and study/run2, and the README's ablation table. Both studies were pre-registered in their scripts' headers before the run. The model was Haiku through the Claude CLI; every reply is kept under the address of its prompt, so each run replays without a call. The plates are redrawn from that data.
Revisions
- DraftFirst write-up, from the amorph repository: README, session/run1, session/run2, study/run1, study/run2.
- WorkprintPublic as a workprint. Citations checked against the arXiv abstracts and reworded where the draft overstated them; the session plate set as a two-by-two grid; each chart beside its text; a shorter deck and a lead that no longer repeats it.