diff --git a/src/resources/extensions/sf/sf-db/sf-db-schema.js b/src/resources/extensions/sf/sf-db/sf-db-schema.js index 06440d957..d53173f77 100644 --- a/src/resources/extensions/sf/sf-db/sf-db-schema.js +++ b/src/resources/extensions/sf/sf-db/sf-db-schema.js @@ -3579,37 +3579,6 @@ function migrateSchema(db, { currentPath, withQueryTimeout }) { if (ok) appliedVersion = 69; } - if (appliedVersion < 72) { - const ok = runMigrationStep("v72", () => { - // Schema v72: per-slice vision trace (ADR-0000 P2, restoration of doctrine). - // Renumbered from the originally-planned v69 because parallel work on - // main used v69 for memory_extraction_attempts.failure_class. - // - // plan-milestone must emit a literal fragment of milestone.vision that each - // slice serves so validate-milestone has structured grounds for assessment - // instead of re-reading the entire vision via the LLM every time. The - // fragment is the canonical "this slice traces back to that purpose" link. - // - // NULL is allowed for legacy rows (slices planned before v72); the - // planning prompt and validation begin requiring it for new slices. - // - // Idempotent ALTER: probe via columnExists because the fresh-DB CREATE - // path already adds the column. - if (!columnExists(db, "slices", "traces_vision_fragment")) { - db.exec( - "ALTER TABLE slices ADD COLUMN traces_vision_fragment TEXT", - ); - } - db.prepare( - "INSERT INTO schema_version (version, applied_at) VALUES (:version, :applied_at)", - ).run({ - ":version": 72, - ":applied_at": new Date().toISOString(), - }); - }); - if (ok) appliedVersion = 72; - } - if (appliedVersion < 70) { const ok = runMigrationStep("v70", () => { // Schema v70: per-task purpose trace (ADR-0000 restoration). @@ -3671,6 +3640,37 @@ function migrateSchema(db, { currentPath, withQueryTimeout }) { if (ok) appliedVersion = 71; } + if (appliedVersion < 72) { + const ok = runMigrationStep("v72", () => { + // Schema v72: per-slice vision trace (ADR-0000 P2, restoration of doctrine). + // Renumbered from the originally-planned v69 because parallel work on + // main used v69 for memory_extraction_attempts.failure_class. + // + // plan-milestone must emit a literal fragment of milestone.vision that each + // slice serves so validate-milestone has structured grounds for assessment + // instead of re-reading the entire vision via the LLM every time. The + // fragment is the canonical "this slice traces back to that purpose" link. + // + // NULL is allowed for legacy rows (slices planned before v72); the + // planning prompt and validation begin requiring it for new slices. + // + // Idempotent ALTER: probe via columnExists because the fresh-DB CREATE + // path already adds the column. + if (!columnExists(db, "slices", "traces_vision_fragment")) { + db.exec( + "ALTER TABLE slices ADD COLUMN traces_vision_fragment TEXT", + ); + } + db.prepare( + "INSERT INTO schema_version (version, applied_at) VALUES (:version, :applied_at)", + ).run({ + ":version": 72, + ":applied_at": new Date().toISOString(), + }); + }); + if (ok) appliedVersion = 72; + } + // Post-migration assertion: ensure critical tables created by historical // migrations are actually present. If a prior migration claimed success but // the table is missing (e.g., due to a rolled-back transaction that failed