Skip to content

Conversation

ericallam
Copy link
Member

No description provided.

Copy link

changeset-bot bot commented Sep 19, 2025

⚠️ No Changeset found

Latest commit: 1057cff

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

Copy link
Contributor

coderabbitai bot commented Sep 19, 2025

Walkthrough

This change removes foreign key constraints from public.TaskRunExecutionSnapshot via a migration and refactors the Prisma schema to decouple TaskRunExecutionSnapshot from several entities. In schema.prisma, executionSnapshots back-relations are removed from Organization, RuntimeEnvironment, Project, WorkerInstance, and BatchTaskRun. TaskRunExecutionSnapshot drops relations to those models, adds scalar projectId and organizationId, keeps environmentId as a scalar with environmentType, and introduces completedWaitpointOrder (String[]). The batchId remains as a scalar without a relation. In the run engine, the heartbeat update no longer writes to the database; it logs a heartbeat instead while retaining scheduling logic.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description Check ⚠️ Warning The pull request has no description and does not follow the repository's required template; the template expects a "Closes #" line, the ✅ checklist, a Testing section, a Changelog entry, and optional Screenshots, all of which are missing, leaving reviewers without guidance on testing, scope, or rollout. Please populate the PR description using the repository template: add "Closes #" if applicable, complete the checklist, describe the exact steps you used to test the migration and code changes, provide a short Changelog entry summarizing the impact and any backward-incompatible behavior, and attach screenshots or database migration/run instructions if relevant; also confirm whether the migration has been run locally or needs special deployment steps.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The title "chore(db): remove unnecessary FK constraints on TaskRunExecutionSnapshot" is concise and directly summarizes the primary change shown in the migration and schema diffs (removal of foreign key constraints and relation fields on TaskRunExecutionSnapshot); it uses a conventional prefix and is clear for reviewers scanning history.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch ea-branch-85

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 and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
internal-packages/database/prisma/schema.prisma (1)

912-912: completedWaitpointOrder lacks a default; create path can omit it → possible NOT NULL insert failure

createExecutionSnapshot only sets this when completedWaitpoints is provided. Make it default to [].

-  completedWaitpointOrder String[]
+  completedWaitpointOrder String[] @default([])

Also ensure the migration sets a DB default and backfills nulls to '{}' for existing rows.

🧹 Nitpick comments (3)
internal-packages/database/prisma/schema.prisma (2)

1532-1536: Optional: name back-relations for clarity/future-proofing

Explicit @relation names on runsBlocked and waitpoints help avoid ambiguity if another relation between the same models is added.

Example:

runsBlocked TaskRunWaitpoint[] @relation("BatchRunsBlocked")
waitpoints  Waitpoint[]        @relation("BatchCompletedWaitpoints")

You’d also need to mirror names on the other sides.


925-925: Deprecate lastHeartbeatAt (heartbeats no longer persisted)

This field is now stale. Either remove it in a follow-up migration or mark as deprecated to prevent accidental reads.

-  lastHeartbeatAt DateTime?
+  /// @deprecated Heartbeats are logged (not persisted) as of this change.
+  lastHeartbeatAt DateTime?
internal-packages/database/prisma/migrations/20250919123905_remove_unnecessary_foreign_key_constraints_task_run_execution_snapshot/migration.sql (1)

1-15: Idempotent FK drops LGTM; plan for brief AccessExclusive lock on table

  • IF EXISTS makes this safe across environments. Good.
  • Postgres will take an AccessExclusive lock on TaskRunExecutionSnapshot; run during low traffic to avoid blocking writers.
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8313800 and 1057cff.

📒 Files selected for processing (3)
  • internal-packages/database/prisma/migrations/20250919123905_remove_unnecessary_foreign_key_constraints_task_run_execution_snapshot/migration.sql (1 hunks)
  • internal-packages/database/prisma/schema.prisma (2 hunks)
  • internal-packages/run-engine/src/engine/systems/executionSnapshotSystem.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

**/*.{ts,tsx}: Always prefer using isomorphic code like fetch, ReadableStream, etc. instead of Node.js specific code
For TypeScript, we usually use types over interfaces
Avoid enums
No default exports, use function declarations

Files:

  • internal-packages/run-engine/src/engine/systems/executionSnapshotSystem.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (23)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (4, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (7, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (8, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (5, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (5, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (8, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (6, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (4, 8)
  • GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - npm)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (3, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (1, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (7, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (3, 8)
  • GitHub Check: e2e / 🧪 CLI v3 tests (ubuntu-latest - npm)
  • GitHub Check: typecheck / typecheck
  • GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - pnpm)
  • GitHub Check: e2e / 🧪 CLI v3 tests (ubuntu-latest - pnpm)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (2, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (6, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (2, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (1, 8)
  • GitHub Check: units / packages / 🧪 Unit Tests: Packages (1, 1)
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (2)
internal-packages/database/prisma/schema.prisma (1)

905-907: projectId/organizationId now scalars: consider adding indexes

Without FKs, add secondary indexes if queries filter by these fields to avoid regressions.

Suggested indexes:

 model TaskRunExecutionSnapshot {
   // ...
   projectId       String
   organizationId  String
   // ...
-  @@index([runId, isValid, createdAt(sort: Desc)])
+  @@index([runId, isValid, createdAt(sort: Desc)])
+  @@index([projectId, createdAt(sort: Desc)])
+  @@index([organizationId, createdAt(sort: Desc)])
 }

Verify need:

internal-packages/run-engine/src/engine/systems/executionSnapshotSystem.ts (1)

377-381: Lower heartbeat log level; confirm DB heartbeat consumers

  • Found lastHeartbeatAt in Prisma schema/migrations (TaskRunExecutionSnapshot & WorkerInstance), in API schema, and writes in:
    • internal-packages/run-engine/src/engine/systems/executionSnapshotSystem.ts
    • apps/webapp/app/v3/services/worker/workerGroupTokenService.server.ts
    • packages/core/src/v3/schemas/api.ts
  • Confirm no internal/external consumer reads TaskRunExecutionSnapshot.lastHeartbeatAt for liveness. If any do, either keep DB writes (or emit an explicit heartbeat event/metric) and/or deprecate/remove the column.
  • Tone down logging to debug and serialize the timestamp; suggested change:
-    this.$.logger.info("heartbeatRun snapshot heartbeat updated", {
-      id: latestSnapshot.id,
-      runId: latestSnapshot.runId,
-      lastHeartbeatAt: new Date(),
-    });
+    this.$.logger.debug("heartbeatRun snapshot heartbeat", {
+      id: latestSnapshot.id,
+      runId: latestSnapshot.runId,
+      lastHeartbeatAt: new Date().toISOString(),
+    });

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