Skip to content

Lighthouse Model Demo ​

Status (2026-11-30): AR / CG / RC scenarios on the mock stream; the same wiring also runs on recorded public CI results and on live test results. A real LLM Brain (ClaudeBrain) can run in shadow beside the rule-based primary on the mock stream. 839 tests, 0 fail.

A demonstration of the Lighthouse Model: using the DCP Pipeline as an observation layer for agentic code generation streams. The core mechanism — re-observing stored raw data through a different lens without touching the live stream — is what the mock scenarios demonstrate. What holds on real data, and what does not, is summarised in the model page.

What this demonstrates ​

The observation layer mechanics, not the domain:

  • A live test_result:v1 stream flows continuously. The observation layer attaches on top — the stream is never paused or blocked.
  • $Q holds observation parameters (window_ms, align/origin, group_by, etc.). The window grid itself is lens state, shared by every reader, not a property of whichever query asked for it. Brain changes $Q; LensViews react live.
  • RetentionBuffer keeps raw events in a ring buffer. Brain can trigger replay at any time.
  • SnapshotCurator ($U) mechanically classifies the observed shape into tiles: spike, dip, gap, step, divergence, baseline.
  • RuleBrain fires three rule types: rerouteSchema (AR), schemaUpdate (CG), replayRequest (RC).

The same observation mechanics work for any high-frequency stream. test_result:v1 is one domain skin on top.

The key distinction ​

Changing the observation lens is not the same as the world changing.

RC (Retroactive Re-observation) makes this concrete: a 2-second failure burst in agent-C is averaged away by the coarse live view (10s window). The world recorded it — the stream holds raw events. Brain notices the recovery signature, triggers replay of the retained segment through a fine lens (1s window), and the burst appears as a dip tile. The data did not change. The lens did.

Architecture ​

The default (mock) wiring. Real test streams replace the generator and widen the windows.

MockStreamGenerator (test_result:v1, 50 evt/s)
  ↓  onEvent
TestorAdapter         ← per-agent / per-domain aggregation → STSnapshot
  +
RetentionBuffer       ← freshness zone (ring, full resolution)
                         + reference zone (thinned, opt-in, $Q-resizable)
  +
ObservationOverlay    ← "coarse" (10s window)  "fine" (1s window)
                         both read $Q[observe] live
  ↓  tick (1s)
RuleBrain             ← observe(STSnapshot) → decide() → BrainDecision[]  (primary)
ClaudeBrain           ← same STSnapshot, async deliberation, own cadence  (shadow)
  ↓                                          ↓
  ├─ rerouteSchema   → console + dashboard SSE  ├─ shadow-logged only, gated
  ├─ schemaUpdate    → console + dashboard SSE  │   against curator before
  └─ replayRequest   → buffer.replay(params)    │   being printed as "backed"
                        → Comparator ($Q[compare])  └─ replayRequest → same replay path
                          → SnapshotCurator
                        → broadcastReplay(pkg) → dashboard SSE

RetentionBuffer → WindowHistory (window summaries) → Forecaster → $F rows (virtual)
  ↓
DashboardServer       ← SSE :3001 (/events/snapshot, /events/decisions)
                         HTTP: /status, /forecast, /persistence, /brain, /control/*, /ingest/build

Brain AI used: RuleBrain is the deterministic primary BrainAdapter. ClaudeBrain (BRAIN_MODE=claude) is a real, measured LLM implementation of the same interface — it deliberates asynchronously (its own cadence, decoupled from the 1s tick) and runs in shadow only: its decisions are logged and gated against the curator but never drive the pipeline. See ClaudeBrain (shadow) below.

Event schema ​

["$S","test_result:v1",8,"ts","testId","agentId","areas","result","duration","weight","commitHash"]

Four agents: agent-A (baseline, 95% pass) · agent-B (broad coverage, 88%) · agent-C (regression target, 95%) · agent-D (flaky output, 90%)

Area space: 256 bits fixed, partitioned by domain:

BitsDomainPriority
0–31authcritical
32–63paymentcritical
64–127uinormal
128–255utilslow

Scenario AR — Agent Regression ​

Trigger: agent-C pass rate drops from 95% → 70% and stays below its learned per-agent threshold for ≥ 2 consecutive ticks.

Thresholds are per-agent, not a single global bar. Each agent's healthy pass rate is tracked as a learned baseline; "regression" means a drop below that agent's normal by at least 0.10 and by at least 3.5 standard errors of the current window:

threshold = baseline − max(0.10, 3.5 · √(baseline · (1 − baseline) / n))     n = events in the window

A global 0.80 bar sat only ~1.9σ above a legitimately-low-baseline agent (agent-B at 0.88), firing spurious regressions on quiet baseline (~30% of seeds). A per-agent baseline − 0.10 fixed that at 50 events/sec only: a fixed delta is a fixed number of σ at one event rate, and when the generator actually ran at about 32 events/sec, quiet false reroutes rose from 0.004 to 0.37 per minute. The standard-error term removes that dependence.

TestorAdapter window (5s): agent-C pass rate crosses below its threshold (≈0.85)
RuleBrain.checkAR(): agentRegressionTicks["agent-C"] = 2 → fires

Brain decision:

rerouteSchema: { agentId: "agent-C", reason: "pass rate 0.70 < threshold for 3 ticks" }

Dashboard event:

json
{ "type": "rerouteSchema", "agentId": "agent-C", "ts": 1234567890 }

Recovery: A tick at or above the threshold clears the regression count. The rule can reroute the same agent again only after 3 consecutive healthy ticks, so one noisy tick inside a regression does not produce a second reroute.

Criterion: Decision fires within 5 seconds of regression onset. Measured mean latency is about 3.85 s; across 40 seeds the maximum was 6 s, so the tail exceeds the criterion. Agent panel shows a visible per-agent separation.

Scenario CG — Coverage Gap ​

Trigger: auth domain bits 16–23 are excluded from all area lists. Coverage gap accumulates above threshold for ≥ 5 ticks.

TestorAdapter: auth coveredBits = 24 (of 32 required) → gap = 8 > GAP_THRESHOLD (4)
RuleBrain.checkCG(): domainGapTicks["auth"] = 5 → fires

Brain decision:

schemaUpdate: { domain: "auth", gap: 8, reason: "coverage gap sustained for 5 ticks" }

Dashboard event:

json
{ "type": "schemaUpdate", "domain": "auth", "gap": 8 }

Criterion: Heatmap hole visible within 10 seconds. Decision fires before the gap closes on its own.

Scenario RC — Retroactive Re-observation ​

This is the scenario that justifies the retention buffer.

What happens in the world: agent-C pass rate drops to 20% for 2 seconds (≈ 25 events), then returns to 95%. Under the coarse live view (10s window), this 2-second dip is diluted: window mean stays close to the baseline.

What Brain sees: agent-C pass rate dips briefly into [0.40, agentThreshold) then recovers above its threshold. This recovery signature is the trigger.

RuleBrain.checkRC():
  tick N:   agent-C passRate = 0.65 → confirmed dip (≥ DIP_REQUIRE_TICKS)
  tick N+1: agent-C passRate = 0.65 → still in dip zone (≤ DIP_MAX_TICKS)
  tick N+2: agent-C passRate = 0.92 → recovered above threshold
            agentDipActive.has("agent-C") → replayRequest fires

Brain decision:

replayRequest: {
  agentId: "agent-C",
  qProposal: {
    scope: "observe:test_result:v1#fine",
    params: { window_ms: 1000, align: "epoch", group_by: ["agentId"], fromTs, toTs }
  }
}

What happens next:

index.ts receives replayRequest
  → buffer.replay({ window_ms: 1000, align: "epoch", group_by: ["agentId"], fromTs, toTs })
  → curator.curate(fineResult, referenceResult)   (SnapshotCurator scores each group against its own reference)
  → dashboard.broadcastReplay(pkg)                 (SSE push to /events/decisions)

The fine-window replay produces dip tiles at the burst windows. Grouping by agentId matters here: scored against the four-agent mixture, agent-C's dip is diluted by the other three agents' healthy pass rate and reads as a shallow signal; scored against agent-C's own history within its group it reads as a clear dip. The coarse view shows nothing anomalous. The contrast is the artifact.

This lens is also where thin windows matter most. With about 12 events per window and a pass rate near 0.95, a Gaussian approximation flagged a false dip in about 41% of quiet replay packages; the exact tail described under SnapshotCurator tiles brought that to 4.3%.

Criterion: Fine-window replay recovers the injected burst at the known position and magnitude. The dip tile regionStart aligns with the burst_start entry in the scenario truth log.

RuleBrain rules ​

RuleTriggerConditionDecision
ARagent.passRate < threshold (per-agent, formula above)Sustained for ≥ 2 ticksrerouteSchema (once per regression)
CGdomain.gap > 4Sustained for ≥ 5 ticksschemaUpdate (once per domain)
RCpassRate in [0.40, agentThreshold) then recoveryRecovery above threshold after a 2–7 tick dipreplayRequest (once per session)

Baselines are a plain running mean during a 10-tick warmup, then an EWMA; no threshold is trusted before the warmup ends, and the baseline is frozen while an agent is below threshold so a regression can't re-normalize itself. An agent window with fewer than 3 events neither teaches that baseline nor moves its AR or RC counters, and a tick with no events at all freezes every counter — an observer that sees nothing does not report a gap. AR re-arms after 3 healthy ticks, CG when the gap closes, RC after brain.reset(). reset() clears per-scenario detection state but keeps the learned baselines (long-lived agent knowledge).

The rules are written for the mock stream.

SnapshotCurator tiles ​

$U produces a SnapshotPackage — a curated set of tiles sorted by significance then time.

ShapeTagDetectionTypical source
spikez-score ≥ threshold (positive)Unusual pass rate burst
dipz-score ≤ −threshold (negative)Failure burst (RC fine-window)
step_upSustained mean elevation ≥ 3 windows (descriptive under the variogram null, see below)Improvement regime
step_downSustained mean drop ≥ 3 windows (same note)AR regression tail
gapNo events for > 2× window_msCG coverage hole
divergenceTwo lenses disagree at same windowCoarse/fine contrast
baselineWindow closest to global meanReference point

The spike/dip threshold is not a fixed 2.0σ constant — it is solved per package via a Šidák correction across however many windows (and, with group_by, groups) the package actually scores, so the package's design false-alarm rate (4.55%) stays fixed regardless of how many independent looks it took. The Šidák family is package-wide, not per group — a per-group budget would re-inflate the same false-alarm rate the correction removed.

Whether the design rate is the actual rate depends on the stream and the lens. Unweighted two- and three-valued windows of up to 2,000 events are scored on an exact tail (a mid-p Dirichlet-multinomial predictive against the reference); other windows use a Gaussian approximation, with a continuity correction for two-valued data. Earlier figures here (29% → 6.5% → 4.40%) were measured on synthetic streams without flaky results and did not describe the live stream: see the model page for that history.

What a verdict is scored against ​

A tile is a window scored against a reference under a null model. Both are declared in $Q[compare], and every package names the comparison it ran.

null_modelAssumesStatus
independentEvents are independent draws at the reference rateShipped default. Alarmed in 99.8% of packages at 10 s windows on a real public event stream
overdispersedEach window draws its own latent rateOpt-in
variogramLatent rates drift, so distant windows differ moreOpt-in; needs window-summary history. Under it, a step tile only describes a run that contains a flagged window

Packages also state the smallest one-window change they could detect (sensitivity, at 80% power), so an empty tile list from a coarse lens does not read like an all-clear.

Tiles are sorted by type priority (spike/dip first, baseline last), then chronologically within type. The package is what Brain — rule-based or LLM — sees instead of raw time series.

agg_func: "median" and "percentile" are supported on the lens chain (exact via raw-value retention, so downsample_factor still pools losslessly by concatenating values before recomputing) but the curator does not attempt to score them: a package built on such a window sets aggFuncUnscored: true and returns zero tiles rather than running the z-test machinery, which assumes Gaussian per-window means. This is the "silence vs. blindness" discipline applied to a statistic, not just to missing data — the curator declines to judge, but the raw values/mean stay readable on the LensResult itself.

ClaudeBrain (shadow) ​

ClaudeBrain implements BrainAdapter with a real Anthropic API call in place of RuleBrain's rules. Two design constraints shaped it:

  • Deliberation is decoupled from the tick. decide() stays synchronous and the tick stays 1s; the model is neither. observe() may start an async deliberation (guarded by an in-flight latch plus a minIntervalMs floor — two independent spend guards), and decide() drains whatever has arrived. Because a decision surfaces several ticks after the snapshot that provoked it, meta.snapshotTs names which data the model was looking at — not the tick it happened to drain on.
  • The proposal gate lives in the Brain, not at the write site. validateObserveParams — the same rulebook $Q writes go through — runs before a replayRequest becomes a BrainDecision at all. A lens the rulebook would reject never reaches the decision log; rejections are counted (stats.rejectedProposals) rather than silently retried.

Measured (real API run, Sonnet 5, $0.49): the core claim holds — every replayRequest correctly carried window_ms: 1000 + group_by: ["agentId"], and the stated reasons named the right mechanism. But target identification does not: the RC burst is caught, but so are quiet, event-free agents at a similar rate (2/17 vs. 5/17 in one run) — the model operates the lens correctly without reliably knowing which lens to point where.

A 2×2×2 discipline experiment (QUIET/AR/RC × base/placebo/disciplined prompt × Sonnet 5/Sonnet 4.6, $1.41) separated "personality" from "how it's asked": a length-matched placebo moved nothing (p = 1.0), but adding real content collapsed the proposal rate from 14/22 to 3/25 (p = 0.0003) — the framing dominates, not the model. The catch: the same discipline block, phrased as one general "be more conservative" instruction in prose, landed on whichever channel each model happened to overuse and zeroed it out entirely rather than tuning it down — for Sonnet 5 that was the RC replayRequest channel itself, deleting the one capability the experiment most wanted to keep. Neither prompt variant is shipped; the conclusion drawn is architectural, not promptable: keep the accept/reject gate in code (the curator), and let the LLM's contribution stay scoped to lens selection — a decision that also avoids the transcription trap from the earlier A/B work (there is no curator judgment available for the model to copy).

GET /brain exposes ClaudeBrainStats / the shadow-vs-primary tally for live inspection; nothing in this build promotes ClaudeBrain past shadow.

Reference zone and $Q[pipeline] (L5) ​

RetentionBuffer has two zones. The freshness zone is the original full-resolution ring (what RC replay reads). An opt-in reference zone sits behind it: instead of discarding evicted events, it keeps 1-in-N (a fixed thinning ratio) with weight = N on the survivor, so the same weighted-aggregation machinery built for decay (Kish effective-N, weighted pooling) prices the reference zone's coarser sampling without a second statistical code path. Both retention_window_ms (freshness) and the reference zone's width/thinning ratio are live $Q[pipeline] rows — a setter only resizes a zone that opted in at construction; $Q cannot cold-start a reference zone that wasn't configured when the buffer was built, and a ratio change is forward-only (already-thinned events keep the weight they were thinned under, so re-weighting can't retroactively rewrite history the way an anchor-slide bug would).

GET /control/replay?fromTs=&toTs=&window_ms= is the reference zone's first real reader: a manual trigger that replays a span against the reference zone and scores it with the curator. Verified against a live server left running ~140s: a request for a span more than the freshness zone's width in the past correctly reports referenceUsable: true, pulled from the thinned zone rather than the (already-evicted) fresh ring.

Division of labor (§A) ​

ClaudeBrain's shadow-logged rerouteSchema/quarantine decisions carry a target agentId and the snapshotTs they were reasoned from — but a shadow decision is, by construction, never checked against anything before it's printed. isReroutedAgentBacked() closes that gap: on shadow-log, it re-runs an on-demand grouped replay (group_by: ["agentId"]) at the named timestamp and asks the curator whether that agent actually has a flagged tile there. Unbacked claims are counted separately (ClaudeBrainStats.gateRejected, distinct from rejectedProposals — malformed lens vs. an assertion the curator can't corroborate) rather than silently logged as fact. The gate deliberately does not read the always-on coarse live view — a multi-trial RC re-run found that view's dip detection inconsistent across runs, while the same on-demand grouped replay caught the injected burst reliably in all three; schemaUpdate (domain-coverage) gating is out of scope, since the curator has no matching judgment concept for it yet.

Forecasts ($F) ​

The window summaries that feed the variogram null also produce forecasts. $Q[forecast] declares the horizons and history for a view, and each row is a kriging prediction of a future window's rate with its variance and interval. Every row carries virtual: true: a forecast is never an observation. A row whose horizon reaches past the history it was fitted on says so (extrapolatedFromLag), and GET /forecast reports whether past forecasts landed inside their intervals. No Brain decision reads $F. The mock profile declares forecast rows; the test-stream profile does not.

Real test streams ​

The mock views cannot score a stream of CI results: builds arrive hours apart and almost all tests pass, so on recorded Kubernetes Prow results the 10 s and 1 s views had no usable reference for 99.8–100% of the questions asked. A second profile and two other sources cover this.

SettingValues
LIGHTHOUSE_PROFILEmock (default) · test-stream: 1-hour windows, 30 windows of reference, 34 hours retained
LIGHTHOUSE_SOURCEmock (default) · prow: replay of imported public CI results on a virtual clock · ingest: finished builds sent to POST /ingest/build as JSON or JUnit XML. The last two require test-stream and the rule Brain

What runs on these streams, beyond the window tiles:

  • Automatic grouped replay — a downward tile or a failure burst in the combined view replays that span grouped by job
  • Persistence (GET /persistence) — a test that fails in consecutive builds, with no pass on the same code, is announced once. Optionally annotated with the test's recent failure history (LIGHTHOUSE_PERSIST_HISTORY=N)
  • Failure bursts — many tests failing in one window. A fixed count of 10, and optionally a count judged against the reference windows (LIGHTHOUSE_RELATIVE_BURST=1; blind until 8 reference windows exist)
  • All-pass references — optionally scored on an exact two-level null in the grouped replays, instead of being left unscored (LIGHTHOUSE_ALL_PASS_NULL=1)

The numbers behind these were fixed on recorded public data; none has been measured on a live ingested stream. Detection results and their limits are on the model page.

Dashboard ​

The live SSE dashboard (:3001) exposes two channels:

  • /events/snapshot — 1s ticks: agents (per-agent pass rate, flaky rate, event count), domains (coverage per domain), coarse SnapshotPackage, $Q history; persistence announcements on test-result sources
  • /events/decisions — Brain decisions and automatic replay requests as they fire; replay_snapshot events carry the replayed SnapshotPackage

HTTP endpoints:

  • GET /demo/start?scenario=AR|CG|RC — starts a scenario (resets Brain state first); 409 while one is running or when the source is not the mock generator
  • GET /demo/stop — stops the generator and any running scenario
  • GET /status — current load and active scenario; source and blindness fields on test-result sources
  • POST /ingest/build — one finished build (LIGHTHOUSE_SOURCE=ingest); a resent build is refused with 409
  • GET /persistence — persistence announcements; active: false when the source has none
  • GET /forecast?view=coarse|fine[&at=ms] — $F rows, scores for realized windows, and calibration
  • GET /control/baseline-delta?value= — write $Q[schema].baseline_delta live
  • GET /control/coarse-downsample?factor= — write the coarse view's downsample_factor live
  • GET /control/compare?null_model=&history_ms=&history_clean= — write $Q[compare]
  • GET /control/forecast?view=&horizons=&recent_windows=&history_ms=&level=&method= — write $Q[forecast]
  • GET /control/replay?fromTs=&toTs=&window_ms= — manual replay + reference-zone scoring (see Reference zone)
  • GET /brain — ClaudeBrain/ShadowBrain diagnostics (shadow tally, gate/reject counters); { mode: "rule" } when no LLM Brain is running

Source ​

dcp-lighthouse/ repository. Key files:

FileRole
server/src/index.tsPipeline wiring and tick loop
server/src/mock-stream-generator.tstest_result:v1 stream + AR/CG/RC injection
server/src/testor-adapter.tsTestEvent → STSnapshot (per-agent, per-domain)
server/src/q-registry.ts$Q observation parameter store
server/src/retention-buffer.tsFreshness ring + opt-in thinned reference zone, replay(params)
server/src/lens.tsapplyLens(segment, params) — full effector chain: group_by → window_ms → downsample_factor → decay → agg_func
server/src/lens-view.tsObservationOverlay — parallel lenses on one stream
server/src/snapshot-curator.tsSnapshotCurator ($U) — shape tile selection, null models
server/src/comparison.tsResolves $Q[compare] and names the comparison on each package
server/src/window-history.tsWindow summaries kept for the variogram null and forecasts
server/src/forecast.ts / forecast-monitor.ts$F rows (kriging) and their calibration monitor
server/src/stream-profile.tsmock / test-stream constant sets
server/src/coarse-replay-trigger.tsCoarse firing → grouped replay
server/src/prow-persist.tsPer-test persistence detector
server/src/prow-live.ts / ingest-build.ts / ingest-log.tsRecorded replay source, live build ingestion, ingest log
server/src/rule-brain.tsRuleBrain — AR / CG / RC rule implementation
server/src/brain-adapter.tsBrainAdapter interface + ResettableBrain
server/src/claude-brain.tsClaudeBrain — LLM BrainAdapter, decoupled deliberation + proposal gate
server/src/shadow-brain.tsShadowBrain — primary/shadow tally, never returns shadow decisions from decide()
server/src/anthropic-ask.tsThin wrapper over the Anthropic Messages API used by ClaudeBrain
server/src/calibration.tsFalse-alarm-rate / detection-power measurement harness (takes a lens as an argument)
server/src/dashboard.tsSSE bridge + HTTP endpoints
dashboard/app.jsBrowser-side dashboard UI