- Add StaleLevel enum (ok, WARN, STALE, DEAD) to types.nim
- Extract computeStaleLevel() as single source of truth
- Simplify isStale() and staleLevel() to use computeStaleLevel()
- Refactor transition() and transitionToFailed() to use withTransaction
- Add schema migration infrastructure:
- CurrentSchemaVersion constant
- Migrations sequence for incremental upgrades
- getSchemaVersion() and runMigrations() procs
- initSchema() now runs pending migrations
Closes: skills-dtk, skills-8fd, skills-9ny
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add try/except blocks in worker commands to catch WorkerNotFound,
InvalidTransition, and StaleState exceptions
- Return ExitInvalidTransition (3) for state transition errors
- Return ExitNotFound (7) for missing workers
- Fix double ROLLBACK bug in state.nim by removing inline ROLLBACKs
and letting the except block handle transaction cleanup
Closes: skills-lxb9
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add branchName() and worktreePath() helpers for consistent path generation
- Add msToTime() for epoch ms to Time conversion (8 occurrences consolidated)
- Add validateTaskId() for CLI input validation (prevents path traversal)
- Add optString/optInt64 helpers for nullable DB values
- Add withTransaction template for automatic rollback on error
Closes: skills-lzh2, skills-3d9o, skills-5x2o, skills-qiq0, skills-73yu, skills-vuj2
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>