-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Description
Problem
storage.ts is 1083 lines with mixed concerns: type definitions, pure data transformers, backend-specific logic (SQLite vs PostgreSQL), and cross-cutting mutex infrastructure.
Extraction Opportunities
1. Data transformers → transformers.ts
validateLabels(),rowToRun(),rowToStep(),rowToLog(),toClientRun()- Pure functions, zero DB dependency, ~80 lines
- Testable in isolation
2. claimNext backend split
claimNext()is 140+ lines with two completely divergent paths:- PostgreSQL:
FOR UPDATE SKIP LOCKED+ advisory locks + retry loop (lines 716–799) - SQLite: simple subquery + UPDATE (lines 801–836)
- PostgreSQL:
- Could become
claim-sqlite.tsandclaim-postgres.ts - Biggest readability win
3. Mutex → keep inline (too small to extract)
createWriteMutex()is 18 lines, only used once- Not worth a separate file
Priority
Medium. Do alongside #124 (getRun JOIN optimization) since both touch the same file.
References
Found during /simplify cohesion review on PR #130
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels