Triggers #1 — Unified triggers table + core model (ADR-0011)#937
Conversation
Issue 1 of the triggers-detachment epic (#927): the data-layer plumbing for a unified, detached `triggers` resource. Pure plumbing — nothing reads or writes the table yet. - platform-core: TriggerResource schema (discriminated union manual|webhook|cron, event reserved), TriggerRepository interface + in-memory double - platform-infra: triggers table (migration 0030), Drizzle schema, Postgres repo, L2 parity test (in-memory + Postgres, 26 cases) - platform-api: AuthorizedTriggerRepository on scope.trigger + system path scope.system.trigger for the heartbeat; wired through caller scope - docs: ADR-0011, CHANGELOG, CONTEXT.md "Trigger" glossary entry Named TriggerResource* transitionally — Trigger/TriggerSchema are still held by the embedded Definition trigger until Issue 5 removes it. Migration is 0030 (not the issue's 0029, taken by audit_actor_index) and ADR-0011 supersedes the unmerged PR #870 design, not a committed ADR (main's ADR-0010 is the timeout ADR). Closes #928 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a6a5423682
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| -- writes the table yet — later epic issues seed and cut over per type. The | ||
| -- cron-only `cron_trigger_state` overlay is left untouched here (see ADR-0011). | ||
| CREATE TABLE "triggers" ( | ||
| "namespace" text NOT NULL, |
There was a problem hiding this comment.
Add a workspace FK for trigger namespaces
Because this new workspace-scoped table stores namespace as plain text, deleting a namespace via PostgresNamespaceRepository.deleteNamespaceCascade() removes only the workspace row and relies on ON DELETE CASCADE FKs for dependent tables. Any trigger rows left behind will still be returned by the system cross-namespace listEnabledByType(...) sweep after the namespace is deleted, and if the handle is recreated those stale triggers become visible under the new namespace; add the same workspaces.handle cascade FK used by the other workspace-scoped tables.
Useful? React with 👍 / 👎.
Issue 1 of the triggers-detachment epic (#927): the data-layer plumbing for a unified, detached
triggersresource. Pure plumbing — nothing reads or writes the table yet. No user-visible behaviour change.Closes #928.
What's here
TriggerResourceschema (discriminated unionmanual|webhook|cron;eventreserved, no runtime),TriggerRepositoryinterface +InMemoryTriggerRepositorydouble.triggerstable (migration0030, keyed by(namespace, workflow_name, trigger_name), partial webhook-path uniqueness index + partial enabled-by-type index), Drizzle schema,PostgresTriggerRepository, L2 parity test (in-memory + Postgres, 13 cases each).AuthorizedTriggerRepositoryonscope.triggers(workspace-gated) + unwrappedscope.system.triggersfor the heartbeat's cross-namespacelistEnabledByType('cron'). Wired through caller scope, create-caller-scope, platform-services, test scope.Deviations from the issue text (issue was drafted against unmerged PR #870's branch)
0030, not0029—0029is taken byaudit_actor_indexonmain.main, ADR-0010 is the unrelated timeout ADR; the cron-overlay ADR (PR Manage cron triggers from CLI and UI (ADR-0010) #870) never merged. ADR-0011 records Manage cron triggers from CLI and UI (ADR-0010) #870 as a rejected alternative.TriggerResource*, notTrigger*—Trigger/TriggerSchemaare still held by the embedded Definition trigger (hard compile collision); Issue 5 renames back. Documented in ADR-0011 + CONTEXT.md.payloadSchemaon webhook config dropped for now — returns with the WebhookRouter epic alongside its reader.Verification
pnpm typecheck— cleancron_trigger_stateoverlay left untouched (its fold-in is epic Issue 2)🤖 Generated with Claude Code