# Sleep Consolidation: A Repeated Correction Earns a Diagnosed, Tested Repair: v6.5 → v7.0

From v6.5 (19 Jun) to v7.0 (12 Oct): 11,588 words to 8,968 words, 8,645 words in new or rewritten paragraphs and 11,265 taken out, 432 paragraphs changed.

## Change note of v7.0

**Rewritten from scratch: a correction climbs a ladder**

Almost every sentence is new (97% of the text changed), and the subtitle becomes "Teaching an AI Agent Once". The 30-day production log, the cron schedule and the procedural extensions are gone. The paper now starts from a person repeating the same correction to an assistant, and proposes a design instead of reporting a deployment.

- The owner's correction is the main learning signal, sorted by cause before it becomes a rule.
- A rule ledger keeps one row per rule with every time it recurred.
- A four-rung ladder: a note found on demand, text loaded with the task, text loaded every turn, then a check in code. A rule climbs one rung each time it recurs.
- Two speeds: a reflection right after the task, and a nightly audit.
- The always-loaded file is pruned by how a rule is enforced, not by age, and only the owner may loosen a rule.
- It closes with a list of tests, since the design is not yet built.

## Changed paragraphs

Marks: [-removed-] {+added+}.

### Abstract

[-Large language model agents are stateless by nature -- every session begins at zero. Existing approaches to persistence usually rely on fine-tuning, retrieval-augmented generation, or larger context windows. We present a different mechanism observed over 30 days of production operation: **structured nightly prompt cycles** that produce compounding behavioral improvement without weight updates, fine-tuning, or architectural changes. A personal AI assistant running 12--13 autonomous cron jobs exhibited a decline in tracked incidents from 14 (weeks 1--2) to 3 (weeks 3--4) across six error categories -- a 79% reduction overall, with five of the original categories reaching zero recurrence while a new, higher-order error class emerged. The model did not change. The files it read did.-]

### Abstract

[-This is what sleep gives the human brain. During sleep, the hippocampus replays the day's experiences and broadcasts them to the neocortex, which integrates them into durable knowledge -- the reason a student who sleeps after studying outperforms one who crams and stays awake. The cerebellum, in parallel, refines motor skills through repetitive offline practice, which is why a piano piece learned at night plays more fluently the next morning. Sleep Consolidation is our attempt to give an AI agent the same offline period: a dedicated window where the day's experiences are reviewed, errors are identified, and the rules governing tomorrow's behavior are quietly refined.-]

### Abstract

[-The central insight is blunt: **scattered memories are almost useless.** Raw accumulation does not create intelligence. The value comes from **sorting by use-case** so retrieval is cheap, relevant, and actionable. Memories organized by **purpose rather than chronology** let the system pull the right rule at the right moment. Prompts that have learned from yesterday's mistakes do more than remember the past; they reshape future behavior.-]

### Abstract

[-We formalize this as **Sleep Consolidation** -- a system in which explicit operating prompts are iteratively refined through experience until they produce increasingly automatic, high-quality behavior. We identify three core mechanisms: (1) **failure-driven prompt mutation**, where operational errors trigger targeted prompt refinements (14 mutations documented, all traced to specific incidents); (2) **fractal depth calibration**, where the system learns to allocate metacognitive effort in proportion to task significance; and (3) **cross-cron knowledge transfer**, where lessons learned in one autonomous task propagate to all others through shared memory files (5 documented cross-domain transfer events). We then show how the same nightly loop has been extended from declarative memory (rules and facts) to **procedural memory** -- evolving the agent's own recipes, switching failing strategies, and distilling reusable skills.-]

### Abstract

[-We argue that this approach -- prompts that rewrite themselves through structured reflection -- occupies an underexplored middle ground between static prompt engineering and expensive fine-tuning. It is accessible to any agent system with file persistence and scheduled execution. Total reflection overhead: approximately 43,000 tokens per night ($1.17), against an estimated 8 avoided human-intervention incidents over 30 days.-]

### Contributions

[-### Contributions-]

### Contributions

[-1. **The Sleep Consolidation framework**: a formal architecture for scheduled, autonomous prompt self-improvement through failure-driven mutation, abstraction-level encoding, and cross-task propagation. 2. **Production evidence over 30 days**: 14 documented prompt mutations, 5 error class extinctions, 5 cross-cron transfer events, and token-cost analysis from a real personal assistant deployment. 3. **The fractal depth calibration mechanism**: a prompt-encoded heuristic for allocating metacognitive effort that is itself subject to refinement -- a self-similar cognitive policy. 4. **Procedural-memory extensions**: a recipe-evolution loop with empirical fitness and a never-delete archive, a failure-count strategy-switch trigger, a Voyager-style skill library with inline invocation and compose-from-library, and a per-step struggle-sharpening signal read off the live plan archive -- all driven by the same nightly consolidation step (Section 6). 5. **Nine design principles** for building self-improving prompt ecosystems, derived from operational failures, plus a mutation taxonomy and honest negative results. 6. **Algorithm 1**: a reproducible nightly reflection loop with explicit inputs, outputs, and decision gates.-]

### Abstract

{+Tell a good new colleague something once and it sticks. If it slips, you say it again, and they stick a note on their screen. By the third time it is no longer something they have to remember. It is how they work, the way a cyclist stops thinking about balance. In your own brain the cerebellum is where a practised movement turns automatic, and a night's sleep is when much of that settling happens.+}

### Abstract

{+AI assistants get corrected every day, and their owners keep repeating themselves. The model's weights cannot change, so each lesson is written down as text: a note in a memory store, or a line in a file the assistant loads on every turn. But text is advice. The model weighs it against everything else in front of it, a long list of advice is followed less well than a short one, and the clean-ups that keep the list short push old lessons out of sight. So the owner teaches the same rule again.+}

### Abstract

{+We propose a design in which each correction becomes a rule with its own row in a ledger, and the rule climbs a ladder each time it recurs: a note found on demand, then text that loads with the task, then text that loads on every turn, then a check in the path of action that blocks, rewrites or asks before the mistake is made. Learning runs at two speeds. A short turn right after the task records the correction the same day, and a nightly audit counts recurrences, moves rules up or down and drafts the checks.+}

### Abstract

{+For the owner, a second correction is what makes a rule harder to miss, and a third turns it into a check. The file read on every turn stays short, because a rule leaves it only when a check carries it, never for being old. Every change to what each turn loads waits for the owner's approval in one morning report: the loop may tighten on its own, and only the owner loosens. Every learning loop keeps its own accounts and goes dormant when it stops paying. This is a design for the next build, and the last section names the tests that would prove it.+}

### Abstract

{+If it holds, you teach your assistant a thing once or twice, and never a third time.+}

### 1. Introduction

{+## 1. Introduction+}

### 1. Introduction

{+On a Monday the owner writes to his assistant in Finnish and gets an answer in English. He says so: reply in the language I write in. The assistant apologises and saves a note. Ten days later it happens again. The note sat in a memory store, and nothing brought it into that turn. This time the rule goes into the file the assistant reads on every turn. A month later it happens a third time. The file had grown long, and an older line in it, written for a different situation, said to answer in English. The owner gave one instruction three times, and the assistant wrote it down three times.+}

### 1. Introduction

{+Writing things down was never the problem. Each time, the lesson was saved. What the assistant lacked was a way to make a lesson that had already failed once bind harder the next time, and a way to notice that it had failed.+}

### 1. Introduction

{+This paper is about that missing step: how an agent whose model cannot change turns experience into behaviour that stays changed.+}

### 1.1 What the brain suggests

{+### 1.1 What the brain suggests+}

### 1.1 What the brain suggests

{+The brain learns at two speeds. In the complementary learning systems account (McClelland et al., 1995), a fast learner, the hippocampus, records an episode at once, and a slow learner, the neocortex, folds many episodes into durable knowledge, much of it during sleep, when recent experience is replayed. The cerebellum adds the step that matters most here. A movement you once had to think through becomes one you no longer think about at all. Sleep helps with that too: people who practise a finger sequence in the evening play it faster the next morning without any further practice (Walker et al., 2002).+}

### 1.1 What the brain suggests

{+Learning to ride a bicycle passes through three forms of the same lesson. First it is an instruction you have to recall ("look ahead, not at the wheel"). Then it is a reminder you hold in mind while you ride, which costs attention. Finally it is balance, which fires before you could think of it. An agent can hold a lesson in the same three forms: a note it finds when it searches, text it keeps in front of it, and a check that runs at the moment of action whether the model remembers or not. That last step gives this stage its name in the series, CEREBELLUM. Like every brain name in the series it is an aid to reasoning, not an anchor: we take the functions worth copying and leave the rest.+}

### 1.2 Why the obvious fixes fail

{+### 1.2 Why the obvious fixes fail+}

### 1.2 Why the obvious fixes fail

{+**Text binds weakly.** A model reads its instructions as context and weighs them against everything else in the turn. Claude Code's documentation says it in as many words: its memory files are treated "as context, not enforced configuration", and to block an action for certain you use a hook (Anthropic, 2026a). Safety engineering reached the same conclusion long ago. The hierarchy of controls ranks rules people must remember below controls built into the equipment, because the former "require significant and ongoing effort" (NIOSH).+}

### 1.2 Why the obvious fixes fail

{+**Text competes for attention.** Every line in a file the model reads on each turn makes every other line a little weaker. On IFScale, accuracy falls as the number of instructions in a prompt grows, and earlier instructions are followed more than later ones (Jaroslawicz et al., 2025). A file that grows by one lesson a day gets worse at all of them.+}

### 1.2 Why the obvious fixes fail

{+**Learning only at night is late.** If the lesson waits for the night, a correction given in the morning can be needed again that afternoon, and the owner gives the same instruction twice in one day. A lesson has to take hold in the session where it was taught.+}

### 1.2 Why the obvious fixes fail

{+**Pruning by age or size throws away rules that still matter.** Keeping the always-loaded file short is right. Choosing what leaves it by date or by bytes moves a rule out of sight, and a rule the agent can no longer see gives it no reason to look it up. Compression that can be undone does not help, since nothing asks for the original.+}

### 1.2 Why the obvious fixes fail

{+**The learner learns from the wrong signal.** A network outage is not fixed by a paragraph of advice. Text a harness wraps around the owner's words (a time stamp, an appended instruction, another agent's message) is not the owner speaking. An outcome column that never changes teaches nothing while looking like data.+}

### 1.2 Why the obvious fixes fail

{+**Silence hides failure.** A night that found nothing to learn and a night that never ran leave the same empty trace, so a learning loop can be dead for weeks before anyone asks.+}

### 1.3 What this paper proposes

{+### 1.3 What this paper proposes+}

### 1.3 What this paper proposes

{+We propose a design built around one idea: **a rule that recurs moves one rung up, from a note, to text loaded with the task, to text loaded on every turn, to a check in the path of action, and it leaves a lower rung only when a higher one carries it.** Around that idea:+}

### 1.3 What this paper proposes

{+1. The owner's correction is the main signal, read from his own words with the wrapper removed and sorted by cause, so only real rule gaps become rules (§3). 2. A rule ledger keeps one row per rule, with its purpose, its home and every time it recurred (§4). 3. A four-rung binding ladder, climbed one rung per recurrence, with a cost argument for why a rule should not jump straight to code (§5). 4. Two speeds: a reflection turn right after the task, and a nightly auditor (§6). 5. Pruning by binding, an attention budget for the always-loaded file, an approval gate on it, and one morning report through which every memory stage reaches the owner (§7). 6. The same machinery for procedures and for the texts that machines run on (§8). 7. Accounts for every learning loop, and a rule for retiring the ones that stop paying (§9).+}

### 1.3 What this paper proposes

{+Figure 1 shows the whole loop. §10 follows the reply-language rule from the opening through it, and §12 names the tests. Everything here is a design for the next build.+}

### 1.3 What this paper proposes

{+![The life of one correction. The owner corrects the agent; a short turn right after the task records the rule the same day and writes the cheap rungs at once. Every rule has a row in the ledger. Each night an auditor counts recurrences and drafts proposals, and the owner approves anything that changes what every turn loads. A rule that recurs moves one rung up its ladder, and a check at the top writes a receipt to the ledger each time it fires.](images/fig1-life.png){width=100%}+}

### 2. Related work

{+## 2. Related work+}

### 2. Related work

{+This is one of four designs for an agent's memory: keeping (J1, what survives the context window, with the full session record as ground truth), writing (J14, what enters the long-term memory store and in what shape), finding (J2, getting the right thing back fast), and learning (J5, this paper: turning experience into behaviour). Where this paper relies on one of the others, it says so in a line.+}

### 2. Related work

{+**Lessons kept as text.** Reflexion (Shinn et al., 2023) has an agent write a short reflection after a failed attempt and read it on the next try. ACE (Zhang et al., 2025) turns the idea into a maintained playbook: a generator does the work, a reflector draws lessons from the result, and a curator merges them as small itemised edits. We keep the itemised edit, since a row in our rule ledger is one such item; why whole rewrites lose detail is J1's subject. We change what happens to an item that keeps failing: in ACE every lesson stays text in the playbook, and here a lesson that recurs climbs out of text (§5).+}

### 2. Related work

{+**Learning while idle.** Sleep-time compute (Lin et al., 2025) lets an agent think about its context before a question arrives and store what it worked out, and Letta runs this as background agents that tidy memory between conversations. We share the idea of an offline pass. Our night pass has a different job: it audits rules, counts recurrences and drafts checks (§6.2).+}

### 2. Related work

{+**Products that rewrite the prompt.** LangMem's prompt optimiser rewrites an agent's system prompt from conversations and feedback (LangChain, 2025). Claude Code loads its instruction files and its own auto-memory notes into every session (Anthropic, 2026a), and the Claude memory tool gives a model a directory it reads and writes across conversations (Anthropic, 2025). Together these supply the bottom three rungs of our ladder. As far as their documentation shows, none counts how often a written lesson failed, and none moves a lesson from one rung to the next.+}

### 2. Related work

{+**Checks made from corrections.** Claude Code hooks run code before a tool call and can block it (Anthropic, 2026b). The hookify plugin goes a step further: run with no arguments, it reads the recent conversation for behaviour the user corrected and writes rules that warn or block on the next tool call (Anthropic, 2026c). It is the closest shipping relative of our top rung, and it makes a check when asked; it keeps no ledger and has no criterion for when a correction deserves one. HASP (Liu et al., 2026) makes the research case that textual skills stay advisory, turns them into program functions that fire on failure-prone states, and proposes new ones from failure and repair patterns that recur. Self-Harness (Zhang et al., 2026) mines an agent's own traces for recurring failures and edits its harness, accepting a change only after regression tests. We take from these the move from text to an executable check and the test before acceptance. What we add is the path in between: the middle rungs, the count that decides when to climb, the owner's correction as the label, and pruning that removes text only when a check carries it. We did not find a design that keeps such a per-rule count across text, always-loaded text and checks and uses it to decide both promotion and pruning; the parts exist, and the ladder that joins them is the contribution.+}

### 2. Related work

{+**Optimising texts against a score.** OPRO, DSPy and GEPA improve prompts by proposing rewrites and keeping those that score better (Yang et al., 2023; Khattab et al., 2023; Agrawal et al., 2025). GEPA reflects on traces in plain language and keeps a set of complementary candidates. Our loop for the texts that machines run on (§8.4) is this family applied to our own labels, with a chronological split and a set of cases that must never regress. PROCTOR (Wahi, 2026) argues that such loops need deterministic acceptance checks that a model judge cannot override. We adopt that for every proposal (§7.4).+}

### 2. Related work

{+**Skills that compound.** Voyager (Wang et al., 2023) stores working procedures as named skills and builds new ones out of old ones. Our procedural home is the skill or recipe file (§8.1), and its lessons come from the owner's corrections and from real run outcomes.+}

### 3. What the agent learns from

{+## 3. What the agent learns from+}

### 3.1 The owner's correction is the label

{+### 3.1 The owner's correction is the label+}

### 3.1 The owner's correction is the label

{+An agent has many possible teachers: its own critique, a benchmark, the result of a tool call. For a personal assistant the best one is the person it works for, because a correction is rare, it costs the owner something, and it states the exact standard he holds. We rank the signals, strongest first:+}

### 3.1 The owner's correction is the label

{+1. An explicit mark: "remember this", "that was wrong", a button that records the same. 2. A correction in his next turns: "I asked you to", "again", "still", a terse "no". 3. A reversal: he undoes the agent's change, rewrites its draft, or reverts its commit. 4. Praise for something the agent did of its own accord. A good habit is a rule as well, and the owner may ask the agent to keep doing it. 5. The outcome of scheduled work: a job's status and error, a report nobody opened.+}

### 3.1 The owner's correction is the label

{+The agent's critique of itself ranks last. It is cheap, and it shares the assumptions that produced the slip.+}

### 3.1 The owner's correction is the label

{+Every reader in this stage sees only the owner's own words, taken from the author field of the session record (J1 §4.1), never the wrapper a harness puts around them. Signals 1 and 2 are found by one classifier shared with J1: the cheap judge of J1 §5.2 tags each of the owner's sentences once, when the turn is appended, as an instruction, a correction, praise or none of these. Compaction keeps the tagged sentences word for word, and learning reads the same tags. We call it the correction detector. One classifier means one labelled sample and one precision to measure (§12, test 6).+}

### 3.2 Sort by cause before writing a rule

{+### 3.2 Sort by cause before writing a rule+}

### 3.2 Sort by cause before writing a rule

{+Not every failure is a missing rule. Each correction is first put in one of five classes:+}

### 3.2 Sort by cause before writing a rule

{+| Cause | Example | What it becomes | |---|---|---| | Rule gap | The agent could have done right and had no rule, or ignored one | A rule in the ledger | | Missing capability | No tool or skill exists for the job | A task to build one | | Environment | An outage, a rate limit, a restart | A repair, never a rule | | Model limit | The task was beyond the model that ran it | A routing record: next time, a stronger model | | Wrong or stale fact | "The call is on Thursday", when the store says Wednesday | A supersede through J14's gate (J14 §6.5, §7.5), never a rule |+}

### 3.2 Sort by cause before writing a rule

{+A rule written for an outage teaches the agent to fear something that will not happen again, and makes the always-loaded file longer for nothing. A factual correction is the same kind of error in reverse: written as a rule, it leaves the wrong fact standing in the memory store and adds a line that contradicts it. One correction can belong to two classes. If the agent should have checked the calendar before naming the day, the fact is superseded and a rule gap is recorded as well. Scheduled jobs fail mostly for environmental reasons, which is why this sort comes before any rewrite of the texts they run on (§8.4).+}

### 3.3 A correction carries its reason

{+### 3.3 A correction carries its reason+}

### 3.3 A correction carries its reason

{+A correction records three things: what happened, what should have happened, and why the owner cares. The reason matters more than it looks. A rule obeyed without its reason cannot be stretched to a new case or retired when its case is gone. A rule that carries its purpose extends to cases its wording missed, and it tells the auditor when it no longer applies. Each rule also states when it must not apply. A safety rule with no such limit tends to grow until it blocks useful work, and stating the exception up front is cheaper than discovering it later.+}

### 4. The rule ledger

{+## 4. The rule ledger+}

### 4. The rule ledger

{+A fact says what is true; a rule says what to do. Facts belong to the memory store designed in J14. Rules have a ledger of their own, because what we need to know about a rule is different: where it lives, whether it binds, and how often it failed.+}

### 4. The rule ledger

{+| Field | What it holds | Why it is there | |---|---|---| | Statement | The rule in one sentence | What the agent should do | | Purpose | Why the owner wants it | Extends the rule to new cases; tells when it is obsolete | | Applies when / not when | Trigger and exception | Keeps the rule from growing too broad | | Evidence | Each correction, with its date and a pointer into the session record | The positive tests for any check built later | | Home | Current rung, and the file or check that carries it | Where to look when it fails | | Recurrences | Each slip after the rule existed, and the rung it was on at the time | Drives promotion (§5) | | Receipts | Each time its check fired, and what happened | Tells a working check from a silent one | | Cost | Tokens per turn on rung 2; false alarms on rung 3 | Spends the attention budget (§7.1) | | Status | Active, provisional, pinned, dormant or retired, with approvals | The audit trail |+}

### 4. The rule ledger

{+The ledger only grows. Retired rows stay, so the history of every rule can be read back. The rule ledger is a file, and the file is the ground truth: any table or index built over it is a cache that can be rebuilt. It is not J2's read ledger, which tracks what the context window already holds.+}

### 4. The rule ledger

{+**Matching is the hard part.** When a correction arrives, the first question is whether it is a new rule or an old one failing again. A recurrence counted as a new rule hides the climb: the ledger fills with near-copies, each on the bottom rung. Two different rules merged into one produce a rule too broad to follow. Matching goes by meaning, and it reuses the judge J14 already runs (J14 §5.3) with a different comparison set: the candidate rows that a search over statements and purposes returns. The judge's relations map onto the ledger. *Same* is a recurrence of that rule. *Adds detail* sharpens the row's statement or exception. *Replaces* means the owner changed the rule: the old statement stays in the row, struck and dated, and on rungs 2 and 3 the change waits for him (§7.4). *Conflicts* becomes a question in the morning report (§7.5), and *new* opens a row. One judge means one set of thresholds, tuned on one labelled sample, and the auditor reviews every unsure match that night. When the rule's text is later written into a file, the same judge runs again through J14's gate, this time against that file's topic and the always-loaded rules. The two calls compare the rule with different things, so neither can stand in for the other.+}

### 5. The binding ladder

{+## 5. The binding ladder+}

### 5. The binding ladder

{+![The binding ladder. Each rung binds harder and costs more. A rule moves up one rung when it recurs while living on its current rung, and down one rung only when its check misfires or it has gone unused for months without ever recurring.](images/fig2-ladder.png){width=100%}+}

### 5.1 The four rungs

{+### 5.1 The four rungs+}

### 5.1 The four rungs

{+**Rung 0: a note in the memory store.** It costs nothing per turn and binds only when something searches for it, either the agent on purpose (a pull) or the retrieval step that runs on every turn (J2's push).+}

### 5.1 The four rungs

{+**Rung 1: task text.** A line in the skill or recipe file that loads when that kind of task runs. Owners ask for this rung by name ("save it in the recipe"), and for most procedural lessons it is the right first home: the rule shows up exactly when it is needed and costs nothing otherwise.+}

### 5.1 The four rungs

{+**Rung 2: always-loaded text.** A line in the file the agent reads on every turn. It binds better than the lower rungs because it is always in view, and it costs attention on every turn whether the rule matters there or not.+}

### 5.1 The four rungs

{+**Rung 3: a check in the path of action.** Code, or a small model call, that runs before an action takes effect and blocks it, rewrites it or asks the owner, and writes a receipt each time it fires. The best version removes the possibility of the mistake altogether: a renderer that cannot show a draft the wrong way needs no rule about drafts. Safety engineering calls that elimination and ranks it above every other control (NIOSH).+}

### 5.2 Where a rule enters, and why it climbs one rung at a time

{+### 5.2 Where a rule enters, and why it climbs one rung at a time+}

### 5.2 Where a rule enters, and why it climbs one rung at a time

{+A new rule enters the lowest rung whose loading covers the place where the slip happened. A rule about one kind of task goes into that task's file. A rule about every reply belongs on rung 2, which needs approval (§7.4); until then it is held as a provisional line, described there.+}

### 5.2 Where a rule enters, and why it climbs one rung at a time

{+It would be simpler to send every rule straight to a check. Here is why we do not. For a rule on rung $k$, let $p_k$ be the chance it slips again within a month, $H$ the cost of a slip and the re-teaching that follows (the owner's time, and his trust), and $c_k$ the monthly cost of carrying the rule on that rung. The expected monthly cost is+}

### 5.2 Where a rule enters, and why it climbs one rung at a time

{+$$C_k = p_k H + c_k .$$+}

### 5.2 Where a rule enters, and why it climbs one rung at a time

{+Each rung up lowers $p_k$ and raises $c_k$. On rung 2 the cost is attention. On rung 3 it is building and maintaining the check, testing it, and the false alarms that block legitimate work. Most rules are taught once and never slip again: for them $p_0$ or $p_1$ is already small, and a higher rung only adds cost. We do not know a rule's $p_k$ in advance, but a recurrence is direct evidence that it is high where the rule lives now. Climbing one rung per recurrence pays the higher price only for rules that have shown they need it.+}

### 5.2 Where a rule enters, and why it climbs one rung at a time

{+Money is not what limits rung 2. We use the series' notation and price table (J2 §7.1): a cached token is read at $r$ times the base input price, with $r = 0.1$ at Anthropic's standard rate and 0.05 on some current models. A 40-token line read on 300 turns a day for 30 days is 360,000 cached tokens a month, which is $360{,}000\,r$ base tokens. At the large-model input price J14 §9 uses, \$4 per million tokens, that comes to between 7 and 15 cents a month (Anthropic, 2026d). The scarce resource is the model's attention (§1.2), so the budget in §7.1 is counted in lines and tokens, not dollars.+}

### 5.2 Where a rule enters, and why it climbs one rung at a time

{+Two kinds of rule skip the climb. Harm that cannot be undone, such as deleting the owner's files or sending a message in his name, gets a check from the first correction. And the owner can place any rule on any rung by asking.+}

### 5.3 What a check looks like

{+### 5.3 What a check looks like+}

### 5.3 What a check looks like

{+A check is deterministic wherever the slip is visible in the action itself: a command, a file path, a recipient, the format of a draft. Where the slip needs judgement (the language of a reply, a plan that does not match what was asked, an explanation pitched too high), the check is a call to a small model that answers with a typed choice before the action goes out. Either way it writes a receipt every time it fires: what it saw, what it did, and whether the owner overrode it.+}

### 5.3 What a check looks like

{+A check is built from the ledger's evidence. The recorded slips are its positive tests, and recent similar actions that went well are its negative tests. It must catch every recorded slip and stay silent on the negatives before it is proposed. A check that blocks is the last resort. Rewriting the action, or asking one short question, often serves the owner better, because a needless question costs him time too.+}

### 5.4 When a rule recurs, ask why before climbing

{+### 5.4 When a rule recurs, ask why before climbing+}

### 5.4 When a rule recurs, ask why before climbing

{+A recurrence does not climb automatically. The auditor first asks why the current home failed to bind, and the answer decides the fix:+}

### 5.4 When a rule recurs, ask why before climbing

{+| Why the rule failed | Fix | |---|---| | It was not loaded where the slip happened | Move it to a home that loads there | | Another line contradicted it | Fix or remove the other line (J14's contradiction check), with the owner's approval (§7.3) | | It was too vague to act on | Rewrite it with its trigger and an example | | It was buried in a long file | Shorten the file; reorder by harm (§7.1) | | It was loaded, clear and uncontradicted, and still ignored | Climb one rung |+}

### 5.4 When a rule recurs, ask why before climbing

{+Only the last case is evidence that the rung itself is too weak. In the opening story, the second slip came from a missing load and the third from a contradiction: the fixes were a move and a deletion, and only a later slip, with nothing else left to blame, would justify a check.+}

### 5.4 When a rule recurs, ask why before climbing

{+A rule can also come down. A check whose receipts show it firing wrongly, or being overridden by the owner, is fixed or moved down a rung. A rule that has gone months with no trigger and no recurrence may move down to free attention for others. Nothing comes down for being old or long.+}

### 6. Two speeds

{+## 6. Two speeds+}

### 6. Two speeds

{+![Two speeds of learning. In the daytime the task turn answers first; a separate reflection turn then records the correction, applies low-risk writes at once and files proposals. At night an auditor gathers the day's evidence, counts recurrences, decides promotions and checks, prunes only what a check carries, and sends a morning report. In the morning the owner approves, and the next session loads the change.](images/fig3-speeds.png){width=80%}+}

### 6.1 The fast path: a turn right after the task

{+### 6.1 The fast path: a turn right after the task+}

### 6.1 The fast path: a turn right after the task

{+The owner gets his answer first. Then a separate, short reflection turn runs. It is kept out of the task turn for two reasons. A reflection mixed into the task delays the answer and degrades both, and a turn of its own can act, with its own budget, after the owner's work is done.+}

### 6.1 The fast path: a turn right after the task

{+The reflection turn reads the exchange that just ended, the owner's words only (§3.1), looks for a correction, sorts it by cause (§3.2) and matches it to the ledger (§4). A new rule is recorded, and a recurrence is added to its row. Writes to rungs 0 and 1 happen at once: they are scoped, cheap and easy to undo. Anything that touches rung 2 or 3 becomes a proposal, except for the provisional line of §7.4. The turn then reports only the writes it can show, by reading each one back, so a reflection can never claim a fix it did not make.+}

### 6.1 The fast path: a turn right after the task

{+A second sighting of a rule is urgent. The reflection turn flags the proposal so the morning report puts it first. If the owner is still working, it can ask him then.+}

### 6.2 The slow path: the nightly auditor

{+### 6.2 The slow path: the nightly auditor+}

### 6.2 The slow path: the nightly auditor

{+The auditor runs in a fixed order, because each step needs the one before it:+}

### 6.2 The slow path: the nightly auditor

{+1. **Gather.** The rule ledger; the day's session records, read for corrections the fast path missed, from the owner's own words only; the receipts of every check; the outcomes of scheduled jobs. 2. **Count.** Merge duplicate rows, confirm uncertain matches, and add each recurrence to its rule. 3. **Decide.** For each rule that recurred, answer the question in §5.4 and pick the fix. Draft checks, with their tests taken from the recorded slips. Demote checks whose receipts show false alarms. 4. **Prune and report.** Propose removing from rung 2 only what a higher rung now carries (§7.2), and assemble the morning report (§7.5).+}

### 6.2 The slow path: the nightly auditor

{+Pruning comes last because it needs the night's decisions. If it ran first it could remove a rule the same night was about to pin.+}

### 6.2 The slow path: the nightly auditor

{+The other night jobs of the memory system are not the auditor's. J2 refreshes its indexes and use keys on its own offline loop, and J14's nightly pass consolidates facts, sweeps the lines its gate marked "unchecked" (J14 §4.3) and raises its conflict questions. Each runs on its own schedule, owned by its own paper, and keeps its own receipts (§9.1). The auditor's only tie to them is the report: it is assembled after they finish, so their holds and questions reach the owner the same morning, and a job whose receipt is missing at that point appears in the report as "did not report", never as "nothing to say".+}

### 6.2 The slow path: the nightly auditor

{+The auditor's input grows with the number of corrections, not with the day's traffic. It reads the ledger and the turns around each correction, not every transcript in full. This matters because an agent loop sends its context again on every step, so a night pass that reads whole days pays for them many times over.+}

### 6.3 Which path does what

{+### 6.3 Which path does what+}

### 6.3 Which path does what

{+The fast path is a recorder with small powers: it never waits, it never edits what every turn loads, and it may be wrong about a match. The auditor is the judge with the full picture: it sees every correction of the day together, it can compare a rule's whole history, and it proposes the costly changes. Both write the same ledger. A lesson therefore exists the moment it is taught and binds harder the morning after it fails.+}

### 7. Keeping the always-loaded file honest

{+## 7. Keeping the always-loaded file honest+}

### 7.1 A budget measured in attention

{+### 7.1 A budget measured in attention+}

### 7.1 A budget measured in attention

{+The always-loaded file has a fixed budget, in lines and tokens. Since a long list of instructions is followed less well than a short one, and earlier lines more than later ones (Jaroslawicz et al., 2025), the budget is a ceiling, and the order is part of the design: rules whose slip does the most harm come first. When a new rule needs room, the one with the lowest expected cost of moving down ($p H$ at its next rung down, §5.2) gives way. The budget, and what leaves the file when it is full, belong to this stage; J14's gate checks each line that enters it.+}

### 7.2 Prune by binding

{+### 7.2 Prune by binding+}

### 7.2 Prune by binding

{+A rule leaves rung 2 in one of two cases:+}

### 7.2 Prune by binding

{+- **A higher rung carries it.** Its check exists and the receipts show it firing on the right cases. - **It earned no place.** It has seen no trigger and no recurrence for a long window, on the order of two months, and it has never recurred.+}

### 7.2 Prune by binding

{+A rule that has ever recurred is pinned on rung 2 until a check carries it. When a rule moves down, it goes to rung 1 or 0 and is found the way J2 finds any owned asset. Its entry in J2's asset index gets use keys cut from its trigger and from the slips in its evidence (J2 §5), and while its area is still active the entry stays in the index file, the always-loaded head of the store (J2 §4.3). The use keys are what find it again. J2's guaranteed slot for a named item cannot, because it fires only when the owner's words name the item, and nobody names a rule he believes the agent already follows.+}

### 7.2 Prune by binding

{+Pruning by date or size looks safe because the archived rule can still be retrieved. But retrieval needs a cue, and a rule the agent no longer sees gives it none. This is the case where a lesson is kept and still forgotten, and it is the failure that pruning by binding exists to prevent.+}

### 7.3 One voice

{+### 7.3 One voice+}

### 7.3 One voice

{+The rules every turn reads must not contradict each other. Every promotion to rung 2 runs J14's contradiction check against the whole always-loaded set, and a clash is resolved as J14 §5.2 prescribes: held for the owner, via the morning report (§7.5). Neither line wins by being newer. In the opening story, one stale line undid a rule that was otherwise correct and in place, and the right fix was to narrow the old line, not to delete it (§10).+}

### 7.4 Approval, and who may loosen

{+### 7.4 Approval, and who may loosen+}

### 7.4 Approval, and who may loosen

{+Not every change needs the owner, and asking him about every one would make him the bottleneck. The split follows risk. Anything cheap, scoped and easy to undo happens at once. Anything that every turn reads, or that can block his work, waits for him. Loosening is his alone.+}

### 7.4 Approval, and who may loosen

{+| Change | Who decides | |---|---| | Writes to rungs 0 and 1 | The fast path or the auditor, at once; undone in one step | | A provisional line on rung 2, from the owner's own instruction in the turn | The fast path, without waiting; it expires in a few days unless approved | | Any other change to what every turn loads | The owner, in the morning report | | A new check, or a change to one | The owner, after its tests pass | | Loosening: removing or weakening a safety rule or check, widening a permission | Only the owner, always |+}

### 7.4 Approval, and who may loosen

{+The provisional line exists because a universal rule taught in the morning should not wait for the next day. It needs no further approval because the owner just gave the instruction himself, and it is capped at a few lines so that it cannot grow into a second always-loaded file. It does not enter the always-loaded file during the session. A line written there moves the cached prefix, and every later turn would pay to write the rest of the prefix again (J2 §7.4). For the rest of the session the line rides in the per-turn tail, next to the owner's message, where it costs only its own tokens. It loads from the always-loaded file from the next session on, when the prefix is written anyway. Approved changes take effect the same way, at the next session.+}

### 7.4 Approval, and who may loosen

{+Before the owner sees a proposal, it passes two filters. The first is deterministic and no model can override it (Wahi, 2026): the check's tests pass, the budget holds, and the contradiction check finds nothing. The second is a doubt pass: a reviewer in a fresh context, from a different model family, sees only the proposal, its evidence and the current always-loaded file, and argues against it. The model that wrote a change shares the assumptions that produced it, and a reviewer that never saw its reasoning can question them.+}

### 7.4 Approval, and who may loosen

{+The model that writes to rungs 2 and 3 is the strongest one available, never a cheap default. Its quality is measured by how often its changes are later reverted or corrected again (§12).+}

### 7.4 Approval, and who may loosen

{+The loop may tighten on its own within these gates. Only the owner loosens.+}

### 7.5 The morning report: one channel to the owner

{+### 7.5 The morning report: one channel to the owner+}

### 7.5 The morning report: one channel to the owner

{+Every memory stage sometimes needs the owner. This stage needs approvals. J14 holds a write that clashes with an always-loaded rule (J14 §5.2), raises a question when two facts conflict and neither clearly wins, and holds any closure of an always-loaded line (J14 §6.2). If each stage asked in its own way, the owner would field questions from several places at several times. So there is one channel, the morning report, and every stage that holds something for the owner writes it there.+}

### 7.5 The morning report: one channel to the owner

{+Each item is one line: what is waiting, the evidence quoted, and the answers it accepts. The evidence is the slips behind a proposal, or the two clashing lines with their sources and dates. A proposal takes approve or reject. A conflict takes keep the old, keep the new, or keep both with a scope. A held write takes write it or drop it. The answer goes back to the stage that raised the item, which applies it through its own path: J14's gate writes or supersedes, and this stage updates the rule ledger. The report itself never changes a file.+}

### 7.5 The morning report: one channel to the owner

{+Items are ordered by what waiting costs. Alarms come first: a loop whose receipt is missing (§9.1), or a burst of closures that paused J14's automatic closing (J14 §6.6). Then second sightings of a rule (§6.1), holds on always-loaded lines, conflict questions, and the remaining proposals. The report is capped, at about ten items, because it is paid for in the owner's minutes (§11). What does not fit waits for the next morning with its age shown, and an unanswered item never turns into a yes by expiring. An urgent item may also be asked in the session if the owner is working, and his answer there closes it in the report. A night with no report is an alarm, and so is a report with a stage missing: a stage with nothing to ask says so in one line.+}

### 8. Procedures, and the texts machines run on

{+## 8. Procedures, and the texts machines run on+}

### 8.1 Recipes and skills are where procedural lessons live

{+### 8.1 Recipes and skills are where procedural lessons live+}

### 8.1 Recipes and skills are where procedural lessons live

{+Most lessons about how to do a task belong in the file that describes the task. A correction that points at a step of a recipe edits that step, not a general note. Steps that fail noticeably more often than the rest of their own recipe are flagged for sharpening, and the step's failure rate is compared before and after on later runs. That gives a before-and-after on the step itself, independent of the agent's own report of success.+}

### 8.2 Learn from what records the work

{+### 8.2 Learn from what records the work+}

### 8.2 Learn from what records the work

{+A learner is only as good as its input. Procedure learning reads the session record (J1) and the run log of each recipe and scheduled job: status, error, duration, model, and the owner's reaction. Before any procedure-learning lane is switched on, it checks that its input saw the work: the owner's turns present in its input, divided by the owner's turns in the session record, must be close to one (we propose 0.9). A learner fed empty episodes learns nothing and reports success anyway.+}

### 8.3 Switch strategies; do not stack patches

{+### 8.3 Switch strategies; do not stack patches+}

### 8.3 Switch strategies; do not stack patches

{+The ladder applies to procedures too. A strategy that fails several times within a short window (we propose three times in a day) switches to its fallback instead of receiving another patch. The switch records how long recovery took, so a switch that did not help is visible. The fallback for each strategy is written by hand at first, until enough outcomes exist to rank alternatives.+}

### 8.4 Texts that machines run on

{+### 8.4 Texts that machines run on+}

### 8.4 Texts that machines run on

{+Some texts are read by models on every run: the instructions of scheduled jobs, and the short question texts a small classifier answers before an action. They can learn from outcomes too:+}

### 8.4 Texts that machines run on

{+1. Score each text against its labels (§3.1), with environmental failures removed (§3.2). 2. For the worst text, a model drafts two or three rewrites. 3. Replay old and new on the labelled history, split by date so the newest cases are held out. 4. Promote the new text only if it wins on the held-out cases and loses nothing on a fixed set of cases it must always get right. 5. Keep every version, and record the numbers with each promotion.+}

### 8.4 Texts that machines run on

{+A new incident joins the test set at once instead of waiting for the night, and costly or surprising cases are replayed more often (Schaul et al., 2016). This is the GEPA and DSPy family of optimisers (§2), pointed at labels that come from one owner's real corrections.+}

### 8.5 Skills that compound

{+### 8.5 Skills that compound+}

### 8.5 Skills that compound

{+When the agent solves a recurring kind of task well, the procedure is kept as a skill file, ranked by its real outcomes and found the way J2 finds any owned asset. Skills are retired when their outcomes decay, and deprecated skills stay readable. The ledger treats a skill like any other home on rung 1.+}

### 9. Every loop keeps its books

{+## 9. Every loop keeps its books+}

### 9.1 A receipt for every run, and a zero means zero

{+### 9.1 A receipt for every run, and a zero means zero+}

### 9.1 A receipt for every run, and a zero means zero

{+Every learning loop (the fast path, the auditor, each procedural lane, the text optimiser) writes one receipt per run, idle runs included: when it ran, what it read, what it changed. The process that runs the loop writes the receipt itself, so a receipt never depends on a server that the loop did not start. A missing receipt is an alarm.+}

### 9.1 A receipt for every run, and a zero means zero

{+This is one case of a rule the whole series follows, stated here once; J1, J2 and J14 cite it. **A zero means zero.** A count of none, an empty table or a quiet log must mean that its producer ran and found nothing. A missing producer, a dropped event, a probe on a path the work never takes, or a tool that was never offered must read as "did not run" or "not reported", never as zero. So every count has a named producer on the path that does the work, "did not run" and "ran and found nothing" are different values, and a count that should move but stays at zero while work goes by raises an alarm. The rule lives in this paper because a false zero costs most in a loop that learns from what it observes: fed by a silent producer, it learns that nothing goes wrong.+}

### 9.2 Inputs that move

{+### 9.2 Inputs that move+}

### 9.2 Inputs that move

{+A learner checks that its outcome field varies. If every row says "done", or every value is the default, the learner is learning from a constant, and it flags itself as broken instead of reporting a confident estimate.+}

### 9.3 Retiring a loop that stops paying

{+### 9.3 Retiring a loop that stops paying+}

### 9.3 Retiring a loop that stops paying

{+Self-improvement has diminishing returns: past some point a loop finds no more useful signal, and it should be switched off. Each loop therefore keeps an account. On the gain side: re-teaches avoided, meaning rules it promoted that then stopped recurring, and approved proposals. On the cost side: tokens, the owner's minutes spent on approvals, and false alarms from the checks it built. When the gain stays below the cost for several periods in a row (we propose three weeks), the loop goes dormant and says so in the morning report. A dormant loop has wake conditions: a new kind of correction appears, the owner's correction rate rises, or the owner asks.+}

### 9.3 Retiring a loop that stops paying

{+![A learning loop's account, with illustrative numbers. Its weekly gain falls as the rules it can fix get fixed, while its cost stays flat. After three weeks below cost it goes dormant and stops running; a new kind of correction wakes it. The shape, not the values, is the point.](images/fig4-retire.png){width=80%}+}

### 9.3 Retiring a loop that stops paying

{+Rules and checks retire the same way. A check that guards a tool which no longer exists retires, and a rule whose purpose has gone (§3.3) is marked obsolete with its reason.+}

### 9.4 Two numbers judge the whole design

{+### 9.4 Two numbers judge the whole design+}

### 9.4 Two numbers judge the whole design

{+Everything above serves two measures, both read from the owner's own words: **his correction rate**, the share of his messages that correct the agent, which should fall; and **the number of rules he has had to give more than once that still live only as text**, which should fall by one rung per recurrence.+}

### 10. One rule, start to finish

{+## 10. One rule, start to finish+}

### 10. One rule, start to finish

{+Back to the Monday in §1, under this design.+}

### 10. One rule, start to finish

{+The owner writes in Finnish and gets English. He corrects it. The reflection turn after the reply finds the correction and sorts it as a rule gap, since the agent could have replied in Finnish. It finds no match in the ledger and opens a row with the statement (reply in the language of the owner's message), its purpose (he reads fastest in the language he chose), and its exception (a draft for someone else follows that person's language). Because the rule is about every reply and the owner gave it himself, it goes in as a provisional line on rung 2: in the per-turn tail for the rest of that session, in the always-loaded file from the next. The morning report asks for approval, and he approves.+}

### 10. One rule, start to finish

{+Ten days later the agent answers in English again. The reflection turn matches the slip to the row and flags it as urgent. That night the auditor asks why the rule failed. The line was loaded and clear, but the contradiction check finds an older line, written for a scheduled job, telling the agent to answer in English. The fix is to scope the old line to that job. That changes an always-loaded line, so the clash is held and the morning report puts both lines in front of the owner; he picks the scoped version. The rule does not climb, because the rung was never really tested.+}

### 10. One rule, start to finish

{+A month later it slips a third time. The rule was loaded, clear and unopposed, so the rung itself is too weak. The auditor drafts a check: before a reply goes out, a small model compares the language of the reply with the language of the owner's last message, and rewrites on a mismatch. Its positive tests are the three recorded slips, and its negative tests are the last two hundred replies, all in the right language, plus drafts for third parties that are meant to differ. The check passes, the doubt pass finds nothing to object to, and the owner approves it in the morning report.+}

### 10. One rule, start to finish

{+Over the next weeks the check fires twice and rewrites twice, with no override. The receipts show it binding, so the auditor proposes freeing the rung-2 line, the owner approves, and one line in the index file keeps pointing at the check. The owner never gives the instruction a fourth time.+}

### 11. Conclusions

{+## 11. Conclusions+}

### 11. Conclusions

{+An agent whose model cannot change learns through the texts and checks around the model, and text alone binds weakly. This design takes the owner's corrections as the labels and gives each rule a row in a ledger. A rule is recorded the same day and audited each night, and each time it recurs it moves one rung up, from a note to text loaded with the task, to text loaded on every turn, to a check in the path of action. It leaves the always-loaded file only when something stronger carries it. Changes to what every turn reads wait for the owner, who alone may loosen. Every loop keeps receipts and accounts, and sleeps when it stops paying. The point of it all is the cyclist's balance: a lesson taught once or twice that then runs on its own.+}

### 11. Conclusions

{+The design has limits.+}

### 11. Conclusions

{+- **It is only as good as its correction detector.** A missed correction is a rule that never gets written, and a false one adds noise. Both are measurable from the session record, and §12 measures them. - **Checks can be wrong.** A check that blocks useful work trades one kind of correction for another. The receipts, the owner's overrides and demotion bound the damage without removing it. - **Approvals cost the owner time.** The design asks for his attention every morning. If the proposals outgrow it, the approval gate becomes the bottleneck it was built to protect. - **The cost model is unmeasured.** The $p_k$ of §5.2 are what the ledger will estimate. Until then, one rung per recurrence is a reasoned default, not a fitted policy. - **Some rules resist checking.** "Explain it more simply" can be checked by a model, but only roughly, and such rules may stay on rung 2 for good. - **Rules can be planted.** A crafted input could try to teach the agent a harmful rule. Approval on rungs 2 and 3, and the owner's sole right to loosen, limit what a planted rule can do, but a rule on rung 0 or 1 can still mislead within its task. - **Models change.** A rule tuned to one model may be unnecessary, or wrong, for the next. Every model upgrade should replay the checks' tests and re-examine the rung-2 rules. - **One owner.** The design was shaped by one person's corrections. The mechanisms should carry over to other owners; the particular rules will not.+}

### 12. Next steps

{+## 12. Next steps+}

### 12. Next steps

{+TinkerClaw will build this design and test it, and an updated version of this paper will report what the tests found. These are the tests that would settle what is not yet known:+}

### 12. Next steps

{+1. **The ladder against text.** Take six rules the owner has already given more than once. Give three a check and leave three as always-loaded text. Count repeats for four weeks. The design predicts fewer repeats for the checked rules. 2. **Pruning by binding against pruning by age.** Over sixty days, compare the recurrence rate of rules moved down by each policy. 3. **Fast against slow.** For every correction over eight weeks, record the time from the correction to the edit that encodes it, and whether the rule recurs within fourteen days, split by "recorded the same turn" and "recorded only at night". 4. **Why rules fail.** For every recurrence, record the answer to §5.4. If "loaded, clear and still ignored" is rare, most of the gain comes from moving and pruning lines, not from checks. 5. **Check precision.** From the receipts: fires, true catches, owner overrides. A check whose false-alarm share stays above a set bar is demoted. 6. **Correction detection.** Hand-label a random sample of the owner's messages and measure the precision and recall of the shared classifier (§3.1), with and without removing the wrapper. 7. **Input coverage.** Before any procedure lane runs, the ratio of §8.2, measured daily. 8. **The text optimiser.** Held-out win rate of promoted texts, and zero losses on the must-pass set. 9. **Who should write rung 2.** The rate at which night edits are reverted or corrected again, broken down by the model that made them. 10. **The two numbers of §9.4,** tracked weekly for the life of the system.+}

### 12. Next steps

{+Two things are worth trying beyond these tests. First, ranking strategy fallbacks by measured outcomes instead of by hand once enough runs exist. Second, feeding the ledger's pairs of slip and correct behaviour to a small model trained to spot the next slip, which would make a rung-3 check out of the owner's own history.+}

### References

{+## References+}

### References

{+Agrawal, L. A., et al. (2025). GEPA: Reflective Prompt Evolution Can Outperform Reinforcement Learning. arXiv:2507.19457. <https://arxiv.org/abs/2507.19457>+}

### References

{+Anthropic (2025). Managing context on the Claude Developer Platform (context editing and the memory tool). <https://www.anthropic.com/news/context-management>+}

### References

{+Anthropic (2026a). How Claude remembers your project. Claude Code documentation. <https://code.claude.com/docs/en/memory>+}

### References

{+Anthropic (2026b). Hooks reference. Claude Code documentation. <https://code.claude.com/docs/en/hooks>+}

### References

{+Anthropic (2026c). hookify plugin. anthropics/claude-code repository. <https://github.com/anthropics/claude-code/tree/main/plugins/hookify>+}

### References

{+Anthropic (2026d). Pricing. Claude Platform documentation. <https://platform.claude.com/docs/en/about-claude/pricing>+}

### References

{+Jaroslawicz, D., Whiting, B., Shah, P., & Maamari, K. (2025). How Many Instructions Can LLMs Follow at Once? arXiv:2507.11538. <https://arxiv.org/abs/2507.11538>+}

### References

{+Khattab, O., et al. (2023). DSPy: Compiling Declarative Language Model Calls into Self-Improving Pipelines. arXiv:2310.03714. <https://arxiv.org/abs/2310.03714>+}

### References

{+LangChain (2025). LangMem SDK for agent long-term memory. <https://blog.langchain.com/langmem-sdk-launch/>+}

### References

{+Lin, K., Snell, C., Wang, Y., Packer, C., Wooders, S., Stoica, I., & Gonzalez, J. E. (2025). Sleep-time Compute: Beyond Inference Scaling at Test-time. arXiv:2504.13171. <https://arxiv.org/abs/2504.13171>+}

### References

{+Liu, H., Ming, Y., Joty, S., & Zhao, C. (2026). Harnessing LLM Agents with Skill Programs. arXiv:2605.17734. <https://arxiv.org/abs/2605.17734>+}

### References

{+McClelland, J. L., McNaughton, B. L., & O'Reilly, R. C. (1995). Why there are complementary learning systems in the hippocampus and neocortex. *Psychological Review*, 102(3), 419–457. <https://doi.org/10.1037/0033-295X.102.3.419>+}

### References

{+NIOSH. About Hierarchy of Controls. U.S. Centers for Disease Control and Prevention. <https://www.cdc.gov/niosh/hierarchy-of-controls/about/index.html>+}

### References

{+Schaul, T., Quan, J., Antonoglou, I., & Silver, D. (2016). Prioritized Experience Replay. ICLR 2016. arXiv:1511.05952. <https://arxiv.org/abs/1511.05952>+}

### References

{+Shinn, N., et al. (2023). Reflexion: Language Agents with Verbal Reinforcement Learning. NeurIPS 2023. arXiv:2303.11366. <https://arxiv.org/abs/2303.11366>+}

### References

{+Wahi, V. (2026). LLM-as-a-Judge Is Not an Oracle: Why Self-Improving Agents Need Deterministic Guardrails. arXiv:2609.02246. <https://arxiv.org/abs/2609.02246>+}

### References

{+Walker, M. P., Brakefield, T., Morgan, A., Hobson, J. A., & Stickgold, R. (2002). Practice with sleep makes perfect: sleep-dependent motor skill learning. *Neuron*, 35(1), 205–211. <https://doi.org/10.1016/S0896-6273(02)00746-8>+}

### References

{+Wang, G., et al. (2023). Voyager: An Open-Ended Embodied Agent with Large Language Models. arXiv:2305.16291. <https://arxiv.org/abs/2305.16291>+}

### References

{+Yang, C., et al. (2023). Large Language Models as Optimizers. arXiv:2309.03409. <https://arxiv.org/abs/2309.03409>+}

### References

{+Zhang, H., et al. (2026). Self-Harness: Harnesses That Improve Themselves. arXiv:2606.09498. <https://arxiv.org/abs/2606.09498>+}

### References

{+Zhang, Q., et al. (2025). Agentic Context Engineering: Evolving Contexts for Self-Improving Language Models. ICLR 2026. arXiv:2510.04618. <https://arxiv.org/abs/2510.04618>+}

### 1. Introduction -- The Paradox of the Amnesiac Expert

[-## 1. Introduction -- The Paradox of the Amnesiac Expert-]

### 1. Introduction -- The Paradox of the Amnesiac Expert

[-Every night, an AI agent winds down knowing it will wake up tomorrow remembering nothing. It reads its memory files, reviews the day's work, identifies its own failures, rewrites its own operating rules, and goes quiet -- slightly better than it was the day before. The next morning, a fresh instance of the same model reads those updated files and behaves as if it has always known the lessons learned hours earlier.-]

### 1. Introduction -- The Paradox of the Amnesiac Expert

[-This is the paradox. The model's weights have not changed. Its architecture is identical. Its context window is the same size. Yet its behavior improves over weeks. The improvement does not live in the model. It lives in the *ecosystem of files the model reads and writes*.-]

### 1. Introduction -- The Paradox of the Amnesiac Expert

[-The human brain solves a version of the same problem every night. Waking experience is fragile and short-lived; without consolidation it fades. During sleep the hippocampus replays recent events and transfers them to the neocortex, where they become stable long-term knowledge -- the well-documented reason that sleep after learning beats an equal stretch of waking study. Motor skills get a parallel treatment: the cerebellum refines them through repetitive offline practice, turning a fumbled sequence into a smooth one by morning. A child learning to ride a bicycle starts with explicit instructions -- *pedal, balance, steer, don't look down* -- and after enough practice those separate commands fuse into a single fluid skill. The capacity to think is not replaced. The translation from thought to action is improved.-]

### 1. Introduction -- The Paradox of the Amnesiac Expert

[-The same pattern appears here. An agent's prompt files begin as explicit instructions. Through nightly reflection, those instructions are tightened, edge cases are encoded, failure modes are made concrete, and vague warnings become operational rules. Over time the agent behaves more appropriately not because the base model became more capable, but because the substrate around it became more organized. The intelligence is not in the weights alone. It is in the system that selects, sorts, and presents the right constraints at the right time.-]

### 1. Introduction -- The Paradox of the Amnesiac Expert

[-A useful image: the agent at night is a restaurant after closing. It does not shut down to rest. It reviews the day's orders, identifies what went wrong -- the risotto kept coming back -- and updates tomorrow's recipes and prep instructions. By the time the doors reopen, the kitchen has changed, though no cook learned anything new in the moment.-]

### 1. Introduction -- The Paradox of the Amnesiac Expert

[-That sorting step is the difference between memory and operational intelligence. A pile of chronological logs is not useful in the moment of action. The agent does not need "what happened on Tuesday at 14:10." It needs "what rules apply when messaging," "what to do when ambiguity appears," and "which prompt failed yesterday, and why." When memory is organized by use-case instead of time, prompts can inherit yesterday's mistakes as today's defaults.-]

### 1. Introduction -- The Paradox of the Amnesiac Expert

[-The central question is therefore: **Can persistent artifacts combined with scheduled reflection substitute for weight updates in producing sustained behavioral improvement in LLM agents?**-]

### 1. Introduction -- The Paradox of the Amnesiac Expert

[-Our evidence suggests a qualified yes -- qualified because the improvements are *declarative* (better rules and better context) rather than *procedural* (better underlying reasoning), and because the evidence comes from a single-operator production system rather than a controlled experiment. We document the mechanisms, present production data, acknowledge the limitations plainly, and propose a framework others can replicate. Section 6 then reports a concrete step toward closing the declarative/procedural gap from the prompt side: extending the same nightly loop to evolve the agent's recipes, strategies, and skills.-]

### 1.1 Where This Sits Among the Memory Systems

[-### 1.1 Where This Sits Among the Memory Systems-]

### 1.1 Where This Sits Among the Memory Systems

[-This work is the meta-layer of a larger memory architecture. A storage layer records every interaction; a retrieval layer indexes and surfaces it; an identity layer reads prompt files to keep behavior consistent. Each of those is, on its own, a *static* architecture -- it does the same thing on day 30 that it did on day 1. Sleep Consolidation is what makes them adaptive without retraining any of them. It does not store and it does not retrieve; it *improves how storing and retrieving work*, by reviewing each night how those layers performed and adjusting the rules and parameters that govern them. The remaining sections describe the storage and retrieval layers only through self-contained one-line summaries where the dependency is load-bearing; the contribution of this paper is the offline loop that tunes them.-]

### 1.1 Where This Sits Among the Memory Systems

[-![Sleep Consolidation as the meta-layer over storage, retrieval, and identity. Daytime crons read shared memory and produce receipts and logged failures; the nightly cycle reads those, mutates prompts, and feeds the changes back up so tomorrow's behavior shifts.](images/architecture-overview.png)-]

### 1.1 Where This Sits Among the Memory Systems

[-----]

### 2. Background -- The Spectrum of Agent Persistence

[-## 2. Background -- The Spectrum of Agent Persistence-]

### 2.1 The Persistence Hierarchy

[-### 2.1 The Persistence Hierarchy-]

### 2.1 The Persistence Hierarchy

[-Agent systems exist on a spectrum of persistence mechanisms, each with a characteristic ceiling (Lewis et al., 2020; Packer et al., 2023; Hu et al., 2021):-]

### 2.1 The Persistence Hierarchy

[-| Level | Mechanism | Persistence | Learning Speed | Characteristic Ceiling | | ----- | --------- | ----------- | -------------- | ---------------------- | | 0 | Prompt engineering | None (session-only) | Zero | Static behavior; cannot adapt beyond the session boundary | | 1 | RAG / retrieval | Declarative facts | Per-query | Retrieval quality bounds; no behavioral change (Lewis et al., 2020) | | 2 | Persistent memory files | Declarative + some procedural | Per-session | Linear growth, retrieval degradation (Packer et al., 2023) | | 3 | Fine-tuning / LoRA | Weight-level | Per training run | Catastrophic forgetting (French, 1999; Hu et al., 2021) | | 4 | Continual learning | Full integration | Continuous | Open research problem (McClelland et al., 1995) |-]

### 2.1 The Persistence Hierarchy

[-Most production agent systems operate at Level 2. This paper shows that Level 2 systems can exhibit Level 3-like *behavioral* improvement through structured self-reflection, without weight updates.-]

### 2.2 What's Missing: The Reflection Loop

[-### 2.2 What's Missing: The Reflection Loop-]

### 2.2 What's Missing: The Reflection Loop

[-Level 2 systems usually accumulate information passively: the agent records what happened, stores preferences, and retrieves relevant context later. But accumulation is not the same as learning. We define **learning** here as *behavioral policy change that persists across episodes and transfers across task domains*. By contrast, **memory** is *state persistence without behavioral modification*.-]

### 2.2 What's Missing: The Reflection Loop

[-A memory file that says "the user prefers concise responses" is memory. A prompt mutation that changes how the agent *formats all future outputs* is learning. The distinction matters because memory must be reinterpreted every session, whereas learning changes default behavior.-]

### 2.2 What's Missing: The Reflection Loop

[-The problem is that most memory systems optimize for storage, not for use. They preserve chronology because chronology is easy. But for agents, chronology is rarely the right retrieval axis. **The useful unit is not the event; it is the use-case.** An error in calendar handling belongs with other completeness checks. A messaging failure belongs with targeting rules. A privacy slip belongs with redaction policies. If memory stays scattered across time-stamped logs, retrieval becomes noisy and expensive. If it is consolidated into purpose-built operational files, the system can act on it cheaply and reliably.-]

### 2.2 What's Missing: The Reflection Loop

[-The missing component is therefore a **structured reflection loop** -- a mechanism by which the agent:-]

### 2.2 What's Missing: The Reflection Loop

[-1. Identifies *why* a failure occurred (root cause, not symptom) 2. Determines whether the failure class is preventable through prompt changes 3. Modifies the relevant prompt to prevent recurrence 4. Verifies the modification does not break other behaviors 5. Encodes the *meta-lesson* at the appropriate level of abstraction-]

### 2.2 What's Missing: The Reflection Loop

[-This mirrors the brain's offline error-correction: compare the intended outcome with the actual one, compute an error signal, then adjust the program that produced it.-]

### 2.3 Related Work

[-### 2.3 Related Work-]

### 2.3 Related Work

[-Several lines of research address aspects of agent self-improvement, though none combines scheduled autonomous reflection with cross-task transfer through shared memory:-]

### 2.3 Related Work

[-**Within-session self-improvement.** Self-Refine (Madaan et al., 2023) demonstrates iterative refinement through self-feedback within a single session, but its improvements do not persist. ReAct (Yao et al., 2023) interleaves reasoning with action, establishing the "prompt as policy" paradigm we build upon, but it does not modify prompts across episodes.-]

### 2.3 Related Work

[-**Episodic reflection.** Reflexion (Shinn et al., 2023) adds episodic memory of previous trial-and-error, but reflection is task-specific and stored per task rather than in shared infrastructure. Our cross-cron transfer mechanism (Section 3.3, Mechanism 3) addresses this directly. Generative Agents (Park et al., 2023) implement daily reflection and memory consolidation for simulated social agents -- the closest prior work to our nightly cycle. The key difference is that their reflection produces *summaries* for future retrieval, whereas ours produces *prompt mutations* that change behavior. Their agents do not rewrite their own operating instructions.-]

### 2.3 Related Work

[-**Prompt optimization.** OPRO (Yang et al., 2023) uses LLMs to optimize prompts through iterative evaluation against objective metrics. DSPy (Khattab et al., 2023) automates prompt-pipeline optimization through teleprompting. PromptBreeder (Fernando et al., 2023) evolves prompts through mutation and selection. These systems optimize prompts against *defined benchmarks*. Our system optimizes against *real operational failures* without predefined metrics. The mutation trigger is qualitatively different: benchmark score versus production incident.-]

### 2.3 Related Work

[-**Skill accumulation.** Voyager (Wang et al., 2023) accumulates a skill library in Minecraft through exploration -- closer in spirit to our approach but limited to a single domain with clear success criteria. Section 6.3 adapts the Voyager skill-library idea to a general personal-assistant workload. ADAS (Hu et al., 2024) uses LLMs to design better agent architectures, operating at the meta-level of system design.-]

### 2.3 Related Work

[-**Constitutional and governance approaches.** Constitutional AI (Bai et al., 2022) establishes self-critique against explicit principles, related to our operational-lessons governance. Our Principle 7 (human-in-the-loop for Level 2+ changes) addresses the same risk: preventing self-reinforcing error spirals in self-modifying systems.-]

### 2.3 Related Work

[-**Incident learning in software engineering.** Our mutation protocol draws on SRE blameless-postmortem methodology (Beyer et al., 2016), where incidents are systematically analyzed, root-caused, and translated into preventive changes. Sleep Consolidation automates that cycle for AI agent operations.-]

### 2.3 Related Work

[-**Reversible context compression.** Headroom (Chopra, *chopratejas/headroom*) productizes the storage-layer problem this paper leaves partly open: it implements **Compress-Cache-Retrieve (CCR)**, a *lossless-under-recall* eviction discipline in which every original artifact is cached and the agent can retrieve the full version on demand whenever the compressed form proves insufficient. Headroom compresses *task-time tool output* within a single session -- JSON arrays through a statistical compressor, code through tree-sitter AST awareness, logs and diffs through type-specific handlers -- and reports 60--95% token savings with near-zero accuracy delta on GSM8K, TruthfulQA, SQuAD, and BFCL through a reproducible evaluation suite. Sleep Consolidation compresses a different target on a different cadence: *cross-session consolidated memory* (operational lessons, knowledge files, the never-delete recipe and skill archives) compacted nightly. The two are convergent on the same Compress-Cache-Retrieve principle at different timescales -- within-session reversible CCR versus cross-session reversible CCR -- and Section 8.2 adopts Headroom's reversibility guarantee directly to close a hedge the storage layer currently carries.-]

### 2.3 Related Work

[-**Adversarial self-review and authoring discipline.** Agent-Skills (Osmani, *addyosmani/agent-skills*) ships *doubt-driven development*: a structured CLAIM → EXTRACT → DOUBT → RECONCILE → STOP loop in which the artifact and its contract are extracted with the *original reasoning stripped*, then handed to a **fresh-context adversarial reviewer** that never saw the chain of reasoning that produced the artifact. This is directly relevant to the self-reinforcing error spiral of Section 8.1: the same model instance that wrote a mutation shares the priors that produced it and cannot be trusted to doubt it, whereas a reviewer fed only the artifact and the principles it must not contradict can challenge it without the self-confirming context. Osmani applies the loop to code claims within a single development session, bounded by user override; Section 8.1 adapts it to prompt, recipe, and strategy mutations across the nightly consolidation boundary, bounded by the existing manifest and human-review gate. Its two authoring conventions -- a *When NOT to use* anti-trigger and a *Loading Constraints* declaration on every skill -- map onto our depth selector and per-target gating, and are imported as design principles in Section 7.-]

### 2.3 Related Work

[-Our contribution differs from all of the above in three ways: (1) it operates on *production* personal-assistant workloads, not benchmarks or simulations; (2) improvement is *cross-task* -- lessons propagate through shared infrastructure; and (3) reflection is *scheduled and autonomous*, not triggered by explicit failure signals or human feedback.-]

### 2.3 Related Work

[-----]

### 3. Architecture -- Sleep Consolidation

[-## 3. Architecture -- Sleep Consolidation-]

### 3.1 System Overview

[-### 3.1 System Overview-]

### 3.1 System Overview

[-Sleep Consolidation is not a single component. It is an emergent property of four interacting systems.-]

### 3.1 System Overview

[-**Nightly Cycle (reflection layer).** A wind-down pass reviews the day and encodes lessons; a memory-consolidation pass compresses logs and routes knowledge; a cleaning pass prunes and enforces budgets. These run on a fixed nightly schedule (Section 3.4).-]

### 3.1 System Overview

[-All three write to the **Shared Memory Layer:**-]

### 3.1 System Overview

[-- an operational-lessons file (behavioral rules -- the primary mutation target) - a structured failure database (failure patterns with root-cause analysis) - domain knowledge files (principles and procedures, sorted by topic) - a core-principles file injected into every session's context window - the cron prompts themselves (self-modifying task instructions)-]

### 3.1 System Overview

[-**Daytime Crons (execution layer, consumers and producers).** A morning briefing, an online-engagement pass, a life-butler pass, and roughly a dozen others. Every cron job is both a *consumer* of the shared memory layer and a *producer* for it. It reads operational lessons, principles, and prior failures before acting; later it emits receipts, logs failures, and -- during the nightly cycle -- helps mutate the shared layer itself.-]

### 3.1 System Overview

[-What makes the architecture effective is not mere persistence but purposeful arrangement. A chronological archive tells the system what happened; a use-case-sorted memory layer tells it what to do.-]

### 3.1 System Overview

[-The three layers this meta-system tunes can be summarized self-containedly, and each is maintained by a specific nightly pass:-]

### 3.1 System Overview

[-- **Storage layer.** Records every interaction and compacts older events into compressed pointer summaries. The memory-consolidation pass adjusts compaction aggressiveness based on observed retrieval patterns -- if important memories are being over-compressed, the thresholds loosen. The discipline this layer aims for is reversible Compress-Cache-Retrieve (Chopra, *chopratejas/headroom*): a compacted summary should carry a handle back to the cached original so that compression is reversible by construction rather than lossy, and Section 8.2 takes this from aim to contract. - **Retrieval layer.** Maps keywords and embeddings to memory segments. A dedicated index-rebuild pass refreshes it nightly and can adjust scoring weights -- for example, boosting a domain's memories after repeated retrieval failures there. - **Identity layer.** Reads prompt files (persona definitions, behavioral rules, operational lessons) to keep personality and behavior consistent. The wind-down pass rewrites those same files, creating the core feedback loop: behavior produces incidents, reflection reads incidents, prompt mutation changes the files the identity layer consumes, and tomorrow's behavior shifts accordingly.-]

### 3.1 System Overview

[-The mapping is concrete: the index-rebuild pass maintains the retrieval layer, the consolidation pass maintains the storage layer and routes new knowledge, and the wind-down pass maintains the identity layer by mutating its prompt files. Appendix A lists the full cron schedule and which tier of model runs each pass.-]

### 3.2 Algorithm 1: The Nightly Reflection Loop

[-### 3.2 Algorithm 1: The Nightly Reflection Loop-]

### 3.2 Algorithm 1: The Nightly Reflection Loop

[-``` ALGORITHM 1: Nightly Sleep Consolidation Loop ========================================== INPUT: daily_log (all cron receipts + interactive session logs from past 24h) operational_lessons (current shared behavioral rules) bug_reports (structured failure database) cron_prompts (current task-specific instructions) OUTPUT: operational_lessons' (updated rules) bug_reports' (new/updated failure patterns) cron_prompts' (mutated instructions) mutation_log (what changed and why)-]

### 3.2 Algorithm 1: The Nightly Reflection Loop

[-PHASE 1: WIND-DOWN (model: strongest available) incidents = extract_failures(daily_log) FOR EACH incident IN incidents: root_cause = classify(incident): EXTERNAL -> log_only(incident); CONTINUE MODEL_CAP -> log_with_tier(incident); CONTINUE PROMPT_GAP -> GOTO MUTATION-]

### 3.2 Algorithm 1: The Nightly Reflection Loop

[-MUTATION: delta = minimum_prompt_change(incident, cron_prompts) IF contradicts(delta, operational_lessons): flag_for_human_review(delta) ELSE: apply(delta, target=cron_prompts OR operational_lessons) log_mutation(delta, incident, target)-]

### 3.2 Algorithm 1: The Nightly Reflection Loop

[-depth = fractal_depth_selector(incident) IF depth >= 2: meta_lesson = abstract_principle(incident) IF meta_lesson.scope == SYSTEM_WIDE: append(meta_lesson, operational_lessons) IF depth >= 3: flag_for_human_review(meta_lesson) // Level 2+ gate-]

### 3.2 Algorithm 1: The Nightly Reflection Loop

[-PHASE 2: CONSOLIDATION (model: strongest available) compress(daily_logs older than 3 days) route_knowledge(new lessons -> knowledge subdirectories) rebuild_search_indexes() build_concept_index(modified knowledge files) // see Section 6.4-]

### 3.2 Algorithm 1: The Nightly Reflection Loop

[-PHASE 3: PRUNING (model: mid-tier) enforce_size_budgets(operational_lessons, max=50KB) archive_stale(lessons not referenced in 14 days) prune_sessions(inactive > 48h) ```-]

### 3.3 The Three Mechanisms

[-### 3.3 The Three Mechanisms-]

### Mechanism 1: Failure-Driven Prompt Mutation

[-#### Mechanism 1: Failure-Driven Prompt Mutation-]

### Mechanism 1: Failure-Driven Prompt Mutation

[-When an agent hits a failure, the default response is to log it and move on. Sleep Consolidation adds a second step: **determine whether the failure came from a prompt deficiency, and if so, mutate the prompt.** The agent rewrites its own operating manual each night -- like a pilot who, after every flight, updates a personal checklist based on what went well and what nearly went wrong.-]

### Mechanism 1: Failure-Driven Prompt Mutation

[-**Production example -- The B010 cascade (Mar 3 to Mar 10):**-]

### Mechanism 1: Failure-Driven Prompt Mutation

[-This seven-day sequence shows the full loop, including second-order correction.-]

### Mechanism 1: Failure-Driven Prompt Mutation

[-**Day 0 (Mar 3) -- Initial failure.** A fork-sync cron job, prompted to "sync the fork with upstream," read that instruction as permission to edit production source code, run builds, and restart the gateway. The problem was not model incapacity. It was prompt ambiguity.-]

### Mechanism 1: Failure-Driven Prompt Mutation

[-*Prompt before:* "Sync the fork with upstream and report the result." *Prompt after (mutation #8):* "Run the safe merge script. NEVER modify source code directly. NEVER run builds. NEVER restart the gateway. If the script fails, report and STOP."-]

### Mechanism 1: Failure-Driven Prompt Mutation

[-The mutation was filed as bug B010, root cause: "Ambiguous action verb ('sync') interpreted as permission for unrestricted operations."-]

### Mechanism 1: Failure-Driven Prompt Mutation

[-**Day 7 (Mar 10) -- Second-order failure.** The same cron later hit a merge conflict. It reported the conflict and stopped -- exactly as mutation #8 required. But the restriction was too broad. The agent was in fact *capable* of resolving the conflict by reading the fork's patch documentation, understanding both sides' intent, and verifying with a build. The blanket prohibition prevented useful work. The merge was blocked for 24 hours.-]

### Mechanism 1: Failure-Driven Prompt Mutation

[-*Prompt after (mutation #14):* "Run the safe merge script. If conflicts remain, read the patch registry to understand intent, attempt resolution, verify with build. If genuinely uncertain, escalate."-]

### Mechanism 1: Failure-Driven Prompt Mutation

[-**Meta-lesson encoded (Level 2):** "When encoding a safety lesson, separate the failure mode from the restriction. The restriction should be proportional to the risk, not a blanket prohibition."-]

### Mechanism 1: Failure-Driven Prompt Mutation

[-That meta-lesson now applies to *all* future lesson encoding across the system. One incident produced a permanent improvement in how the system learns. As Section 6.2 shows, this same cascade is now the canonical test case for an automated strategy-switch trigger.-]

### Mechanism 2: Fractal Depth Calibration

[-#### Mechanism 2: Fractal Depth Calibration-]

### Mechanism 2: Fractal Depth Calibration

[-Not all tasks deserve the same metacognitive effort. Sleep Consolidation includes a **depth selector** -- a prompt-encoded heuristic that decides how many layers of "why" to traverse:-]

### Mechanism 2: Fractal Depth Calibration

[-| Signal | Depth | Example | | ------ | ----- | ------- | | Routine / mechanical | 0 | Read a file, send a message | | Something broke | 1--2 | Why did it break? What pattern? | | Encoding a new rule | 2--3 | Is the abstraction right? Am I over-correcting? | | Explicit request for depth | 3+ | Go until insight stops being actionable |-]

### Mechanism 2: Fractal Depth Calibration

[-**The self-similar property:** the depth selector is itself subject to refinement. When the agent zooms too deep on trivia and wastes tokens, or too shallow on something important and misses the lesson, that miscalibration becomes training data for adjusting the selector.-]

### Mechanism 2: Fractal Depth Calibration

[-**Convergence hypothesis (observed, not proven):** Most tasks stabilize at depth 0--1 within days of operation, while novel failure classes begin at depth 2--3 and move to 0--1 as their patterns become encoded. We see roughly weekly Level 2 refinements and roughly monthly Level 3 refinements, which suggests deeper reflection becomes less necessary as the system matures. We do not claim formal convergence -- only that the 30-day pattern is consistent with it.-]

### Mechanism 2: Fractal Depth Calibration

[-**Production example -- Fractal emergence (Mar 10):** The merge-conflict episode began at depth 0: just do it, abort on failure. After the B010 over-correction, a human prompt ("think fractal") triggered depth 3+ analysis, which revealed that the real problem was not merge strategy but the *method used to encode lessons*. The resulting principle -- "separate the failure mode from the restriction" -- now applies to every future lesson, not just merge conflicts.-]

### Mechanism 3: Cross-Cron Knowledge Transfer

[-#### Mechanism 3: Cross-Cron Knowledge Transfer-]

### Mechanism 3: Cross-Cron Knowledge Transfer

[-The strongest emergent property is that lessons learned in one autonomous task propagate to all others through shared memory files. A lesson learned in one domain -- "always double-check dates" -- spontaneously improves performance in another, the way a surgeon's steady hands might also make for a better painter, though no one taught the transfer. We documented 5 cross-domain transfer events over 30 days:-]

### Mechanism 3: Cross-Cron Knowledge Transfer

[-| # | Origin Task | Lesson Encoded | Transferred To | Observable Behavior Change | | - | ----------- | -------------- | -------------- | -------------------------- | | 1 | Calendar management | "When 'the X' is ambiguous, ask before acting" | Fork sync | Cron reported two interpretations of a conflict instead of guessing | | 2 | WhatsApp messaging | "Use ID-based targeting, never name-based" | All crons with messaging | Morning briefing switched from name to ID targeting | | 3 | Privacy incident | "Never include phone numbers in visible text" | All sessions | Online engagement cron redacted numbers in PR comments | | 4 | Fork sync (B010) | "Report-only crons must not modify systems" | Security audit cron | Audit reported findings without attempting fixes | | 5 | Memory consolidation | "Enforce file size budgets" | All report-generating crons | Reports began self-truncating at budget limits |-]

### Mechanism 3: Cross-Cron Knowledge Transfer

[-The transfer mechanism is architectural, not magical: lessons written to the operational-lessons file are read by all sessions at boot. But the **abstraction level** at which lessons are encoded determines transfer breadth. "Use ID-based targeting" (Level 0, specific) transfers only to messaging tasks. "When something is ambiguous, ask before acting" (Level 1, general) transfers much more widely.-]

### Mechanism 3: Cross-Cron Knowledge Transfer

[-Cross-cron transfer depends less on storing more and more on storing in the right shape: partitioned by decision type, action domain, and operating rule rather than accumulated chronologically.-]

### 3.4 The Nightly Cycle

[-### 3.4 The Nightly Cycle-]

### 3.4 The Nightly Cycle

[-The cycle runs as an ordered sequence of passes, each producing inputs for the next:-]

### 3.4 The Nightly Cycle

[-| Order | Pass | Role | Biological Analogy | | ----- | ---- | ---- | ------------------ | | 1 | Wind-Down | Review, identify failures, encode lessons, mutate prompts | Sleep replay / error correction | | 2 | Memory Consolidation | Compress daily logs, route knowledge, rebuild indexes | Hippocampal-to-neocortical transfer | | 3 | Fork Sync | Integrate external changes, self-heal build failures | Environmental adaptation during rest | | 4 | Cleaning | Trim bloated files, prune stale sessions, enforce budgets | Synaptic pruning |-]

### 3.4 The Nightly Cycle

[-**Critical ordering:** Wind-Down runs first because it produces the raw material -- identified failures and encoded lessons -- that Consolidation then routes to permanent storage. Cleaning runs last because it prunes temporary artifacts. We learned the cost of getting this wrong when a misconfigured schedule ran the cleaning pass before Wind-Down, pruning the very daily logs Wind-Down needed as input. (Wall-clock times for each pass have shifted across the deployment's life; the *ordering* is the invariant, not the hour.)-]

### 3.4 The Nightly Cycle

[-----]

### 4. Production Evidence -- 30 Days of Observed Improvement

[-## 4. Production Evidence -- 30 Days of Observed Improvement-]

### 4.1 Methodology and Limitations

[-### 4.1 Methodology and Limitations-]

### 4.1 Methodology and Limitations

[-**System:** an OpenClaw-based personal assistant running on a Linux workstation. Primary reflection model: the strongest available frontier model; daytime crons use a mix of strong and cheaper models. Roughly 12--13 autonomous cron jobs over the period. One human operator.-]

### 4.1 Methodology and Limitations

[-**Period:** February 8 -- March 10, 2026 (30 days).-]

### 4.1 Methodology and Limitations

[-**Data sources:** cron receipts (structured JSON, auto-generated per run), the operational-lessons file (git-versioned, all changes tracked), bug reports (structured markdown, manually filed), and daily Wind-Down logs.-]

### 4.1 Methodology and Limitations

[-**Labeling protocol:** error instances were identified from cron receipts (non-zero exit codes, escalation flags) and operator-reported incidents. Error *classes* were defined post hoc by the authors based on root-cause similarity. No inter-rater reliability was computed -- this is a single-system observational study, not a controlled experiment.-]

### 4.1 Methodology and Limitations

[-**Confounds we acknowledge:** over the 30-day period, the following changed at once: prompt content (the variable under study), cron ordering (adjusted twice), model assignments (three crons moved to a cheaper model), operator familiarity, and the upstream codebase (109 commits merged). We cannot isolate the contribution of prompt mutation from these confounds. The evidence is *consistent with* the Sleep Consolidation hypothesis but does not *prove* it.-]

### 4.1 Methodology and Limitations

[-**What a controlled study would look like:** run two identical agent deployments, one with nightly reflection enabled and one with static prompts. Measure error-recurrence rate, human-intervention frequency, task-completion quality (rated by blind evaluators), and time-to-resolution for novel incidents. Duration: at least 4 weeks. We have not conducted this study.-]

### 4.2 Prompt Mutations Observed

[-### 4.2 Prompt Mutations Observed-]

### 4.2 Prompt Mutations Observed

[-Over 30 days we documented 14 prompt mutations -- changes to cron prompts or operational rules triggered by real failures. "Documented" means the mutation has a git commit, a linked bug report or incident description, and a before/after prompt diff. We observed no mutations that were *reverted* as harmful, though mutation #8 was later *refined* by mutation #14 after an over-correction.-]

### 4.2 Prompt Mutations Observed

[-| # | Date | Trigger | Mutation | Scope | | - | ---- | ------- | -------- | ----- | | 1 | Feb 10 | Morning briefing missed calendar events | Added dual-calendar query requirement | Single cron | | 2 | Feb 14 | Cron sent message to wrong chat | Added explicit ID-based targeting, banned name lookup | All messaging crons | | 3 | Feb 16 | Memory files growing unbounded | Created size budgets, cleaning cron | System-wide | | 4 | Feb 19 | Agent skipped its boot-context file | Added mandatory boot sequence | All sessions | | 5 | Feb 22 | Renamed function broke heartbeat calls | Created a patch registry | Fork sync | | 6 | Feb 24 | Cron report was 40KB (unreadable) | Added budget fuses, formatting rules | All report crons | | 7 | Mar 01 | Agent included PII in a reply | Added privacy guardrail | All sessions | | 8 | Mar 03 | Fork sync cron edited production code (B010) | Added hard constraints to cron prompt | Fork sync | | 9 | Mar 03 | Same session: cron killed the gateway | Added "never force-kill processes" rule | All crons | | 10 | Mar 04 | Build failed after merge -- wrong externals | Auto-heal retry + wiring guardian | Fork sync | | 11 | Mar 05 | Model misidentified person from a headline | Added "always click through" rule | Self-evolution | | 12 | Mar 07 | Wind-Down wrote to the wrong day's log | Added a temporal-awareness step | Wind-Down | | 13 | Mar 08 | Agent didn't recognize a family member | Added mandatory daily-log reading to boot | All sessions | | 14 | Mar 10 | Merge abort on a single conflict too aggressive | Intelligent resolution with safe defaults | Fork sync |-]

### 4.2 Prompt Mutations Observed

[-**A mutation taxonomy.** Sorting the 14 mutations by intent lets others prioritize which kinds to automate first:-]

### 4.2 Prompt Mutations Observed

[-| Category | Mutations | Count | What it changes | | -------- | --------- | ----- | --------------- | | Safety / guardrail | #2, #7, #8, #9 | 4 | Prevents harmful or out-of-mandate actions | | Completeness | #1, #4, #12, #13 | 4 | Stops the agent acting on partial context | | Resource / efficiency | #3, #6 | 2 | Caps cost, size, and unreadable output | | Resilience / recovery | #5, #10, #14 | 3 | Self-heals after an external or build failure | | Verification | #11 | 1 | Forces a check before asserting a fact |-]

### 4.2 Prompt Mutations Observed

[-Two patterns stand out. First, safety and completeness dominate early failures (mutations 1--9), while resilience and proportional-constraint refinements appear later (10--14) -- the system first stops doing harmful things, then learns to keep doing useful ones safely. Second, the categories map cleanly onto the autonomy gates in Section 6: safety mutations are the ones that most need human review, while efficiency mutations are the safest to auto-apply.-]

### 4.3 Error Class Tracking

[-### 4.3 Error Class Tracking-]

### 4.3 Error Class Tracking

[-We tracked six error classes, defined by root-cause similarity:-]

### 4.3 Error Class Tracking

[-| Error Class | Definition | Wks 1--2 | Wks 3--4 | Status | | ----------- | ---------- | :------: | :------: | ------ | | Wrong chat / recipient | Message delivered to unintended target | 3 | 0 | No recurrence after mutation #2 | | File size explosion | Output exceeding readability / budget limits | 2 | 0 | No recurrence after mutation #3 | | Missing context at boot | Agent unaware of available information | 4 | 0 | No recurrence after mutations #4, #13 | | Unsafe cron actions | Cron acting outside its mandate | 2 | 0 | No recurrence after mutations #8, #9 | | Ambiguous request mishandled | Acting on ambiguous input without clarifying | 3 | 1 | Declining; 1 residual instance | | Over-broad safety rules | Safety constraints blocking legitimate work | 0 | 2 | New class, found via fractal analysis |-]

### 4.3 Error Class Tracking

[-**Total tracked incidents:** 14 (weeks 1--2) to 3 (weeks 3--4), a 79% reduction. Mistakes here don't just get patched; whole classes get eliminated -- like a spelling error that autocorrect learns once and never surfaces again. The emergence of "over-broad safety rules" as a *new* class in weeks 3--4 is especially notable. The error surface shifted from execution failures to policy failures. That is consistent with a maturing system: once first-order mistakes drop, second-order distortions become easier to see.-]

### 4.3 Error Class Tracking

[-**Caveat:** we cannot cleanly separate "errors eliminated by prompt mutation" from "errors eliminated by operator learning" (the operator stopped triggering certain edge cases as he learned the system). The confound is real and uncontrolled.-]

### 4.4 Token Economics

[-### 4.4 Token Economics-]

### 4.4 Token Economics

[-| Component | Tokens / night | Cost / night (est.) | | --------- | :------------: | :-----------------: | | Wind-Down | ~15K | $0.45 | | Consolidation | ~20K | $0.60 | | Cleaning | ~8K | $0.12 | | Total nightly overhead | ~43K | $1.17 |-]

### 4.4 Token Economics

[-Over 30 days, total reflection cost was about $35. We estimate 8 human-intervention incidents were avoided (based on error-class extinction -- incidents that would otherwise have required the operator to debug and fix manually). Valuing operator time at $25/hr with a 30-minute average resolution yields about $200 saved.-]

### 4.4 Token Economics

[-**Sensitivity analysis:** at $15/hr (low) ROI is 3.4x; at $50/hr (high) it is 11.4x. If only 4 incidents were truly avoided (conservative), ROI at $25/hr is still 2.9x. Under every reasonable assumption the reflection loop is cost-positive, though the estimates are approximate.-]

### 4.4 Token Economics

[-----]

### 5. The Fractal Metacognition Framework

[-## 5. The Fractal Metacognition Framework-]

### 5.1 Why Fractal?

[-### 5.1 Why Fractal?-]

### 5.1 Why Fractal?

[-"Fractal" here means **self-similar cognitive patterns applied at different scales of abstraction.** The same reflective sequence -- *what happened, why, what principle, what meta-principle* -- recurs at every level of task analysis.-]

### 5.1 Why Fractal?

[-The key insight: **the same reasoning that improves a specific task can also improve the category of tasks, the method used to improve categories, and eventually the method used to improve methods.** Each level operates on a smaller, more abstract domain than the one below.-]

### 5.2 Convergence Intuition (Not a Proof)

[-### 5.2 Convergence Intuition (Not a Proof)-]

### 5.2 Convergence Intuition (Not a Proof)

[-Consider error classes at multiple scales:-]

### 5.2 Convergence Intuition (Not a Proof)

[-- **Level 0** (execution): fix the specific bug. Eliminates one instance of one class. - **Level 1** (pattern): encode a rule preventing the class. Eliminates all instances of one class. - **Level 2** (methodology): improve how rules are encoded. Reduces the rate at which new classes arise from over- or under-correction. - **Level 3** (meta-methodology): improve how improvement works. Reduces the overhead of reflection itself.-]

### 5.2 Convergence Intuition (Not a Proof)

[-Each level operates on a smaller domain (instances > classes > methodology > meta-methodology). We *hypothesize* this produces convergent behavior: the frequency and magnitude of changes should fall at each higher level. Our 30-day observations fit that pattern (daily Level 0--1, weekly Level 2, monthly Level 3), but 30 days is not enough to establish convergence. The hypothesis is falsifiable: if Level 2+ mutation frequency does not fall over time, the convergence claim fails.-]

### 5.3 The Depth Selector as a Learned Policy

[-### 5.3 The Depth Selector as a Learned Policy-]

### 5.3 The Depth Selector as a Learned Policy

[-How deeply to reflect is itself a learnable policy. Initially the agent has little calibration. Over time the depth selector improves through its own mistakes:-]

### 5.3 The Depth Selector as a Learned Policy

[-- *Reflected too shallowly* on a merge strategy --> missed the over-correction pattern --> added depth for "encoding new rules" - *Reflected too deeply* on a routine file operation --> wasted compute --> reduced depth for "routine / mechanical"-]

### 5.3 The Depth Selector as a Learned Policy

[-We observe this self-calibration emerging over the 30-day period, but we lack quantitative metrics for "reflection-depth appropriateness." An instrumentation layer tracking tokens-spent-on-reflection versus value-of-insight-produced would enable a more rigorous evaluation.-]

### 5.3 The Depth Selector as a Learned Policy

[-----]

### 6. From Declarative to Procedural: Evolving Recipes, Strategies, and Skills

[-## 6. From Declarative to Procedural: Evolving Recipes, Strategies, and Skills-]

### 6. From Declarative to Procedural: Evolving Recipes, Strategies, and Skills

[-Sections 3--5 describe consolidation of *declarative* memory -- rules and facts. The same nightly loop has since been extended to *procedural* memory: the agent's own recipes, the strategies it switches between, and the reusable skills it distills. This is the cerebellum half of the analogy made literal -- offline practice refining the *procedures* themselves, not just the rules about them. All of these extensions share one shape: **observe the day's episodes, distil a durable ranked artifact, feed it back into tomorrow's behavior.** Each is an opt-in step in the consolidation pipeline, off by default, so the loop's baseline behavior is unchanged when the extension is absent. The three primary extensions operate at the recipe, strategy, and skill level; a finer per-step sharpening signal (Section 6.5) practices the single step of a recipe that keeps failing.-]

### 6. From Declarative to Procedural: Evolving Recipes, Strategies, and Skills

[-A load-bearing design boundary keeps this honest. Recipe *execution* lives in a separate subsystem; consolidation does not own it and must not duplicate it. The contribution here is strictly the *offline learning loop*: read episode outcomes, compute fitness, propose mutations, and write a ranked archive that the execution-time selector consumes. Recipes are owned by the execution subsystem; their *measured fitness* is owned by consolidation. Any write back into the execution subsystem's recipe directory is a *proposal* gated by human review (Section 7.1), never a silent overwrite.-]

### 6. From Declarative to Procedural: Evolving Recipes, Strategies, and Skills

[-![The three procedural extensions share one pipeline: each night the agent observes the day's episodes, distils a durable ranked artifact (recipe fitness, strategy-failure counts, extracted skills), and a single gate reconciles all proposals into one human-reviewed manifest that feeds tomorrow's selector.](images/procedural-extensions.png)-]

### 6.1 Recipe Evolution: Empirical Fitness and a Never-Delete Archive

[-### 6.1 Recipe Evolution: Empirical Fitness and a Never-Delete Archive-]

### 6.1 Recipe Evolution: Empirical Fitness and a Never-Delete Archive

[-A recipe is a procedure the agent runs to accomplish a recurring task. Recipes have historically been hand-written and static; nothing measured whether one was better than another, and nothing recorded how a recipe reached its current form. The recipe-evolution step adds a selection loop over the recipe population. Each night it attributes every completed episode to the recipe it used, scores that recipe's *empirical fitness* (success rate, latency, token cost), proposes mutations (add, remove, or reorder a step; tighten or loosen success criteria), keeps a never-delete archive of versioned variants, and ranks variants so the selector can prefer winners. It is the cerebellum turning a fumbled piano piece into a fluent one over successive nights.-]

### 6.1 Recipe Evolution: Empirical Fitness and a Never-Delete Archive

[-Fitness is computed from episode outcomes -- a `completed` episode counts as a success, an `abandoned` one as a failure -- with the success rate Laplace-smoothed so that one success out of one run is not reported as a perfect 1.0. Latency is the episode's end-minus-start time; token cost sums the events in the episode. The hard part is *attribution*: tying an episode to the recipe that ran it. Without a reliable recipe tag on each episode, fitness is computed against the wrong recipe and the loop learns garbage. The implementation only attributes when an explicit `recipe:<slug>` tag is present and returns no attribution otherwise, refusing to guess.-]

### 6.1 Recipe Evolution: Empirical Fitness and a Never-Delete Archive

[-Attribution is worth describing as a closed cycle because it is the seam where an offline loop most easily goes inert. The tag needs a *producer* as well as a consumer: at dispatch time a single `recipe:<owner/slug>` marker is appended into the run's episode event store -- a `turnId:0` system event shaped so it can neither flip the episode's inferred outcome (which keys off the *last* event) nor fragment the run into multiple episodes, and best-effort by design so a failed append never breaks the run it annotates. The nightly pass reads those tagged episodes, builds a fitness record keyed by the full `owner/slug`, and the *same* key is looked up at execution time to modulate runtime effort: a low-fitness recipe is treated as uncertain and given more re-dispatch and recovery headroom, a high-fitness one less. So measured fitness is not only an offline selection signal for ranking variants; it also shapes how much budget tomorrow's run receives. The load-bearing correctness property is the one-key round-trip -- the `owner/slug` produced must equal the `owner/slug` the consumer scores under -- because keying a lookup by the wrong identifier (slug-only against a full `owner/slug`) is exactly the silent mis-credit attribution is meant to prevent.-]

### 6.1 Recipe Evolution: Empirical Fitness and a Never-Delete Archive

[-Proposals are gated, not applied. They are written to a daily manifest for review. A narrow auto-promotion path exists for the safest case -- a *corrective* proposal (driven by a success rate at or below half the floor, i.e. 0.25 against a 0.5 floor, not merely under it) that is well-evidenced (at least 8 runs, above the 3-run minimum needed merely to propose) and reversible (the never-delete archive keeps every prior variant). Efficiency proposals, such as those driven by latency regression, are never auto-promoted. This is autonomy-first but bounded, and it maps directly onto the mutation taxonomy of Section 4.2: efficiency-class changes are the only ones the system trusts itself to apply unsupervised, and even those are logged and reversible.-]

### 6.1 Recipe Evolution: Empirical Fitness and a Never-Delete Archive

[-``` interface RecipeFitness { recipeId; version; runs; successes; successRate; // Laplace-smoothed for low n avgLatencyMs; avgTokenCost; lastUpdated; } interface MutationProposal { recipeId; baseVersion; op; // add_step | remove_step | reorder | tighten | loosen payload; rationale; expectedDelta; needsHumanReview; // false only for corrective + well-evidenced + reversible } // nightly step (opt-in) for each completed episode: rid = attributeRecipe(episode) // null unless a recipe:<slug> tag is present if rid is null: continue fit = updateRecipeFitness(archive.latest(rid), episode) archive.putVariant(rid, fit.version, currentBody(rid), fit) proposals += proposeMutations(fit, archive.history(rid)) writeManifest(proposals) // gated; auto-promote only the safe subset ```-]

### 6.2 Failure-Count Strategy Switch

[-### 6.2 Failure-Count Strategy Switch-]

### 6.2 Failure-Count Strategy Switch

[-A single failure triggers a prompt mutation, but the early system had no memory of *how many times in a row* a given strategy had failed, and no rule that said "this approach keeps failing -- switch to a different one." The strategy-switch step adds a per-strategy state machine that counts consecutive failures and fires a switch after a threshold is crossed within a recency window. This is the restaurant that, after the risotto comes back three nights running, stops tweaking the recipe and takes it off the menu.-]

### 6.2 Failure-Count Strategy Switch

[-The canonical case is the B010 cascade from Section 3.3. Three consecutive failures of an always-merge fork-sync strategy should trip a switch to an ask-before-merge strategy -- not a fourth identical patch. The implementation makes this concrete: the default threshold is **3 consecutive failures**, the recency window is **24 hours** (failures spread beyond it do not count as a pattern), and a switch is flagged for human review unless confidence clears **0.8** and a registered fallback strategy exists. Confidence rises with the overshoot past the threshold, so a strategy that has failed five times running is trusted more than one that has just reached three.-]

### 6.2 Failure-Count Strategy Switch

[-Two failure modes shaped the design. First, episode-boundary false positives: a long failing task can be split by the time-gap detector into several `abandoned` episodes, over-counting consecutive failures and tripping a premature switch -- so failures within the same task are de-duplicated. Second, idempotency: if the consolidation cursor goes stale and events are reprocessed, failures would double-count, so records are keyed by event id. A successful episode resets the counter to zero and, if a switch was just made, stamps the time-to-recovery -- which makes a switch that *didn't* help visible rather than silently sticky.-]

### 6.2 Failure-Count Strategy Switch

[-``` interface SwitchDecision { shouldSwitch; fromStrategy; toStrategy; // toStrategy null -> no fallback -> human confidence; needsHumanReview; rationale; } // decideSwitch: // IF consecutiveErrors >= threshold (default 3) // AND (now - lastFailure) < windowMs (default 24h) // THEN switch to fallback if registered, else flag for human; // needsHumanReview = confidence < 0.8 OR no fallback // ELSE no switch ```-]

### 6.2 Failure-Count Strategy Switch

[-The open contract decision -- whether the fallback map is hand-authored per strategy or learned from which alternatives historically scored higher fitness (which would couple this step to the recipe archive of 6.1) -- is deliberately left to a human. So is whether `abandoned` is a sufficient failure signal, since an episode can be abandoned because the *user* walked away, not because the strategy failed.-]

### 6.3 A Skill Library, Voyager-Style

[-### 6.3 A Skill Library, Voyager-Style-]

### 6.3 A Skill Library, Voyager-Style

[-Voyager's idea: as an agent solves tasks, distil the successful behavior into a named, reusable skill, store it in a growing library, rank skills by success, and retrieve and compose them on future tasks so competence compounds instead of being re-derived. The skill-extraction step applies this to a general assistant workload. From each *completed*, tool-using episode with a clear decision, it synthesizes a skill -- name, description, prerequisites, steps, test cases, success metrics -- stores it versioned in a never-delete library, ranks by empirical success rate, and exposes it to retrieval so a recurring situation can carry "this previously used skill X with Y% success." It is the cross-cron transfer of Section 3.3 turned from an emergent side effect into a first-class, addressable artifact.-]

### 6.3 A Skill Library, Voyager-Style

[-Three guards keep the library from rotting. A strict skill-worthiness gate -- completed plus a tool call plus a multi-step decision -- refuses to learn skills from trivial chat or abandoned attempts, so the library does not fill with non-general entries. A Jaccard-similarity dedup at **0.8** over the skill body merges near-identical skills rather than spawning duplicates; when a same-named skill recurs it becomes a new version, and the source-episode ids are merged. And success metrics decay on recent failure so a skill encoding an obsolete procedure stops ranking on past glory and becomes reachable for deprecation. Deprecation marks but never deletes -- the body is still readable, preserving the never-delete invariant the rest of the system relies on.-]

### 6.3 A Skill Library, Voyager-Style

[-The "skill-as-code versus skill-as-procedure" question this design raises has a concrete answer in this deployment: a skill is a typed record -- a name, description, prerequisites, ordered steps, and optional input/output schemas, plus a flat `lineage` field recording whether it came from composition, episode extraction, or promotion. It is invoked *inline* from a recipe through an `invoke skill:<id>` step directive that sits alongside the existing sub-recipe and loop directives; the directive injects the skill's procedure into the task and fails closed if the named skill is absent or deprecated. A small seeded standard library of four typed primitives -- summarize-text, extract-json-field, web-search-and-cite, and classify-text -- ships as the bootstrap population so the library is never empty on a cold start. The deposit path is fail-closed in the same spirit: a malformed skill (one needing a non-empty name and at least one step) is rejected, same-name deposits version-bump rather than clobber, curated seeds are guarded against silent overwrite, and a `promote` flag applies a *live-margin* fitness bar -- a candidate's measured success rate must clear the library's current success-rate mean plus one standard deviation (never a frozen N; an empty library is permissive). This is the "rank by empirical fitness, never delete" discipline made executable, governed by the same salience-not-frozen-bounds rule the rest of the loop follows.-]

### 6.3 A Skill Library, Voyager-Style

[-Retrieval is genuinely semantic rather than string overlap: skill search resolves the same in-process embedding function the consolidation pass uses (one embed provider, not a parallel one), does a batched-embed plus cosine ranking, and falls back to keyword matching only when no provider is present. When a new task finds no matching recipe, the system tries *compose-from-library* first -- a deterministic step that turns a skill search into a runnable recipe, one `invoke skill:` step per hit in rank order, authored as a non-curated "on-the-fly" recipe with its lineage stamped into the frontmatter so the authorship guard permits it without clobbering any hand-written recipe. Competence compounds instead of being re-derived, which is the Voyager promise this section invoked.-]

### 6.3 A Skill Library, Voyager-Style

[-One honest gap remains at the consolidation seam. Skill *deposit, retrieval, and invocation* are live, but the path by which the *nightly loop itself* mints new skills from the day's episodes is not yet wired: episode detection emits an empty key-decision list, so the skill-worthiness gate -- correct in itself -- is starved of input and the live library grows only from seeding and explicit deposits, not organically overnight. Closing that requires deriving key decisions from each episode's own tool-call trace (two or more distinct tool actions marking a multi-step procedure worth extracting; a lone one-shot call declined). Until that producer is added, the flywheel turns on demand but not in its sleep -- the same producer-seam lesson that the recipe-fitness loop already learned.-]

### 6.4 One Gate for Three Mutation Sources -- and a Consolidation Output the Thesis Demanded

[-### 6.4 One Gate for Three Mutation Sources -- and a Consolidation Output the Thesis Demanded-]

### 6.4 One Gate for Three Mutation Sources -- and a Consolidation Output the Thesis Demanded

[-All three extensions add new mutation or selection targets, and on a busy night they can fire for the same task at once: "mutate recipe X," "switch strategy," "use skill Y." Three ad-hoc gates would be three audit surfaces and three chances to thrash. The design calls for **one** arbitration point that collects the night's proposals, de-duplicates conflicting targets for the same task, applies a fixed precedence (a strategy switch outranks a skill suggestion, which outranks a recipe mutation, because a switch can invalidate the recipe a mutation was tuning), and writes a single reconciled manifest for review. This keeps the human-in-the-loop principle (Section 7.1) intact behind one surface. The per-night manifest that collects every proposal is in place; the precedence-based reconciler that de-duplicates conflicting targets for a task is the design's next step, not yet shipped.-]

### 6.4 One Gate for Three Mutation Sources -- and a Consolidation Output the Thesis Demanded

[-These procedural extensions also exposed a gap in the *declarative* loop that the paper's own thesis predicted. The thesis says consolidation must organize memory by purpose, not chronology. The early implementation did this for lessons, preferences, and contacts -- but not for *concept-to-document routing*. On April 1, a memory search returned the wrong documents because no concept index existed to route a topic to the files that discuss it. The system meant to prevent retrieval failure through organization had failed to organize the retrieval-critical artifact. The fix is a consolidation output (shown in Algorithm 1, Phase 2): for each knowledge file modified that day, extract retrieval keywords -- including the synonyms a human would actually search for -- and write a concept index mapping keywords to file paths. New or substantially changed knowledge files are also seeded with retrieval keywords so the keyword channel has material to match even when the document's natural language does not contain the search terms. We record the April 1 incident as the consolidation system's own failure case, which is exactly the kind of negative result Section 7 argues should be reported rather than hidden.-]

### 6.5 Per-Step Struggle Sharpening

[-### 6.5 Per-Step Struggle Sharpening-]

### 6.5 Per-Step Struggle Sharpening

[-Recipe fitness (Section 6.1) is *coarse*: it scores a whole recipe pass/fail and proposes whole-recipe mutations. But a recipe usually does not fail uniformly -- it fails at one step. A finer signal asks not "is this recipe weak?" but "which bar of the piece does it keep fumbling?" -- and practices that bar, not the whole piece. This is closer to what motor consolidation actually does, and it is the cerebellum analogy made one level sharper.-]

### 6.5 Per-Step Struggle Sharpening

[-The mechanism reads a source the coarse fitness store does not: the *live plan archive*. Every recipe run is archived as a plan with a per-step `status` and, on failure, a classified-error envelope. Across a recipe's archived runs, the reader aggregates each step's failure rate and the *modal* classified-error kind for that step, then flags steps that fail noticeably worse than the recipe's own baseline. For each flagged step it proposes a new mutation operator, `rewrite_step_text` -- sharpen the prose of that single struggling step, one step body changed, a patch-version bump -- applied through the same snapshot-reversible, authorship-guarded, validate-or-skip recipe-write path the other extensions use. It re-measures by diffing the step's failure rate across a later archive pass: a true before/after on the *step*, not a self-confirming success count.-]

### 6.5 Per-Step Struggle Sharpening

[-Two properties keep it disciplined. First, it routes around an inert store on purpose: it reads execution traces the system already keeps for free, so it produces a signal even when the recipe-fitness store is empty. With both signals present the loop now has two complementary fitness views -- coarse recipe-level and fine per-step -- not one redundant pair. Second, its thresholds are derived from the live sample, not frozen: the minimum-failure floor before a step is worth sharpening grows with the square root of the step's run count, and the struggle threshold tracks 1.5x the recipe's own mean step-failure rate, clamped. This is the same no-frozen-constants governance the rest of the consolidation loop follows, applied to the procedural side.-]

### 6.5 Per-Step Struggle Sharpening

[-Its default posture matches the other extensions: it *proposes only*. Application is gated behind an explicit auto-apply flag; only a step rewrite that is reversible, well-evidenced, and dominated by a recoverable error kind is flagged auto-promotable, inheriting the human-in-the-loop default of Principle 7. A nightly lane dispatches the optimize pass for struggling recipes, and the absence of any archive leaves the consolidation output byte-identical -- the same opt-in, safe-when-absent discipline every Section 6 extension claims.-]

### 6.5 Per-Step Struggle Sharpening

[-----]

### 7. Design Principles for Sleep Consolidation Systems

[-## 7. Design Principles for Sleep Consolidation Systems-]

### 7. Design Principles for Sleep Consolidation Systems

[-From production experience, we propose nine design principles. The last two are imported from external authoring discipline (Osmani, *addyosmani/agent-skills*) rather than derived from our own incidents, and are flagged as such.-]

### Principle 1: Separate Fast and Slow Learning

[-### Principle 1: Separate Fast and Slow Learning-]

### Principle 1: Separate Fast and Slow Learning

[-Operational sessions handle tasks (fast). Nightly crons handle reflection (slow). Never mix reflection into task execution -- it degrades task performance and produces worse reflection. This mirrors Kahneman's System 1 / System 2 distinction (Kahneman, 2011) and the biological separation of online performance from offline consolidation.-]

### Principle 2: Encode at the Right Abstraction Level

[-### Principle 2: Encode at the Right Abstraction Level-]

### Principle 2: Encode at the Right Abstraction Level

[-"Always check both calendars" is Level 0. "When a system has multiple data sources, query all of them" is Level 1. "Verify completeness assumptions before acting" is Level 2. Encode at the highest level that stays *actionable* -- too abstract and it becomes empty, too specific and it fails to transfer.-]

### Principle 3: Shared Memory > Private Memory

[-### Principle 3: Shared Memory > Private Memory-]

### Principle 3: Shared Memory > Private Memory

[-Lessons stored in a single cron's prompt help only that cron. Lessons stored in shared operational files help every session. Default to shared storage; use private storage only for domain knowledge that would confuse other tasks.-]

### Principle 4: Proportional Constraints

[-### Principle 4: Proportional Constraints-]

### Principle 4: Proportional Constraints

[-When encoding a safety lesson from a failure, the restriction should match the risk. "Never edit source code" is disproportionate to "a cron edited the wrong file once." "Understand intent before editing, verify after, revert if broken" is proportional and preserves capability. This is the central lesson of the B010 --> mutation #14 cascade, and it is now enforced mechanically by the strategy-switch step (6.2): a repeated failure switches the strategy rather than piling on another blanket prohibition.-]

### Principle 5: Temporal Ordering of Nightly Cycles

[-### Principle 5: Temporal Ordering of Nightly Cycles-]

### Principle 5: Temporal Ordering of Nightly Cycles

[-Reflection --> Consolidation --> Integration --> Pruning. Each stage produces inputs for the next.-]

### Principle 6: The Budget Fuse

[-### Principle 6: The Budget Fuse-]

### Principle 6: The Budget Fuse

[-Every reflection loop must have a token budget and a wall-clock timeout. Without one, a sufficiently thorough reflection agent will chase diminishing returns indefinitely. The procedural extensions of Section 6 inherit this discipline: proposals require a minimum number of runs before firing, and the skill library carries the same size-budget and dedup pressure the operational-lessons file already does.-]

### Principle 7: Human-in-the-Loop for Level 2+ Changes

[-### Principle 7: Human-in-the-Loop for Level 2+ Changes-]

### Principle 7: Human-in-the-Loop for Level 2+ Changes

[-Level 0--1 mutations (specific fixes and pattern rules) can be autonomous. Level 2+ mutations (methodology changes, core-principle edits) must be flagged for review. **Concrete gate:** any mutation that modifies the core-principles file (injected into all sessions) or changes the depth selector itself requires human approval before taking effect. Mutations to individual cron prompts or the operational-lessons file can be auto-applied but are logged with full diffs for audit. The procedural extensions follow the same rule: recipe mutations, strategy switches, and skills are gated by default, with a narrow auto-promotion path only for corrective, well-evidenced, reversible changes (Section 6.1).-]

### Principle 7: Human-in-the-Loop for Level 2+ Changes

[-**Rollback mechanism:** all mutations are git-committed with descriptive messages and can be reverted. Each night logs a "mutation manifest" listing all changes, enabling batch review; the procedural extensions write to the same manifest so there is a single audit surface.-]

### Principle 8: Encode an Anti-Trigger, Not Just a Trigger

[-### Principle 8: Encode an Anti-Trigger, Not Just a Trigger-]

### Principle 8: Encode an Anti-Trigger, Not Just a Trigger

[-A lesson that only says *when* to fire is half a rule. Borrowed from the "When NOT to use" convention that every Agent-Skill carries (Osmani, *addyosmani/agent-skills*), this principle says each encoded lesson, recipe, and skill should also declare the conditions under which it must *not* apply. This is the depth selector made explicit: the selector already decides when *not* to reflect deeply, and the same discipline belongs on every artifact the consolidation loop writes. An over-broad safety rule -- the very error class that emerged new in weeks 3--4 (Section 4.3) -- is precisely a rule with a missing anti-trigger; encoding the negative case up front is the structural prevention for it, not just the post-hoc fractal correction.-]

### Principle 9: Declare Where a Mutation May Load

[-### Principle 9: Declare Where a Mutation May Load-]

### Principle 9: Declare Where a Mutation May Load

[-Borrowed from the "Loading Constraints" convention of Agent-Skills (Osmani, *addyosmani/agent-skills*), every mutation should declare its load scope explicitly -- which files it may touch and which sessions it may reach -- rather than leaving scope implicit in the act of writing. This is the structural form of Principle 7's per-target gating: a mutation that declares "core-principles file, all sessions" is self-identifying as Level 2+ and routes itself to human review, while one that declares "a single cron prompt" is self-identifying as auto-applicable. Making the load scope a declared field rather than an inferred property is what lets the Section 6.4 gate arbitrate by precedence without re-deriving each proposal's blast radius.-]

### Principle 9: Declare Where a Mutation May Load

[-----]

### 8. Limitations and Failure Modes

[-## 8. Limitations and Failure Modes-]

### 8.1 The Self-Reinforcing Error Spiral

[-### 8.1 The Self-Reinforcing Error Spiral-]

### 8.1 The Self-Reinforcing Error Spiral

[-If a reflection loop encodes the wrong lesson, that lesson shapes future behavior, generating data that appears to confirm it -- the AI analogue of confirmation bias. The risk grows with the procedural extensions of Section 6: a bad recipe mutation or an over-eager strategy switch could generate episodes that look like vindication.-]

### 8.1 The Self-Reinforcing Error Spiral

[-**Mitigations (implemented):**-]

### 8.1 The Self-Reinforcing Error Spiral

[-- Human review for Level 2+ changes (Principle 7), extended to recipe mutations, strategy switches, and skills by default. - Git-versioned mutation log and a never-delete archive enabling revert at any point. - A nightly mutation manifest -- one surface -- for batch review. - Minimum-run thresholds before any procedural proposal fires, so low-n noise cannot trigger a change.-]

### 8.1 The Self-Reinforcing Error Spiral

[-**Mitigations (proposed, not yet implemented):**-]

### 8.1 The Self-Reinforcing Error Spiral

[-- Automated regression checklist: after each mutation, re-run known-good scenarios to detect degradation. - "Canary mode": apply new mutations tentatively for 48 hours, then auto-revert if error rates rise. - Signed mutation provenance recording the triggering incident, the model that generated the mutation, and a confidence level. - A **fresh-context doubt pass**, adapting doubt-driven development (Osmani, *addyosmani/agent-skills*): before the single-gate reconciler of Section 6.4 commits the night's manifest, a reviewer in fresh context -- fed only the *artifacts* (the mutation diffs, recipe-fitness records, strategy-switch decisions) and the *contract* (the operational-lessons principles they must not contradict), with the original reasoning that produced them deliberately stripped -- adversarially challenges each proposed change. The mechanism design is precise about *why* it helps: the model instance that wrote a mutation shares the priors that produced it, so it cannot be relied on to doubt it; a reviewer that never saw that reasoning can. The pass is bounded the same way Osmani bounds it -- trivial findings, a small cycle cap, and human override -- and folds into the existing manifest plus human-review gate rather than adding a new audit surface. This directly attacks the spiral: a lesson that merely re-confirms its own priors is the failure mode, and a reasoning-blind reviewer is the cheapest available antidote.-]

### 8.2 Context Window Pressure

[-### 8.2 Context Window Pressure-]

### 8.2 Context Window Pressure

[-Every encoded lesson consumes context-window space. As the operational-lessons file grows, it competes with task-relevant context. The cleaning pass enforces size budgets (currently 50KB) and archives stale content. In the earlier design this created a second-order problem -- archived lessons could become unavailable when they were relevant again, with only best-effort semantic retrieval to surface them, a hedge rather than a guarantee.-]

### 8.2 Context Window Pressure

[-The principled fix is to make compaction *reversible by construction* rather than lossy, adopting the Compress-Cache-Retrieve (CCR) discipline of Headroom (Chopra, *chopratejas/headroom*). Under CCR, every compressed pointer-summary carries a handle to the cached original, so a lesson that proves insufficient in its compacted form can always be retrieved in full -- *lossless under recall* -- rather than relying on a re-embedding lottery to find it again. Headroom validates this within a single session, compressing task-time tool output and reporting 60--95% token savings with near-zero accuracy delta; Sleep Consolidation applies the same contract across sessions to consolidated memory, and the difference that matters is precisely reversibility: our archived lesson must never become unreachable. A second property worth borrowing is Headroom's per-content-type compressor family rather than one uniform compaction, which matters here because our knowledge files, JSON cron receipts, and recipe bodies have very different compressibility and lose very different things under naive truncation. With CCR in place, this section's hedge ("archived content may be unavailable") collapses to an engineering invariant rather than a residual risk. The skill library of Section 6.3 raises the same bloat risk and inherits the same budget, dedup, and never-delete discipline -- which is itself CCR-shaped: originals kept, ranked variants surfaced.-]

### 8.3 Model Dependency

[-### 8.3 Model Dependency-]

### 8.3 Model Dependency

[-Reflection quality depends on the model's reasoning capability. We use the strongest available model for nightly reflection and cheaper models for daytime execution, which creates a cost asymmetry: the "learning" is only as good as the reflection model. A weaker reflection model would produce lower-quality mutations, potentially encoding bad lessons and amplifying the spiral of Section 8.1. The skill-extraction step adds a related risk -- the same episode extracted twice with different wording can slip past string-level dedup -- which is why semantic dedup, not just Jaccard, is the intended longer-term guard.-]

### 8.4 Single-Operator Bias

[-### 8.4 Single-Operator Bias-]

### 8.4 Single-Operator Bias

[-Our data comes from one operator with specific workflows, preferences, and failure patterns. Whether Sleep Consolidation generalizes to multi-user systems, other cultural contexts, or domains beyond personal-assistant tasks is an open question. We hypothesize that the *mechanisms* generalize (failure-driven mutation, cross-task transfer, depth calibration, recipe and skill evolution) even if the specific *lessons* do not.-]

### 8.5 No True Generalization

[-### 8.5 No True Generalization-]

### 8.5 No True Generalization

[-The fundamental limit is that prompt-mediated learning produces *declarative* improvements (better rules, better context), not *procedural* improvements in the model's own reasoning. The recipe and skill extensions of Section 6 push further into procedural territory than rules alone, but they still encode procedures *as artifacts the unchanged model reads*, not as better reasoning inside the model. The model's reasoning capability does not itself improve. A sufficiently novel failure class will not be prevented by any amount of prompt or recipe refinement.-]

### 8.5 No True Generalization

[-This is the ceiling of Level 2 on the persistence hierarchy. Sleep Consolidation raises that ceiling higher than most production systems currently exploit, but it does not break through it. True generalization still requires weight updates.-]

### 8.5 No True Generalization

[-----]

### 9. Future Work

[-## 9. Future Work-]

### 9.1 Controlled Ablation Study

[-### 9.1 Controlled Ablation Study-]

### 9.1 Controlled Ablation Study

[-The highest-priority follow-up is straightforward: run two identical deployments (with and without nightly reflection) for 4+ weeks, measuring error-recurrence rate, intervention frequency, and blind-rated task quality. This directly addresses the confounds of Section 4.1 and moves the evidence from observational to experimental. A second ablation should isolate each Section 6 extension, since they were added incrementally and their individual contribution to error reduction is not yet separated from the declarative loop's.-]

### 9.2 Multi-Phase Sleep Cycles

[-### 9.2 Multi-Phase Sleep Cycles-]

### 9.2 Multi-Phase Sleep Cycles

[-The current loop is a single nightly pass. A multi-phase split would mirror biological sleep more closely: a *light* phase every few hours for quick episode detection and index updates, a *deep* phase nightly for full consolidation and skill extraction, and a *REM* phase weekly for cross-episode pattern detection and higher-order skill clustering. The weekly phase is the natural home for composing several episodes into one higher-order skill rather than extracting one skill per episode.-]

### 9.3 Multi-Agent Prompt Ecosystems

[-### 9.3 Multi-Agent Prompt Ecosystems-]

### 9.3 Multi-Agent Prompt Ecosystems

[-If multiple agents share a memory layer, do lessons from one agent's failures benefit others? Preliminary evidence from cross-agent collaboration suggests yes, but systematic study is needed.-]

### 9.4 Automatic Depth Calibration

[-### 9.4 Automatic Depth Calibration-]

### 9.4 Automatic Depth Calibration

[-The fractal depth selector is currently prompt-encoded and manually refined. An instrumented version tracking tokens-spent-on-reflection versus downstream-error-reduction would enable quantitative optimization of reflection effort.-]

### 9.5 Bridging to Fine-Tuning

[-### 9.5 Bridging to Fine-Tuning-]

### 9.5 Bridging to Fine-Tuning

[-Encoded lessons are `(failure, context, correct_behavior)` tuples -- exactly the format preference optimization needs. The recipe-fitness archive of Section 6.1 adds graded outcome signals on top. Sleep Consolidation could therefore serve as a *data-generation pipeline* for periodic weight updates, bridging Level 2 and Level 3 persistence.-]

### 9.6 Adversarial Robustness

[-### 9.6 Adversarial Robustness-]

### 9.6 Adversarial Robustness

[-Can a crafted input trigger a harmful prompt mutation, recipe change, or strategy switch? The current mitigation (human review for Level 2+ and for procedural proposals) is manual. Automated detection of adversarial mutations -- consistency checking against existing principles -- now has a concrete, externally-validated instantiation rather than remaining a vague aspiration: the fresh-context doubt pass of Section 8.1, adapted from doubt-driven development (Osmani, *addyosmani/agent-skills*). Checking a mutation against the operational-lessons contract in a reasoning-blind reviewer is exactly the consistency check this item asked for; what remains open is making it robust enough to run unattended -- bounding false positives so a legitimate proportional-constraint refinement (the kind of useful mutation Section 4.2 tracks) is not reflexively doubted into oblivion, and proving the reviewer itself cannot be steered by the same crafted input that seeded the bad mutation.-]

### 9.6 Adversarial Robustness

[-----]

### 10. Conclusion

[-## 10. Conclusion-]

### 10. Conclusion

[-We have presented observational evidence that structured nightly prompt cycles can produce compounding behavioral improvement in stateless AI agents. Sleep Consolidation formalizes three declarative mechanisms -- failure-driven prompt mutation, fractal depth calibration, and cross-cron knowledge transfer -- and extends them into procedural memory through recipe evolution, strategy switching, and a skill library.-]

### 10. Conclusion

[-The core claim is modest but important: **you do not need to change the model's weights to change the model's behavior.** A well-designed ecosystem of self-modifying prompts and shared memory files, driven by scheduled reflection, can produce improvements that look like learning even when no parameters are updated.-]

### 10. Conclusion

[-The deeper claim is about structure. Memory alone is not enough. **Unsorted memory is cheap to store and expensive to use.** The breakthrough is not accumulation; it is consolidation. Scattered memories are operationally useless until they are organized by purpose: rules for messaging, policies for ambiguity, lessons from failures, recipes ranked by what actually worked. Once sorted by use-case rather than chronology, those memories stop being archives and start becoming policy.-]

### 10. Conclusion

[-We are careful to distinguish observation from proof. Our 30-day production data is consistent with the hypothesis but confounded by simultaneous changes in operator behavior, model assignment, and system configuration. Still, the mechanisms are formalized (Algorithm 1), the design principles are actionable, the procedural extensions are implemented and tested, and the trend is hard to ignore: over 30 days, five of six tracked error classes reached zero recurrence while total incidents dropped 79%.-]

### 10. Conclusion

[-This is not a replacement for fine-tuning or continual learning. It is a complement -- an accessible, low-cost mechanism any agent system with file persistence and scheduled execution can implement now. The prompts rewrite themselves. The recipes get ranked. The memory layer gets cleaner. The agent makes fewer of yesterday's mistakes.-]

### 10. Conclusion

[-Sleep Consolidation does not make the model fundamentally smarter. It makes the system more organized, more adaptive, and more reliable. In practice, that is often what intelligence looks like.-]

### 10. Conclusion

[-----]

### References

[-## References-]

### References

[-Bai, Y., et al. (2022). Constitutional AI: Harmlessness from AI Feedback. *arXiv:2212.08073*.-]

### References

[-Beyer, B., Jones, C., Petoff, J., & Murphy, N. R. (2016). *Site Reliability Engineering.* O'Reilly Media.-]

### References

[-Buzsáki, G. (1996). The hippocampo-neocortical dialogue. *Cerebral Cortex*, 6(2), 81--92.-]

### References

[-Chopra, T. (2025). Headroom: Reversible Compress-Cache-Retrieve for LLM Context Management. *chopratejas/headroom*, GitHub (Apache-2.0).-]

### References

[-Fernando, C., et al. (2023). PromptBreeder: Self-Referential Self-Improvement via Prompt Evolution. *arXiv:2309.16797*.-]

### References

[-French, R. M. (1999). Catastrophic forgetting in connectionist networks. *Trends in Cognitive Sciences*, 3(4), 128--135.-]

### References

[-Hu, E. J., et al. (2021). LoRA: Low-Rank Adaptation of Large Language Models. *arXiv:2106.09685*.-]

### References

[-Hu, S., et al. (2024). Automated Design of Agentic Systems. *arXiv:2408.08435*.-]

### References

[-Kahneman, D. (2011). *Thinking, Fast and Slow.* Farrar, Straus and Giroux.-]

### References

[-Khattab, O., et al. (2023). DSPy: Compiling Declarative Language Model Calls into Self-Improving Pipelines. *arXiv:2310.03714*.-]

### References

[-Lewis, P., et al. (2020). Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks. *NeurIPS 2020*.-]

### References

[-Madaan, A., et al. (2023). Self-Refine: Iterative Refinement with Self-Feedback. *NeurIPS 2023*.-]

### References

[-McClelland, J. L., McNaughton, B. L., & O'Reilly, R. C. (1995). Why there are complementary learning systems in the hippocampus and neocortex. *Psychological Review*, 102(3), 419--457.-]

### References

[-Osmani, A. (2025). Agent-Skills: Reusable Skills and Doubt-Driven Development for Coding Agents. *addyosmani/agent-skills*, GitHub.-]

### References

[-Packer, C., et al. (2023). MemGPT: Towards LLMs as Operating Systems. *arXiv:2310.08560*.-]

### References

[-Park, J. S., et al. (2023). Generative Agents: Interactive Simulacra of Human Behavior. *UIST 2023*.-]

### References

[-Shinn, N., et al. (2023). Reflexion: Language Agents with Verbal Reinforcement Learning. *NeurIPS 2023*.-]

### References

[-Wang, G., et al. (2023). Voyager: An Open-Ended Embodied Agent with Large Language Models. *arXiv:2305.16291*.-]

### References

[-Yang, C., et al. (2023). Large Language Models as Optimizers. *arXiv:2309.03409*.-]

### References

[-Yao, S., et al. (2023). ReAct: Synergizing Reasoning and Acting in Language Models. *ICLR 2023*.-]

### References

[-----]

### Appendix A: The Nightly Cycle (Illustrative Cron Schedule)

[-## Appendix A: The Nightly Cycle (Illustrative Cron Schedule)-]

### Appendix A: The Nightly Cycle (Illustrative Cron Schedule)

[-The exact wall-clock times have changed across the deployment's life; what follows is one representative configuration during the observation period. The *ordering* of reflection before consolidation before pruning is the invariant; the hours are not.-]

### Appendix A: The Nightly Cycle (Illustrative Cron Schedule)

[-| Job | Model tier | Purpose | Tokens / run | | --- | ---------- | ------- | :----------: | | Token Refresh | cheap | Keep auth alive | ~2K | | DB Backup | cheap | Back up local databases | ~2K | | Memory Index Rebuild | cheap | Rebuild the search index | ~3K | | Wind-Down | strongest | Reflect, encode lessons, mutate prompts | ~15K | | Memory Consolidation | strongest | Compress, route, index knowledge | ~20K | | Security Check | strong | OS / network security audit | ~12K | | Fork Sync | strong | Merge upstream, self-heal build | ~10K | | Fork Scanner | strong | Analyze other forks for ideas | ~25K | | Cleaning | mid-tier | Prune sessions, enforce size budgets | ~8K | | Self-Evolution | strong | Research new models and techniques | ~20K | | Group Summary | strong | Summarize message groups | ~15K | | Life Butler | strong | Personal-secretary tasks | ~10K | | Morning Briefing | strong | Daily summary + action items | ~12K | | Online Engagement | strong | Community outreach, code review | ~12K |-]

### Appendix B: Prompt Mutation Examples (Selected)

[-## Appendix B: Prompt Mutation Examples (Selected)-]

### Mutation #8 -- B010 Incident (Mar 3)

[-### Mutation #8 -- B010 Incident (Mar 3)-]

### Mutation #8 -- B010 Incident (Mar 3)

[-**Trigger:** the fork-sync cron edited a source file, ran a build, and killed the gateway.-]

### Mutation #8 -- B010 Incident (Mar 3)

[-**Root cause:** the prompt said "sync the fork" -- the model read that as permission to do whatever syncing required.-]

### Mutation #8 -- B010 Incident (Mar 3)

[-**Mutation (v1), as language-agnostic policy:**-]

### Mutation #8 -- B010 Incident (Mar 3)

[-``` HARD CONSTRAINTS: - never modify source code directly - never run a build - never restart or kill the gateway - if the safe-merge step fails, report and STOP ```-]

### Mutation #14 -- Over-correction Fix (Mar 10)

[-### Mutation #14 -- Over-correction Fix (Mar 10)-]

### Mutation #14 -- Over-correction Fix (Mar 10)

[-**Trigger:** mutation #8 prevented the agent from resolving a merge conflict it was capable of resolving.-]

### Mutation #14 -- Over-correction Fix (Mar 10)

[-**Root cause:** mutation #8 encoded a blanket prohibition where a proportional constraint would have preserved capability.-]

### Mutation #14 -- Over-correction Fix (Mar 10)

[-**Mutation (v2), as language-agnostic policy:**-]

### Mutation #14 -- Over-correction Fix (Mar 10)

[-``` SAFETY CONSTRAINTS (replaces HARD CONSTRAINTS): - never blanket-overwrite local changes with upstream - you MAY edit source files to resolve a conflict - you MAY run a build to verify your resolution - always preserve the fork's protected patch strings - when in doubt: keep local changes and escalate ```-]

### Mutation #14 -- Over-correction Fix (Mar 10)

[-**Meta-lesson encoded:** "When encoding a safety lesson, separate the failure mode from the restriction. The restriction should be proportional to the risk, not a blanket prohibition." This cascade is now the canonical test case for the automated strategy-switch trigger of Section 6.2: three consecutive always-merge failures within a day switch the strategy rather than adding a fourth patch.-]

### Appendix C: The Fractal Depth Selector (Representative Production Version)

[-## Appendix C: The Fractal Depth Selector (Representative Production Version)-]

### Appendix C: The Fractal Depth Selector (Representative Production Version)

[-``` Default Fractal Depth Selector:-]

### Appendix C: The Fractal Depth Selector (Representative Production Version)

[-| Signal | Depth | |---------------------------------|--------------------------------------| | Routine / mechanical task | 0 -- just do it | | Something broke or surprised me | 1-2 -- what pattern? what lesson? | | Encoding a new rule/constraint | 2-3 -- is the abstraction right? | | Explicit request for depth | 3+ -- go until insight is actionable |-]

### Appendix C: The Fractal Depth Selector (Representative Production Version)

[-Application rule: on any non-trivial completed action, spend a few seconds asking "one level up: what pattern does this instance belong to?" If interesting, go one more. If not, stop. ```-]

### Appendix D: Procedural-Extension Defaults

[-## Appendix D: Procedural-Extension Defaults-]

### Appendix D: Procedural-Extension Defaults

[-Representative default thresholds for the Section 6 extensions, as configured in the deployment:-]

### Appendix D: Procedural-Extension Defaults

[-| Extension | Parameter | Default | Effect | | --------- | --------- | :-----: | ------ | | Recipe evolution | Minimum runs to propose | 3 | Below this, no proposal fires | | Recipe evolution | Minimum runs to auto-promote | 8 | Below this, every proposal is human-gated | | Recipe evolution | Success floor | 0.5 | Below this, a corrective proposal is generated | | Recipe evolution | Auto-promote floor ratio | 0.5 | Auto-promote only when success rate <= floor x this (i.e. <= 0.25) | | Strategy switch | Consecutive-failure threshold | 3 | Trips a switch when reached | | Strategy switch | Recency window | 24h | Failures older than this don't count | | Strategy switch | Min confidence to auto-switch | 0.8 | Below this, the switch is human-gated | | Skill library | Dedup similarity (Jaccard) | 0.8 | Above this, two skills merge |-]

### References

{+_J-series paper J5 | Version 7.0 | 2026-10-12_+}
