Skip to content

feat(run-ops): activation — drop cross-DB FKs, provision run-ops DB, enable split#4124

Merged
d-cs merged 9 commits into
mainfrom
runops/pr10-activation
Jul 4, 2026
Merged

feat(run-ops): activation — drop cross-DB FKs, provision run-ops DB, enable split#4124
d-cs merged 9 commits into
mainfrom
runops/pr10-activation

Conversation

@d-cs

@d-cs d-cs commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

What

The activation PR for the run-ops database split. This is the behaviour-changing top of the stack: it drops the cross-database Prisma foreign keys, provisions the dedicated run-ops database, and enables the split.

  • Schema (schema.prisma): removes the Prisma relations that span what is now a database boundary — RuntimeEnvironment.batchTaskRuns, TaskRun.tags, TaskRun.alerts, TaskRunTag.runs, TaskRunAttempt.alerts, BatchTaskRun.runtimeEnvironment, BulkActionGroup.items, BulkActionItem.group, and the ProjectAlert.taskRun / taskRunAttempt relations. The underlying scalar id columns are kept; the relationships are resolved through the run store instead of a DB-level FK. ProjectAlert gets a comment explaining why those references are now scalar-only.

  • Migrations: five FK-drop migrations —

    • drop_task_run_to_task_run_tag_join
    • drop_bulk_action_item_group_fk
    • drop_batch_task_run_environment_fk
    • drop_run_ops_control_plane_foreign_keys
    • drop_project_alert_run_subgraph_foreign_keys

    These remove the cross-subgraph foreign key constraints so run-subgraph rows can live on the dedicated run-ops database.

  • Enables the split at runtime.

Tests cover the FK drops (batchTaskRunEnvironmentFkDrop, dropTaskRunToTaskRunTagJoin, PostgresRunStore.controlPlaneAlertFk) and the cascade-cleanup behaviour that the store now owns in place of the dropped DB cascades (runOpsCascadeCleanup).

Why

Part of the run-ops database split. This is PR10 of the series (PR8/9/10) and is the one that actually changes behaviour: it flips the split on. It depends on all prior PRs in the series being merged first — the read presenters (PR8) and the route wiring (PR9) must be in place before the split is enabled, or reads and token resolution across the boundary will break.

Note that the FK-drop migrations run regardless of the runtime split flag: dropping the constraints is a schema fact, and the migrations apply on deploy whether or not the split is switched on at runtime. This is intentional — the constraints cannot hold once run-subgraph rows may live on a separate database.

Tests

pnpm run test --filter @internal/database / --filter webapp for the FK-drop and cascade-cleanup suites. The cascade-cleanup suite verifies the store-side deletes that replace the dropped DB-level cascades.

Notes

Draft, stacked on #4123 (runops/pr09-routes). Review that first; this diff is against it.

Server-change / changeset note to be added at stack-assembly time.

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: aff12d85-bb0f-4444-8b6f-c4936b406a68

📥 Commits

Reviewing files that changed from the base of the PR and between 4c34881 and 21df941.

📒 Files selected for processing (1)
  • docker/Dockerfile
📜 Recent review details
⏰ Context from checks skipped due to timeout. (24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (8, 10)
  • GitHub Check: internal / 🧪 Unit Tests: Internal (4, 12)
  • GitHub Check: internal / 🧪 Unit Tests: Internal (6, 12)
  • GitHub Check: internal / 🧪 Unit Tests: Internal (10, 12)
  • GitHub Check: internal / 🧪 Unit Tests: Internal (9, 12)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (3, 10)
  • GitHub Check: internal / 🧪 Unit Tests: Internal (12, 12)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (4, 10)
  • GitHub Check: internal / 🧪 Unit Tests: Internal (3, 12)
  • GitHub Check: internal / 🧪 Unit Tests: Internal (1, 12)
  • GitHub Check: internal / 🧪 Unit Tests: Internal (5, 12)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (5, 10)
  • GitHub Check: internal / 🧪 Unit Tests: Internal (7, 12)
  • GitHub Check: internal / 🧪 Unit Tests: Internal (8, 12)
  • GitHub Check: internal / 🧪 Unit Tests: Internal (11, 12)
  • GitHub Check: internal / 🧪 Unit Tests: Internal (2, 12)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (6, 10)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (10, 10)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (9, 10)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (7, 10)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (1, 10)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (2, 10)
  • GitHub Check: typecheck / typecheck
  • GitHub Check: e2e-webapp / 🧪 E2E Tests: Webapp
🧰 Additional context used
📓 Path-based instructions (1)
**/Dockerfile*

📄 CodeRabbit inference engine (CLAUDE.md)

When updating Docker image references, always use multiplatform/index digests, not architecture-specific digests.

Files:

  • docker/Dockerfile
🔇 Additional comments (1)
docker/Dockerfile (1)

34-35: LGTM!

Also applies to: 90-92


Walkthrough

This PR removes Prisma relation fields and matching foreign keys for run-ops and control-plane entities, drops the _TaskRunToTaskRunTag join table, adds migration lock timeouts and idempotent constraint drops, expands integration tests for BatchTaskRun, TaskRun tags, RunOpsCascadeCleanupService, and ProjectAlert cross-database behavior, adds a run-ops split note, and updates the Docker image to ship run-ops Prisma client artifacts.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description uses a custom What/Why/Tests format but omits required template sections like Closes #, checklist, changelog, and screenshots. Rewrite it to match the repository template, including Closes #, the checklist, testing steps, changelog, and screenshots sections.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the split activation, cross-DB FK drops, and run-ops DB provisioning.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch runops/pr10-activation

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@d-cs d-cs self-assigned this Jul 2, 2026
devin-ai-integration[bot]

This comment was marked as resolved.

@d-cs d-cs force-pushed the runops/pr09-routes branch from 4ba9267 to ec1aa6e Compare July 2, 2026 18:03
@d-cs d-cs force-pushed the runops/pr10-activation branch from 76dabfd to dffb0d2 Compare July 2, 2026 18:03
@changeset-bot

changeset-bot Bot commented Jul 2, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 8879201

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

coderabbitai[bot]

This comment was marked as resolved.

@pkg-pr-new

pkg-pr-new Bot commented Jul 2, 2026

Copy link
Copy Markdown

Open in StackBlitz

@trigger.dev/build

npm i https://pkg.pr.new/@trigger.dev/build@a5b52e5

trigger.dev

npm i https://pkg.pr.new/trigger.dev@a5b52e5

@trigger.dev/core

npm i https://pkg.pr.new/@trigger.dev/core@a5b52e5

@trigger.dev/python

npm i https://pkg.pr.new/@trigger.dev/python@a5b52e5

@trigger.dev/react-hooks

npm i https://pkg.pr.new/@trigger.dev/react-hooks@a5b52e5

@trigger.dev/redis-worker

npm i https://pkg.pr.new/@trigger.dev/redis-worker@a5b52e5

@trigger.dev/rsc

npm i https://pkg.pr.new/@trigger.dev/rsc@a5b52e5

@trigger.dev/schema-to-json

npm i https://pkg.pr.new/@trigger.dev/schema-to-json@a5b52e5

@trigger.dev/sdk

npm i https://pkg.pr.new/@trigger.dev/sdk@a5b52e5

commit: a5b52e5

@d-cs

d-cs commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator Author

On the out-of-diff finding that TaskRunAttempt (backgroundWorker/backgroundWorkerTask/runtimeEnvironment) and TaskRunTag (project) still declare @relation for the FKs dropped in 20260629120000: this is intentional and mirrors TaskRun itself, which keeps its project/runtimeEnvironment relations after its cross-DB FKs were dropped earlier in the series. These relations are never JOINed on the dedicated run-ops DB — the run store strips them from Prisma selects and rehydrates from scalar columns. The BatchTaskRun scalarization was a special case (its relation had no consumers). Prisma-migrate won't re-add these in the managed flow: hand-dropped constraints are an accepted drift condition throughout this schema.

Also fixed the one genuine consumer regression flagged inline: PerformBulkActionService now uses scalar groupId queries and reads the action kind from BulkActionItem.type instead of the removed group/items relations. Verified with a green webapp typecheck against a freshly regenerated client.

@d-cs d-cs force-pushed the runops/pr09-routes branch from 30ccb91 to caebbbc Compare July 2, 2026 19:25
@d-cs d-cs force-pushed the runops/pr10-activation branch from 3aa59bd to 3276836 Compare July 2, 2026 19:25
@d-cs d-cs force-pushed the runops/pr09-routes branch from e2cdc6d to 00f588c Compare July 2, 2026 20:23
@d-cs d-cs force-pushed the runops/pr10-activation branch from 3276836 to 25312fc Compare July 2, 2026 20:23
@d-cs d-cs force-pushed the runops/pr09-routes branch from 00f588c to 077917b Compare July 2, 2026 20:38
@d-cs d-cs force-pushed the runops/pr10-activation branch from 25312fc to 8b6bb5a Compare July 2, 2026 20:38
@d-cs d-cs force-pushed the runops/pr09-routes branch from 077917b to b74993f Compare July 2, 2026 21:44
@d-cs d-cs force-pushed the runops/pr10-activation branch from 8b6bb5a to 806b7bb Compare July 2, 2026 21:45
@d-cs d-cs force-pushed the runops/pr09-routes branch from b74993f to e7056ff Compare July 3, 2026 00:17
@d-cs d-cs force-pushed the runops/pr10-activation branch from 806b7bb to 1a72386 Compare July 3, 2026 00:17
@d-cs d-cs force-pushed the runops/pr09-routes branch from e7056ff to fa76c1b Compare July 3, 2026 01:32
@d-cs d-cs force-pushed the runops/pr10-activation branch 2 times, most recently from d338e32 to af028f7 Compare July 3, 2026 02:24
@d-cs d-cs force-pushed the runops/pr09-routes branch from 3bee9ab to be4e08a Compare July 3, 2026 08:51
@d-cs d-cs force-pushed the runops/pr10-activation branch from af028f7 to fb0bb45 Compare July 3, 2026 08:51
@d-cs d-cs force-pushed the runops/pr09-routes branch from be4e08a to d9ee04f Compare July 3, 2026 10:02
@d-cs d-cs force-pushed the runops/pr10-activation branch from fb0bb45 to fbd7cb9 Compare July 3, 2026 10:02
@d-cs d-cs force-pushed the runops/pr09-routes branch from d9ee04f to 495be7c Compare July 3, 2026 10:37
@d-cs d-cs force-pushed the runops/pr10-activation branch from fbd7cb9 to af3338a Compare July 3, 2026 10:37
@d-cs d-cs force-pushed the runops/pr09-routes branch from 495be7c to 0c5b193 Compare July 3, 2026 10:44
@d-cs d-cs force-pushed the runops/pr10-activation branch from af3338a to f27fb06 Compare July 3, 2026 10:44
@d-cs d-cs force-pushed the runops/pr09-routes branch from dd883b6 to 56ec38c Compare July 3, 2026 17:08
@d-cs d-cs force-pushed the runops/pr10-activation branch from fc4be3c to a5b52e5 Compare July 3, 2026 17:08
@d-cs d-cs force-pushed the runops/pr09-routes branch from 56ec38c to dc8dd5a Compare July 3, 2026 17:53
@d-cs d-cs force-pushed the runops/pr10-activation branch from a5b52e5 to 4744063 Compare July 3, 2026 17:53
@d-cs d-cs force-pushed the runops/pr09-routes branch from dc8dd5a to 5888fdd Compare July 3, 2026 18:07
@d-cs d-cs force-pushed the runops/pr10-activation branch from 4744063 to 335e3d6 Compare July 3, 2026 18:07
@d-cs d-cs force-pushed the runops/pr09-routes branch from 5888fdd to d36e335 Compare July 3, 2026 19:03
@d-cs d-cs force-pushed the runops/pr10-activation branch from 335e3d6 to faa1854 Compare July 3, 2026 19:03
@d-cs d-cs force-pushed the runops/pr09-routes branch from d36e335 to 4713776 Compare July 3, 2026 19:12
@d-cs d-cs force-pushed the runops/pr10-activation branch from faa1854 to f51b285 Compare July 3, 2026 19:12
@d-cs d-cs force-pushed the runops/pr09-routes branch from 4713776 to daf148a Compare July 3, 2026 19:39
@d-cs d-cs force-pushed the runops/pr10-activation branch from f51b285 to 9806c65 Compare July 3, 2026 19:39
Base automatically changed from runops/pr09-routes to main July 3, 2026 20:10
d-cs and others added 6 commits July 3, 2026 21:12
…ps DB, enable split

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…11 activation tests

Remove Test A–F enumeration prefixes from the run-ops cascade-cleanup
comments and the RED/GREEN TDD framing from the ProjectAlert control-plane
FK reconciliation test header. Comment-only; no product logic, test
behavior, or migration SQL changed.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ion drop

The activation schema removed the BulkActionGroup.items and BulkActionItem.group
Prisma relations, but PerformBulkActionService still queried them via include,
which would fail once the client regenerates. Switch to scalar groupId lookups and
read the action kind from BulkActionItem.type. Also drop a stale test comment.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@d-cs d-cs force-pushed the runops/pr10-activation branch from 9806c65 to b3e0709 Compare July 3, 2026 20:14
d-cs and others added 3 commits July 3, 2026 21:36
…-locking drops last for safe prod deploy

These FK/table drops take ACCESS EXCLUSIVE on huge hot tables (TaskRun,
Waitpoint, TaskRunAttempt, RuntimeEnvironment, Project). Without a
lock_timeout a migration can queue behind a long VACUUM/transaction and
hang the whole platform, so set lock_timeout = '5s' at the top of each
migration to fail fast and roll back cleanly.

Also make the two remaining DROP CONSTRAINTs idempotent with IF EXISTS,
matching the others, and reorder so the two migrations that lock TaskRun
run last (rename the join-table drop to 20260630130000). That way a
lock_timeout fail-fast leaves the cheap FK drops already applied.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…he image

The runner image only copied @trigger.dev/database's generated client, so a split-ON
deployment would hit a missing query engine when constructing RunOpsPrismaClient. Generate
the run-ops-database client in dev-deps and copy internal-packages/run-ops-database/generated
into the runner. No-op for single-DB/no-flags deploys (client is never constructed).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@d-cs d-cs marked this pull request as ready for review July 3, 2026 21:49

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Devin Review found 2 new potential issues.

Open in Devin Review

Comment thread apps/webapp/app/v3/services/bulk/performBulkAction.server.ts
Comment thread apps/webapp/app/v3/services/bulk/performBulkAction.server.ts
@d-cs d-cs enabled auto-merge (squash) July 3, 2026 22:02
@d-cs d-cs merged commit 70bca82 into main Jul 4, 2026
50 checks passed
@d-cs d-cs deleted the runops/pr10-activation branch July 4, 2026 06:02
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.

2 participants