Skip to content

[T-056b] Diversity penalty over known failure modes + cheap mode cache #113

Closed

Description

@CodewithJha

Task T-056b · Milestone M5 — Intelligent selection · Size S · Priority P0 · Epic #5

Implements FR-SEL-003

Branch feat/t-056b-diversity-penalty-over-known-failure — one task = one branch = one PR (doc 32 §6)

Summary

Implement penalty(x) = Π_k (1 − exp(−½ Σ_j ((x_j − m_kj)/r_j)²)) with r_j = κ·ℓ_j and α_falsify = log EV + λ·log(penalty + 1e−12) (doc 07 §5.3), plus a mode cache refreshed every mode_cache_refresh_every observations by a cheap HDBSCAN on failing points.

Context / motivation

Pushes the budget towards new failure modes instead of 50 copies of one (MET-02).

Scope

In scope

  • selection/diversity.py: ModeCache, DiversityPenalizedEV acquisition.

Implementation guidance

  • Cheap clustering may reuse sklearn HDBSCAN with small min_cluster_size; do not depend on the analysis package (layering: selection must not import analysis — implement locally).
  • Standards: respect the layering contracts (doc 16 §2) and conventions in doc 34; no hard-coded tunables — thresholds/defaults come from typed settings (doc 27); no magic numbers (ruff PLR2004); public APIs typed (mypy strict) and documented.

Configuration keys

From the configuration reference (doc 27). Keys marked (new) must be added to the typed settings models and appear in the generated reference (T-003c).

  • selection.probe.lambda_div
  • selection.probe.kappa_radius
  • selection.mode_cache_refresh_every

Acceptance criteria

  • Penalty → 0 at medoids, → 1 far away (tests).
  • Cache refresh cadence honoured.
  • Tests listed below added and green in CI; coverage of new code meets the gate in doc 18 §3.
  • Docs, config reference and CHANGELOG Unreleased updated where behaviour, keys or interfaces changed.
  • Definition of Done (doc 32 §3) satisfied.

Tests required

  • tests/unit/selection/test_diversity.py.

Dependencies

Blocked by: #112 (T-056a)

Blocks: #119 (T-059c)

Parallelization notes

Files / paths owned by this task — avoid editing other paths; shared files (pyproject.toml entry points, cli/main.py, api/routers/__init__.py, router.tsx, docker/compose.yaml, ci.yml) are append-only:

  • backend/src/roboprobe/selection/diversity.py

Parallel with T-056c.

Definition of Done

Per doc 32 §3 and AGENTS.md §5: lint, format, mypy strict and import-linter green; tests added and passing; docs updated; PR template completed with Closes #<this issue>; Conventional Commit messages referencing T-056b (doc 16 §6); commits authored only by the repository owner identity (AGENTS.md §4); CI green; reviewer checklist (doc 32 §5.1) satisfied.

References

Design docs: doc 07 §5.3 · doc 07 §6.3

Requirements: FR-SEL-003 (traceability: doc 28)

External:

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:selectionScenario selection strategies (BO, LSE, PROBE, baselines)milestone:M5M5 — Intelligent selectionpriority:P0Critical path / blocks otherssize:S<= 1 daytaskChild task of a milestone epictype:featureNew functionality

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions