diff options
| author | Ben Sima <ben@bensima.com> | 2025-11-27 09:55:55 -0500 |
|---|---|---|
| committer | Ben Sima <ben@bensima.com> | 2025-11-27 09:55:55 -0500 |
| commit | f151fbf764670369c54d2b9c03a5d1c8c1bb82fb (patch) | |
| tree | 25ee597904196cec3bc25ca54ca29c9bb82b7620 /Omni/Task/Core.hs | |
| parent | 27792ace8ae994c84ccbed9b80671fd0e133bb6f (diff) | |
Add logActivity helper and integrate into Worker.hs
Implementation complete. The task is done:
1. **Created `logActivity` helper** in `Omni/Task/Core.hs` that writes
t 2. **Integrated into Worker.hs** at all key points:
- `Claiming` - when claiming task - `Running` - when starting amp
- `Reviewing` - when amp completes successfully - `Retrying` -
on retry (includes attempt count in metadata) - `Completed` - on
success (includes result type in metadata) - `Failed` - on failure
(includes exit code or reason in metadata)
Task-Id: t-148.2
Diffstat (limited to 'Omni/Task/Core.hs')
| -rw-r--r-- | Omni/Task/Core.hs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Omni/Task/Core.hs b/Omni/Task/Core.hs index 3a5dd49..d9ea98c 100644 --- a/Omni/Task/Core.hs +++ b/Omni/Task/Core.hs @@ -1005,3 +1005,12 @@ incrementRetryAttempt tid = do let newAttempt = retryAttempt ctx + 1 setRetryContext ctx {retryAttempt = newAttempt} pure newAttempt + +-- | Log activity to the task_activity table +logActivity :: Text -> ActivityStage -> Maybe Text -> IO () +logActivity tid stage metadata = + withDb <| \conn -> + SQL.execute + conn + "INSERT INTO task_activity (task_id, stage, message, metadata) VALUES (?, ?, ?, ?)" + (tid, show stage, Nothing :: Maybe Text, metadata) |
