feat(database,web): planless-ready agents and Inbox items (expand migration 2)
Merged
DA
6d ago+18206+18206+01234567890123456789012345678901234567890123456789-20-20-01234567890123456789
PR 2 of the approved automations plan (docs/proposals/automations-scope.md §4, D4 and D9). Stacked on #2634. This is the expand step only, additive, so a coding agent and an Inbox item can later exist with no plan.
Schema:
coding_agent:organization_id: the workspace;automation_id: the automation whose run started it, set null when that automation is deleted;repositories: an ordered jsonb list, withrepositoryits first entry until full multi-repo;plan_idbecomes nullable;- index
(organization_id, created_at).
inbox_itemandinbox_attachment:organization_id, withplan_idnullable. Index oninbox_item (organization_id, updated_at).
Migrations:
ā¦_planless_agents: generated, then hardened to be idempotent (IF NOT EXISTS, guarded constraints), so a preview database that ran an earlier draft runs it as a no-op.ā¦_planless_agents_backfill: custom and idempotent. Agents, items and attachments take their plan's workspace, and agents take[repository].
Writers:
- A started agent records its plan's workspace and
[repository]. - A posted item and its attachments record their agent's workspace. While the backfill hasn't reached an agent, that falls back to the agent's plan's workspace.
- Readers are unchanged: agents and items are still reached through their plan until the next PR moves their access to the workspace.
Test (inbox-store.test.ts): an agent started on a plan records the plan's workspace and ["acme/relay"], and the item it posts records the same workspace. The migrations test and drizzle-kit check pass.
No Mac UI. pnpm check:affected exits 0.
š¤ Generated with Claude Code
Summary by cubic
Adds workspace scoping to coding agents, inbox items, and inbox attachments so they can later exist without a plan, and records the automation that started an agent and the repositories it works in.
- Writers now record the workspace, falling back to the plan's workspace while the backfill hasn't reached the agent; agents also record the automation that started them and their repositories list.
- Moving a plan to another workspace takes its agents and inbox items along, so deleting the workspace it left keeps them.
- Readers are unchanged.
Migration
- Agents, items, and attachments take their plan's workspace, and agents take
[repository]; rows already filled are left alone. - Both migrations are idempotent, so a preview database that ran an earlier draft runs them as no-ops.