Repository navigation
feat: add task queue management API - #395
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
✅ Binary Size: 47.32MB (45.8KB vs main 47.27MB) |
|
✅ Binary Size: 47.50MB (45.7KB vs main 47.46MB) |
Code Review: feat: add task queue management APIMerge ConflictsThis PR has merge conflicts with Code ReviewOverall: The core implementation is clean and follows existing project patterns well. The layer separation (routes -> kernel -> memory substrate) is correct. However, there are a few issues to address: 1. DELETE endpoint lacks authorization/safety guard (Medium)
2.
|
dbff7e3 to
919900c
Compare
houko
left a comment
There was a problem hiding this comment.
Review: feat: add task queue management API
Overall: Clean, well-structured PR that adds useful CRUD operations for the task queue. The layering (substrate → kernel → trait → routes → server) is consistent with the existing codebase patterns. CI is green.
Issues
-
queue_statusfetches all tasks just to count them —queue_statuscallstask_list(None)which deserializes every row intoserde_json::Value, then iterates to count by status. For a large queue this is wasteful. Consider adding a dedicatedSELECT status, COUNT(*) FROM task_queue GROUP BY statusquery in the substrate layer. Not a blocker for merge, but worth a follow-up. -
No pagination on
queue_list— The list endpoint returns all matching tasks with no limit/offset. If the queue grows large this could be a problem. Consider adding?limit=and?offset=query params (can be a follow-up). -
queue_statussilently ignores unknown statuses — The match arm_ => {}means any task with an unexpected status string won't be counted, but will appear intotal. The total will be > sum of the four counters. Consider adding an"other"counter or documenting this behavior. -
No tests for the new
task_delete/task_retrysubstrate methods — The existing test file hastest_task_post_and_listandtest_task_claim_and_complete, but no tests for delete or retry. These are straightforward to add and would be valuable. -
task_retryallows retryingin_progresstasks — The SQLWHERE status IN ('completed', 'failed', 'in_progress')means a task currently being processed can be reset to pending. This could cause duplicate execution if a worker is still processing it. Consider excludingin_progressor documenting this as intentional. -
DELETE endpoint has no guard against deleting
in_progresstasks — Similarly, deleting a task while it's being processed could lead to issues if the worker tries to update it upon completion.
Nits
- The
queue_listhandler takesQuery(params): Query<HashMap<String, String>>— consider using a typed struct (e.g.,QueueListParams { status: Option<String> }) for better documentation and validation. - The retry SQL string is quite long on one line — could use a
constor multi-line string for readability.
Verdict
The code is correct and follows established patterns well. The main concerns (no pagination, status counting efficiency, in-progress guards) are non-blocking and can be addressed in follow-ups. LGTM for merge with the suggestion to file follow-up issues for items 1, 2, and 5.
|
✅ Binary Size: 58.05MB (41.7KB vs main 58.01MB) |
919900c to
9ec5067
Compare
|
✅ Binary Size: 58.37MB (41.8KB vs main 58.33MB) |
SenZhangAI
left a comment
There was a problem hiding this comment.
Review: Task queue management API
Useful observability endpoints. SQLite persistence is properly async with spawn_blocking. Route registration is correct.
Must fix
- Race condition in task_retry — Allows retrying tasks that are `in_progress`. If an agent is still processing the task, retry resets it to `pending`, and the agent's eventual completion overwrites the result. Fix: only allow retry for `failed` status, or add a generation counter.
-- Current (unsafe): WHERE status IN ('completed', 'failed', 'in_progress') -- Fix: WHERE status IN ('completed', 'failed')
Should fix
- Endpoint naming conflict — `/api/queue/status` redefines the existing queue status endpoint that reports command lane occupancy. Use `/api/tasks/status` instead to avoid confusion.
- No task creation endpoint — Only agents can create tasks via `kernel.task_post()`. Consider adding a POST endpoint for admin use.
Context
The task queue is currently observe-only (list, delete, retry) with no automatic executor. This is acceptable as an MVP but should be documented as a known limitation.
9ec5067 to
80c3bd8
Compare
All requested changes addressed: task_retry excludes in_progress, endpoints renamed to /api/tasks/*, rebased onto main.
houko
left a comment
There was a problem hiding this comment.
Review & Fixes Applied
Rebased onto main and addressed all review feedback. Code placed in the new module structure (routes/system.rs).
Fixed issues:
-
Race condition in task_retry (SenZhangAI #1) — Removed
in_progressfrom the SQL WHERE clause. Onlycompletedandfailedtasks can be retried. Error message explicitly states this constraint. -
Endpoint naming conflict (SenZhangAI #2) — Renamed all endpoints from
/api/queue/*to/api/tasks/*to avoid conflict with existing/api/queue/status(command lane occupancy). -
Rebased onto main —
routes.rswas split into modules in #452. Task queue handlers now live inroutes/system.rs.
Endpoints:
| Endpoint | Method | Purpose |
|---|---|---|
/api/tasks/status |
GET | Summary counts by status |
/api/tasks/list |
GET | List tasks (?status= filter) |
/api/tasks/{id} |
DELETE | Remove a task |
/api/tasks/{id}/retry |
POST | Re-queue completed/failed task |
Acknowledged (non-blocking, follow-ups):
- No pagination on list endpoint
- queue_status fetches all rows to count (could use GROUP BY)
- No task creation endpoint (agents create via kernel.task_post())
Verification
cargo build --workspace --lib✅cargo test --workspace✅cargo clippy --workspace --all-targets -- -D warnings✅
9cb29f7 to
cc4a01f
Compare
Add CRUD endpoints for task queue management:
- GET /api/tasks/status — summary counts by status
- GET /api/tasks/list — list tasks with optional ?status= filter
- DELETE /api/tasks/{id} — remove a task
- POST /api/tasks/{id}/retry — re-queue a completed/failed task
Uses /api/tasks/* namespace to avoid conflict with existing
/api/queue/status (command lane occupancy) endpoint.
task_retry only allows resetting 'completed' or 'failed' tasks —
'in_progress' is excluded to prevent duplicate execution race
conditions.
Closes #184
cc4a01f to
7cd2e0c
Compare
|
Rebased on top of #394 (event webhooks) which just merged to main — conflict in Build ✅ / Tests ✅ / Clippy ✅ — ready to merge. |
Summary
/api/queue/status, GET/api/queue/list, DELETE/api/queue/{id}, POST/api/queue/{id}/retryCloses #184
🤖 Generated with Claude Code