-- Adds a signal storage column to cases. PTB-XL records ship WFDB signal
-- data; if the operator ingests with --signals-dir set, each case gets both
-- a rendered image and the underlying signal stored. The signal is what
-- the ECG-FM verifier (Phase 4) operates on.
--
-- Backward compatible: signal_storage_key is nullable. Existing PNG-only
-- cases keep working; the verifier path skips cases without signals.

ALTER TABLE cases
  ADD COLUMN IF NOT EXISTS signal_storage_key TEXT;

-- Per-section verifier corrections. Stored on the case so we can show the
-- learner that a measurement was numerically verified (or that the LLM
-- estimate differed from the verifier by >threshold and was corrected).
ALTER TABLE cases
  ADD COLUMN IF NOT EXISTS measurements_verified JSONB;

COMMENT ON COLUMN cases.signal_storage_key IS
  'Storage key for the WFDB signal record (Phase 4). Nullable.';
COMMENT ON COLUMN cases.measurements_verified IS
  'ECG-FM verifier output: per-measurement comparison + correction decision.';
