Stop Persisting Non-Signal Option Prints in ClickHouse

Date: 2026-05-22 23:06:02 EDT
Beads Issue: islandflow-l9h

Summary

Implemented a signal-gated persistence path for option prints in ingest-options. With the new default configuration, prints that fail the initial signal gate (signal_pass=false) are no longer inserted into ClickHouse, while JetStream publish behavior remains unchanged.

Changes Made

Context

The options pipeline enriches and classifies prints before persistence and fanout. Previously, all enriched prints were inserted into ClickHouse regardless of signal eligibility, which retained low-value noise in durable history. The intended direction is to keep durable history aligned with the signal gate while preserving stream fanout compatibility.

Important Implementation Details

Relevant Diff Snippets

Unified diffs below are formatted to be compatible with diffs.com rendering conventions.

diff --git a/services/ingest-options/src/index.ts b/services/ingest-options/src/index.ts
@@
+  OPTIONS_PERSIST_SIGNAL_ONLY: z.preprocess(..., z.boolean()).default(true),
@@
+  logger.info("option print clickhouse persistence mode", { signal_only: env.OPTIONS_PERSIST_SIGNAL_ONLY });
@@
-        await insertOptionPrint(clickhouse, print);
-        await publishJson(js, SUBJECT_OPTION_PRINTS, print);
-        if (print.signal_pass) {
-          await publishJson(js, SUBJECT_OPTION_SIGNAL_PRINTS, print);
-        }
+        await processOptionTrade(print, {
+          persistSignalOnly: env.OPTIONS_PERSIST_SIGNAL_ONLY,
+          persist: async (value) => insertOptionPrint(clickhouse, value),
+          publishRaw: async (value) => publishJson(js, SUBJECT_OPTION_PRINTS, value),
+          publishSignal: async (value) => publishJson(js, SUBJECT_OPTION_SIGNAL_PRINTS, value)
+        });
diff --git a/services/ingest-options/src/trade-pipeline.ts b/services/ingest-options/src/trade-pipeline.ts
@@
+export const shouldPersistOptionPrint = (print, persistSignalOnly) => !persistSignalOnly || print.signal_pass === true;
+
+export const processOptionTrade = async (print, deps) => {
+  if (shouldPersistOptionPrint(print, deps.persistSignalOnly)) {
+    await deps.persist(print);
+  }
+  await deps.publishRaw(print);
+  if (print.signal_pass) {
+    await deps.publishSignal(print);
+  }
+};
diff --git a/docs/clickhouse-reset-runbook.md b/docs/clickhouse-reset-runbook.md
@@
+## One-Time Cleanup: Remove Non-Signal Option Prints
+docker compose exec clickhouse clickhouse-client --query "ALTER TABLE option_prints DELETE WHERE signal_pass = 0"
+...monitor with system.mutations and verify remaining_non_signal count...

Expected Impact for End-Users

Options history and replay streams backed by ClickHouse contain less noise and better reflect actionable signal flow. This improves signal-to-noise in historical tape usage without changing event schemas or API contract shapes.

Validation

Issues, Limitations, and Mitigations

Follow-up Work