-- KB spine: document_chunk — unique-key fix + exclusion flag -- Additive: does not modify 001_envelope.sql or 002_chunks.sql. -- Version: 003 — chunk model key + excluded_reason (module 5, phase 3, plan §3.3) -- -- (a) UNIQUE rozszerzony o model — bez tego drugi model embeddingów cicho się no-opuje -- na ON CONFLICT DO NOTHING (finding z review kroku 6 fazy 2). -- (b) excluded_reason — flaga wykluczenia chunka z retrievalu i kompilacji -- (NULL = aktywny; 'ocr_junk' | 'duplicate'). ALTER TABLE document_chunk DROP CONSTRAINT IF EXISTS document_chunk_envelope_id_chunk_index_key; ALTER TABLE document_chunk ADD CONSTRAINT document_chunk_envelope_chunk_model_key UNIQUE (envelope_id, chunk_index, model); ALTER TABLE document_chunk ADD COLUMN IF NOT EXISTS excluded_reason TEXT; -- NULL = aktywny