Skip to content

feat(alerts): cut over insight alerts that use the investigation agent - #127926

Merged
trunk-io[bot] merged 17 commits into
claude/insight-investigation-ui-275c09from
jimmy/insight-investigation-cutover
Nov 4, 2026
Merged

trunk-io[bot] merged 17 commits into
claude/insight-investigation-ui-275c09from
jimmy/insight-investigation-cutover

Conversation

@jzhu13

@jzhu13 jzhu13 commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Problem

  • The per-team insight cutover skips every alert with the investigation agent on, so those alerts stay on the insight stack.
  • The layers below (#127922, #127923, #127925) run both investigations on the platform.

Changes

  • The cutover now moves an alert with the agent on.
  • An edit that turns the agent on for an owned alert stays on the platform. The remaining ownership error now names only an unsupported check frequency.

Note

This PR moves no alert by itself. The cutover command moves one team at a time.

  • Merged with #127910, which removed the real-time clause, so can_move keeps neither gate.
  • Before any team with agent-on alerts moves, #127913 must land so a moved alert's history shows its investigations.

How did you test this code?

Test rationale: the moved-alert case for an agent-on alert replaces the skip case, so a reintroduced gate fails it.

Ran the cutover and alert API suites locally.

Release status

  • No feature flag controls this change

Docs update

  • None.

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

Agent: Claude Code, Claude Opus 5.5 (claude-opus-5-5)

Skills: /writing-tests, /writing-code-comments, /writing-user-facing-copy, /stacking-prs, /reviewing-with-coderabbit, /simplify, /code-review, /writing-pr-descriptions

  • No duplicate: no open PR builds the agent's platform path.
  • Public artifact: nothing here comes from customer material.
  • CodeRabbit CLI: skipped. The CLI refused both runs (rate limit, then no assigned seat), so the bot's review on this PR is the CodeRabbit pass.

🤖 Generated with Claude Code

The platform now runs the investigation agent and the metrics investigation
for the insight alerts it owns, so the per-team cutover no longer skips an
alert with the agent on, and an edit that turns the agent on stays on the
platform. Real-time alerts still stay with the insight stack.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jzhu13 jzhu13 self-assigned this Nov 3, 2026
@jzhu13
jzhu13 added this pull request to stack #127927 November 3, 2026 01:33
@github-actions

github-actions Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

🤖 CI report

⚠️ Trunk lane — backend Python lane

This PR is assigned to the backend Python lane. It runs backend Python tests and may merge in parallel with PRs in other lanes.

✅ Duplication (Python) — clean

New Python code duplication introduced by this branch. Fails at 70+ tokens in app code, or 150+ tokens when both copies live in test files. Advisory while the gate proves itself: extract a shared helper instead of copying.

✅ Duplication (TypeScript) — clean

New TypeScript code duplication introduced by this branch. Fails at 70+ tokens in app code, or 150+ tokens when both copies live in test files. Advisory while the gate proves itself: extract a shared helper instead of copying.

⚠️ Backend coverage — 92.0% of changed backend lines covered — 7 uncovered

🧪 Backend test coverage

Patch coverage — changed backend lines (products + core): ██████████████████░░ 92.0% (84 / 91)

File Patch Uncovered changed lines
products/alerts/backend/platform_ownership.py 0.0% 62
products/alerts_platform/backend/facade/testing.py 50.0% 258
products/alerts_platform/backend/facade/api.py 50.0% 94
products/alerts_platform/backend/logic/delivery_holds.py 57.1% 196–198
products/alerts/backend/platform_cutover.py 91.7% 168

🤖 Agents: add a test only if an uncovered line exposes a realistic regression that existing tests miss. Otherwise explain why no new test is needed under "How did you test this code?". Gap list: the patch-coverage artifact on this run (gh run download 334446966888636 -n patch-coverage), or the coverage-data block at the end of this comment.

Per-product line coverage (touched products)
Product Coverage Lines
knowledge_writer █░░░░░░░░░░░░░░░░░░░ 4.8% 5 / 105
platform_features ██░░░░░░░░░░░░░░░░░░ 12.1% 7 / 58
data_tools ████████████░░░░░░░░ 60.9% 95 / 156
warehouse_sources_queue █████████████░░░░░░░ 65.2% 2,161 / 3,314
demo ██████████████░░░░░░ 71.2% 1,979 / 2,778
batch_exports ████████████████░░░░ 82.2% 23,536 / 28,622
engineering_analytics █████████████████░░░ 84.9% 11,753 / 13,841
commands █████████████████░░░ 85.4% 1,621 / 1,898
ml_inference █████████████████░░░ 86.3% 524 / 607
mcp_analytics █████████████████░░░ 86.3% 5,812 / 6,731
posthog_ai ██████████████████░░ 87.9% 4,303 / 4,895
apm ██████████████████░░ 88.2% 1,973 / 2,236
notebooks ██████████████████░░ 88.8% 15,454 / 17,407
mcp_registry ██████████████████░░ 89.0% 1,596 / 1,794
dashboards ██████████████████░░ 89.4% 8,048 / 9,003
product_tours ██████████████████░░ 89.7% 1,355 / 1,510
warehouse_suggestions ██████████████████░░ 90.1% 3,836 / 4,257
cohorts ██████████████████░░ 90.1% 9,032 / 10,021
signals ██████████████████░░ 90.7% 101,663 / 112,105
visual_review ██████████████████░░ 90.7% 9,849 / 10,860
today ██████████████████░░ 91.1% 3,907 / 4,291
canvas ██████████████████░░ 91.2% 8,199 / 8,988
tasks ██████████████████░░ 91.3% 82,241 / 90,102
managed_warehouse ██████████████████░░ 91.3% 12,839 / 14,066
data_warehouse ██████████████████░░ 91.3% 15,840 / 17,343
data_modeling ██████████████████░░ 91.4% 11,664 / 12,757
autoresearch ██████████████████░░ 91.5% 11,717 / 12,805
cdp ██████████████████░░ 91.5% 10,433 / 11,399
metrics ██████████████████░░ 91.7% 11,255 / 12,275
slack_app ██████████████████░░ 91.8% 22,406 / 24,401
wizard ██████████████████░░ 91.8% 6,908 / 7,521
streamlit_apps ██████████████████░░ 91.9% 3,139 / 3,415
business_knowledge ██████████████████░░ 92.0% 10,556 / 11,476
review_hog ██████████████████░░ 92.3% 17,768 / 19,256
conversations ██████████████████░░ 92.3% 31,161 / 33,749
stamphog ███████████████████░ 92.6% 9,009 / 9,733
early_access_features ███████████████████░ 92.6% 1,339 / 1,446
error_tracking ███████████████████░ 92.6% 20,656 / 22,305
alerts_platform ███████████████████░ 92.6% 8,632 / 9,317
notifications ███████████████████░ 92.8% 1,218 / 1,312
alerts ███████████████████░ 93.1% 11,701 / 12,574
surveys ███████████████████░ 93.3% 7,256 / 7,780
webmcp ███████████████████░ 93.3% 277 / 297
ai_training ███████████████████░ 93.3% 598 / 641
web_analytics ███████████████████░ 93.4% 26,472 / 28,347
aeo ███████████████████░ 93.4% 2,312 / 2,475
ai_gateway ███████████████████░ 93.6% 787 / 841
approvals ███████████████████░ 93.7% 5,004 / 5,341
marketing_analytics ███████████████████░ 93.8% 22,043 / 23,512
context_layer ███████████████████░ 93.8% 3,984 / 4,247
messaging ███████████████████░ 93.8% 7,016 / 7,478
exports ███████████████████░ 93.9% 4,320 / 4,603
cross_project_dashboards ███████████████████░ 93.9% 858 / 914
workflows ███████████████████░ 93.9% 27,562 / 29,360
mcp_store ███████████████████░ 93.9% 9,193 / 9,789
ai_observability ███████████████████░ 93.9% 32,846 / 34,965
authorization ███████████████████░ 94.0% 671 / 714
billing_alerts ███████████████████░ 94.0% 2,322 / 2,470
customer_analytics ███████████████████░ 94.1% 30,487 / 32,403
managed_migrations ███████████████████░ 94.1% 1,877 / 1,994
replay_vision ███████████████████░ 94.4% 33,354 / 35,345
legal_documents ███████████████████░ 94.4% 2,313 / 2,451
logs ███████████████████░ 94.5% 19,437 / 20,572
experiments ███████████████████░ 94.7% 44,228 / 46,715
reminders ███████████████████░ 94.8% 782 / 825
actions ███████████████████░ 94.9% 997 / 1,051
endpoints ███████████████████░ 94.9% 9,610 / 10,123
growth ███████████████████░ 95.0% 11,563 / 12,176
warehouse_sources ███████████████████░ 95.0% 156,303 / 164,494
annotations ███████████████████░ 95.1% 1,097 / 1,153
skills ███████████████████░ 95.2% 7,633 / 8,018
uptime_monitoring ███████████████████░ 95.3% 306 / 321
access_control ███████████████████░ 95.5% 8,395 / 8,794
data_catalog ███████████████████░ 95.7% 4,714 / 4,928
subscriptions ███████████████████░ 95.7% 14,017 / 14,651
product_analytics ███████████████████░ 95.8% 30,387 / 31,726
feature_flags ███████████████████░ 95.8% 29,654 / 30,953
revenue_analytics ███████████████████░ 95.9% 1,877 / 1,958
data_quality ███████████████████░ 96.0% 8,561 / 8,915
tracing ███████████████████░ 96.5% 4,572 / 4,737
account_audits ███████████████████░ 96.7% 770 / 796
security ███████████████████░ 96.8% 1,597 / 1,650
pulse ███████████████████░ 97.3% 2,036 / 2,093
analytics_platform ████████████████████ 98.0% 2,879 / 2,939
groups ████████████████████ 98.3% 1,862 / 1,895
field_notes ████████████████████ 99.4% 172 / 173

Report-only. Patch coverage = changed backend lines covered vs origin/master. Sorted lowest first.
Known gaps: lines covered only by Temporal tests show as uncovered; core line numbers may drift if master changed the same file.

✅ Django migration risk — migration analysis complete

We've analyzed your migrations for potential risks.

Summary: 1 Safe | 0 Needs Review | 0 Blocked

✅ Safe

Brief or no lock, backwards compatible

alerts.0016_insight_alert_investigation_age_index
  └─ #1 ✅ SafeAddIndexConcurrently
     PostHog concurrent-index helper: idempotent (timeout disabling + invalid-leftover recovery)
     model: insightalertinvestigation, index: insight_alert_inv_age_idx

Last updated: 2026-11-04 01:24 UTC (65de5a1)

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

PostHog Review · Standard · reviewed ad115f3: 2 Should fix.

This is the only automatic review while this pull request is a draft. Comment @posthog review to review new changes sooner. Otherwise, a review of the new changes runs when you mark it ready for review.

See this review and its findings in PostHog Review. Comment @posthog review --deep for a Deep review. A Deep review takes longer and looks deeper than a Standard review.

@jzhu13
jzhu13 marked this pull request as ready for review November 3, 2026 02:51
@parameterai

parameterai Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Risk: No findings

This increment adds an investigation_unsettled skip to the insight-to-platform cutover: an alert whose insight-stack investigation agent is still in flight, or whose agent-held notification has not gone out, stays with the insight stack until it settles, plus tests. It is a net hardening that closes the previously reported two-agent handover window, and introduces no new security surface.

Sentinel reviewed 673732a · Review settings

@pr-assigner-resolver-posthog
pr-assigner-resolver-posthog Bot requested a review from a team November 3, 2026 02:52
…-investigation-cutover

# Conflicts:
#	products/alerts/backend/platform_cutover.py
#	products/alerts/backend/platform_ownership.py
#	products/alerts/backend/test/test_platform_cutover.py

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

PostHog Review · Standard · reviewed 5a846d7: 1 Must fix, 1 Should fix.

jzhu13 and others added 3 commits November 2, 2026 19:52
An alert whose insight-stack agent still runs, or whose held notification is
neither sent nor suppressed, now stays with the insight stack. Moved earlier,
that notification could not go out, and the platform would start a second
agent for the next firing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jzhu13 jzhu13 added the stamphog Request AI approval (no full review) label Nov 3, 2026

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

Not approved — this change needs a human reviewer.

Re-add the stamphog label to request another review once you have addressed this.

The author has owning-team membership and strong familiarity, but the current-head review retains substantive concerns confirmed in the checkout. Address the notification-loss, overlapping-investigation, and missing-history threads with @PostHog/team-apm before re-requesting.

  • Author wrote 100% of the modified lines and has 25 merged PRs in these paths (familiarity STRONG).
  • PostHog Review (Standard) reviewed the current head: 2 findings, posted on the PR.
  • posthog[bot] reviewed the current head.
  • @PostHog, products/alerts/backend/platform_cutover.py: Pending legacy notifications can be lost during handover. The cutover checks current firing state and owed evaluations but not outstanding investigation deliveries; posthog/tasks/alerts/utils.py:656-663 rejects legacy notification dispatch after platform ownership changes. Defer handover until legacy deliveries settle and address this thread before re-requesting.
  • @PostHog and @parameterai, products/alerts/backend/platform_cutover.py: Handover still permits an unresolved legacy investigation to overlap a new platform investigation. products/alerts/backend/platform_investigation.py:131-137 checks only InsightAlertInvestigation, whereas posthog/temporal/alerts/investigation.py:119-122 checks only AlertCheck. Add an in-flight investigation handover guard or cross-stack coordination and address these threads before re-requesting.
  • @PostHog, outdated thread on products/alerts/backend/platform_cutover.py: Investigation results remain absent from moved-alert history. products/alerts/backend/platform_alert_reads.py builds history without joining investigation rows, and products/alerts/backend/presentation/views/alert.py:1500-1518 does not populate investigation fields. Land the history integration identified in the thread and verify it in the reviewed checkout before re-requesting; the author's promise to wait does not resolve the concern.
Gate mechanics and policy version
Gate Result
prerequisites ✓ all clear
deny-list ✓ no deny categories matched
size ✓ 14L, 2F substantive, 20L/3F incl. docs/generated/snapshots — within ceiling
tier ✓ T1-agent / T1a-trivial (20L, 3F, single-area, feat)
stamphog 2.7.0 .stamphog/policy.yml @ 5a846d7 · reviewed head 5a846d7

@stamphog stamphog Bot removed the stamphog Request AI approval (no full review) label Nov 3, 2026
@jzhu13 jzhu13 added the stamphog Request AI approval (no full review) label Nov 3, 2026

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

Not approved — this change needs a human reviewer.

Re-add the stamphog label to request another review once you have addressed this.

Owning-team authorship and strong familiarity provide assurance for the risky changes, but @PostHog's investigation-history concern remains present in the current checkout. Land the history fix and request verification from @PostHog/team-apm before re-requesting.

  • Author wrote 100% of the modified lines and has 25 merged PRs in these paths (familiarity STRONG).
  • @PostHog on products/alerts/backend/platform_cutover.py: the investigation-history concern remains unfixed. products/alerts/backend/platform_alert_reads.py builds moved history without reading InsightAlertInvestigation, and presentation/views/alert.py::_as_alert_check does not populate investigation results. Land the history hydration fix and have the reviewer verify it before re-requesting; the author's promise to defer team cutovers does not resolve the concern.
Gate mechanics and policy version
Gate Result
prerequisites ✓ all clear
deny-list ✓ no deny categories matched
size ✓ 41L, 2F substantive, 85L/3F incl. docs/generated/snapshots — within ceiling
tier ✓ T1-agent / T1b-small (85L, 3F, single-area, feat)
stamphog 2.7.0 .stamphog/policy.yml @ 673732a · reviewed head 673732a

@stamphog stamphog Bot removed the stamphog Request AI approval (no full review) label Nov 3, 2026
@jzhu13
jzhu13 removed this pull request from stack #127927 November 3, 2026 05:07
@jzhu13
jzhu13 changed the base branch from jimmy/insight-metrics-investigation to claude/insight-investigation-ui-275c09 November 3, 2026 05:08
@jzhu13
jzhu13 added this pull request to stack #127948 November 3, 2026 05:08
@jzhu13 jzhu13 added the stamphog Request AI approval (no full review) label Nov 3, 2026

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

Approved.

The change enters alert ownership write paths, with assurance supplied by owning-team authorship and STRONG familiarity plus focused tests. The older reviews provide no concrete concerns to verify, and no unresolved substantive concern is evidenced in the supplied context.

  • Author wrote 100% of the modified lines and has 24 merged PRs in these paths (familiarity STRONG).
Gate mechanics and policy version
Gate Result
prerequisites ✓ all clear
deny-list ✓ no deny categories matched
size ✓ 41L, 2F substantive, 85L/3F incl. docs/generated/snapshots — within ceiling
tier ✓ T1-agent / T1b-small (85L, 3F, single-area, feat)
stamphog 2.7.0 .stamphog/policy.yml @ a14ffc3 · reviewed head a14ffc3

@jzhu13

jzhu13 commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

/trunk merge

@trunk-io

trunk-io Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

😎 Stack merged successfully - details.

@jzhu13

jzhu13 commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

/trunk merge

@trunk-io
trunk-io Bot merged commit 02a98aa into master Nov 4, 2026
264 checks passed
@trunk-io
trunk-io Bot deleted the jimmy/insight-investigation-cutover branch November 4, 2026 02:11
@deployment-status-posthog

deployment-status-posthog Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Deploy status

Environment Status Deployed At Workflow
dev ✅ Deployed 2026-11-04 02:29 UTC Run
prod-us ✅ Deployed 2026-11-04 02:40 UTC Run
prod-eu ✅ Deployed 2026-11-04 02:42 UTC Run

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

Labels

stamphog Request AI approval (no full review)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant