Skip to content

validate-milestone.ts writes disk before DB — crash inconsistency #13

@igouss

Description

@igouss

Summary

validate-milestone.ts writes assessment files to disk (line ~80) before writing to the DB (transaction at line ~104). Every other handler in the engine writes DB first, then disk. This inverts the recovery guarantee.

Impact

If the process crashes between the disk write and the DB transaction:

  • Assessment file exists on disk
  • DB has no record of it
  • The system believes the assessment never happened
  • Stale assessment file sits on disk, potentially picked up by a projection renderer expecting DB-backed content

Context

All other handlers follow the pattern: DB transaction → disk render → (if disk fails, compensate DB). This handler does: disk render → DB transaction → (if DB fails, orphaned file on disk).

Fix

Invert the order to match every other handler: write DB first, then render to disk. If disk render fails, compensate the DB write.

Files

  • src/resources/extensions/gsd/tools/validate-milestone.ts — lines ~80 (disk write), ~104 (DB transaction)

Confidence

82%

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions