Skip to content

feat(observer): add extraction fidelity metric (message_quality_rate)#417

Merged
ProtocolWarden merged 4 commits into
mainfrom
goal/89fdd864
Jun 26, 2026
Merged

feat(observer): add extraction fidelity metric (message_quality_rate)#417
ProtocolWarden merged 4 commits into
mainfrom
goal/89fdd864

Conversation

@ProtocolWarden

Copy link
Copy Markdown
Owner

Summary

  • Adds message_quality_rate to ExtractionHealth — a second quality axis alongside the existing presence-only success_rate. A message is informative when it is non-empty, ≥ 10 characters, and not a bare exception-type placeholder (e.g. TimeoutError).
  • Persists the new metric in the ExtractionHealthSnapshot JSONL store (backwards-compatible: old rows load with None).
  • Fires MESSAGE_QUALITY_RATE_LOW alerts via the existing alert channel stack (WARNING < 80 %, CRITICAL < 50 %, EMERGENCY < 10 %).
  • Surfaces message_quality_rate and low_quality_messages in both table and JSON output of the extraction-health CLI command.
  • Adds docs/reference/EXTRACTION_FIDELITY_METRIC.md — full operator reference covering quality gates, alert thresholds, CLI examples, and JSONL schema.

Changed files

File Change
src/operations_center/observer/query_flaky.py ExtractionHealth dataclass gains two new fields; get_extraction_health() classifies messages
src/operations_center/observer/cli.py Table format prints quality line + samples; fires quality alert
src/operations_center/observer/extraction_health_history.py ExtractionHealthSnapshot.message_quality_rate field
src/operations_center/observer/collectors/extraction_history_collector.py Passes message_quality_rate into collect_snapshot()
src/operations_center/observer/flaky_test_alert_config.py MESSAGE_QUALITY_RATE_LOW channel route + should_alert_on_message_quality_rate()
src/operations_center/observer/flaky_test_alerts.py check_message_quality_rate() static method
docs/reference/EXTRACTION_FIDELITY_METRIC.md New reference document
tests/unit/observer/test_extraction_health_queries.py 17 new tests for quality rate calculation
tests/unit/observer/test_cli_extraction_health.py 10 new tests for CLI rendering and storage wiring
tests/unit/observer/test_extraction_history.py 10 new tests for JSONL round-trips
tests/unit/observer/test_flaky_test_alert_config.py 6 new tests for alert config
tests/unit/observer/test_flaky_test_alerts.py 10 new tests for alert logic

Test plan

  • 239/239 extraction-health tests pass
  • 1667 observer unit tests pass (1 skipped + 2 xfailed, pre-existing)
  • Full suite: 10113 passed; 5 pre-existing sandbox/root failures confirmed unchanged vs. main
  • ruff check . → 0 violations
  • All 11 changed Python files properly formatted

🤖 Generated with Claude Code

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

Copy link
Copy Markdown
Owner Author

Needs human attention (reason=ci_misconfigured_check). Left open — not merged (unresolved) and not closed (work preserved).

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.

@ProtocolWarden

ProtocolWarden commented Jun 26, 2026

Copy link
Copy Markdown
Owner Author

Resolved: new push — automated review resumed

Needs human attention (reason=ci_misconfigured_check). Left open — not merged (unresolved) and not closed (work preserved).

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.

ProtocolWarden and others added 3 commits June 26, 2026 01:48
…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>
@ProtocolWarden ProtocolWarden merged commit 71c6184 into main Jun 26, 2026
25 checks passed
@ProtocolWarden ProtocolWarden deleted the goal/89fdd864 branch June 26, 2026 05:59
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