Skip to content

feat(logs): start a team's first logs alert on the alerts platform - #127773

Merged
trunk-io[bot] merged 4 commits into
masterfrom
posthog/logs-new-alerts-on-platform
Nov 2, 2026
Merged

trunk-io[bot] merged 4 commits into
masterfrom
posthog/logs-new-alerts-on-platform

Conversation

@jzhu13

@jzhu13 jzhu13 commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Problem

  • A team with no logs alerts creates its first one on the legacy logs stack, and it gets no platform copy.
  • New logs alerts went to the alerts platform only once the platform owned another of the team's alerts.
  • Every existing logs alert now runs on the platform, so new customers and teams setting up their first alert are the only ones still landing on legacy. Legacy cannot be retired while that happens.

Changes

  • A team's first logs alert now starts on the platform, through the logs API, Terraform or MCP.
  • The rule in takes_new_alert: the platform owns a new logs alert unless the team has other logs alerts and none of them is on the platform.
  • A team rolled back with roll_back_logs_alerts_from_platform keeps its new alerts on logs, as before.
  • Alerts in a child environment still stay on logs.
  • Mechanical: 19 tests of the legacy path now set their team up as kept on logs first.

How did you test this code?

  • test_where_a_new_alert_starts covers four cases: a team's first alert, a team the platform owns alerts for, a team whose alerts are on logs, and a team rolled back with roll_back_team. Before this change, the first-alert case started on logs.
  • Ran locally: the logs backend tests and the platform's logs tests.
  • Not checked: creating a first alert in a running dev stack.

Test rationale: the regression is a new team's first alert landing on legacy again, or a rolled-back team's new alert landing on the platform. The nearest test was the single platform-owned case, now parameterized.

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

Skills: /simplify, /code-review, /writing-pr-descriptions, /reviewing-with-coderabbit

More context for AI agents
  • Decisions: A rollback is inferred from the team's other alerts rather than recorded, so this needs no model change.
  • Follow-ups: Record a rollback per team. Then a rolled-back team that deletes every alert, or one left partly rolled back, keeps new alerts on logs.
  • Follow-ups: Insight alerts need the same change once their cutover finishes. Their rule in products/alerts/backend/platform_ownership.py also checks that the platform can run the alert.
  • Reviews: CodeRabbit --deep found nothing. /simplify merged two owner queries into one; the rollback-flag suggestion went to follow-ups. /code-review added the rolled-back test case; three rollback edge cases were skipped as follow-ups or as predating this PR.
  • Duplicates: none found.

🤖 Generated with Claude Code

jzhu13 and others added 3 commits November 2, 2026 11:50
A new logs alert went to the platform only once the platform owned another
of the team's alerts, so a team creating its first alert stayed on logs.
The platform now owns a new alert unless the team has other logs alerts
and none of them is on the platform, which keeps a rolled-back team on logs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jzhu13 jzhu13 self-assigned this Nov 2, 2026
@trunk-io

trunk-io Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

😎 Merged successfully - details.

@jzhu13
jzhu13 marked this pull request as ready for review November 2, 2026 20:09
@jzhu13 jzhu13 added the stamphog Request AI approval (no full review) label Nov 2, 2026
@parameterai

parameterai Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Risk: No findings

This PR changes where a team's new logs alert starts: the alerts platform now owns it unless the team's other alerts all stay on logs (e.g. a rolled-back team), replacing the old rule that required the platform to already own one of the team's alerts. The change is a team-scoped routing decision with no new endpoints, inputs, or authorization surfaces, and I found no security impact.

Sentinel reviewed 6319b7c · Review settings

@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 6319b7c: 1 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.

@pr-assigner-resolver-posthog
pr-assigner-resolver-posthog Bot requested a review from a team November 2, 2026 20:10

@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's ownership and STRONG familiarity provide assurance, but @PostHog's substantive rollback concern remains unresolved. Preserve rollback state independently of remaining alerts and add deletion-and-recreation coverage, then request review from @PostHog/team-apm before re-requesting.

  • Author wrote 100% of the modified lines and has 24 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, products/logs/backend/platform_cutover.py: rollback persistence remains unfixed. roll_back_team only updates existing alert rows; delete_alert physically deletes those rows (products/logs/backend/alert_deletion.py:39). After the last rolled-back alert is deleted, takes_new_alert sees no other owners and assigns the replacement to the platform, reversing the team's rollback.
Gate mechanics and policy version
Gate Result
prerequisites ✓ all clear
deny-list ✓ no deny categories matched
size ✓ 31L, 3F substantive, 82L/4F incl. docs/generated/snapshots — within ceiling
tier ✓ T1-agent / T1b-small (82L, 4F, single-area, feat)
stamphog 2.7.0 .stamphog/policy.yml @ 6319b7c · reviewed head 6319b7c

@stamphog stamphog Bot removed the stamphog Request AI approval (no full review) label Nov 2, 2026
@github-actions

github-actions Bot commented Nov 2, 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.

@jzhu13 jzhu13 added the stamphog Request AI approval (no full review) label Nov 2, 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 change has owning-team and STRONG-familiarity assurance, with regression coverage. The current-head review reports an unspecified finding but supplies no substantive concern to verify; it is not counted as a concern-free review.

  • Author wrote 100% of the modified lines and has 24 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.
Gate mechanics and policy version
Gate Result
prerequisites ✓ all clear
deny-list ✓ no deny categories matched
size ✓ 31L, 3F substantive, 82L/4F incl. docs/generated/snapshots — within ceiling
tier ✓ T1-agent / T1b-small (82L, 4F, single-area, feat)
stamphog 2.7.0 .stamphog/policy.yml @ 6319b7c · reviewed head 6319b7c

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

jzhu13 commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

/trunk merge

@trunk-io
trunk-io Bot merged commit 0f11cf1 into master Nov 2, 2026
265 checks passed
@trunk-io
trunk-io Bot deleted the posthog/logs-new-alerts-on-platform branch November 2, 2026 21:41
@deployment-status-posthog

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

Copy link
Copy Markdown

Deploy status

Environment Status Deployed At Workflow
dev ✅ Deployed 2026-11-02 22:21 UTC Run
prod-us ✅ Deployed 2026-11-02 22:42 UTC Run
prod-eu ✅ Deployed 2026-11-02 22:43 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