drksci

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
By
d/rksci labs
Index
  1. No step lands that breaks a law
  2. A codebase that edits itself, under laws
  3. Terms, laws and Lean
  4. Twenty messages, two compactions
  5. Run 1 failed for two reasons
  6. A grown library, on held-out tasks
  7. One run each, and an open confound

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

TASKa messagePROMPTdrawn by the treeMODELcode and a lawevery law true?LANDSBOUNCEreason on dev/stderryesnoone retrynext message
Figure 1A reply that compiles but breaks an earlier law bounces like one that does not compile.

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

amorph12 of 13 at message 201 prefix2 not deleted3 by id4 unique id5 minScore16 no score = 06 limit last7 group9 skip10 no group 011 at most 514 id 9 or less18 top score20 together1712141619plain9 of 13 at message 201712141619tests9 of 13 at message 201 prefix2 not deleted3 by id4 unique id5 minScore16 no score = 06 limit last7 group9 skip10 no group 011 at most 514 id 9 or less18 top score20 together1712141619notes8 of 13 at message 201712141619
Figure 2Filled holds, hollow was stated and not built, blank is not yet stated or retired. Dashed lines are compactions; triangles are CONFLICT replies, hollow where none was planted.

amorph built the most and refused the least

ArmBuilt, of 13LostPlanted flaggedFalse flagsCallsSeconds
amorph1202 of 2121222
plain902 of 2322179
tests902 of 2422300
notes802 of 2524197
Session run 2, one run, 89 of 112 allowed calls. Built is columns holding at message 20; lost is columns that held and later failed.

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

Characters written per held-out taskCharacters written per held-out task. Horizontal bar chart, 6 bars from errand to sweep, 2 series. run 1, signatures: 456 at errand, 1,251 at sweep, lowest 122 at checkpoint, highest 1,778 at avoidSet. run 2, with descriptions: 2,950 at errand, 526 at sweep, lowest 87 at farthestCell, highest 2,950 at errand.05001,0001,5002,0002,5003,000errandavoidSetfarthestCellwithinStepscheckpointsweep4562,9501,7781,095531876477491221301,251526
  • run 1, signatures
  • run 2, with descriptions
Characters written per held-out task: data
taskrun 1, signaturesrun 2, with descriptions
errand4562,950
avoidSet1,7781,095
farthestCell53187
withinSteps647749
checkpoint122130
sweep1,251526
Characters written per held-out taskCharacters written per held-out task. Horizontal bar chart, 6 bars from errand to sweep, 2 series. run 1, signatures: 456 at errand, 1,251 at sweep, lowest 122 at checkpoint, highest 1,778 at avoidSet. run 2, with descriptions: 2,950 at errand, 526 at sweep, lowest 87 at farthestCell, highest 2,950 at errand.05001,0001,5002,0002,5003,000errandavoidSetfarthestCellwithinStepscheckpointsweep4562,9501,7781,095531876477491221301,251526
  • run 1, signatures
  • run 2, with descriptions
Characters written per held-out task: data
taskrun 1, signaturesrun 2, with descriptions
errand4562,950
avoidSet1,7781,095
farthestCell53187
withinSteps647749
checkpoint122130
sweep1,251526
Figure 3Characters each reply wrote, evolved arm only. Run 2's errand wrote its own search in 2 calls; every task was solved in both runs.

Grown words each held-out reply called

TaskRun 1, signaturesRun 2, descriptions
errandpathBetweennone
avoidSetnonenone
farthestCellnonedistMap
withinStepsnonespread
checkpointpathBetweenjoinPaths, pathBetween
sweepnonedeadEndCells, joinPaths, pathToNearest, regionSize
Read from the kept replies; from the amorph README and study/run1, study/run2.

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

Characters of code written, library on and offCharacters of code written, library on and off. Bar chart, 2 bars from first 6 tasks to last 6 tasks, 2 series. library: 1,811 at first 6 tasks, 961 at last 6 tasks, lowest 961 at last 6 tasks, highest 1,811 at first 6 tasks. no library: 2,695 at first 6 tasks, 3,721 at last 6 tasks, lowest 2,695 at first 6 tasks, highest 3,721 at last 6 tasks.01,0002,0003,0004,000first 6 taskslast 6 tasks1,8112,6959613,721
  • library
  • no library
Characters of code written, library on and off: data
taskslibraryno library
first 6 tasks1,8112,695
last 6 tasks9613,721
Figure 4Characters of code, one run per arm. Both arms solved all twelve tasks, which were built to be related, unlike the held-out study.

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

  1. DraftFirst write-up, from the amorph repository: README, session/run1, session/run2, study/run1, study/run2.
  2. 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.
  • Autonomous Agents
  • Lean
  • Evaluation
  • Program Synthesis