Repository navigation
feat(automations): Keep both Automation kinds in one table - #2179
Merged
Merged
Conversation
Add junior_automations with a kind column and copy Scheduled and event automations into it. Versions now key on automation_id and version, with a foreign key to the new table. All readers and writers use the new table. The old tables stay for workers that run during the deploy. A later change drops them. Refs #2176 Co-Authored-By: David Cramer <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Inline the copied column values in each store and remove the shared helper. Drop the cross-kind save guard and the exported kind and status types. Remove backfill fallbacks that earlier migrations already applied. Shorten comments and name what PR 3 removes. Refs #2176 Co-Authored-By: David Cramer <[email protected]>
dcramer
marked this pull request as ready for review
October 17, 2026 01:19
dcramer
approved these changes
Oct 17, 2026
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 3922544. Configure here.
The old reader fell back to record.creatorIdentityId when the column was null. Keep that fallback in the copy so those Scheduled automations stay visible. Refs #2176
dcramer
approved these changes
Oct 17, 2026
This was referenced Oct 17, 2026
dcramer
added a commit
that referenced
this pull request
Oct 18, 2026
Follow-up cleanup after the Automation table migrations (#2179, #2183, #2184). ## Bug The heartbeat settled Scheduled automation runs only for automations that were not deleted. It did this through `listIncompleteScheduledRuns` → `listScheduledAutomations`, which filters `status <> 'deleted'`. Delete marks only *pending* runs as skipped. So when an automation was deleted while its run was dispatched, the run stayed `running` forever and never became an execution. Event runs already settle in this case. `listIncompleteScheduledRuns` now reads `junior_automation_runs` joined to `kind = 'scheduled'`, with no status filter. One function now covers both the heartbeat and the per-automation claim check. This also stops the heartbeat from loading and decoding every Scheduled automation on each tick. The new heartbeat integration case fails on `main` (the run stays `running`) and passes with this change. ## Dead code - `scheduled-automations/personal.ts`: removed `listViewerScheduledAutomations` and its cursor code. `collection.ts` replaced it, and it had no callers. - Removed `scheduledAutomationPrincipalLabel` and `ScheduledAutomationCredentialMode`, which had no callers. - Removed the `scheduled-automations/index.ts` and `tools.ts` barrels. Their two consumers now import the tool files directly, as AGENTS.md asks. - Removed the "adopts deployed Scheduler rows" component test. It builds the dropped legacy tables to test migration SQL, which the testing policy rules out. - Removed the `kind` tie-breaker from the Automation collection order. Ids are unique in one table, so it never decided anything. - Removed README notes about older workers during rolling deploys. ## Not in this PR These change behavior or contracts, so they need their own PRs: - `executionActor` is written and never read. The schema is `.strict()` and stored rows contain the field, so removing it needs a data migration first. - Ownership uses two rules: `creator_identity_id` for scheduled rows, `team_id + creator_slack_user_id` for event rows. - Remove `kind` from `/api/automations/:kind/:id` and the dashboard `/automations/:kind/:id/...` URLs. Both already have it today; ids are unique, so the routes can key on id alone. - Two locking schemes: an advisory lock for scheduled rows, `FOR UPDATE` for event rows. - Run writes are split across `execution-stats.ts` and the two `runs.ts` files. `recordAutomationExecution` also swallows write errors. - Migration 0058, which drops `junior_automation_versions.kind` and `junior_conversations.origin_*`. ## Checks - `pnpm typecheck` passed. - `pnpm lint` passed. It includes the file-length, migration-metadata and test-architecture checks. - `vitest`: `heartbeat`, `scheduled-automations-sql`, `api/automations` and `api/automation-edits` all pass. - `slack-schedule-tools` and `event-automations`: everything passes with `--testTimeout=30000`, except "delivers the current automation card and retains its reference in web history". That test fails the same way on `main` in my sandbox. At the default 5s timeout, unrelated tests in these files time out in my sandbox on `main` too. <!-- junior-request-attribution:start --> via **David Cramer**. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:slack%3AC0B595QDZLL%3A1792312176.174969 --> -- [View Junior Session](https://junior-prod.sentry.dev/conversations/slack%3AC0B595QDZLL%3A1792312176.174969) [[Sentry]](https://sentry.sentry.io/explore/conversations/slack%3AC0B595QDZLL%3A1792312176.174969/?project=4510944073809921) <!-- junior-session-footer:end --> Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: David Cramer <[email protected]>
6 tasks
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

This is PR 1 of 3 for #2176.
What changed
junior_automations, holds Scheduled automations and event automations. Akindcolumn tells them apart.recordJSON.junior_scheduler_tasksandjunior_event_tasksinto the new table. If one id is in both old tables, the migration stops.Why
With two tables, a lookup by Automation id must check both tables. One table lets later code use direct joins.
During the deploy
Old workers can run while the new code starts.
Known risk
The migration does not stop for a malformed old row. If a row has no channel or no instruction, the copy gets an empty value. The code skips or rejects these rows, as it did before.
Next PRs
junior_scheduler_tasks,junior_event_tasks, and thekindcolumn ofjunior_automation_versions.via David Cramer.
--
View Junior Session [Sentry]