(id: string)
| 230 | * read-back here cannot race with a concurrent writer in this process. |
| 231 | */ |
| 232 | export function claimProposedTask(id: string): Task | null { |
| 233 | const db = getDb(); |
| 234 | const now = new Date().toISOString(); |
| 235 | const info = db |
| 236 | .prepare( |
| 237 | "UPDATE tasks SET status = 'working', updated_at = ? WHERE id = ? AND status = 'proposed'", |
| 238 | ) |
| 239 | .run(now, id); |
| 240 | if (info.changes === 0) return null; |
| 241 | return getTask(id); |
| 242 | } |
| 243 | |
| 244 | /** |
| 245 | * Flip a working task to `blocked` (waiting on an approval). Only transitions |
no test coverage detected