ubiquitous-invention/plans/Plan-agent-coordination/Epic-task-as-runnable-unit/Task-add-workflow-prompt-to-backlog-items.md

98 lines
3.5 KiB
Markdown
Raw Normal View History

plans: scaffold daily-driver-finish, saas-hardening, agent-coordination Three new plan trees that fill in the gaps surfaced during repo review. Together they map out what remains between the current scaffold-with-stubs state and a daily-usable, multitenant, agent-coordinated app. * Plan-daily-driver-finish (P0): turn stubs into real data. Five tasks covering the lint/shared-types breakage, hardcoded dashboard mocks, AI-page setTimeout placeholder, post-signin landing decision, and a cross-browser collab smoke test against the deployed Hocuspocus instance. * Plan-multitenant-saas-hardening (P1): everything multitenant needs beyond what Plan-multitenant-cursor-sync already covers. Invites and role management, soft-delete + append-only audit log, rate limits on the auth + mutation hot paths, and a Vitest + GitHub Actions test foundation so PRs can't ship red. * Plan-agent-coordination (P2): the layer that makes a Task-*.md runnable, not just readable. Adds workflow_prompt with task -> epic -> plan inheritance, an agent_runs table for auditable sessions, and two new MCP tools (claim_task / complete_task) that replace the freeform update_object composition agents do today. Includes an intentionally-deferred Epic-optional-orchestrator that captures the Symphony-shaped runner as a decision point rather than an immediate build. Each task is bead-scale (one focused Cursor session) with explicit in-scope, out-of-scope, and anti-goal sections so a future agent can pick up a single Task-*.md and start without scrollback context. Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-02 00:52:22 -04:00
---
kind: task
slug: add-workflow-prompt-to-backlog-items
title: Add workflow_prompt column to markdown_backlog_items, with inheritance
plan_slug: agent-coordination
epic_slug: task-as-runnable-unit
status: ready
priority: P2
tenant_id: global
owner: unassigned
cursor_todo_id: null
updated_at: "2026-06-01"
---
# Task summary
Backlog items need a place to store a per-item agent prompt. Add a `workflow_prompt` text column to `markdown_backlog_items`, parse it from frontmatter, and define an inheritance chain (task → epic → plan → workspace default).
## Description
### Frontmatter contract
Add an optional `agent_prompt:` field to the YAML frontmatter of Plan/Epic/Task templates. It's a multiline string (use `|` block scalar in YAML). Example:
```yaml
agent_prompt: |
You are working on a focused implementation task in a multitenant TypeScript monorepo.
Read the task body in full before writing any code.
Validate every external input with zod.
Run pnpm lint && pnpm type-check before declaring done.
```
Update `docs/templates/{plan,epic,task}-template.md` to include the field (commented-out for tasks, since most tasks will inherit).
### Schema
Add to `markdown_backlog_items`:
- `workflow_prompt` text null
No new index needed; this column is rarely filtered on.
### Parser
In `packages/database/src/markdown-backlog/parse.ts`, extract `agent_prompt` from the parsed frontmatter into `workflow_prompt` on the upserted row. Use the existing zod schema for backlog frontmatter — extend it; don't fork.
### Inheritance helper
A new function `resolveWorkflowPrompt(db, { workspaceId, backlogItemId })` that walks task → epic → plan and returns the first non-null `workflow_prompt`. If none exist, return a built-in default string (lives as a constant in `packages/database/src/markdown-backlog/`). Workspace-level overrides can come later.
Don't store the resolved prompt anywhere — always compute on read. Caching is premature; this is a small lookup.
### Minimal UI
Add a "Workflow prompt" section to the task detail panel (`apps/web/components/panels/object-detail.tsx` or wherever the backlog-item detail lives). Show:
- "Effective prompt" — the result of `resolveWorkflowPrompt` (read-only).
- "Override" — a textarea bound to the item's own `workflow_prompt`. Empty = inherit.
Use a tRPC procedure `backlog.updateWorkflowPrompt({ backlogItemId, workflowPrompt })` that re-renders the panel on success.
### Anti-goals
- Don't write a template engine for the prompt. Symphony uses Liquid; we don't need that yet. A plain string is fine.
- Don't store prompts in `objects`. The agent flow is anchored on the markdown backlog, not the generic objects table.
## Subtasks
- [ ] Extend backlog frontmatter zod schema with `agent_prompt`.
- [ ] Add `workflow_prompt` column + migration.
- [ ] Parse and persist in `parse.ts`.
- [ ] Implement `resolveWorkflowPrompt` with the inheritance walk.
- [ ] Update Plan/Epic/Task templates in `docs/templates/`.
- [ ] Add UI panel section.
## Owner or assignee
Unassigned
## Status
ready
## Estimation
M
## Acceptance criteria
- [ ] A task with no override falls back to its epic's prompt; an epic with no override falls back to its plan; a plan with no override falls back to the built-in default.
- [ ] Setting `agent_prompt:` in frontmatter and re-importing populates `workflow_prompt`.
- [ ] UI shows effective prompt and override box.
## Links to related Epic / Plan
- Epic: `./Epic-task-as-runnable-unit.md`
- Plan: `../Plan-agent-coordination.md`