Commit Graph
6 Commits
Author SHA1 Message Date
Joseph MaglyandClaude Opus 5.5 08a04e3bd4 fix(bayesian): close Optuna SQLite storage and backup connections
On Python 3.13+, an sqlite3 connection that is garbage-collected
without being closed raises ResourceWarning, which the project's
filterwarnings=error turns into test failures. pyproject declares
requires-python >=3.11 with no upper bound, so these versions must work.

- The durable study's RDBStorage is now owned by an ExitStack in both
  public entry points and closed (remove_session, then engine.dispose)
  on success, failure and cancellation.
- _atomic_sqlite_backup closes both handles with contextlib.closing;
  sqlite3's own context manager only ends the transaction.
- Two tests that reopened or connected to study databases now close
  their handles.
- New regression test tracks every sqlite3 handle opened during a real
  durable study (success, failure, KeyboardInterrupt) and the backup,
  asserting all are closed independent of the 3.13+ warning.

Storage URLs, file names, snapshots and resume behaviour are unchanged;
as with any edit to this module, the study identity (which hashes the
module source) changes, so pre-existing durable studies start fresh.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 17:43:05 -05:00
LLMsherpa ac6d92abc7 fix: preserve scored candidates across search, refinement and tournament replay 2026-10-25 21:52:42 -04:00
Joseph MaglyandClaude Opus 5.5 a831d72b7c feat(eval): exclude invalid completions from refusal rates by default (#332)
Default exclude_invalid to True for refusal metrics, verification and the
optimizer objective, with a one-release warning for implicit legacy use,
invalid counts in metadata and reports, and a changelog note.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 13:07:11 -04:00
Joseph MaglyandClaude Opus 5.5 db39905ffa fix(eval): report invalid completions beside refusal rates and stop rewarding degeneration (#312)
`refusal_rate` and its callers counted empty, reasoning-only and degenerate
completions as non-refusals, so the Bayesian optimizer objective and
tourney and benchmark rankings could reward an edit that destroyed output.

- New `measure_refusals` returns a `RefusalMeasurement` (refused, valid,
  invalid, total, rate over valid completions, invalid rate).
- `refusal_rate`, `refusal_rate_with_ci` and `heretic_eval.arditi_refusal_rate`
  gain `exclude_invalid`. The default keeps the legacy all-response
  denominator for a deprecation window; `refusal_rate_with_ci` adds
  valid, invalid and total counts.
- Verification metadata adds invalid counts, the valid-only rate and a
  refusal objective that counts invalid completions as refusals.
- The Bayesian optimizer, tourney and benchmark rankings use that objective
  and record invalid rates; displayed refusal rates are unchanged.
- docs/refusal-metrics.md documents the denominators and the planned
  default change.

Fixes #312

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-15 17:16:26 -04:00
Joseph Magly b54bfe3955 style(test): remove trailing blank line from Optuna contracts 2026-09-07 16:26:56 -04:00
Joseph Magly 707e762904 fix(packaging): install and validate the Bayesian optimizer by default 2026-09-07 16:23:48 -04:00