feat(database,web): planless-ready agents and Inbox items (expand migration 2)

Merged
DA
6d ago
+18206-20

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, with repository its first entry until full multi-repo;
    • plan_id becomes nullable;
    • index (organization_id, created_at).
  • inbox_item and inbox_attachment: organization_id, with plan_id nullable. Index on inbox_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


Open workspace in Conductor


Devin Review


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.