feat(observer): add extraction fidelity metric (message_quality_rate)#417
Merged
Conversation
Adds a second quality axis to the extraction-health system alongside the existing presence-only success_rate. message_quality_rate measures the fraction of assertion messages that are informative (non-empty, ≥10 chars, not a bare exception-type placeholder like "TimeoutError"). Changes: - query_flaky.py: ExtractionHealth gains message_quality_rate + low_quality_messages; get_extraction_health() classifies messages as empty/too_short/bare_exception_type - cli.py: table format surfaces message_quality_rate and low_quality_messages sections; fires MESSAGE_QUALITY_RATE_LOW alert when quality is low - extraction_health_history.py + extraction_history_collector.py: persist message_quality_rate in ExtractionHealthSnapshot JSONL (backwards-compatible) - flaky_test_alert_config.py + flaky_test_alerts.py: alert channel and threshold for MESSAGE_QUALITY_RATE_LOW (WARNING <80%, CRITICAL <50%, EMERGENCY <10%) - docs/reference/EXTRACTION_FIDELITY_METRIC.md: full reference doc covering quality gates, alert thresholds, CLI examples, and JSONL storage schema Tests: 239 fidelity-metric tests across 5 test files; 1667 observer unit tests pass. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Owner
Author
|
Needs human attention (reason= CI has not gone green after 20 checks (1 failing: audit: failure). Not merged (red CI) and not closed (work preserved) — needs a human to fix CI. |
Owner
Author
CI has not gone green after 21 checks (1 failing: audit: failure). Not merged (red CI) and not closed (work preserved) — needs a human to fix CI. |
…he new ref doc C29: fold the test_status `= None` init + `else` into a "missing" default (identical behavior, -2 lines → 500/500). DC7: link docs/reference/EXTRACTION_FIDELITY_METRIC.md from docs/README.md. Stands in for the reviewer's audit-autofix, which was blocked by the claude OAuth 401 outage during the run. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
… metric Adds 32 tests (271 total fidelity tests, up from 239) covering gaps in edge-case, formula-accuracy, and threshold-boundary coverage. New TestMessageQualityRateEdgeCases (12 tests): whitespace-only → too_short; each bare exception type individually; frozenset case-sensitivity; "ValueError" at 10-char boundary; OSError hits bare-exception gate before too-short; 0.0 vs None distinction; partial extraction contributing to quality denominator; all three reason values in one run; cap not affecting computed rate; denominator exclusion of None-message tests. New TestMessageQualityRateFormula (5 tests): exact fractional outputs 1/3, 2/3, 2/5; float type; single-test case. New TestMessageQualityRateThresholdBoundaries (8 tests): exact boundary values 80.0/79.9/50.0/49.9/10.0/9.9/0.0; alert details keys. New TestMessageQualityRateThresholdValues (7 tests): configured values 80/50/10; should_alert_on_message_quality_rate() boundary behaviour. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
Summary
message_quality_ratetoExtractionHealth— a second quality axis alongside the existing presence-onlysuccess_rate. A message is informative when it is non-empty, ≥ 10 characters, and not a bare exception-type placeholder (e.g.TimeoutError).ExtractionHealthSnapshotJSONL store (backwards-compatible: old rows load withNone).MESSAGE_QUALITY_RATE_LOWalerts via the existing alert channel stack (WARNING < 80 %, CRITICAL < 50 %, EMERGENCY < 10 %).message_quality_rateandlow_quality_messagesin both table and JSON output of theextraction-healthCLI command.docs/reference/EXTRACTION_FIDELITY_METRIC.md— full operator reference covering quality gates, alert thresholds, CLI examples, and JSONL schema.Changed files
src/operations_center/observer/query_flaky.pyExtractionHealthdataclass gains two new fields;get_extraction_health()classifies messagessrc/operations_center/observer/cli.pysrc/operations_center/observer/extraction_health_history.pyExtractionHealthSnapshot.message_quality_ratefieldsrc/operations_center/observer/collectors/extraction_history_collector.pymessage_quality_rateintocollect_snapshot()src/operations_center/observer/flaky_test_alert_config.pyMESSAGE_QUALITY_RATE_LOWchannel route +should_alert_on_message_quality_rate()src/operations_center/observer/flaky_test_alerts.pycheck_message_quality_rate()static methoddocs/reference/EXTRACTION_FIDELITY_METRIC.mdtests/unit/observer/test_extraction_health_queries.pytests/unit/observer/test_cli_extraction_health.pytests/unit/observer/test_extraction_history.pytests/unit/observer/test_flaky_test_alert_config.pytests/unit/observer/test_flaky_test_alerts.pyTest plan
mainruff check .→ 0 violations🤖 Generated with Claude Code