Skip to content

Commit 8a91465

Browse files
fix(harbor): reject invalid aggregate_attempts values at construction
Only the exact string 'mean' switches collation to mean-of-k; any other value silently fell through to best-of-k, so a config typo ('Mean', 'avg') would run an experiment with inflated pass@k scores while looking de-noised. HarborConfig now raises at construction, which surfaces the mistake at sidecar startup instead of after the trial's budget is spent. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 4698439 commit 8a91465

2 files changed

Lines changed: 30 additions & 0 deletions

File tree

vero/src/vero/harbor/config.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,15 @@ class HarborConfig:
3232
aggregate_attempts: str = "best"
3333
extra_args: list[str] = field(default_factory=list) # passthrough harbor run flags
3434

35+
def __post_init__(self) -> None:
36+
# Only the exact string "mean" activates de-noising; without this check a
37+
# typo ("Mean", "avg") would silently run best-of-k with inflated scores.
38+
if self.aggregate_attempts not in ("best", "mean"):
39+
raise ValueError(
40+
f"aggregate_attempts must be 'best' or 'mean', got "
41+
f"{self.aggregate_attempts!r}"
42+
)
43+
3544
@property
3645
def is_registry(self) -> bool:
3746
"""Local if the source resolves to an existing path; otherwise a registry ref."""

vero/tests/test_harbor_runner.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,3 +362,24 @@ def test_default_best_unchanged(self, tmp_path):
362362
0, "t0", _params(),
363363
)
364364
assert r.score == 1.0
365+
366+
367+
class TestAggregateAttemptsValidation:
368+
"""A mistyped aggregate_attempts value must fail loudly at construction:
369+
only the exact string 'mean' activates de-noising, so 'Mean'/'avg' would
370+
otherwise silently run inflated best-of-k."""
371+
372+
def test_invalid_value_raises(self):
373+
with pytest.raises(ValueError, match="aggregate_attempts"):
374+
HarborConfig(
375+
task_source="org/ds", agent_import_path="p:m",
376+
aggregate_attempts="Mean",
377+
)
378+
379+
def test_valid_values_accepted(self):
380+
for value in ("best", "mean"):
381+
cfg = HarborConfig(
382+
task_source="org/ds", agent_import_path="p:m",
383+
aggregate_attempts=value,
384+
)
385+
assert cfg.aggregate_attempts == value

0 commit comments

Comments
 (0)