Skip to content

feat: log a typed kind on every operational alert [RAI-3103] - #1695

Open
JuaniRios wants to merge 1 commit into
rai-2998-console-jsonfrom
rai-2998-alert-kind
Open

JuaniRios wants to merge 1 commit into
rai-2998-console-jsonfrom
rai-2998-alert-kind

Conversation

@JuaniRios

@JuaniRios JuaniRios commented Oct 9, 2026 •

Copy link
Copy Markdown
Collaborator

Part of RAI-3103.

Every operational alert now logs a typed kind field. Item 5 of the RAI-2998 stack, part 3 of 3.

Live effect: each operational_alert line gets kind="...". The message text is unchanged · Risk: medium (the alert pager reads these lines. A text-mode label changes only for an alert whose embedded error text named a different phrase, see below) · Ships: with the next bot release

Why

Today the kind label on operational_alerts comes from a regex over the message text in t0.devops. Every new or reworded alert needs a t0.devops PR, or it pages as unclassified. With JSON logs the bot can emit the kind itself (RAI-2998 comment, scope addition for item 5).

Decisions

  • AlertKind in src/alerts/mod.rs is a closed enum, declared by one macro in two groups:
    • extracted: 68 kinds. Their strings are exactly the extractor's phrases, in its order. Tests pin the list against the unclassified rule in observability/alerting/liquidity.rules.yml, and a proptest checks the bot classifier against the real regex.
    • not_extracted: 26 new kinds for alerts the regex cannot classify today (hedge stall, capital CCTP burns, recovery jobs, PnL ledger startup, and others). They still page as unclassified until the extractor and the rules learn them.
  • Notifier::notify(kind, message). All 31 direct error!(target: "operational_alert", ...) sites log kind = AlertKind::X.as_str(), and a test fails on a site without one.
  • CapturingNotifier checks every alert a test drives: the kind must be what the regex reads from that message.
  • Wrapper alerts that embed a rendered error (job dead letters, worker terminal failures, and the Alpaca to Base burn latch) take the most specific kind in their text, with the same rightmost-phrase rule as the regex. This stays until those errors carry a typed kind.
  • In text mode the line renders kind="..." after the message, and the regex takes the rightmost phrase. So a text line now classifies by the field. This only changes a label when an embedded runtime error named a different phrase.

Before the kind comparison on staging

Proof

  • Full cargo nextest run -p st0x-hedge -p st0x-config passes. Clippy, fmt, pre-commit, and gen-t0-liquidity.py --check are clean.
  • I scripted every direct site's message through the extractor rule. All agree with their kind.
  • Multi-model review (sol, Cursor Grok, composer, flash, opus): 3 passes, the last clean on every lane.
  • Not verified: a test alert on staging through the new metric. That is the rollout check.

Not in this PR

The liq_trade, liq_transfer, and liq_event structured event lines. A stable event_id needs the committed event sequence, and the event-sorcery Reactor drops it before the reactor sees it. That needs a sequence-aware hook in event-sorcery first, so it comes as a follow-up.

Merge conditions

Same as the stack below.

@linear-code

linear-code Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

RAI-2998

RAI-3063

RAI-3103

@JuaniRios JuaniRios self-assigned this Oct 9, 2026
@JuaniRios
JuaniRios requested a review from findolor October 9, 2026 00:31
@JuaniRios JuaniRios changed the title feat(alerts): log a typed kind on every operational alert [RAI-2998] Log a typed kind on every operational alert Oct 9, 2026

JuaniRios commented Oct 9, 2026 •

Copy link
Copy Markdown
Collaborator Author

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more


How to use the Graphite Merge Queue

Add the label add-to-gt-merge-queue to this PR to add it to the merge queue.

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@JuaniRios

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@JuaniRios
JuaniRios force-pushed the rai-2998-alert-kind branch 2 times, most recently from fbd6bef to 94cbce9 Compare October 10, 2026 01:15
@JuaniRios
JuaniRios force-pushed the rai-2998-console-json branch 2 times, most recently from fe16690 to c8c36c9 Compare October 10, 2026 01:58
@JuaniRios
JuaniRios force-pushed the rai-2998-alert-kind branch 2 times, most recently from 93e82b9 to 2d7244c Compare October 10, 2026 02:39
@JuaniRios
JuaniRios force-pushed the rai-2998-console-json branch from c8c36c9 to 04a3de7 Compare October 10, 2026 02:39
@JuaniRios
JuaniRios force-pushed the rai-2998-alert-kind branch from 2d7244c to 86403e8 Compare October 10, 2026 03:14
@JuaniRios
JuaniRios force-pushed the rai-2998-console-json branch from 04a3de7 to 5130604 Compare October 10, 2026 03:14
@JuaniRios
JuaniRios force-pushed the rai-2998-console-json branch from 5130604 to c752cfa Compare October 10, 2026 04:11
@JuaniRios
JuaniRios force-pushed the rai-2998-alert-kind branch from 86403e8 to 7320f93 Compare October 10, 2026 04:11
This was referenced Oct 10, 2026

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant