Reactive Prompt Models Rosetta Stone
Side-by-side harness running six reactive execution architectures against the same six failure-mode torture tests and a 5-node Spec-to-PRD pipeline: comparing signal effects, async resource epoch barriers, WICG Observables, Salsa early-cutoff hashing, keyed incremental view maintenance (IVM), and append-only human-pinned event logs.
Problem & Hypothesis
Bare synchronous effect() prompt chains hit six failure modes: undefined cold starts,
out-of-order overwrites, diamond glitches, wording-jitter cascades, clobbered manual edits, and O(N) list recomputes.
Replacing implicit effects with epoch barriers, cancelable observables, canonical schema-hash cutoffs, keyed IVM,
and event-sourced pins isolates and eliminates each failure class.
Confirm / Falsify Signals
Confirm: Naive effect() fails all five multi-step pathologies while specialized engines
record 0 glitches, 0 race corruptions, 0 jitter cascades, and preserved human edits.
Falsify: Epoch barriers or early cutoffs deadlock or fail to beat imperative cancellation wrappers.
What To Try First
Click Run All 6 Tests Across All 6 Engines below to populate the comparison scorecard, then switch to Spec-to-PRD Synthesizer to pin a manual Step 1 edit and observe conflict preservation.
3 Things To Try
LanguageModel: checking...1. Trigger Rapid Burst Race: Run the 5-edit out-of-order burst across all 6 engines and compare naive-effect overwrites against async-resource aborts.
2. Jitter + Diamond Skew: Switch to Tab 2 under salsa-cutoff, send paraphrased wording jitter, and inspect downstream cutoffHits.
3. Pin Step 1 + Replay Log: Pin a manual compliance edit in Tab 2 under event-sourced-pin, mutate Context, and scrub the event log.
| Engine | Calls | Aborted | Cutoff / Reused | Glitches | Race Corruptions | Human Edits Lost | Est. Tokens | Status |
|---|
Selected Engine
Where It Scales
Where It Breaks
Torture Test Execution & HTTP NDJSON Wire Log
Ready. Run any torture test to inspect step dispatches, aborts, schema hashes, and HTTP wire frames.
Node 0: Context + Constraints
readyNode 1: Requirements Extractor
idleUpstream changed, so the new model proposal is staged without overwriting your pinned edit:
Node 2: Risk Analyzer (Parallel Diamond Branch)
idleNode 3: Feature Table IVM (N = 6 Editable Rows)
idleNode 4: Executive PRD Draft
idleEvent Log Time-Travel Replay (Model 6)
0 eventsWhere This Model Scales vs. Where It Breaks
Where It Scales
Where It Breaks
Live Wire & Execution Event Log (POST /api/prompt-step & State Transitions)
Ready. Trigger an update above to trace HTTP NDJSON frames, aborts, barriers, cutoffs, and conflicts.
Selected Engine Core Loop Reference
Implementation & Reactive Engine Contract
Multi-stage prompt graphs fail when synchronous effect() closures fire on undefined inputs,
overlap without cancellation, propagate wording jitter, and clobber manual edits. Replacing implicit callbacks with
epoch-gated resources, WICG when() concurrency operators, canonical schema-hash cutoffs, keyed row
deltas, and event-sourced pins isolates each failure mode.
// Raw @paulkinlan/reactive-prompt effect() chain (unguarded)
const reqs = signal(undefined);
const prd = signal("");
effect(() => {
// 1. Cold boot fires immediately with literal "undefined"
const p = prompt`Extract specs for: ${specInput.value}`;
// 2. No AbortController: slow v1 overwrites fast v5
// 3. Overwrites manual user edits stored in reqs.value
runModel(p).then((out) => { reqs.value = out.text; });
});
effect(() => {
// 4. Diamond A->B,C->D runs on torn epochs; punctuation jitter cascades
runModel(prompt`Draft PRD: ${reqs.value} + ${risks.value}`)
.then((out) => { prd.value = out.text; });
});
// Epoch-gated Resource + WICG when() + Salsa cutoff + Event-Sourced Pin
const draft$ = specEl.when("input")
.filter((val) => val !== undefined)
.switchMap((val, signal) =>
joinEpochBarrier(epoch, [
step1.run(val, { signal }),
step2.run(val, { signal }),
])
);
// Skip step3/step4 when canonical schemaHash matches prior epoch
if (s1NewHash === s1PrevHash && s2NewHash === s2PrevHash) {
nodes.step3.status = "cutoff-cached";
return cachedStep3;
}
// Pinned human edits stay intact; upstream updates record proposals
if (nodes.step1.pinned) eventLog.push({ type: "ConflictDetected", proposal });
Complete Page Setup: HTML Controls, Engine Contract & Worker Stream
Switcher controls in public/index.html, ENGINE_DEFS descriptors and canonical
schemaHash fingerprinting in public/lib/engines.js, and NDJSON streaming across
public/app.js and src/worker.ts.
<!-- 1. Page HTML Setup (public/index.html) -->
<select id="complex-engine-select">
<option value="naive-effect">1. naive-effect (accumulate + effect)</option>
<option value="async-resource" selected>2. async-resource (Resource + Epoch Barrier)</option>
<option value="wicg-observable">3. wicg-observable (Observable + Operators)</option>
<option value="salsa-cutoff">4. salsa-cutoff (Canonical Schema Hash Cutoff)</option>
<option value="collection-ivm">5. collection-ivm (Keyed Row Delta IVM)</option>
<option value="event-sourced-pin">6. event-sourced-pin (Event Log + Human Pin)</option>
</select>
<select id="complex-wicg-op">
<option value="switchMap">switchMap</option><option value="exhaustMap">exhaustMap</option>
<option value="concatMap">concatMap</option><option value="mergeMap">mergeMap</option>
</select>
<select id="complex-backend-select">
<option value="simulated">Simulated Fast</option>
<option value="worker">Live Worker (/api/prompt-step)</option>
<option value="chrome-ai">Chrome Built-in AI (LanguageModel)</option>
</select>
<textarea id="context-input">Build an offline-first field inspection web app...</textarea>
<button type="button" id="pin-step1-btn">Pin Manual Edit</button>
<script type="module" src="/app.js"></script>
// 2. ENGINE_DEFS + Canonical Schema Hash & Epoch Join (public/lib/engines.js)
export const ENGINE_IDS = ["naive-effect", "async-resource", "wicg-observable", "salsa-cutoff", "collection-ivm", "event-sourced-pin"];
const schema = {
step: spec.step,
subject: keywords.slice(0, 3).join("-") || "general-spec",
keywords,
priority, // "P0" | "P1" | "P2"
constraints, // ["offline-first", "on-device", "audit-trail", "bounded-latency"] | ["standard-sla"]
rowKey: spec.rowKey ?? null,
};
const schemaHash = canonicalHash(schema); // 64-bit FNV-1a over sorted keys
// 3. Page Bootstrap & /api/prompt-step Wiring (public/app.js + src/worker.ts)
const session = createSpecToPrdSession({
engineId: complexEngineSelect.value,
wicgOperator: complexWicgOp.value,
onStateChange: renderComplexSnapshot,
onLog: (entry) => appendLogLine(complexWireLog, `[${entry.engineId} e#${entry.epoch}] ${entry.event}`),
});
session.setExecutor(createBackendExecutor(complexBackendSelect.value, appendWire));
// createBackendExecutor("worker") posts to /api/prompt-step with AbortSignal:
const response = await fetch("/api/prompt-step", {
method: "POST", headers: { "Content-Type": "application/json" },
body: JSON.stringify({ step: spec.step, input: spec.input, latencyMs, jitterSeed, epoch, rowKey }),
signal: opts.signal,
});
// src/worker.ts -> src/prompt-step.ts streams NDJSON frames bound to request.signal:
if (url.pathname === "/api/prompt-step") return await handlePromptStep(request);
Core Plumbing Required Today (Browser + Edge / Protocol Contract)
// public/lib/engines.js — Epoch Join Barrier & Salsa Early Cutoff (maybeJoin)
if (sig1.aborted || sig2.aborted) return;
if (useBarrier && (s1DoneEpoch !== runEpoch || s2DoneEpoch !== runEpoch)) {
emitLog("barrier:waiting", { runEpoch, s1DoneEpoch, s2DoneEpoch });
return;
}
if (engineId === "salsa-cutoff" && s1PrevHash && s2PrevHash
&& s1NewHash === s1PrevHash && s2NewHash === s2PrevHash) {
metrics.cutoffHits += 2;
nodes.step3.status = "cutoff-cached";
nodes.step4.status = "cutoff-cached";
emitLog("salsa:early-cutoff", { runEpoch, s1SchemaHash: s1NewHash, s2SchemaHash: s2NewHash });
return;
}
// src/worker.ts + src/prompt-step.ts — Abort-aware NDJSON stream
if (url.pathname === "/api/prompt-step") return await handlePromptStep(request);
const stream = createPromptStepStream(params, request.signal);
return new Response(stream, {
headers: { "Content-Type": "application/x-ndjson; charset=utf-8", "Cache-Control": "no-store" }
});
Ad-hoc boolean busy flags, manual timer debounce wrappers, literal "undefined" prompt invocations, and silent overwrites of user-edited outputs.
Per-node Resource<T> lifecycles (idle, pending, streaming, ready, conflict), epoch join barriers, concurrency operators (switchMap, exhaustMap, concatMap), canonical schemaHash cutoffs, and keyed row deltas.
Browser DOM signals and WICG EventTarget.prototype.when() are not yet shipped uniformly across engines, and built-in LanguageModel sessions do not enforce graph epoch barriers, schema-hash memoization, or conflict logs.