-- Migration 062: Add pipeline_version to track which generation rules produced each control/chunk -- -- v1 = Original pipeline (local LLM prefilter, old prompt without null-skip) -- v2 = Improved pipeline (skip_prefilter, Anthropic decides relevance, annexes protected) -- -- This allows identifying controls that may need reprocessing when pipeline rules change. ALTER TABLE canonical_controls ADD COLUMN IF NOT EXISTS pipeline_version smallint NOT NULL DEFAULT 1; ALTER TABLE canonical_processed_chunks ADD COLUMN IF NOT EXISTS pipeline_version smallint NOT NULL DEFAULT 1; -- Index for efficient querying by version CREATE INDEX IF NOT EXISTS idx_canonical_controls_pipeline_version ON canonical_controls (pipeline_version); CREATE INDEX IF NOT EXISTS idx_canonical_processed_chunks_pipeline_version ON canonical_processed_chunks (pipeline_version); COMMENT ON COLUMN canonical_controls.pipeline_version IS 'Generation pipeline version: 1=original (local prefilter), 2=improved (Anthropic decides relevance, annexes protected)'; COMMENT ON COLUMN canonical_processed_chunks.pipeline_version IS 'Pipeline version used when this chunk was processed';