Pairs with the parallel complete_task commit. claim_task opens an agent_runs row, flips status to in_progress only when it's safe (ready/draft → in_progress, never overwriting a deliberate blocked/done/in_progress), and returns the resolved workflow prompt + source level. Idempotent re-claim by the same actor returns the existing run with reused=true and refreshes notes only — started_at is sacred. Different-actor re-claim errors with ALREADY_CLAIMED naming the existing actor and run id. Tenancy fence: if the backlog item exists but in a different workspace than the resolved handle, we refuse with "doesn't belong to workspace" rather than 404. Prevents cross-tenant existence fishing. All three writes (run insert + status flip + audit insert) happen in one db.transaction() so a partial claim is unreachable. tools/index.ts now registers both claim_task and complete_task. Co-authored-by: Cursor <cursoragent@cursor.com>
53 lines
2 KiB
Markdown
53 lines
2 KiB
Markdown
---
|
|
kind: epic
|
|
slug: task-as-runnable-unit
|
|
title: Task as runnable unit — workflow prompts and a runs table
|
|
plan_slug: agent-coordination
|
|
status: ready
|
|
priority: P2
|
|
tenant_id: global
|
|
cursor_epic_id: null
|
|
updated_at: "2026-06-01"
|
|
---
|
|
|
|
# Epic objective
|
|
|
|
Every backlog item can carry a workflow prompt; every agent session against a task gets recorded in a `runs` table. These two changes are the foundation that `claim_task` / `complete_task` build on.
|
|
|
|
## In scope / out of scope
|
|
|
|
**In scope**
|
|
|
|
- Schema additions for workflow prompts.
|
|
- New `runs` table + tRPC router.
|
|
- Minimal UI for editing the prompt and viewing recent runs.
|
|
|
|
**Out of scope**
|
|
|
|
- The actual MCP tools (next epic).
|
|
- Orchestrator process (deferred epic).
|
|
|
|
## Related tasks
|
|
|
|
| Task | Link |
|
|
|------|------|
|
|
| Add workflow prompt to backlog items | `./Task-add-workflow-prompt-to-backlog-items.md` |
|
|
| Runs table and tRPC router | `./Task-runs-table-and-trpc-router.md` |
|
|
|
|
## Dependencies
|
|
|
|
- Depends on: `Plan-daily-driver-finish` (don't extend stubs).
|
|
- Blocks: `Epic-mcp-claim-complete`.
|
|
|
|
## Acceptance criteria
|
|
|
|
- [x] A task row can store an optional workflow prompt that overrides the epic/plan default. (Schema column `workflow_prompt`, parser plumbing, slug-based inheritance walk all shipped.)
|
|
- [x] An `agent_runs` row captures `started_at`, `finished_at`, `actor_user_id`, `outcome`, `tokens_input`, `tokens_output`, `tokens_total`, `notes`, `error`, and `metadata`. (One column more than the spec — added `tokens_total` because Symphony's "absolute totals win" rule needs explicit storage.)
|
|
- [x] Minimal UI lets an operator read recent runs at `/[workspaceSlug]/settings/runs`. Prompt-editing UI is deferred to `Task-workflow-prompt-task-detail-ui.md` because `apps/web` doesn't yet have a backlog-item detail panel.
|
|
|
|
## Proposed timeline
|
|
|
|
| Phase | Window | Notes |
|
|
|-------|--------|-------|
|
|
| Schema + procedures | Day 1 | Columns, table, tRPC router. |
|
|
| UI surfacing | Day 2 | Inline prompt editor, recent-runs panel. |
|