Skip to content

feat(seer): Add workflow run snapshots and lifecycle helpers - #128135

Draft
trevor-e wants to merge 9 commits into
masterfrom
telkins/codex/feat/seer-run-history
Draft

trevor-e wants to merge 9 commits into
masterfrom
telkins/codex/feat/seer-run-history

Conversation

@trevor-e

@trevor-e trevor-e commented Oct 19, 2026 •

Copy link
Copy Markdown
Member

Adds helpers that reuse a run for repeated requests, capture typed snapshots of its configuration and inputs, and record completion or failure. History queries are scoped to the organization, and deleting a config cascades to its runs and execution records.

Generalizes schedule_id to request_key, preserving its database column, unique index and scheduled task arguments. One migration adds four nullable columns, with no new indexes or backfill. Stacked on #127892; connecting the helpers to the manual execution coordinator stays in AIML-3682.

Refs AIML-3723.

…ness

Add the filters, output policy, and version columns, the SeerWorkflowConfigProject table, and the agentic_triage_v2 strategy, with project and environment selection stored as JSON in the shape of SeerWorkflowFilters. Uniqueness on (organization, strategy) now covers only legacy strategies so an organization can hold many agentic_triage_v2 configs, and the new partial index is created before the old constraint is dropped. get_or_create_for_strategy accepts only legacy strategies.

Refs AIML-3722
SeerAutomation wraps a SeerWorkflowConfig with the logic for interpreting it. ensure_defaults seeds a Sentry-managed agentic_triage_v2 automation for any organization that has no config with that strategy, never overwriting or re-seeding existing ones. get_project_ids returns the active projects a config covers.

Refs AIML-3722
@linear-code

linear-code Bot commented Oct 19, 2026

Copy link
Copy Markdown

AIML-3723

@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Oct 19, 2026
@github-actions

github-actions Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

This PR has a migration; here is the generated SQL for src/sentry/seer/migrations/0038_add_workflow_config_scope.py src/sentry/seer/migrations/0039_add_workflow_run_history.py

for 0038_add_workflow_config_scope in seer

--
-- Create model SeerWorkflowConfigProject
--
CREATE TABLE "seer_workflowconfigproject" ("id" bigint NOT NULL PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, "date_updated" timestamp with time zone NOT NULL, "date_added" timestamp with time zone NOT NULL, "config_id" bigint NOT NULL, "project_id" bigint NOT NULL);
--
-- Add field output_policy to seerworkflowconfig
--
ALTER TABLE "seer_workflowconfig" ADD COLUMN "output_policy" jsonb DEFAULT '{}'::jsonb NOT NULL;
--
-- Add field filters to seerworkflowconfig
--
ALTER TABLE "seer_workflowconfig" ADD COLUMN "filters" jsonb DEFAULT '{}'::jsonb NOT NULL;
--
-- Add field version to seerworkflowconfig
--
ALTER TABLE "seer_workflowconfig" ADD COLUMN "version" integer DEFAULT 1 NOT NULL CHECK ("version" >= 0);
--
-- Create constraint seer_workflowconfig_legacy_org_strategy_uniq on model seerworkflowconfig
--
CREATE UNIQUE INDEX CONCURRENTLY "seer_workflowconfig_legacy_org_strategy_uniq" ON "seer_workflowconfig" ("organization_id", "strategy") WHERE "strategy" IN ('agentic_triage', 'duplicate_monitors');
--
-- Remove constraint seer_workflowconfig_org_strategy_uniq from model seerworkflowconfig
--
ALTER TABLE "seer_workflowconfig" DROP CONSTRAINT "seer_workflowconfig_org_strategy_uniq";
--
-- Create constraint seer_workflowconfigproject_config_project_uniq on model seerworkflowconfigproject
--
CREATE UNIQUE INDEX CONCURRENTLY "seer_workflowconfigproject_config_project_uniq" ON "seer_workflowconfigproject" ("config_id", "project_id");
ALTER TABLE "seer_workflowconfigproject" ADD CONSTRAINT "seer_workflowconfigproject_config_project_uniq" UNIQUE USING INDEX "seer_workflowconfigproject_config_project_uniq";
ALTER TABLE "seer_workflowconfigproject" ADD CONSTRAINT "seer_workflowconfigp_config_id_70b352a2_fk_seer_work" FOREIGN KEY ("config_id") REFERENCES "seer_workflowconfig" ("id") DEFERRABLE INITIALLY DEFERRED NOT VALID;
ALTER TABLE "seer_workflowconfigproject" VALIDATE CONSTRAINT "seer_workflowconfigp_config_id_70b352a2_fk_seer_work";
ALTER TABLE "seer_workflowconfigproject" ADD CONSTRAINT "seer_workflowconfigp_project_id_1e68f8e6_fk_sentry_pr" FOREIGN KEY ("project_id") REFERENCES "sentry_project" ("id") DEFERRABLE INITIALLY DEFERRED NOT VALID;
ALTER TABLE "seer_workflowconfigproject" VALIDATE CONSTRAINT "seer_workflowconfigp_project_id_1e68f8e6_fk_sentry_pr";
CREATE INDEX CONCURRENTLY "seer_workflowconfigproject_config_id_70b352a2" ON "seer_workflowconfigproject" ("config_id");
CREATE INDEX CONCURRENTLY "seer_workflowconfigproject_project_id_1e68f8e6" ON "seer_workflowconfigproject" ("project_id");

for 0039_add_workflow_run_history in seer

--
-- Custom state/database change combination
--
-- (no-op)
--
-- Add field date_started to seerworkflowrun
--
ALTER TABLE "seer_nightshiftrun" ADD COLUMN "date_started" timestamp with time zone NULL;
--
-- Add field error to seerworkflowrun
--
ALTER TABLE "seer_nightshiftrun" ADD COLUMN "error" jsonb NULL;
--
-- Add field snapshot to seerworkflowrun
--
ALTER TABLE "seer_nightshiftrun" ADD COLUMN "snapshot" jsonb NULL;
--
-- Add field status to seerworkflowrun
--
ALTER TABLE "seer_nightshiftrun" ADD COLUMN "status" varchar(16) NULL;
--
-- Alter field workflow_config on seerworkflowrun
--
-- (no-op)

@cursor cursor 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.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit cc59de4. Configure here.

Comment thread src/sentry/seer/migrations/0039_add_workflow_run_history.py Outdated
Reuse the schedule column and unique index as request_key.
Cascade config deletion to runs and remove the extra history indexes.

Refs AIML-3723
@trevor-e trevor-e changed the title feat(seer): Add invocation identity and run history feat(seer): Add workflow run snapshots and lifecycle helpers Oct 20, 2026
@trevor-e
trevor-e force-pushed the telkins/feat/seer-config-service branch from dabc099 to 779db23 Compare October 20, 2026 17:37
Base automatically changed from telkins/feat/seer-config-service to master October 20, 2026 19:09

This branch has not been deployed

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

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant