-- 0003_shadow_receipts.sql
CREATE TABLE IF NOT EXISTS shadow_receipts (
  id TEXT PRIMARY KEY,                              -- uuid
  ts TEXT NOT NULL DEFAULT (datetime('now')),
  horizon_id TEXT NOT NULL,                         -- grouping key for “unrealized futures”
  counterfactual_hash TEXT NOT NULL,                -- hash of normalized counterfactual payload
  entropy_delta REAL,                               -- optional numeric signal (can be NULL)
  reason_unrealized TEXT NOT NULL,                  -- short enum-like string (e.g. "blocked", "operator_abort")
  observer_signature TEXT,                          -- optional (future: Ed25519 signature)
  trace_id TEXT,                                    -- correlate to invocation chain
  meta_json TEXT                                    -- redacted metadata
);

-- minimal safety constraints
CREATE INDEX IF NOT EXISTS idx_shadow_receipts_ts ON shadow_receipts(ts);
CREATE INDEX IF NOT EXISTS idx_shadow_receipts_horizon ON shadow_receipts(horizon_id);
CREATE INDEX IF NOT EXISTS idx_shadow_receipts_trace ON shadow_receipts(trace_id);
CREATE INDEX IF NOT EXISTS idx_shadow_receipts_reason ON shadow_receipts(reason_unrealized);
