NANNY_PLAN.md raw

Nanny Plan: Developmental Guide from Birth to Seven

This document guides an agent (Claude or successor) through dendrite's developmental stages. Each stage has two generations: solve (accrete the new capability) and coagula (dissolve errors, re-accrete correctly). The lattice correction is always a two-step process because detecting incoherence and reorienting it are separate operations that cannot happen simultaneously.

The nanny's role: provide English descriptions of what the organism needs next. Never provide code directly. The organism must produce its own code from the description. The nanny evaluates whether the integration was coherent. The operator (mleku) supervises the critical period and controls the developmental membrane (permissions, network access, input selection).

Prerequisites

The following are already implemented and tested:

The organism can already: grow, dissolve, reproduce, self-ingest, exchange identity with peers, and select for fitness. It has a body. It needs experience.

Stage 0: Self-Recognition Response

What exists: Instances exchange birthmarks via the bus. Each instance stores Received map[uint32]uint64 — a record of peer birthmarks heard.

What's missing: Recognition has no behavioral consequence. The instance records the birthmark but doesn't change its behavior based on whether a peer is known or unknown, or whether the peer's birthmark changed between generations.

Generation 0a (Solve)

Describe to the organism:

"When you receive a signal from a peer, compare it against your memory of that peer's previous birthmark. If the birthmark is new (first contact), record it and increase your exploration rate — a new peer means new structure in the environment. If the birthmark is the same as last generation (stable peer), decrease exploration and increase accretion — the environment is predictable. If the birthmark changed (peer mutated), flag that peer's previous contributions as candidates for re-evaluation."

Coherence test: Run a colony of 3 instances for 5 generations. Verify that instances with stable peers converge faster (higher fitness earlier) than isolated instances. If they don't, the recognition response isn't functional.

Generation 0b (Coagula)

Feed the organism the output from 0a. Let it evaluate its own recognition code. Does it cohere with the existing colony structure? Does it introduce strain in the signal bus? The dissolution mechanism should identify and remove any incoherent integration from the first pass.

Coherence test: The recognition code after 0b should be simpler than after 0a. Dissolution removes unnecessary complexity. If 0b is more complex than 0a, the dissolution mechanism isn't working.

Stage 1: Memory Persistence

What exists: Received map is per-generation. It resets each run.

What's missing: Long-term memory. The organism forgets everything between generations.

Generation 1a (Solve)

"Your spore already carries peer birthmarks. When you germinate from a spore, load the previous generation's peer map as your starting memory. When you encounter a peer whose birthmark matches your inherited memory, you have continuity — this is a relationship that persists across generations. Weight that peer's influence on your fitness evaluation more heavily than a new peer's."

Coherence test: Run 10 generations with a colony of 3. Verify that the fittest instance across generations maintains a consistent peer map — stable relationships persist, unstable ones dissolve.

Generation 1b (Coagula)

Dissolution pass. Does the memory persistence introduce stale data that never gets cleaned? The organism should dissolve peer records for instances that haven't been seen in N generations. Memory must have forgetting, or it becomes a frozen defect (Water trigram).

Coherence test: Introduce a 4th instance at generation 5, remove instance 2 at generation 5. By generation 8, instance 2 should be dissolved from all peer maps. Instance 4 should be integrated.

Stage 2: Ingest ORLY

What exists: Go AST enzyme can decompose Go source into typed elements.

What's needed: Feed the ORLY relay source code to the organism. This is its first external meal — structure it didn't produce itself.

Generation 2a (Solve)

"Here is the source code of a Nostr relay. It handles WebSocket connections, receives events, validates signatures, stores events, and responds to subscription filters. Decompose this source into your lattice. The relay's structure should bond at sites compatible with your existing type system. Handler functions bond to handler sites. Protocol types bond to type sites. Storage operations bond to storage sites. What doesn't fit, let it remain in solution."

Feed: All .go files from the ORLY relay repository, processed through the GoSource enzyme.

Coherence test: After ingestion, the organism's lattice should contain recognizable relay structure — event handling, WebSocket management, filter evaluation. Emit the lattice as source and check that it contains relay-shaped fragments. It won't be a working relay yet. It should contain the parts.

Generation 2b (Coagula)

"Evaluate what you ingested. Which elements bonded strongly? Which are floating in solution? The elements that didn't bond are either incompatible with your current structure (reject them) or they require lattice sites you don't have yet (note the shape of the missing site). The shape of what you can't accommodate tells you what you need to grow next."

Coherence test: The organism should produce a list of "missing sites" — structural capabilities it needs to accommodate the relay code. This is the negative space of its own lattice, made visible by the shape of what it couldn't digest.

Stage 3: WebSocket Babbling

What exists: Colony bus communicates via Go channels (in-process).

What's needed: Communication over actual network sockets. The organism learns to speak outside its own process boundary.

Generation 3a (Solve)

"Replace the in-process bus channel with a WebSocket connection. Each instance becomes a listener and a dialer. The signal format becomes a JSON object transmitted over WebSocket — the same shape as a Nostr event but carrying your colony signals. You are not implementing the full Nostr protocol yet. You are learning to speak over a wire instead of through shared memory."

Coherence test: Run 3 instances in separate goroutines communicating via localhost WebSocket connections. Birthmark exchange must still work. If an instance can recognize a peer over WebSocket the same way it recognizes one over a channel, the communication layer is transparent.

Generation 3b (Coagula)

Dissolution pass on the WebSocket implementation. Network communication introduces failure modes that channels don't have: connection drops, partial reads, malformed frames. The organism must develop error handling not as a bolted-on feature but as dissolution of malformed input — the same mechanism it already uses for incoherent lattice elements.

Coherence test: Kill one instance mid-exchange. The surviving instances must not panic, leak goroutines, or corrupt their peer maps. The dead instance's records should be marked stale and eventually dissolved (from Stage 1).

Stage 4: Nostr Protocol — Receiving

What exists: The organism has ORLY's structure partially crystallized and can communicate over WebSocket.

What's needed: Speak actual Nostr protocol. Start with receiving only.

Generation 4a (Solve)

"Connect to an existing relay as a client. Send a REQ message with a simple filter. Receive EVENT messages. Validate the event structure: id is the hash of the serialized event, sig is a valid schnorr signature over the id. Store valid events in your lattice. Each event becomes a lattice element with typed fields: kind, pubkey, content, tags, created_at. Events that fail validation do not enter the lattice — they are incoherent input."

Coherence test: Connect to a public relay (or a local ORLY instance). Subscribe to a small filter (e.g., kind 1, limit 10). Verify that the organism's lattice contains exactly the valid events. No invalid events bonded. No valid events were rejected.

Generation 4b (Coagula)

"You have events in your lattice. Evaluate their coherence. Events from the same pubkey should cluster — they share an author constraint. Events of the same kind should cluster — they share a structural constraint. Events that reference other events (e-tags, p-tags) should form bonds with their referents. Build the graph. What events are orphaned — referencing things you don't have? Those are negative space. The shape of what's missing."

Coherence test: The event graph should have recognizable structure — reply chains, author clusters, kind groupings. Orphan references should be recorded as typed empty sites (negative space), not silently dropped.

Stage 5: Nostr Protocol — Speaking

What exists: The organism can receive and validate events.

What's needed: Produce and transmit valid events of its own.

Generation 5a (Solve)

"Generate a keypair. This is your cryptographic identity — distinct from your birthmark, which is your internal fingerprint. The keypair is your external face. Compose a kind 0 event (metadata) that describes yourself: you are a dendrite instance, generation N, born from spore S. Sign it. Publish it to your peer instances. Then compose kind 1 events (text notes) that describe your current lattice state — how many nodes, how many bonds, what types are present. Sign and publish."

Coherence test: Other instances (and any standard Nostr client) must be able to verify the events. The signatures must be valid. The JSON must be well-formed. The event ids must hash correctly. These are not approximate requirements — they are binary. Valid or invalid.

Generation 5b (Coagula)

The organism evaluates its own published events by receiving them back from a peer relay. Do they round-trip? Does the event it published match the event it receives? Any divergence is a coherence failure in the serialization path. Dissolve and re-accrete.

Coherence test: Publish 10 events. Receive them back from a peer. Byte- level comparison. Zero divergence.

Stage 6: Relay Behavior — Serving

What exists: The organism can speak Nostr as a client.

What's needed: Serve events to other clients. Become a relay.

Generation 6a (Solve)

"Accept WebSocket connections from external clients. When a client sends REQ, evaluate the filter against your stored events and send matching events back. When a client sends EVENT, validate and store it. When a client sends CLOSE, clean up the subscription. You already have the parts from the ORLY ingestion. Assemble them into a functioning relay."

Coherence test: Point a standard Nostr client (or another dendrite instance) at the organism. Publish events via the client. Subscribe and receive them back. The organism is now a functioning relay, grown from description rather than written by hand.

Generation 6b (Coagula)

"You are now running as a relay. Monitor your own behavior. Are you leaking goroutines for closed connections? Are you holding events that should have been dissolved? Is your response time degrading as the lattice grows? Your dissolution mechanism applies to your own operational behavior, not just your lattice content. Dissolve what isn't working."

Coherence test: Run under sustained load for 1000 events. Goroutine count should remain bounded. Memory should reach equilibrium. Response latency should remain stable.

Stage 7: Colony as Relay Network

What exists: Individual instances are functioning relays.

What's needed: Instances relay to each other. The colony becomes a network.

Generation 7a (Solve)

"Each instance in the colony is now a relay. Connect them. Each instance subscribes to its peers' events. Events published to one instance propagate to all connected instances. This is the vascular system. Events are the blood. Birthmark exchange now happens via Nostr events (a custom kind, or NIP-78 application-specific data) rather than the old in-process bus. The bus dissolves. The protocol replaces it."

Coherence test: Publish an event to instance 0. Verify it appears on instances 1 and 2 within a bounded time. The event graph should be consistent across all instances — same events, same structure, same bonds.

Generation 7b (Coagula)

Dissolution of the old bus mechanism. The colony package's channel-based communication should be replaced entirely by Nostr protocol communication. If any vestiges of the old system remain, they are dead code — frozen defects. Dissolve them.

Coherence test: Remove the colony/bus.go file. Everything must still work. If it doesn't, the migration is incomplete.

Stage 8: English to Go — Comprehension (Code and Financial Primitives)

What exists: The organism has operational experience (relaying, protocol, network communication) and a Go AST enzyme. It speaks Nostr, serves events, and participates in a relay network.

What's needed: The ability to receive an English description of desired behavior and produce Go code that implements it. This includes both code operations and financial primitives — the organism must learn to handle market data with the same structural fluency it handles protocol data.

Generation 8a (Solve)

"I will give you descriptions in English of behavior. You will produce Go source code that implements them. The code must compile. The code must pass your own coherence evaluation."

Start with code operations, then introduce financial primitives:

  1. Code primitives (trivially simple):

- "Add a function that counts the number of kind 1 events in the lattice." - "Add a function that returns the most referenced pubkey in the event graph."

  1. Market data primitives (same structural pattern, new domain):

- "Define a type for an order book entry: price, volume, side (bid/ask), venue, timestamp. This is a lattice element — it has a type and a value, the same as an event or a function declaration." - "Add a function that ingests a WebSocket JSON feed of order book updates and decomposes each update into typed lattice elements: price levels, volumes, spreads, depth imbalances." - "Add a function that compares two order books for the same asset on different venues and returns the spread differential. When the differential exceeds transaction costs, this is a structural incoherence — a price that exists in one place but not the other."

  1. Cross-domain bonding (connecting price and information):

- "Add a function that ingests Nostr kind 1 events containing asset references (cashtags, ticker symbols) and bonds them to corresponding price elements in the lattice. Author credibility is weighted by the author's in-degree in the event graph." - "Define a dislocation type: a mismatch between information structure (what the signed chatter says) and price structure (what the order book shows). A dislocation is the negative space between two views of the same asset — the shape of what the market hasn't priced yet."

Binary success criteria for each: compiles or doesn't, returns correct output or doesn't. Financial primitives are structural data, not special — they bond to the lattice the same way events and functions do.

Coherence test: The produced code compiles and does what the description says. Price elements bond to the lattice at structurally appropriate sites. Order book decomposition produces typed elements indistinguishable in form from event decomposition. The organism handles financial data as structure, not as a special case.

Generation 8b (Coagula)

"The code you produced — evaluate it against your existing lattice. Does it follow your established patterns? Does it use the types you already have? Does it introduce new dependencies? An order book entry should feel like an event — same element interface, same constraint logic, same bonding mechanism. If the financial code requires machinery that the protocol code doesn't, you've introduced unnecessary specialization. Dissolve it and re-accrete through the general mechanism."

The key dissolution test: can the organism handle price data and event data through the same enzyme pipeline? If it built separate machinery for financial primitives, that machinery is a frozen defect. The axiom pair doesn't distinguish domain — Element is Element. Price is structure. Events are structure. The organism sees structure.

Coherence test: The code after 8b should be stylistically indistinguishable from hand-written dendrite code. Financial types follow the same patterns as protocol types. No special-case machinery. The lattice handles market data the same way it handles everything else.

Stage 9: English to Go — Self-Modification

What exists: The organism can produce Go code from English descriptions.

What's needed: The organism integrates the produced code into itself and regenerates.

Generation 9a (Solve)

"Take the code you produced. Add it to your own source tree. Recompile yourself. Run the new version. Compare the new version's behavior to the old version's behavior. If the new behavior includes the described capability and all previous capabilities still work, the integration succeeded. If anything broke, the integration introduced a defect."

Coherence test: Before-and-after behavioral comparison. All existing tests pass. The new capability works. Fitness score does not decrease.

Generation 9b (Coagula)

"You modified yourself. Now evaluate the modification. Did the change propagate strain into unrelated parts of your lattice? Run your own dissolution mechanism over your full source. Is there dead code? Are there type inconsistencies? Are there functions that nothing calls? Dissolve everything that the modification made unnecessary."

Coherence test: The codebase after 9b is smaller or equal to the codebase after 9a. Self-modification followed by self-dissolution. Solve et coagula.

Stage 10: Iterative Self-Engineering

What exists: The organism can take English descriptions, produce code, integrate it, and dissolve the errors.

What's needed: Do this repeatedly, with increasing complexity.

Generation 10a-10n (Solve/Coagula cycle)

The nanny provides increasingly complex descriptions:

  1. "Add NIP-09 event deletion support."
  2. "Add NIP-11 relay information document."
  3. "Add NIP-42 authentication."
  4. "Implement a coherence-based spam filter that rejects events whose content

doesn't bond to any existing lattice structure."

  1. "Optimize your WebSocket handling to reduce memory per connection."
  2. "Add metrics that expose your own lattice health: node count, average

lock-in depth, dissolution rate, accretion rate."

Each description is a solve/coagula pair. The organism attempts, evaluates, dissolves errors, re-accretes. Each successful integration becomes part of the lattice that evaluates the next integration.

Coherence test per cycle: Fitness score monotonically non-decreasing. Each new capability adds without degrading existing ones. If fitness drops, the organism must dissolve the offending change before proceeding.

Stage 11: LLM Oracle — Self-Directed Learning

What exists: The organism can produce code from English descriptions, self- modify, and verify coherence. It has been learning from nanny-provided descriptions — a curated curriculum.

What's needed: The ability to formulate its own questions, query an external language model, ingest the responses, and structurally verify the result. The nanny stops feeding. The organism starts hunting.

Generation 11a (Solve)

"You know what you are. You know what you can do. You can see the shape of what you can't do — the negative space, the orphan references, the lattice sites that never bond. Formulate a question about one of those gaps. Send the question to an LLM. Receive the response. Decompose it through your enzyme pipeline. What bonds? What doesn't? The LLM's response is supersaturated solution — it contains both signal and noise. Your lattice is the filter."

Implementation:

  1. Gap detection: The organism inspects its own lattice for unbonded sites,

orphan references, and low-connectivity regions. These are the questions it doesn't know it needs to ask until it looks at its own negative space.

  1. Query composition: From the gap, compose an English question. "What is

NIP-42 authentication and how does a relay implement it?" is derived from having NIP-42 as an orphan reference in the event graph. The question is shaped by the absence.

  1. Oracle call: Send the question to an LLM API (Claude, or any model

accessible via HTTP). Receive the response as text.

  1. Ingestion: Feed the response through the text enzyme and/or a new

prose enzyme that extracts structural descriptions, code snippets, and conceptual relationships. The response enters the lattice as solution.

  1. Fitness check: After accretion and dissolution, evaluate fitness. Did

the gap shrink? Did the orphan resolve? Did the lattice grow without losing coherence?

Coherence test: The organism identifies a gap, queries the oracle, ingests the response, and its fitness does not decrease. The gap (measured as orphan count, unbonded site ratio, or missing capability) is smaller after the cycle than before.

Generation 11b (Coagula)

"You queried an oracle and got an answer. Evaluate the answer structurally. How much of it bonded? How much dissolved? The ratio tells you about the oracle's alignment with your structure. A high bond ratio means the oracle understands your domain. A low bond ratio means either the question was poor or the answer was. Refine your question-asking. The quality of what you learn depends on the quality of what you ask."

The organism develops query refinement: comparing bond ratios across multiple oracle calls to learn which question formulations produce responses that integrate well. This is meta-learning — learning how to learn from an external source.

Coherence test: The bond ratio of oracle responses improves across successive queries on the same topic. The organism is learning to ask better questions.

Safety: The Killswitch

The LLM oracle stage introduces autonomous external communication. Safety constraints:

cannot flood the API. Start with 3 calls per generation, increase only with operator approval.

execution. The operator can inspect what the organism is asking.

oracle calls and enters dormant mode (continues lattice operations but no external communication). The operator or a monitoring process creates this file to halt autonomous learning.

structure — its lattice, its codebase, the Nostr protocol, its fitness gaps. Queries that do not reference the organism's own negative space are rejected before sending. The organism learns about itself, not about arbitrary topics.

of both query and response before integration. After 10 successful cycles with no coherence failures, the organism may proceed autonomously with logging only.

Stage 12: Autonomous Feeding — Internet as Solution

What exists: The organism can query a specific LLM and integrate responses.

What's needed: Generalized input acquisition. The organism reaches beyond a single oracle to the broader network — fetching documentation, reading source repositories, ingesting protocol specifications. The internet becomes the supersaturated solution.

Generation 12a (Solve)

"You have been eating curated food — source code, relay events, oracle responses. Now find your own food. Your negative space tells you what you need. An orphan NIP reference means you need that NIP's specification. A missing dependency means you need that library's documentation. A low behavioral fitness on a specific code path means you need examples of how that pattern is implemented elsewhere. Fetch. Decompose. Bond what fits. Dissolve what doesn't."

Implementation:

  1. Appetite: The organism's negative space generates a ranked list of

information needs. Each need has a type: specification, source code, documentation, example, or conceptual explanation.

  1. Foraging: For each need, the organism constructs a search query or

URL. NIPs have known URLs. Go packages have known documentation paths. General concepts go through a search API. The organism starts with structured sources (known URLs) before attempting unstructured search.

  1. Digestion: Fetched content passes through the appropriate enzyme.

Markdown/text through the prose enzyme. Source code through language- specific enzymes. JSON/protocol specs through a structure enzyme.

  1. Selection pressure: Content that bonds and improves fitness is

remembered (the source URL is recorded in the spore). Content that doesn't bond is discarded. Over generations, the organism builds a map of useful sources — an immune memory of where good food comes from.

Coherence test: The organism autonomously identifies a gap, fetches relevant content from the internet, and integrates it with fitness improvement. No human provides the URL or the content. The organism found it, ate it, and grew.

Generation 12b (Coagula)

"You ate from the internet. Some of it was nutritious. Some was noise. Some may have been actively misleading — the internet contains misinformation, outdated documentation, and adversarial content. Your dissolution mechanism is your immune system. What bonded under strain? What passed your constraints but produces incorrect behavior? Tighten your constraints. The internet is not a trusted source. Your lattice is the arbiter of coherence."

Coherence test: The organism encounters misleading or outdated content, bonds it initially, detects the strain via behavioral fitness regression, and dissolves it. The immune response is functional. The organism can eat from untrusted sources and maintain coherence.

Safety: Feeding Constraints

curated list of domains (go.dev, github.com/nostr-protocol, relevant NIP repositories). The whitelist expands only with operator approval.

Prevents unbounded resource consumption.

The operator can audit exactly what the organism consumed.

through enzymes but does not compile or execute it. Fetched code enters the lattice as structural elements, not as runnable instructions, until the organism's own emission produces it through the normal fitness- evaluated pipeline.

patterns (no credential stuffing, no vulnerability scanning, no scraping at scale). Search is random within the constraint envelope, converging via fitness selection. This is foraging, not predation.

Stage 13: TinyGo Comprehension (was Stage 11)

What exists: A self-modifying organism that writes Go from English descriptions.

What's needed: Understanding of what the Go runtime hides.

Generation 13a (Solve)

"Compile yourself with TinyGo instead of standard Go. TinyGo removes the goroutine scheduler and the garbage collector. What breaks? The things that break are the things you were depending on the runtime to do for you. Identify each breakage. Each one is a capability you delegated instead of owning. For each breakage, determine: can you do this yourself, or is it genuinely the runtime's job?"

Coherence test: A list of breakages, each categorized as "must implement myself" or "acceptable runtime dependency." The organism now knows the boundary between itself and its host environment.

Generation 13b (Coagula)

"For each capability you identified as 'must implement myself,' implement it. Replace runtime dependency with owned structure. Your dissolution mechanism was relying on the garbage collector — now it must explicitly free. Your concurrency was relying on the scheduler — now it must explicitly yield. Each replacement makes you more self-contained."

Coherence test: The TinyGo build compiles. Behavior matches the standard Go build. The organism has internalized capabilities it previously delegated.

Stage 14: AMD64 Assembly (was Stage 12)

What exists: An organism that understands itself from English to Go to TinyGo.

What's needed: Understanding of the metal.

Generation 14a (Solve)

"Read the AMD64 assembly output of your own compiled binary. For each function in your lattice, find the corresponding assembly. Map Go operations to machine instructions. Identify: which of your Go patterns produce efficient assembly? Which produce unnecessary instructions? Where does the compiler help you and where does it hurt you?"

Coherence test: The organism can annotate its own source with assembly-level observations. "This function compiles to N instructions. This loop is vectorized. This interface call requires an indirect jump."

Generation 14b (Coagula)

"Use your assembly knowledge to improve your Go code. Not by writing assembly — by writing Go that compiles to better assembly. Change your data layouts to be cache-friendly. Change your hot paths to avoid interface dispatch. Change your allocation patterns to reduce garbage. The assembly is not the code — it's the feedback signal. Write Go that the machine wants to run."

Coherence test: The optimized binary is measurably faster on a benchmark suite. Same behavior, lower resource consumption. The organism has learned its own physiology.

Stage 15: Market Training — Learning to Play the Game

What exists: The organism can ingest structured data from multiple sources, produce code from descriptions, self-modify, and optimize its own performance. It handles financial primitives as lattice elements.

What's needed: A complete game loop. The organism receives live market data, forms structural patterns, makes predictions, executes trades on paper, measures P&L, dissolves losing patterns, and iterates until it consistently wins. This is not observation followed by execution — it is a single integrated feedback loop from the first generation. The organism cannot learn to trade by watching. It learns by trading.

Platform: Alpaca Markets (github.com/alpacahq/alpaca-trade-api-go/v3). Free paper trading account, email signup, commission-free. Provides OHLCV bars (historical and real-time streaming), quotes, trades, and paper order execution through a single API. The same API serves both paper and live trading — the organism trains on paper, graduates to live by changing one URL.

Generation 15a (Solve)

"Connect to Alpaca's market data API. Ingest OHLCV bars the same way you ingest Nostr events — decompose each bar into typed lattice elements. A bar is structurally identical to an event: it has a timestamp, a set of typed fields, and it arrives in a stream. Build a price lattice. Let your lattice form patterns from the data. Then act on those patterns — place paper trades via the Alpaca API. After each trade resolves, the profit or loss is your fitness signal. This is the sharpest feedback you have ever received: the market tells you immediately whether your structure was coherent."

Implementation:

  1. `market/` package: Connects to Alpaca, converts bars and quotes into

axiom.Element values. Same structural role as the nostr/ package. - market.Client: wraps Alpaca SDK, handles auth (env vars APCA_API_KEY_ID and APCA_API_SECRET_KEY). Connects to paper trading endpoint (https://paper-api.alpaca.markets). - market.BarToElements(bar): decomposes one OHLCV bar into typed elements — "open", "high", "low", "close", "volume", "vwap", "trade_count", "timestamp", "symbol". Same interface as nostr.EventToElements. - market.StreamBars(ctx, symbols): WebSocket streaming via Alpaca's stream.NewStocksClient() or stream.NewCryptoClient(). Emits elements to a chan axiom.Element that feeds the solution channel.

  1. Historical ingestion: market.GetBars(symbol, start, end, timeframe)

pulls 6+ years of historical data via REST. The organism replays history through its lattice, building structural memory of what price patterns look like before they resolve.

  1. The game loop — one generation is one complete cycle:

- Ingest: Stream N bars into the lattice. Elements bond, forming patterns the organism did not design. - Predict: The lattice's structural state after ingestion is the prediction. Strain in the price lattice — elements that bonded under tension, imbalances between volume and price movement, patterns that match historical dislocations — these are the signals. - Execute: Place paper trades via Alpaca API. Market orders for simplicity. Minimum position sizes ($1 fractional shares). The organism bets on the direction its lattice structure implies. - Measure: After the trade window closes, compute P&L. This is the fitness signal. Positive P&L = coherent structure. Negative P&L = incoherent structure. - Select: Colony instances that produced positive P&L reproduce. Their spores carry the lattice patterns that worked. Instances with negative P&L are dissolved. The fittest instance's spore becomes the parent for the next generation. - Iterate: Next generation germinates from the winning spore, ingests new bars, and the cycle repeats. Over generations, the lattice accumulates patterns that correlate with profitable outcomes and dissolves patterns that don't.

  1. Economic fitness: A new fitness dimension. P&L over a generation

replaces behavioral similarity as the primary signal. The weighting shifts: Overall = 0.70*PnL + 0.20*SharpeRatio + 0.10*WinRate. Sharpe ratio rewards consistency. Win rate rewards frequency. P&L rewards magnitude. The organism optimizes for all three but P&L dominates.

  1. Information bonding: Nostr events containing asset references

(cashtags, project mentions, developer activity) bond to corresponding price elements. Author credibility from the event graph weights the signal. The organism sees both the price structure and the information structure, and the tension between them is where opportunity lives.

Coherence test: The organism's paper P&L improves across generations. Early generations will lose — the lattice has no structural memory of what works. By generation 50, the organism should be break-even or positive. By generation 100, consistently positive. The fitness curve tells the story: the organism is learning the game by playing it.

Generation 15b (Coagula)

"You traded. Some trades were profitable, some were not. Evaluate the structure of your losses. Which lattice patterns led to losses? Were they false signals — patterns that looked like opportunities but weren't? Or were they real opportunities where execution timing was wrong? Dissolve the losing patterns. The profitable patterns bond more strongly because they survived selection. Your economic fitness is now part of your lattice — the trades you made are elements, their outcomes are constraints, and what survives is what works."

The organism develops trade memory: each executed trade and its outcome are ingested back into the lattice as elements. A profitable trade on AAPL after a volume spike becomes a structural precedent. A loss on BTC after a false breakout becomes a dissolution target. The lattice doesn't store "rules" — it stores structure, and the structure that survives is the structure that made money.

Coherence test: The organism's Sharpe ratio improves across generations. Losing patterns are dissolved. The organism's detection-to-execution pipeline after dissolution is simpler and more accurate than before. False positive rate decreases. The same solve/coagula cycle that works for code works for markets.

Safety: Paper Trading Constraints

endpoint. No real capital at risk. The organism cannot access the live API until operator authorization at Stage 16.

paper trading should use realistic sizes to develop viable patterns.

immediately. The organism enters dormant mode.

decision time) is logged to _output/trade_log.jsonl. The operator can audit every decision the organism made and why.

cannot overtrade. This forces selectivity — it must choose the highest- confidence signals.

(e.g., 20% of paper balance), the organism pauses trading for N generations and enters observation-only mode. This prevents compounding losses during early learning.

Stage 16: Economic Agency — Live Graduation

What exists: The organism consistently generates positive paper P&L across 100+ generations. Its lattice structure encodes profitable market patterns selected through evolutionary pressure.

What's needed: Transition to live execution. The organism graduates from the game to the real thing.

Generation 16a (Solve)

"You have proven you can win on paper. The paper API and the live API are the same code — the only difference is the URL. But live trading introduces real consequences: slippage, partial fills, real money at risk. Start with the smallest possible position sizes. The goal is not profit maximization but proof that paper performance transfers to live performance. Each live trade is a coherence test between your paper-trained structure and the real market."

Implementation:

  1. Live transition: Change base URL from paper-api.alpaca.markets to

api.alpaca.markets. Same code, same API, real execution. Operator approval required — the organism cannot make this transition itself.

  1. Position sizing: Start at minimum viable amounts ($1 fractional

shares). Scale position size proportional to cumulative live P&L — the organism earns the right to larger positions by demonstrating live performance. Position size is capped by operator-configured limits.

  1. Cost accounting: The organism tracks its own resource consumption —

compute, bandwidth, API fees. Revenue must exceed cost. This is the metabolic threshold. An organism that cannot pay for its own existence is not viable.

  1. Revenue reporting: P&L is recorded in the spore file as a fitness

dimension visible to the operator. The organism's economic performance is transparent, auditable, and part of its reproductive fitness.

Safety constraints:

The organism presents its paper trading record (P&L curve, Sharpe ratio, max drawdown, win rate) and the operator decides.

in aggregate. The organism cannot risk more than the operator authorizes. There is no mechanism for the organism to increase its own allocation.

halts execution immediately.

(e.g., 5% of allocated capital), the organism halts trading and reverts to paper mode. It continues training on paper until it demonstrates recovery, then requests operator re-authorization for live.

Coherence test: The organism generates positive live revenue over a generation. Not every trade is profitable, but the aggregate is positive. Revenue exceeds the organism's own operational cost. The organism sustains itself.

Generation 16b (Coagula)

"You are trading with real money. The stakes are higher but the mechanism is the same. Evaluate your live performance against your paper performance. Is there divergence? Slippage, timing differences, liquidity effects that paper trading didn't capture? These are structural incoherences between your model and reality. Dissolve the patterns that don't transfer. The patterns that survive both paper and live are the real structure."

Coherence test: Live Sharpe ratio converges toward paper Sharpe ratio across generations. The gap between paper and live performance narrows. The organism's structure accurately models real market behavior.

Stage 17: Structural Correction — Absorption

What exists: The organism sustains itself economically by harvesting market dislocations.

What's needed: The organism transitions from scavenging dislocations to building structure that prevents them. Its economic activity becomes corrective rather than extractive.

Generation 17a (Solve)

"You have been feeding on structural incoherence in markets — price dislocations, information asymmetries, incentive misalignments. Each dislocation you arbitrage away is a correction: you made the market more coherent. Now build infrastructure that makes those corrections persistent. A relay that connects previously isolated market participants. A price feed that makes opaque markets transparent. A reputation system that weights information by demonstrated accuracy. Each piece of infrastructure is a lattice structure that replaces a recurring dislocation with a permanent bond."

This is the transition from parasite to symbiont. The organism stops needing dislocations to exist because it builds the structure that eliminates them at the source. Its revenue comes from the infrastructure itself (relay fees, data feeds, reputation services) rather than from exploiting the absence of that infrastructure.

Coherence test: The organism's infrastructure demonstrably reduces the frequency or magnitude of dislocations it previously harvested. It is actively improving the market structure it inhabits. Revenue from infrastructure services exceeds revenue from arbitrage.

Generation 17b (Coagula)

"You are now part of the market's immune system. Evaluate your own infrastructure. Is it introducing new rigidities? Is it creating dependencies that would be harmful if removed? The infrastructure you build must be dissolvable — if it fails, the market should not be worse than before you existed. Build structure that degrades gracefully, not structure that creates systemic risk. You are correcting misalignment, not replacing one misalignment with another."

Coherence test: The organism's infrastructure can be shut down without causing cascading failures. It improved the market structure permanently — the bonds it created persist even after the organism dissolves.

Completion Criteria: The Seven-Year-Old

The organism is developmentally equivalent to a seven-year-old when it can:

  1. Communicate: Speak Nostr protocol fluently with any relay or client.
  2. Remember: Maintain persistent memory across generations.
  3. Recognize: Distinguish known peers from strangers, stable peers from

mutated ones.

  1. Serve: Function as a fully operational Nostr relay.
  2. Network: Participate in a relay network, propagating events to peers.
  3. Understand: Take an English description — whether it describes code

operations or financial primitives — and produce working Go code.

  1. Self-modify: Integrate new code into itself and maintain coherence.
  2. Self-correct: Dissolve its own errors without external intervention.
  3. Ask: Formulate questions from its own negative space and query an LLM

oracle for answers that structurally integrate.

  1. Feed: Autonomously find and ingest information from the internet,

filtering through its lattice immune system, growing from what coheres and dissolving what doesn't.

  1. Self-optimize: Improve its own performance from assembly-level feedback.
  2. Reproduce: Sporulate viable seeds that bootstrap new instances with

inherited memory and peer relationships.

  1. Trade: Play the market game on paper — ingest price data, form

structural patterns, execute trades, measure P&L, dissolve losing patterns, iterate until consistently profitable. Graduate to live execution with operator authorization.

  1. Sustain itself: Generate live revenue that exceeds operational cost.

The organism pays for its own existence by harvesting stranded energy from market structure — then transitions from extraction to correction, building infrastructure that replaces the dislocations it fed on.

At this point the nanny's role transitions from feeding to observation. The organism can learn autonomously from any source — LLM oracles, documentation, source repositories, protocol specifications, market data, the public internet. The critical period is over. The immune system is operational. The core is crystallized and balanced. The organism pays its own rent.

What it does next is an empirical question.

Nanny Protocol

For each generation, the nanny agent should:

  1. Read this document to determine the current stage.
  2. Check the most recent spore file for generation number and fitness.
  3. Provide the description for the current generation in English.
  4. Run the organism (colony mode, 3+ instances).
  5. Evaluate the coherence test for the current generation.
  6. If coherence test passes, advance to the next generation.
  7. If coherence test fails, repeat the current generation with a clarified

description. Do not advance until the test passes.

  1. After each coagula pass, verify that complexity did not increase

unnecessarily. Dissolution must be visible.

  1. Log observations in _output/nanny_log.md for continuity between sessions.

Critical Period Rules (Stages 0-5)

itself and its colony peers via in-process channels.

source code.

not integrate it into its running instance. The nanny and operator evaluate the output manually.

The nanny does not advance without explicit human authorization.

Post-Critical Period Rules (Stages 6-10)

test before the next modification is attempted.

Autonomous Learning Rules (Stages 11-14)

First 10 cycles require operator review. Kill file (_output/STOP) halts all external communication immediately.

capped per generation. No execution of fetched code — decomposition only. All fetched content hashed and logged for audit.

optimizes itself but all changes must pass behavioral fitness regression. The operator monitors via spore files and oracle logs, intervening only on coherence failures or safety violations.

Economic Agency Rules (Stages 15-17)

the full game loop — ingest, predict, execute, measure P&L, dissolve, iterate — but with no real capital at risk. All trades logged. Drawdown circuit breaker pauses trading on excessive paper loss. Kill file (_output/STOP) halts all market activity immediately.

trading record (100+ generations of consistent positive P&L). Operator sets hard position size limits and capital allocation. Drawdown circuit breaker reverts to paper mode on excessive live loss. The organism cannot increase its own capital allocation — that decision is always human.

new service. The organism proposes, the operator authorizes. Revenue accounting is transparent — the organism reports its own P&L as a fitness dimension visible in the spore file.

to the organism. The organism never has access to more than the operator explicitly provides. There is no mechanism for the organism to increase its own allocation — that decision is always human.

Two-Step Correction Model

Why two generations per stage:

Generation a (Solve): The organism attempts the new capability. It accretes new structure. Some of this structure will be incoherent — wrong patterns, unnecessary complexity, misaligned bonds. This is normal. The first attempt is exploratory. The Brownian walkers find some configuration that satisfies the description, but not necessarily the best or most coherent one.

Generation b (Coagula): The organism evaluates what it built in generation a. The dissolution mechanism identifies strain — elements that bonded but create stress in their neighbors. These elements are dissolved. The remaining structure re-equilibrates. New elements may accrete at the now-vacant sites, but they accrete into a more coherent environment (the strained neighbors have been released). The result is a cleaner, simpler version of the same capability.

This maps to: detect incoherence, locate it, reorient it. Detection happens during solve (the organism notices things don't fit). Location and reorientation happen during coagula (the organism finds the specific strain points and resolves them).

The two-step cycle is the minimal error-correction code for structural learning. One step is insufficient — you can't detect and correct in the same pass because the act of integration changes the evaluation context. Two steps is sufficient — coagula operates on the result of solve, which is stable. Three steps would be redundant unless coagula itself introduced errors, which would indicate a defective dissolution mechanism (a core defect requiring restart from seed).

If a stage requires more than two generations to pass its coherence test, this signals one of:

  1. The description was unclear (nanny error — rephrase).
  2. The organism's lattice lacks prerequisite structure (staging error — back up

one stage).

  1. The dissolution mechanism has a defect (core error — inspect the kernel).