-- Phase 3: A-G evaluation pipeline.
-- Extends applications + reports with block-level detail, legitimacy tier, archetype,
-- and per-block markdown segments so the TUI can re-render without re-invoking Claude.

ALTER TABLE applications ADD COLUMN archetype TEXT;
ALTER TABLE applications ADD COLUMN legitimacy TEXT; -- high | caution | suspicious
ALTER TABLE applications ADD COLUMN evaluated_at TIMESTAMP;

ALTER TABLE reports ADD COLUMN seq INTEGER;          -- 3-digit sequential number used in filename
ALTER TABLE reports ADD COLUMN slug TEXT;            -- company slug used in filename
ALTER TABLE reports ADD COLUMN legitimacy TEXT;      -- mirrors applications.legitimacy
ALTER TABLE reports ADD COLUMN score REAL;
ALTER TABLE reports ADD COLUMN block_a TEXT;
ALTER TABLE reports ADD COLUMN block_b TEXT;
ALTER TABLE reports ADD COLUMN block_c TEXT;
ALTER TABLE reports ADD COLUMN block_d TEXT;
ALTER TABLE reports ADD COLUMN block_e TEXT;
ALTER TABLE reports ADD COLUMN block_f TEXT;
ALTER TABLE reports ADD COLUMN block_g TEXT;
ALTER TABLE reports ADD COLUMN file_path TEXT;       -- absolute path to on-disk .md report

CREATE INDEX IF NOT EXISTS idx_reports_application ON reports(application_id);
CREATE INDEX IF NOT EXISTS idx_reports_seq ON reports(seq);
CREATE INDEX IF NOT EXISTS idx_applications_job ON applications(job_id);
CREATE INDEX IF NOT EXISTS idx_applications_status ON applications(status);
