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

From v6.0 (2 Jun) to v6.1 (2 Jun): 9,441 words to 10,375 words, 1,138 words in new or rewritten paragraphs and 204 taken out, 16 paragraphs changed.

## Change note of v6.1

**Architecture diagram added and the three layers tied to nightly jobs**

A large architecture diagram is added to Section 1.1: daytime jobs, the nightly cycle and shared memory, with the arrows between them. The system overview now names which nightly pass maintains each layer: index rebuild for retrieval, consolidation for storage, wind-down for the prompt files. The diagram for Section 6 is drawn in the same way. The revision-history appendix is dropped.

## Changed paragraphs

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

### Sleep Consolidation: How Structured Nightly Prompting Produces Emergent Behavioral Improvement in Stateless AI Agents

[-# Sleep Consolidation: How Structured Nightly Prompting Produces Emergent Behavioral Improvement in Stateless AI Agents-]

### Sleep Consolidation: How Structured Nightly Prompting Produces Emergent Behavioral Improvement in Stateless AI Agents

[-**Authors:** Oscar Serra, JarvisOne AI Research **Date:** June 2026 (v6.0) **Keywords:** emergent behavior, prompt engineering, cron-driven learning, self-improving agents, fractal metacognition, autonomous orchestration, memory consolidation, recipe evolution, skill libraries, operational lessons-]

### Sleep Consolidation: How Structured Nightly Prompting Produces Emergent Behavioral Improvement in Stateless AI Agents

[-----]

### 1.1 Where This Sits Among the Memory Systems

{+\begin{figure}[htbp] \centering \resizebox{\linewidth}{!}{% \begin{tikzpicture}[ font=\small, box/.style={rectangle, rounded corners=4pt, draw, line width=0.9pt, align=center, inner sep=8pt}, chip/.style={rectangle, rounded corners=2pt, draw=jsBorder, fill=white, align=center, inner sep=4pt, font=\scriptsize, minimum height=0.7cm}, tag/.style={rectangle, rounded corners=2pt, draw=jsLink!60, fill=jsLink!8, align=center, inner sep=4pt, font=\scriptsize}, lbl/.style={font=\scriptsize\itshape, align=center}, ] % Daytime crons (orange) \node[box, fill=orange!12, draw=orange!70, text width=13.5cm, minimum height=1.7cm] (crons) { \textbf{\color{jsTitle}Daytime Crons --- execution layer}\\[1pt] {\scriptsize\itshape consumers AND producers}\\[1.0cm] }; \node[chip] at ($(crons.south)+(-5.6,0.45)$) {Morning Briefing}; \node[chip] at ($(crons.south)+(-3.05,0.45)$) {Online Engagement}; \node[chip] at ($(crons.south)+(-0.9,0.45)$) {Life Butler}; \node[chip] at ($(crons.south)+(0.95,0.45)$) {Fork Sync}; \node[chip] at ($(crons.south)+(3.1,0.45)$) {Security Check}; \node[chip] at ($(crons.south)+(5.5,0.45)$) {$\sim$12--13 crons}; % Nightly cycle (green) \node[box, fill=jsSection!12, draw=jsSection!70, text width=11cm, below=2.2cm of crons] (nightly) { \textbf{\color{jsSection}Nightly Cycle --- reflection layer}\\[5pt] \begin{minipage}{10.2cm}\centering \fbox{\parbox{9.6cm}{\centering\scriptsize\textbf{1. Wind-Down} --- identify failures, encode lessons, mutate prompts}}\\[2pt] $\downarrow$\\[1pt] \fbox{\parbox{9.6cm}{\centering\scriptsize\textbf{2. Memory Consolidation} --- compress logs, route knowledge, rebuild + concept-index}}\\[2pt] $\downarrow$\\[1pt] \fbox{\parbox{9.6cm}{\centering\scriptsize\textbf{3. Cleaning} --- prune stale, enforce 50KB budgets}} \end{minipage}\\[3pt] {\scriptsize\itshape ordering is the invariant (Reflection $\rightarrow$ Consolidation $\rightarrow$ Pruning)} }; % Shared memory (blue) \node[box, fill=jsLink!12, draw=jsLink!70, text width=13.5cm, minimum height=1.6cm, below=2.2cm of nightly] (mem) { \textbf{\color{jsLink}Shared Memory Layer}\\[0.9cm] }; \node[chip] at ($(mem.south)+(-5.3,0.4)$) {operational-lessons}; \node[chip] at ($(mem.south)+(-2.7,0.4)$) {failure DB}; \node[chip] at ($(mem.south)+(0,0.4)$) {domain knowledge}; \node[chip] at ($(mem.south)+(2.7,0.4)$) {core-principles}; \node[chip] at ($(mem.south)+(5.3,0.4)$) {cron prompts}; % three static layer tags \node[tag, below=1.1cm of mem.south, xshift=-4.5cm] (storage) {Storage layer\\compaction thresholds}; \node[tag, below=1.1cm of mem.south] (retrieval) {Retrieval layer\\index + scoring weights}; \node[tag, below=1.1cm of mem.south, xshift=4.5cm] (identity) {Identity layer\\prompt files}; % arrows \draw[-{Stealth[length=3mm]}, jsSection, line width=1.2pt] (crons) -- node[right, lbl] {emit receipts + logged failures} (nightly); \draw[-{Stealth[length=3mm]}, jsAccent, line width=1.2pt] (nightly) -- node[right, lbl] {writes mutations} (mem); \draw[-{Stealth[length=2mm]}, dotted, jsLink, line width=0.8pt] (mem.south) -- (storage.north); \draw[-{Stealth[length=2mm]}, dotted, jsLink, line width=0.8pt] (mem.south) -- (retrieval.north); \draw[-{Stealth[length=2mm]}, dotted, jsLink, line width=0.8pt] (mem.south) -- (identity.north); % big return arrow up the right side \draw[-{Stealth[length=3.5mm]}, jsSection, line width=1.8pt] (mem.east) -- ++(2.6,0) |- node[pos=0.25, right, lbl, text width=2.6cm] {read at boot $\rightarrow$ changed behavior tomorrow} (crons.east); \end{tikzpicture}% } \caption{Sleep Consolidation as the meta-layer over storage, retrieval, and identity. Daytime crons read shared memory and produce receipts and failures; the nightly cycle reads those, mutates prompts, and feeds the changes back so tomorrow's behavior shifts.} \label{fig:architecture-overview} \end{figure}+}

### 3.1 System Overview

The three layers this meta-system tunes can be summarized [-self-containedly:-] {+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 [-nightly cycle can adjust-] {+memory-consolidation pass adjusts+} compaction aggressiveness based on observed retrieval patterns -- if important memories are being over-compressed, the thresholds loosen. - **Retrieval layer.** Maps keywords and embeddings to memory segments. [-The-] {+A dedicated index-rebuild pass refreshes it+} nightly [-cycle triggers index rebuilds-] 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 [-nightly cycle-] {+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.+}

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

{+\begin{figure}[htbp] \centering \resizebox{\linewidth}{!}{% \begin{tikzpicture}[ font=\small, box/.style={rectangle, rounded corners=4pt, draw, line width=0.9pt, align=center, inner sep=7pt}, lane/.style={box, fill=jsSection!12, draw=jsSection!70, text width=4.3cm, minimum height=2.8cm}, lbl/.style={font=\scriptsize\itshape, align=center}, ] % top banner \node[box, fill=black!6, draw=black!30, text width=15cm] (banner) { {\scriptsize\itshape shared shape: observe episodes $\rightarrow$ distil durable ranked artifact $\rightarrow$ feed back} }; % input (orange) \node[box, fill=orange!12, draw=orange!70, text width=2.8cm, below=2.2cm of banner.west, anchor=west] (input) { \textbf{\color{jsTitle}Day's Episodes}\\[2pt] {\scriptsize completed / abandoned, with \texttt{recipe:<slug>} where present} }; % three lanes \node[lane, right=1.0cm of input, yshift=2.6cm] (recipe) { \textbf{\color{jsSection}Recipe Evolution}\\[2pt] {\scriptsize attribute episode $\rightarrow$ Laplace-smoothed fitness $\rightarrow$ propose add/remove/reorder/tighten/loosen. Never-delete archive.}\\[2pt] {\scriptsize\itshape auto-promote only corrective + $\geq$8 runs + reversible} }; \node[lane, right=1.0cm of input] (strategy) { \textbf{\color{jsSection}Strategy Switch}\\[2pt] {\scriptsize per-strategy consecutive-failure counter $\rightarrow$ switch after 3 failures / 24h. Confidence $\geq$0.8 to auto-switch, else human.}\\[2pt] {\scriptsize\itshape B010 always-merge $\rightarrow$ ask-before-merge} }; \node[lane, right=1.0cm of input, yshift=-2.6cm] (skill) { \textbf{\color{jsSection}Skill Library}\\[2pt] {\scriptsize skill-worthy episode $\rightarrow$ extract skill (name/steps/tests/metrics) $\rightarrow$ Jaccard 0.8 dedup, decay on failure, never delete.} }; % gate (red) \node[box, fill=red!12, draw=red!70, text width=3.4cm, right=1.2cm of strategy] (gate) { \textbf{\color{red!60!black}Evolution Gate}\\[2pt] {\scriptsize one arbitration point; de-dup conflicting targets; precedence: strategy $>$ skill $>$ recipe.}\\[2pt] {\scriptsize\itshape human-in-the-loop (Principle 7)} }; % output (purple) \node[box, fill=jsAccent!15, draw=jsAccent!70, text width=3.2cm, right=1.2cm of gate] (out) { \textbf{\color{jsAccent}Reconciled daily manifest}\\[2pt] {\scriptsize human review $\rightarrow$ approved changes feed tomorrow's selector} }; % arrows fan-out \draw[-{Stealth[length=2.5mm]}, orange!80, line width=1pt] (input.east) -- (recipe.west); \draw[-{Stealth[length=2.5mm]}, orange!80, line width=1pt] (input.east) -- (strategy.west); \draw[-{Stealth[length=2.5mm]}, orange!80, line width=1pt] (input.east) -- (skill.west); % converge on gate \draw[-{Stealth[length=2.5mm]}, jsSection, line width=1pt] (recipe.east) -- (gate.west); \draw[-{Stealth[length=2.5mm]}, jsSection, line width=1pt] (strategy.east) -- (gate.west); \draw[-{Stealth[length=2.5mm]}, jsSection, line width=1pt] (skill.east) -- (gate.west); % gate to output \draw[-{Stealth[length=3mm]}, jsAccent, line width=1.3pt] (gate.east) -- (out.west); % dashed tomorrow return \draw[-{Stealth[length=2.5mm]}, dashed, jsMuted, line width=0.9pt] (out.south) -- ++(0,-1.6) -| node[pos=0.25, below, lbl] {tomorrow} (input.south); \end{tikzpicture}% } \caption{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.} \label{fig:procedural-extensions} \end{figure}+}

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

## Appendix B: Prompt Mutation [-Changelog-] {+Examples+} (Selected)

### Appendix D: Procedural-Extension Defaults

[-----]

### Appendix E: Revision History

[-## Appendix E: Revision History-]

### Appendix E: Revision History

[-**v1.0:** initial draft.-]

### Appendix E: Revision History

[-**v1.1:** major revision after external review. Added abstract metrics, contributions list, explicit research question, expanded related work, Algorithm 1, cross-cron transfer examples, methodology and confound discussion, sensitivity analysis, falsifiability criterion, gating and rollback mechanisms, expanded mitigations.-]

### Appendix E: Revision History

[-**v2.0:** quality revision. Fixed terminology in biological references, removed uncited references, reduced redundancy, corrected attributions, tightened prose.-]

### Appendix E: Revision History

[-**v5.0:** retitled to "Sleep Consolidation"; reframed the analogy from cerebellum-only to whole-sleep consolidation.-]

### Appendix E: Revision History

[-**v6.0:** brain-grounded opening (hippocampal replay + cerebellar motor consolidation); self-contained inline summaries of the storage / retrieval / identity layers; added Section 6 (procedural-memory extensions: recipe evolution, strategy switch, skill library) grounded in the implemented system; added a mutation taxonomy (4.2) and honest negative results (the April 1 concept-index failure, 6.4); added the concept-index consolidation output to Algorithm 1; added similes throughout; added Appendix D (procedural-extension defaults). Prose tightened.-]
