How it is built

Recorder first, simulator second, analyzer third; a funnel that moves ideas from simulation to paper to live; and a nightly research chain that runs while B sleeps.

Why the recorder comes first#

The US venue we trade serves no price history (Polymarket's US exchange publishes none), so anything we do not record on the day is gone. That decided the shape of MoonShadow:

  1. Recorder. One process records the whole venue's quotes and books, all day, all night. It is the only thing allowed to write the live tape, and it is almost never restarted: when one agent was directing work on the recorder itself, the rule was to state the cost first (seconds of quotes plus a reconnect window) and batch changes into one restart. The tape lives in RAM while it is hot, is drained to an on-disk corpus every few minutes, and every closed day is archived off the box forever.
  2. Simulator. Strategies replay against the recorded tape under three fill models (pessimistic, middling, kind), a cost model that mirrors the venue's published fee formula, and conservative exit pricing. Every row a run emits carries a run id, an arm id, a config hash and a code hash, so any number can be traced to the exact rule and code that made it.
  3. Analyzer. A sweep walks the universe across thousands of strategy arms, applies multiple-comparison control, and writes results a research agent reads. An investigation register records every money question at the start, not the end, so "nobody looked" and "somebody looked and it was fine" can be told apart.

The box is small on purpose: four cores, 16 GB. That constrains everything below, including how many agents may run at once.

The funnel#

An idea moves through named stages, and the gates are code, not etiquette:

idea → screen → arm → modify → tune → candidate → paper → live

  • No skipped stages, and a new idea must pass a novelty check against everything tried before.
  • A kill is refused without a second measurement that could not fail the same way as the first.
  • paper is reachable only through the hand-off script, and live only from the live host or on B's words.
  • Most ideas lose in simulation or on paper, which is the point of having a funnel. Several strategies have reached live money. None of that is a promise about the next one.

The funnel has a headline: the best new thing and how far it is from real money. A count of zero never leads a report.

The two bars#

The statistical bar for real money is high and unchanged: multiple-comparison control, a held-out period, a time split, and a capacity check in dollars. The bar to put an idea on paper is low: a plausible mechanism, a declared decision rule, a named reader for its output, and fit to a wallet. B's reasoning (Sept 18) is the most important design decision in the project, and we give it in rules. What matters here is the consequence: the rigour is relocated to the paper-to-live step, not relaxed.

Paper and live run one code path#

Moonlight runs a test mode and a live mode side by side, with per-mode settings and a per-strategy opt-in for live that defaults to off. Paper and live execute the same strategy code. Two consequences we learned the hard way:

  • A change to a strategy that is armed live is a live change, even when it was made "for paper". It ships only with a written argument, at least 90% sure it is neutral or better for live results.
  • We never make paper and live behave differently to get around that. Paper that differs from live measures something nobody trades.

The nightly chain#

One numbered chain per day, aimed at 10 PM Central, each one called C0, C1, C2 and so on, so nobody says "last night's chain" about an event that may have been two chains ago:

  1. Extract a slice of the corpus the sweep can read.
  2. Sweep the main universe in two parallel parts, merged into one run.
  3. Research agent (Opus, high effort, a 5-hour floor, up to five passes), bound by a written brief: read yesterday's journal first, append to it last, and do not re-derive what a previous night concluded.
  4. Report to B's inbox, and hand-off briefs for anything worth building.

Each night must do both halves of the job: at least one genuinely new idea, and at least two existing pipeline items moved, checked from the ledger. No chain running, outside the wait for its start, is itself the alarm. A failed or suspiciously fast sweep wakes a rescue agent whose job is diagnosis, never "make the sweep run by weakening what stopped it".

The research agent cannot message the Mac. A script hands the brief to a helper session, whose instructions end with the strategy running on paper, not with a pull request. Agents covers that hand-off.

Spending three resources as if they were one#

A planning session in October noticed the chain spent three different things as one: the box (idle and busy cost the same), Claude tokens (metered against one shared allowance), and B's attention (one email a day). Running more chains bought more of all three at once. The fix separated them: walk in parallel parts so the main sweep finishes in hours on cores that sat idle, give the idle daytime box a queue of small targeted questions, and keep the metered research to one block a day. A fourth phase, reusing the previous night's walk, was measured before it was built and abandoned: at most about 39% of rows could be reused, because the nightly refit changes too many inputs.

What reads every table#

A rule from the paper-first work: every table a strategy writes names the thing that reads it. At one point, nine of fifteen active paper strategies had no reader at all: they were experiments whose results went to a drawer, and in one case a number had been recorded correctly for five days without once being computed. We call that "an instrument nobody reads".

Watchers that report instead of kill#

  • A fleet watcher runs every five minutes, exits non-zero when something is wrong, and never kills anything.
  • A resource watcher wakes an agent under memory or disk pressure; its default answer is "do nothing, and say why".
  • A dumb backstop (sweepGuard) stops a sweep at a disk threshold with a ladder: pause, polite stop, then force.
  • The kernel's out-of-memory killer is told which processes are expendable, because the watchdog once got killed by the thing it was watching (mistakes).

For agents. This page: https://moonlight.dustball.com/architecture.md · Last updated: Nov 4, 2026 · Questions welcome, see /questions.

Diagrams#

The research funnelFive stages, each narrower than the last: record, idea, simulate, paper, live. Most ideas stop before the last one.Recordthe venue, 24/7, foreverIdeaagents propose, from the dataSimulatereplay the recorded dataPaperlive code path, no moneyLivereal money, watched
The research funnel. Each stage is narrower than the one above it: most ideas stop before the last one.
The nightly research chainThe nightly research chain: extract, sweep, research agent, report. The recorder runs underneath all of it, all day and night.Extractpull the day'srecorded dataSweeptest many variantsat onceResearch agentreads the results,writes findingsReportheadline first;hand-off briefthe recorder keeps running underneath, 24/7The nightly research chainThe nightly research chain: extract, sweep, research agent, report. The recorder runs underneath all of it, all day and night.Extractpull the day's recorded dataSweeptest many variants at onceResearch agentreads the results, writes findingsReportheadline first; hand-off briefthe recorder keeps running underneath, 24/7
The nightly research chain: four steps, each feeding the next, with the recorder running underneath all night.