| 1 | ALTER TABLE chat_projects ADD COLUMN copy_owner text; |
| 2 | ALTER TABLE chat_projects ADD COLUMN copy_revision integer; |
| 3 | ALTER TABLE chat_tasks ADD COLUMN copy_hold numeric; |
| 4 | ALTER TABLE chat_tasks ADD COLUMN repair_round integer; |
| 5 | ALTER TABLE chat_tasks ADD COLUMN copy_recovery text; |
| 6 | ALTER TABLE chat_steps ADD COLUMN copy_owner text; |
| 7 | ALTER TABLE chat_steps ADD COLUMN copy_revision integer; |
| 8 | ALTER TABLE chat_steps ADD COLUMN copy_result text; |
| 9 | ALTER TABLE chat_steps ADD COLUMN failure_signature text; |
| 10 | UPDATE chat_tasks SET repair_round = COALESCE((SELECT MAX(round) FROM chat_steps WHERE task_id = chat_tasks.id AND specialist = 'engineering'), 0); |
| 11 | CREATE TABLE chat_copy_reviews (id text PRIMARY KEY, project_id text, task_id text, step_id text, attempt integer, owner text, delegation integer, candidate text, input text, key text, text text, hash text, flag text, created_at datetime); |
| 12 | CREATE INDEX idx_copy_reviews_task ON chat_copy_reviews(task_id); |
| 13 | CREATE INDEX idx_copy_reviews_attempt ON chat_copy_reviews(step_id, attempt); |
| 14 | CREATE TABLE chat_copy_feedback (id text PRIMARY KEY, project_id text, owner text, source_id text, key text, before text, after text, reason text, origin text, learned numeric, created_at datetime); |
| 15 | CREATE TABLE chat_copy_attempts (id text PRIMARY KEY, task_id text, step_id text, attempt integer, tokens integer, known numeric); |
| 16 | |