Repository navigation
ref(aci): BaseDetectorHandler owns the detector evaluation lifecycle - #127133
Draft
saponifi3d wants to merge 1 commit into
Draft
saponifi3d wants to merge 1 commit into
saponifi3d wants to merge 1 commit into
Conversation
saponifi3d
added this pull request to stack #127136
October 10, 2026 01:03
| Decides the outcome for each group's extracted value. Ungrouped detectors receive a single value keyed by `None`. | ||
|
|
||
| Return `DetectorGroupValues` to evaluate each group independently. | ||
| Return a triggered `DetectorEvaluation` with `result=None` for each group that should create an issue; |
Member
There was a problem hiding this comment.
I do not think from a type standpoint it is super clear that result=None means that this method will handle create_occurrence for you
I think it would be nice if we could have a more explicit typing to make it super clear from the perspective of building a detector "In THIS case I want to create issues, in THIS OTHER case I do not"
_evaluate now composes extract_value, evaluate, and create_occurrence for every handler: evaluate decides which groups trigger, and the platform builds the IssueOccurrence, evidence, fingerprint, and event data for each triggered evaluation without a result. A new detector built on DetectorHandler only implements extract_value and create_occurrence; detection logic lives in the detector's data conditions. StatefulDetectorHandler layers dedupe, thresholds, and state over super().evaluate() instead of copying the condition evaluation and occurrence decoration. Uptime overrides evaluate instead of _evaluate. Issue platform payloads are unchanged.
saponifi3d
force-pushed
the
jcallender/detector-handler-2-lifecycle
branch
from
October 21, 2026 23:50
c6a205d to
187388f
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
BaseDetectorHandler._evaluatenow runs every detector through one lifecycle.evaluatedecides which groups trigger. For each triggered evaluation that has no result yet, the platform callscreate_occurrenceand builds theIssueOccurrence, evidence, fingerprint, and event data. Before this, each handler did that work itself.flowchart LR P[DataPacket] --> X[extract_value] X -->|empty DetectorGroupValues| Skip[skip] X --> E["evaluate(data_packet, values)"] E -->|triggered, result=None| C[create_occurrence] C --> O[platform: IssueOccurrence + evidence + fingerprint + event data] E -->|already has a result, e.g. StatusChangeMessage| Out[results] O --> OutA new detector that decides with the detector's data conditions now needs just two methods:
Thresholds and priorities come from the
DataConditions on the detector's trigger group. To change ids or fingerprints, overrideget_event_id,get_occurrence_id, orget_issue_fingerprint. A handler that doesn't use a condition group subclassesBaseDetectorHandlerand implementsevaluate.create_occurrence(evaluation, data_packet): priority, group key, and trigger group evaluation now come from theDetectorEvaluation.StatefulDetectorHandler.evaluateadds dedupe, threshold counters, and state on top ofsuper().evaluate()(this resolves its TODO). Its event/occurrence id behavior is now expressed through theget_event_idandget_occurrence_idhooks.evaluateinstead of_evaluate, so no handler overrides_evaluateanymore.GroupedDetectorEvaluationResultis renamed toDetectorEvaluations.trigger_group_evaluationis optional for handlers that don't use a condition group.Issue platform payloads are unchanged. I recorded every
_evaluateresult (IssueOccurrence,StatusChangeMessage,event_data, and the evaluation artifact logged to EAP) from the product detector test suites onmasterand on this branch. After masking per-run values (DB ids, UUIDs, timestamps, random fixture names), both runs produced the same output:incidents/)uptime/)preprod/size_analysis/)processing_errors/)workflow_engine/processors/)Five
ProcessUpdateComparisonAlertTestcases were left out because they also give different results between runs onmaster. Product test files are untouched.The one contract change: a triggered evaluation returned without a result used to pass through with no result. Now the platform builds an occurrence for it. Only the mock handler in
processors/test_detector.pyreturned that shape, so the two tests that relied on it now assert the occurrence.