Repository navigation
Description
Task
T-071a· Milestone M6 — Analysis + risk · Size M · Priority P0 · Epic #6Implements FR-ANA-002 · PR-06
Branch
feat/t-071a-modesummarizer-ranges-characteristic-params-medoid— one task = one branch = one PR (doc 32 §6)
Summary
Implement analysis/modes.py ModeSummarizer.summarize() producing FailureModeSummary per doc 09 §3.3: size, primary class & class mix, [q05,q95] ranges vs space, characteristic flag (< characteristic_coverage), medoid run, minimal reproducing scenario (closest-to-nominal failing member), label "<class> | top-3 conditions".
Context / motivation
Modes are what users read in the Casebook; labels must be human-meaningful ('speed high · light low · noise high').
Scope
In scope
- Physical-unit formatting for labels (log scale for illuminance).
ParamRangevalue object.- Label builder function
build_label(summary, space) -> str(pure, separately tested).
Implementation guidance
- Module
roboprobe/analysis/modes.py:class ModeSummarizer: def summarize(self, result: ClusteringResult, runs: Sequence[RunRecord], space: ScenarioSpace) -> list[FailureModeSummary](doc 05 §7). FailureModeSummary(frozen,analysis/types.py):code(assigned later by matching),size,primary_class,class_mix: Mapping[FailureClass, float],ranges: Mapping[str, ParamRange](unit + physicalq05,q95,space_coverage = (q95-q05)/1),characteristic: frozenset[str](coverage <analysis.characteristic_coverage),medoid_run_id,minimal_run_id,member_run_ids,label,provisional: bool.- Medoid: member minimising the sum of Euclidean distances in feature space (use
scipy.spatial.distance.cdist; O(n²) acceptable for clusters ≤ 2 000, else sample 500 members with the analysis seed stream). - Minimal reproducing scenario: failing member with the smallest normalised distance to the nominal scenario over characteristic parameters (doc 09 §3.3) — this is what engineers replay first.
- Label:
"<CLASS> | p1 high · p2 low · p3 high"with up to 3 characteristic params ranked by smallest coverage; direction word from range midpoint vs nominal (unit space) — words configurable via a small mapping, not inline literals. - Physical formatting via
ParameterSpec.denormalize+ unit; illuminance displayed on log scale. - Noise points (label −1) are reported as a pseudo-mode
UNCLUSTEREDonly in the report, never persisted as afailure_modesrow. - 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).
analysis.characteristic_coverage
Acceptance criteria
- Golden synthetic campaign → expected summaries.
- Label format matches doc example.
- Characteristic flag honours
analysis.characteristic_coverage(env override test). - Medoid and minimal-scenario selections verified on a hand-built 5-run cluster.
- Noise points never produce a persisted mode.
- Provisional flag propagated from fallback clustering.
- Tests listed below added and green in CI; coverage of new code meets the gate in doc 18 §3.
- Docs, config reference and CHANGELOG
Unreleasedupdated where behaviour, keys or interfaces changed. - Definition of Done (doc 32 §3) satisfied.
Tests required
tests/unit/analysis/test_modes.py.- Golden JSON snapshot of summaries for the synthetic
multi_mode_6dfixture (tests/fixtures/analysis/).
Dependencies
Blocked by: #127 (T-070b)
Blocks: #133 (T-074a), #137 (T-075a)
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/analysis/modes.py
Parallel with T-071b.
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-071a (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 09 §3.3 · doc 13 §3.5 · doc 02 §3.5 · doc 05 §7
Requirements: FR-ANA-002 · PR-06 (traceability: doc 28)
Metadata
Metadata
Assignees
Labels
Projects
- StatusShow more project fieldsBacklog
Activity
report.jsonand analysis artefacts #137