Skip to content

Triggers #1 — Unified triggers table + core model (ADR-0011)#937

Open
Griphu wants to merge 1 commit into
mainfrom
feat/issue-928-unified-triggers-table
Open

Triggers #1 — Unified triggers table + core model (ADR-0011)#937
Griphu wants to merge 1 commit into
mainfrom
feat/issue-928-unified-triggers-table

Conversation

@Griphu

@Griphu Griphu commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

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. No user-visible behaviour change.

Closes #928.

What's here

  • platform-coreTriggerResource schema (discriminated union manual | webhook | cron; event reserved, no runtime), TriggerRepository interface + InMemoryTriggerRepository double.
  • platform-infratriggers table (migration 0030, 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).
  • platform-apiAuthorizedTriggerRepository on scope.triggers (workspace-gated) + unwrapped scope.system.triggers for the heartbeat's cross-namespace listEnabledByType('cron'). Wired through caller scope, create-caller-scope, platform-services, test scope.
  • docs — ADR-0011, CHANGELOG, CONTEXT.md "Trigger" glossary entry.

Deviations from the issue text (issue was drafted against unmerged PR #870's branch)

  • Migration 0030, not 00290029 is taken by audit_actor_index on main.
  • ADR-0011 supersedes nothing — on 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.
  • Type named TriggerResource*, not Trigger*Trigger/TriggerSchema are still held by the embedded Definition trigger (hard compile collision); Issue 5 renames back. Documented in ADR-0011 + CONTEXT.md.
  • payloadSchema on webhook config dropped for now — returns with the WebhookRouter epic alongside its reader.

Verification

  • pnpm typecheck — clean
  • L2 parity suite (in-memory + Postgres) + affected scope/heartbeat tests — 42 passing
  • cron_trigger_state overlay left untouched (its fold-in is epic Issue 2)

🤖 Generated with Claude Code

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>
@vercel

vercel Bot commented Jul 17, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
mediforce Ignored Ignored Preview Jul 17, 2026 5:33pm

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Triggers #1 — Unified triggers table + core model (+ ADR-0011)

1 participant