-- 004_check_coverage.sql
--
-- 002_seed.sql loads 134 check DEFINITIONS. The engine currently implements 55
-- of them. The other 79 are specified, seeded and ready, but no code evaluates
-- them yet.
--
-- This is not a scoring bug: an unimplemented check writes no check_result row,
-- and the scorer excludes it from BOTH the numerator and the denominator, so it
-- neither inflates nor deflates the score. It IS a reporting problem — anyone
-- reading "134 checks" in the database assumes 134 checks ran, and a developer
-- handed a clean report has no way to tell "we looked and it was fine" from
-- "nobody looked". Make the distinction explicit in the schema.
--
-- When a check is implemented, set its flag to 1 in the same commit as the code.
-- Re-runnable.

ALTER TABLE check_definition
  ADD COLUMN IF NOT EXISTS implemented TINYINT(1) NOT NULL DEFAULT 0
  COMMENT '1 = an evaluator exists in src/Audit and this check actually runs';

UPDATE check_definition SET implemented = 0;

UPDATE check_definition SET implemented = 1 WHERE code IN (
    'A03',  'A04',  'A05',  'A06',  'A07',  'A09',  'A10',  'A12',  'A13',  'A14',  'A17',
    'A18',  'C02',  'C06',  'C09',  'O001',  'O002',  'O003',  'O009',  'O014',  'O031',
    'O067',  'O080',  'O087',  'T001',  'T003',  'T004',  'T005',  'T006',  'T007',
    'T009',  'T010',  'T011',  'T012',  'T015',  'T025',  'T026',  'T027',  'T028',
    'T036',  'T075',  'T076',  'T085',  'T087',  'T109',  'T113',  'T114',  'T118',
    'T120',  'T127',  'T128',  'T131',  'T137',  'T138',  'T139'
);
