Skip to content

test: regression tests for _safe_score error boundary integrity#545

Merged
isaacschepp merged 1 commit intomainfrom
test/safe-score-misbehaving-scorer
Apr 4, 2026
Merged

test: regression tests for _safe_score error boundary integrity#545
isaacschepp merged 1 commit intomainfrom
test/safe-score-misbehaving-scorer

Conversation

@isaacschepp
Copy link
Copy Markdown
Owner

Summary

Add regression tests that catch the structural bug where replace() escapes _safe_score's error isolation boundary. A NoneReturningScorer simulates a scorer with a missing return statement.

How it prevents the bug

If someone moves replace(score, duration_seconds=...) outside the try/except in _safe_score, the NoneReturningScorer causes replace(None, ...) which raises TypeError. This escapes _safe_score and drops sibling scorer results. The test catches this because it asserts _safe_score returns a valid Score with passed=False and details['error'].

Tests Added

  • NoneReturningScorer — scorer that returns None (simulates missing return)
  • test_safe_score_handles_none_returning_scorer — verifies error Score produced
  • test_none_returning_scorer_does_not_kill_siblings — verifies sibling scorers complete

Test plan

  • 429/429 tests pass, 100% coverage, 0 lint errors

Add NoneReturningScorer that returns None (simulates missing return
statement) and two tests verifying _safe_score produces a valid
error Score and doesn't kill sibling scorers.

These tests would fail if replace() is moved outside the try/except
in _safe_score, since replace(None, ...) raises TypeError that
escapes the error isolation boundary.
Copilot AI review requested due to automatic review settings April 4, 2026 22:24
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 4, 2026

Coverage report

This PR does not seem to contain any modification to coverable code.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds regression coverage to ensure _safe_score’s error isolation boundary remains intact even when a scorer incorrectly returns None, preventing failures from escaping and canceling/losing sibling scorer results during parallel scoring.

Changes:

  • Introduces a NoneReturningScorer test helper that simulates a scorer missing a return statement.
  • Adds a regression test asserting _safe_score converts a None return into a synthetic error Score (including duration).
  • Adds a regression test asserting a None-returning scorer does not prevent sibling scorers from completing in run_scan(..., parallel_scoring=True).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@isaacschepp isaacschepp merged commit df9f6b6 into main Apr 4, 2026
22 checks passed
@isaacschepp isaacschepp deleted the test/safe-score-misbehaving-scorer branch April 4, 2026 23:15
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.

2 participants