Skip to content

feat(alerts): let the cutover move real-time insight alerts - #127910

Merged
trunk-io[bot] merged 3 commits into
masterfrom
jimmy/insight-real-time-cutover
Nov 3, 2026
Merged

trunk-io[bot] merged 3 commits into
masterfrom
jimmy/insight-real-time-cutover

Conversation

@jzhu13

@jzhu13 jzhu13 commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Changes

  • The cutover command moves real-time alerts. A new real-time alert on a team already on the platform is handed over when it's created, and a moved alert can be edited to real-time.
  • An edit that resets the insight alert's due time now makes the copy due at the same time. A cadence change also writes the new cadence onto the copy right away. Other edits, such as a rename, leave the copy's due time alone.
  • The insight API and the Max tool already know when they reset the due time, so they pass that through update_owned_copy as rescheduled. The platform side follows the rule upsert_configuration already applies to copies the source owns.
  • A rescheduled copy is due no sooner than a minute from now, the same fence the handover uses. A due time in the minute of a check that just finished would reuse that check's evaluation key, so the recheck's history and notification would be dropped.
  • Turning a moved alert back on through the platform API now checks the plan's interval entitlement and then the active real-time limit, as the insight API and the Max tool do.
  • Alerts with the investigation agent on still stay with insight. That gate is lifted in a separate PR.

How did you test this code?

Test rationale:

  • test_an_alert_moves_with_its_state_and_schedule gains a real-time row, which fails while the gate is in place. The real-time row in the skip test is removed.
  • test_an_edit_reschedules_the_copy_when_it_reschedules_the_insight_alert replaces the test that expected the platform to refuse a real-time edit. It covers a real-time edit, a threshold edit and a rename. The first two failed before the reschedule change, and the rename guards against a carry-over that fires on every edit.

Ran the alerts, Max tool and alerts platform suites, plus repo-wide mypy, locally. Not checked: a deploy, or a real-time alert moved in production. The cutover waits for the customer email about check timing.

Release status

  • No feature flag controls this change

Docs update

None.

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

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

Skills: /writing-tests, /writing-code-comments, /code-review, /writing-pr-descriptions

  • CodeRabbit CLI: one finding, the copy keeping its old due time after a cadence edit. Fixed. A second pass hit the CLI's review limit, so the bot reviews the PR instead.
  • /code-review high --fix: two findings, quiet-hours edits and threshold edits not rescheduling the copy. Both fixed by the rescheduled flag.
  • PostHog Review, first round: two findings, slot reuse on a same-minute reschedule and the real-time limit on platform enables. Both fixed in d42da77.
  • PostHog Review, second round: one finding, the plan entitlement on platform enables. Fixed in 4b24353.
  • /simplify was not run. The diff is small and mostly removes a gate.
  • No duplicate: no open PR changes the real-time cutover gate.

🤖 Generated with Claude Code

The cutover no longer skips real-time alerts. An edit to a moved alert
that resets its due time on the insight stack, such as a new cadence,
threshold or quiet hours, now resets the platform copy's due time too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@trunk-io

trunk-io Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

😎 Merged successfully - details.

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

⚠️ Comment density — 6% of added code lines are comments (7 of 122)

This section warns when comments are more than 3% of the code lines a PR adds, and alerts above 6%. Before agent-assisted PRs, the typical share was about 2%. Only full-line comments count. Docstrings, generated files, snapshots, migrations, and workflow files are left out.

Comments that restate the code, record how the change came about, or narrate the next line add noise for the next reader. Keep the comments that explain a reason the code cannot show, and remove the rest. See .agents/skills/writing-code-comments/SKILL.md for the house rules.

Files with the most added comment lines:

File Comment lines Added lines
products/alerts/backend/platform_ownership.py 3 30
products/alerts_platform/backend/logic/platform_lifecycle.py 3 27
products/alerts/backend/platform_cutover.py 1 5

This check does not block merging. It updates on every push and clears when the share drops.

⚠️ Backend coverage — 70.0% of changed backend lines covered — 14 uncovered

🧪 Backend test coverage

Patch coverage — changed backend lines (products + core): ██████████████░░░░░░ 70.0% (34 / 48)

File Patch Uncovered changed lines
products/alerts_platform/backend/logic/platform_writes.py 0.0% 307–308
products/alerts/backend/max_tools.py 0.0% 480
products/alerts_platform/backend/logic/platform_lifecycle.py 9.1% 973–975, 980–984, 988–989
products/alerts/backend/platform_ownership.py 90.0% 62

🤖 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 155059815298946 -n patch-coverage), or the coverage-data block at the end of this comment.

Per-product line coverage (touched products)
Product Coverage Lines
platform_features ██░░░░░░░░░░░░░░░░░░ 12.1% 7 / 58
data_tools ████████████░░░░░░░░ 60.9% 95 / 156
warehouse_sources_queue █████████████░░░░░░░ 65.3% 2,163 / 3,314
demo █████████████░░░░░░░ 65.7% 1,803 / 2,743
batch_exports ████████████████░░░░ 82.3% 23,568 / 28,654
engineering_analytics █████████████████░░░ 84.9% 11,699 / 13,779
commands █████████████████░░░ 85.4% 1,621 / 1,898
ml_inference █████████████████░░░ 86.3% 524 / 607
mcp_analytics █████████████████░░░ 86.3% 5,803 / 6,722
posthog_ai ██████████████████░░ 87.9% 4,303 / 4,895
apm ██████████████████░░ 88.2% 1,973 / 2,236
notebooks ██████████████████░░ 88.5% 15,356 / 17,347
mcp_registry ██████████████████░░ 89.0% 1,596 / 1,794
webmcp ██████████████████░░ 89.3% 292 / 327
dashboards ██████████████████░░ 89.4% 8,048 / 9,003
product_tours ██████████████████░░ 89.7% 1,355 / 1,510
warehouse_suggestions ██████████████████░░ 89.9% 3,707 / 4,124
cohorts ██████████████████░░ 90.1% 8,996 / 9,990
signals ██████████████████░░ 90.5% 99,647 / 110,116
today ██████████████████░░ 90.6% 3,494 / 3,858
visual_review ██████████████████░░ 90.7% 9,852 / 10,863
managed_warehouse ██████████████████░░ 91.2% 12,686 / 13,914
canvas ██████████████████░░ 91.2% 8,203 / 8,994
data_warehouse ██████████████████░░ 91.3% 15,661 / 17,162
tasks ██████████████████░░ 91.3% 82,102 / 89,969
autoresearch ██████████████████░░ 91.5% 11,717 / 12,805
cdp ██████████████████░░ 91.5% 10,432 / 11,396
data_modeling ██████████████████░░ 91.6% 11,193 / 12,216
metrics ██████████████████░░ 91.7% 11,234 / 12,253
slack_app ██████████████████░░ 91.8% 21,945 / 23,913
wizard ██████████████████░░ 91.8% 6,868 / 7,479
streamlit_apps ██████████████████░░ 91.9% 3,139 / 3,415
business_knowledge ██████████████████░░ 92.0% 10,505 / 11,423
review_hog ██████████████████░░ 92.3% 17,768 / 19,256
conversations ██████████████████░░ 92.3% 31,158 / 33,746
error_tracking ███████████████████░ 92.5% 20,487 / 22,146
authorization ███████████████████░ 92.5% 544 / 588
early_access_features ███████████████████░ 92.6% 1,339 / 1,446
stamphog ███████████████████░ 92.6% 8,875 / 9,584
alerts_platform ███████████████████░ 92.6% 8,448 / 9,122
notifications ███████████████████░ 92.8% 1,218 / 1,312
alerts ███████████████████░ 93.0% 10,878 / 11,701
aeo ███████████████████░ 93.0% 2,150 / 2,312
surveys ███████████████████░ 93.3% 7,248 / 7,772
ai_training ███████████████████░ 93.3% 598 / 641
web_analytics ███████████████████░ 93.4% 26,448 / 28,325
ai_gateway ███████████████████░ 93.6% 787 / 841
messaging ███████████████████░ 93.7% 6,756 / 7,214
approvals ███████████████████░ 93.7% 5,004 / 5,341
cross_project_dashboards ███████████████████░ 93.7% 862 / 920
marketing_analytics ███████████████████░ 93.7% 21,955 / 23,420
context_layer ███████████████████░ 93.8% 3,984 / 4,247
exports ███████████████████░ 93.8% 4,314 / 4,597
workflows ███████████████████░ 93.8% 27,397 / 29,194
mcp_store ███████████████████░ 93.9% 9,188 / 9,784
ai_observability ███████████████████░ 93.9% 32,676 / 34,793
billing_alerts ███████████████████░ 94.0% 2,322 / 2,470
customer_analytics ███████████████████░ 94.0% 29,901 / 31,794
managed_migrations ███████████████████░ 94.1% 1,877 / 1,994
replay_vision ███████████████████░ 94.4% 33,325 / 35,317
legal_documents ███████████████████░ 94.4% 2,313 / 2,451
logs ███████████████████░ 94.5% 19,432 / 20,567
experiments ███████████████████░ 94.7% 43,959 / 46,433
reminders ███████████████████░ 94.8% 782 / 825
actions ███████████████████░ 94.9% 997 / 1,051
endpoints ███████████████████░ 94.9% 9,566 / 10,077
growth ███████████████████░ 95.0% 11,563 / 12,176
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,358 / 8,753
subscriptions ███████████████████░ 95.6% 13,645 / 14,275
data_catalog ███████████████████░ 95.7% 4,714 / 4,928
product_analytics ███████████████████░ 95.8% 30,289 / 31,620
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,564 / 4,729
warehouse_sources ███████████████████░ 96.5% 492,991 / 510,624
account_audits ███████████████████░ 96.7% 770 / 796
security ███████████████████░ 96.8% 1,597 / 1,650
pulse ███████████████████░ 97.3% 2,036 / 2,093
analytics_platform ████████████████████ 97.9% 2,862 / 2,922
groups ████████████████████ 98.3% 1,864 / 1,897
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.

@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 5696a09: 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.

…nables

A rescheduled copy is now due a minute out at the earliest, so it never
reuses the evaluation key of a check that just finished. Turning a moved
real-time alert back on through the platform API now checks the active
real-time limit, as the insight API and the Max tool do.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jzhu13
jzhu13 marked this pull request as ready for review November 3, 2026 01:06
@jzhu13 jzhu13 added the stamphog Request AI approval (no full review) label Nov 3, 2026
@parameterai

parameterai Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Risk: No findings

This increment adds the plan-entitlement check (interval_entitlement_error) in front of the real-time limit check when a platform edit turns a moved alert back on, so an enable that evaluation would immediately revert is now refused at write time. The check is a pure strengthening that matches the insight API's admission rules, and it only fires for plan-restricted intervals (real_time, every_15_minutes). No new security risk was found.

Sentinel reviewed 4b24353 · Review settings

@pr-assigner-resolver-posthog
pr-assigner-resolver-posthog Bot requested a review from a team November 3, 2026 01:07

@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 d42da77: 1 Should fix.

@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 current-head entitlement concern remains unfixed. Address that comment and request another review from @PostHog/team-apm or Matt Pua before re-requesting.

  • Author wrote 98% of the modified lines and has 38 merged PRs in these paths (familiarity STRONG).
  • PostHog Review (Standard) reviewed the current head: 1 finding, posted on the PR.
  • posthog[bot] reviewed the current head.
  • @PostHog on products/alerts/backend/platform_ownership.py: the entitlement concern remains unresolved. _write_insight_row calls real_time_alert_validation_error without interval_entitlement_error; products/alerts/backend/models/alert.py confirms that the former only checks active-count limits and permits organizations without the feature. The evaluation path in products/alerts/backend/platform_source_cycle.py subsequently rejects the missing entitlement. Add the entitlement check before enabling and cover a downgraded organization in a regression test before re-requesting review.
Gate mechanics and policy version
Gate Result
prerequisites ✓ all clear
deny-list ✓ no deny categories matched
size ✓ 108L, 7F substantive, 163L/9F incl. docs/generated/snapshots — within ceiling
tier ✓ T1-agent / T1c-medium (163L, 9F, single-area, feat)
stamphog 2.7.0 .stamphog/policy.yml @ d42da77 · reviewed head d42da77

@stamphog stamphog Bot removed the stamphog Request AI approval (no full review) label Nov 3, 2026
…t on

Turning a moved alert back on through the platform API now checks the
interval entitlement before the active real-time limit, as the insight
API does. An organization that lost real-time can no longer enable an
alert that the next evaluation would switch off again.

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.

Approved.

The risky write-path and plan-admission changes have current-head review assurance, owning-team authorship, and strong author familiarity. The current code addresses the earlier scheduling and admission findings; no unresolved substantive concerns or other refusal grounds were found.

  • Author wrote 98% of the modified lines and has 38 merged PRs in these paths (familiarity STRONG).
  • PostHog Review (Standard) reviewed the current head: no findings.
Gate mechanics and policy version
Gate Result
prerequisites ✓ all clear
deny-list ✓ no deny categories matched
size ✓ 112L, 7F substantive, 172L/9F incl. docs/generated/snapshots — within ceiling
tier ✓ T1-agent / T1c-medium (172L, 9F, single-area, feat)
stamphog 2.7.0 .stamphog/policy.yml @ 4b24353 · reviewed head 4b24353

@jzhu13

jzhu13 commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

/trunk merge

@trunk-io
trunk-io Bot merged commit c0ca174 into master Nov 3, 2026
302 checks passed
@trunk-io
trunk-io Bot deleted the jimmy/insight-real-time-cutover branch November 3, 2026 02:34
@deployment-status-posthog

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

Copy link
Copy Markdown

Deploy status

Environment Status Deployed At Workflow
dev ✅ Deployed 2026-11-03 03:00 UTC Run
prod-us ✅ Deployed 2026-11-03 03:19 UTC Run
prod-eu ✅ Deployed 2026-11-03 03:12 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