diff --git a/docs/adr/0011-public-api-and-object-model.md b/docs/adr/0011-public-api-and-object-model.md index 0c0bc91..9a1acae 100644 --- a/docs/adr/0011-public-api-and-object-model.md +++ b/docs/adr/0011-public-api-and-object-model.md @@ -9,7 +9,7 @@ The public API must reflect the methodological separation between structural dis ## Decision -The normative alpha-stage public flow is: +The normative alpha-stage low-level public flow is: ```python mis_set = misda.discover(Y, ...) @@ -17,9 +17,15 @@ misda.evaluate(mis_set, metrics=(...), candidates=...) ranking = misda.rank(mis_set, policy="size_span") ``` -This low-level flow remains valid for scientific instrumentation and advanced use, but ADR 0022 supersedes it as the canonical user-facing workflow with `profile(Y) -> discovery(profile)`. +This low-level flow remains valid for scientific instrumentation and advanced use. ADR 0022 supersedes it as the canonical user-facing flow with the additional profile stage while preserving the same discovery/ranking separation: -The canonical low-level structural ranking policy name is governed by ADR 0017. +```python +profile = misda.profile(Y) +mis_set = misda.discovery(profile) +ranking = misda.rank(mis_set) +``` + +The canonical structural ordering policy name is governed by ADR 0017. The public default policy of the separate `rank()` operation is governed by ADR 0021/0022. ### MISSet @@ -44,9 +50,9 @@ These quantities are deliberately distinct. ## Invariants -- `discover()` does not accept ranking policy; +- `discover()` and high-level `discovery()` do not accept ranking policy; - `evaluate()` does not change candidate membership, graphs, dimensions, or canonical order; -- `rank()` does not reorder or mutate the owning `MISSet`; +- `rank()` does not reorder or mutate the owning `MISSet` structurally; - integer ranking access returns underlying candidates; slicing returns a ranking view; - candidate canonical positions remain stable for the life of the `MISSet`; - selected dimension belongs to `Ranking`, not `MISSet`. @@ -67,4 +73,4 @@ Do not reintroduce discovery-time ranking policy, intrinsic candidate rank, a `r ## Verification -API contract tests should cover ownership, indexing/slicing semantics, object identity, immutability of canonical positions, and absence of discovery mutation after evaluation/ranking. +API contract tests should cover ownership, indexing/slicing semantics, object identity, immutability of canonical positions, absence of ranking-policy parameters on discovery, and absence of discovery mutation after evaluation/ranking. diff --git a/docs/adr/0017-size-span-canonical-ranking.md b/docs/adr/0017-size-span-canonical-ranking.md index 2a3bc7a..55a28dd 100644 --- a/docs/adr/0017-size-span-canonical-ranking.md +++ b/docs/adr/0017-size-span-canonical-ranking.md @@ -1,6 +1,6 @@ # ADR 0017 — Size-span canonical structural ranking -- Status: Accepted +- Status: Accepted; public `rank()` default clause superseded by ADR 0022 - Recorded: 2026-09-16 - Supersedes: ADR 0008 - Tracking issue: #53 @@ -40,7 +40,7 @@ simpler two-criterion policy. ## Decision -The canonical structural ranking policy is named `size_span` and compares +The canonical **structural** ranking policy is named `size_span` and compares candidates lexicographically by: ```text @@ -52,8 +52,19 @@ A deterministic label-based tie-break may order otherwise equal candidates for reproducibility, but it does not create a scientific distinction. Candidates with equal `size` and equal `span` belong to the same scientific rank group. -`misda.rank(mis_set)` is equivalent to -`misda.rank(mis_set, policy="size_span")`. +Discovery stores this canonical structural order in the `MISSet`, and the +explicit ranking call + +```python +misda.rank(mis_set, policy="size_span") +``` + +reproduces it. + +The original statement that `misda.rank(mis_set)` defaults to `size_span` is +superseded by ADR 0022. The public ranking default is now +`dominance_preservation`; that change does not alter the canonical structural +order owned by discovery. The previous exported constant name `STRUCTURAL_COVERAGE` may remain as a compatibility alias, but its value resolves to the canonical `size_span` policy. @@ -62,20 +73,25 @@ The literal policy name `"structural_coverage"` is not normative. ## Rationale The policy name should describe the quantities that actually determine the -scientific ranking. Retaining redundant criteria in the ranking key gives the -false impression that multiple independent forms of structural coverage are -being combined when, for maximal independent sets, they cannot change the -ordering. +scientific structural ranking. Retaining redundant criteria in the ranking key +gives the false impression that multiple independent forms of structural +coverage are being combined when, for maximal independent sets, they cannot +change the ordering. Cardinality remains first because it selects the largest mutually independent objective subsets. `span` then distinguishes candidates of equal cardinality by the total number of positive structural adjacencies connecting retained and excluded objectives. +Separating the canonical structural order from the public preference-ranking +default also preserves ADR 0007: discovery owns structural ordering, while +`rank()` may create a different policy-dependent view without changing the +`MISSet`. + ## Descriptive structural metrics -This decision changes the ranking key, not the candidate metric model. -`neighborhood`, `neighborhood_ratio`, `avg_external_degree`, and +This decision changes the structural ranking key, not the candidate metric +model. `neighborhood`, `neighborhood_ratio`, `avg_external_degree`, and `avg_internal_degree` may remain available as descriptive or audit quantities. Their presence in reports or the public object model must not imply that they are independent ranking criteria. @@ -87,16 +103,19 @@ metrics are useful to display. ## Invariants -- the canonical policy name is `size_span`; -- scientific ordering is determined only by `size` descending and then `span` - descending; -- scientific tie groups are determined by equality of `size` and `span`; +- the canonical structural policy name is `size_span`; +- scientific structural ordering is determined only by `size` descending and + then `span` descending; +- scientific structural tie groups are determined by equality of `size` and + `span`; - deterministic label ordering is operational only and must not split a scientific tie group; - complete MIS discovery is unchanged; - ranking does not prune or alter the discovered candidate universe; - `structural_dimension` remains the independence number of `G+` and is not - redefined by ranking. + redefined by ranking; +- the public default of `rank()` may differ from the canonical structural order + without changing any discovery output. ## Behavioral preservation @@ -120,10 +139,13 @@ rule. Tests should verify: -1. the default and explicit public policy name is `size_span`; -2. the sort key is equivalent to descending `size`, then descending `span`; +1. the canonical structural policy name is `size_span` and explicit + `policy="size_span"` reproduces the stored structural order; +2. the structural sort key is equivalent to descending `size`, then descending + `span`; 3. candidates with equal `size` and `span` remain in the same scientific tie group even when deterministic labels differ; 4. representative graphs produce the same candidate order under the old redundant key and the simplified key; -5. benchmark serialization and public reports expose `size_span` consistently. +5. changing the public `rank()` default does not mutate or redefine the stored + canonical structural order. diff --git a/docs/adr/0021-conservative-dominance-preservation-ranking.md b/docs/adr/0021-conservative-dominance-preservation-ranking.md index 3b1e5ae..8f07776 100644 --- a/docs/adr/0021-conservative-dominance-preservation-ranking.md +++ b/docs/adr/0021-conservative-dominance-preservation-ranking.md @@ -1,8 +1,9 @@ # ADR 0021 — Conservative dominance-preservation reduction selection -- Status: Experimental +- Status: Accepted for the public ranking default - Recorded: 2026-09-25 -- Does not supersede: ADR 0017 or ADR 0020 +- Promoted: 2026-10-01 after the clean/noisy default-policy audit consolidated in #85 +- Does not supersede: ADR 0017 structural-order semantics or ADR 0020 ## Context @@ -22,9 +23,17 @@ A variable-cardinality safe control showed that the metric is deliberately conservative: it may prefer a larger safe MIS over a smaller safe MIS. This is acceptable because MISDA prioritizes safe reduction, not maximal reduction. +The later clean/noisy audit established two additional points. First, +`dominance_preservation` is the best-supported optimization-oriented public +default when observed Y is representative. Second, severe corruption of Y can +mislead both dominance geometry and support inferred from the same observations; +this is a data-quality/identifiability boundary rather than a reason to fold +ranking back into discovery. + ## Decision -Add an experimental ranking policy named `dominance_preservation`. +The ranking policy `dominance_preservation` is the public default of +`misda.rank(mis_set)`. For a candidate retained set S, let U be the unordered row pairs for which neither row dominates the other in full Y. Let N_S be the members of U for @@ -41,11 +50,18 @@ an exact tie, larger MISs are ordered first as a conservative operational tie-break, followed by deterministic objective labels. The tie-break does not split the scientific group. +The canonical structural order stored by discovery remains `size_span` under +ADR 0017. Making dominance preservation the default of the separate `rank()` +operation does not change discovery, structural dimensions, candidate identity, +or canonical structural ordering. + ## Trust annotation does not suppress the answer MISDA always returns the ranking-selected MIS. It never replaces an -unsupported answer with the full objective set and never stops the analysis. -Instead, `Ranking.assessment` annotates the selected answer with one of: +unsupported answer with the full objective set and never silently filters an +unsupported candidate out of the ranking universe. + +`Ranking.assessment` annotates the selected answer with one of: ```text NO_REDUNDANCY @@ -64,23 +80,39 @@ intentional so validation can measure how wrong unsupported answers become. Support evidence is computed and stored for every discovered MIS using the shared permutation engine. The historical aggregate `MISSet.support` remains -defined over the canonical first `size_span` group for compatibility. -`MISSet.support_for(candidate)` exposes the stored support of any candidate, -including one selected by an alternative ranking. +defined over the canonical first `size_span` group for compatibility and for +regime-level discovery support. `MISSet.support_for(candidate)` exposes the +stored support of any candidate, including one selected by dominance ranking. ## Evaluation contract -`dominance_preservation` requires stored dominance evidence: +`dominance_preservation` requires dominance evidence for every ranked MIS. +The canonical user flow may therefore use: ```python -mis_set.evaluate(metrics=("dominance",), candidates="all") -ranking = misda.rank(mis_set, policy="dominance_preservation") +ranking = misda.rank(mis_set) candidate = ranking.mis() assessment = ranking.assessment ``` -Alternatively, `accept_cost=True` may explicitly authorize the missing -dominance evaluation. Ranking and reporting do not silently consult truth. +The default public call authorizes computation of missing dominance evidence as +part of the ranking operation. This is evidence enrichment owned by ranking and +must not alter the discovered MIS universe, graph structure, graph-derived +dimensions, or canonical order. + +Callers that need strict control of computation may pre-evaluate evidence or +forbid implicit ranking-time evaluation: + +```python +mis_set.evaluate(metrics=("dominance",), candidates="all") +ranking = misda.rank( + mis_set, + policy="dominance_preservation", + accept_cost=False, +) +``` + +Benchmark truth is never used. ## Interpretation @@ -93,14 +125,17 @@ extra objectives is acceptable when that better preserves the observed order. ## Invariants -- `size_span` remains the canonical structural default. +- `dominance_preservation` is the public default of `rank()`. +- `size_span` remains the canonical structural order owned by discovery. - discovery still enumerates the same complete MIS universe. - structural and latent dimensions are unchanged by ranking policy. - benchmark truth never enters runtime selection or trust annotation. - an unsupported selected MIS is still returned and remains fully inspectable. +- unsupported candidates are not filtered from ranking merely because support + contradicts them. - `NO_REDUNDANCY` must be possible when no objective reduction is discovered. -- support attached to an alternative selected MIS is candidate-specific rather - than borrowed from the canonical first structural group. +- support attached to a selected MIS is candidate-specific rather than borrowed + from the canonical first structural group. ## Research history @@ -109,7 +144,6 @@ SAFE_PATH, Pareto-retention comparison, and the conservative decision probe, are recorded chronologically in `docs/research-notes/2026-09-optimization-reduction-safety-and-ranking.md`. -The later pre-default audit that tested this policy across existing clean and -noisy benchmark batteries, and rejected immediate promotion to the public -default, is recorded in -`docs/research-notes/2026-10-ranking-policy-default-audit.md`. +The pre-default audit and the subsequent clean/noisy ranking-policy work are +recorded in the October 2026 research notes and were consolidated before the +public-default decision in #85. diff --git a/docs/adr/0022-profile-to-discovery-user-workflow.md b/docs/adr/0022-profile-to-discovery-user-workflow.md index e83e06c..4a18a09 100644 --- a/docs/adr/0022-profile-to-discovery-user-workflow.md +++ b/docs/adr/0022-profile-to-discovery-user-workflow.md @@ -2,14 +2,27 @@ - Status: Accepted - Recorded: 2026-10-01 +- Corrected: 2026-10-01 under issue #91 - Supersedes: ADR 0019 as the canonical user-facing workflow -- Partially supersedes: ADR 0011 public-flow section -- Refines but does not supersede: ADR 0017 and ADR 0021 +- Partially supersedes: ADR 0011 public-flow section and the public-default clause of ADR 0017 +- Refines but does not supersede: ADR 0007, ADR 0014, ADR 0017, and ADR 0021 + +## Correction note + +The first version of this ADR, merged in PR #90, incorrectly made +`discovery(profile)` apply a ranking policy and select a representative MIS. +That contradicted ADR 0007, whose central invariant is that discovery, +evaluation, and ranking are separate operations and that ranking policy is not +an input to structural discovery. + +Issue #91 corrects that regression explicitly rather than silently redefining +the older architectural contract. The corrected workflow below restores ADR +0007 as a binding invariant. ## Context -The low-level MISDA API deliberately separated structural discovery, -candidate evaluation, and ranking: +The low-level MISDA API deliberately separates structural discovery, +candidate evidence, and preference among already discovered candidates: ```python mis_set = misda.discover(Y) @@ -17,19 +30,18 @@ mis_set.evaluate(...) ranking = misda.rank(mis_set, policy=...) ``` -That separation remains valuable for benchmarks, validation, and expert -instrumentation. It is, however, too low-level as the canonical workflow for a -user who wants a defensible reduction recommendation. +That separation remains scientifically important. A higher-level user workflow +is still useful because the calibrated alpha path may contain several distinct +structural regimes and the user should not need to choose an aggressiveness +value manually. -Two logically distinct decisions were being exposed as if they were one: +There are therefore three logically distinct questions: -1. which alpha/aggressiveness regime should be used for the observed `Y`; -2. which MIS should represent the chosen regime. +1. which alpha/aggressiveness regime is admissible for the observed `Y`; +2. what complete MIS universe is discovered in that regime; +3. which discovered MIS is preferred under a declared ranking policy. -The ranking-policy experiments in issues #83 and #84 further showed that these -questions should remain distinct. Structural support and threshold sensitivity -are properties of the observed-data profile. Representative selection is a -ranking problem within a selected regime. +These questions must remain separate in the public API. ## Decision @@ -39,21 +51,32 @@ The canonical user-facing workflow is: profile = misda.profile(Y) profile.report() -result = misda.discovery(profile) -result.report() +mis_set = misda.discovery(profile) +mis_set.report() + +ranking = misda.rank(mis_set) +ranking.report() + +mis = ranking.mis() +mis.report() ``` The convenience form ```python -result = misda.discovery(Y) +mis_set = misda.discovery(Y) ``` -is equivalent to profiling first and then discovering from the resulting -profile. +is equivalent to profiling first and then returning the MISSet associated with +the selected profile regime. -The low-level `discover`, `evaluate`, and `rank` functions remain public and -retain their existing semantics for scientific and advanced use. +`profile`, `discovery`, and `rank` have separate ownership: + +```text +profile -> selects the threshold regime / alpha + discovery -> returns the complete MISSet for that regime + rank -> orders the already discovered MISs and selects a representative +``` ## Profile semantics @@ -64,96 +87,155 @@ shows their consequences, including: - alpha/aggressiveness; - latent and structural dimensions; - structural/latent topology and components through the stored regime result; -- MIS universe and structural ranking; -- dimensional-support assessment and reasons; +- complete MIS universe and canonical structural order; +- dimensional-support evidence; - `alpha_onset`, `alpha_null`, and separation/null-envelope context. -Regimes are represented at their **most aggressive boundary**. Critical -thresholds are probed on both sides and structurally equivalent consecutive -states are compressed. This lets the stored aggressiveness of a regime mean the -most aggressive point at which that same structural state still holds. +Profile construction may internally build the MISSet for each structural regime +because support is defined on discovered MISs. This does not make profile a +ranking operation: no ranking policy is accepted or consulted when selecting +the regime. -`profile.report()` must remain observational: reporting does not trigger -additional candidate evaluation. +Candidate-specific support is stored for every MIS in each regime, matching the +low-level `discover()` contract. The historical aggregate `MISSet.support` +remains defined over the complete first canonical `size_span` scientific tie +group as required by ADR 0014. Deterministic ordering inside that tie group may +not decide regime support. -## Selected regime +Regimes are represented at their most aggressive boundary. Critical thresholds +are probed on both sides and structurally equivalent consecutive states are +compressed. -`profile.selected` is the **most aggressive acceptable regime**. +### Regime status and automatic selection -A regime is acceptable when the canonical structural selection at that regime -has assessment: +A regime has one of the following profile-level interpretations: + +```text +NO_REDUNDANCY no structural reduction is present +SUPPORTED_REDUCTION aggregate discovery support is SUPPORTED +PARTIALLY_SUPPORTED the first structural tie group has mixed support +UNSUPPORTED_REDUCTION aggregate discovery support is UNSUPPORTED +``` + +`profile.selected` is the most aggressive regime that is fully admissible for +automatic use. The admissible states are: ```text NO_REDUNDANCY SUPPORTED_REDUCTION ``` -A regime whose canonical structural selection is -`UNSUPPORTED_REDUCTION` is not acceptable for automatic selection. +`PARTIALLY_SUPPORTED` remains visible but is not auto-selected because a +scientific tie must not be resolved by deterministic candidate order. +`UNSUPPORTED_REDUCTION` is likewise not auto-selected. -If no acceptable regime exists, `profile.selected` is `None` and the high-level -workflow abstains rather than silently using `aggressiveness=1`. +If no admissible regime exists, `profile.selected` is `None`. The profile +remains inspectable, but high-level discovery refuses to invent a fallback +regime. -Selection does not hide alternatives: all regimes remain available for -inspection in the profile. +`profile.report()` remains a compact table. Its final column may include a +short human-readable interpretation of the status, and the report must state +that selecting a regime does not select an MIS. Reporting remains a view over +stored state and triggers no scientific computation. ## Discovery semantics -`discovery(profile)` operates only on `profile.selected` and then chooses a -representative MIS within that regime. +`discovery(profile)` returns exactly the `MISSet` stored for +`profile.selected`. + +It does not: + +- accept a ranking policy; +- rank candidates; +- select a representative MIS; +- filter unsupported candidates; +- compute dominance or Pareto preference evidence. + +If `profile.selected is None`, high-level discovery raises rather than silently +falling back to `aggressiveness=1` or another regime. + +`discovery(Y)` is only the convenience composition +`profile(Y) -> discovery(profile)`. -The default high-level ranking policy is: +## Ranking semantics + +`rank()` is the only public step that applies a ranking policy. + +The public default is: ```text dominance_preservation ``` -because the clean end-to-end experiments in #83 showed that it is more aligned -with downstream optimization than the structural `size_span` order when the -observed geometry is representative. Issue #84 established the epistemic -boundary: severe corruption of `Y` can mislead dominance ranking and even -support inferred from the same data. The default is therefore an -observed-data recommendation, not an unconditional noise-robustness claim. +because the clean end-to-end experiments consolidated in #85 showed that this +policy is better aligned with downstream optimization than structural +`size_span` when the observed geometry is representative. -Users may request the structural policy explicitly: +The canonical structural ordering stored by discovery remains `size_span`. +Users may request it explicitly: ```python -result = misda.discovery(profile, rank_policy="size_span") +ranking = misda.rank(mis_set, policy="size_span") ``` -The low-level call `misda.rank(mis_set)` continues to default to `size_span`. -This preserves ADR 0017: `size_span` remains the canonical zero-cost structural -ordering. The new high-level default applies only to the recommendation layer. +The default dominance ranking may compute missing dominance evidence as part of +the ranking operation. This is ranking-time evidence enrichment, not discovery. +Callers that require precomputed evidence may pass `accept_cost=False`. -## Abstention and assessment +Ranking considers the complete requested candidate set. Unsupported candidates +are not filtered out. If the ranking-selected MIS is contradicted by its stored +support diagnostics, `Ranking.assessment` reports +`UNSUPPORTED_REDUCTION` while preserving the selected candidate for inspection +and validation. -If `profile.selected is None`, `discovery(profile)` returns an abstaining result -rather than inventing a reduction. +## Reporting non-regression -If a selected regime exists, the ranking-selected MIS retains its -candidate-specific `ReductionAssessment`. A high-level result therefore remains -inspectable even when alternative ranking evidence exposes a candidate-specific -warning. +This ADR does not redesign the established report formats of: -## Data-quality boundary +- `MISSet.report()`; +- `Ranking.report()`; +- `MISCandidate.report()`. -`profile()` diagnoses structure **conditional on the observed `Y`**. It does not -claim to estimate an external measurement-noise variance, reliability ratio, or -systematic distortion from a single matrix. +Those formats remain protected by ADR 0016 and their existing reporting +contract tests. Only `profile.report()` is new to this workflow and may be +refined within the compact tabular design described above. + +## Data-quality boundary -Known data-quality information may inform how a user interprets the profile or -chooses a ranking policy. X-aware or replicate-aware diagnostics remain separate -research questions. +`profile()` and ranking diagnose the observed `Y`. They do not claim to infer +an arbitrary external measurement-noise variance, reliability ratio, or +systematic distortion from one matrix. Severe corruption of observed geometry +can still mislead support and dominance evidence; the noisy-safety experiments +record that epistemic boundary. ## Compatibility -- `misda.discover(Y, aggressiveness=...)` remains available. +- `misda.discover(Y, aggressiveness=...)` remains available for exact low-level + structural control. - `MISSet.evaluate(...)` remains available. -- `misda.rank(...)` remains available and defaults to `size_span`. -- benchmark runners may continue using the low-level API where exact control of - regime, candidate scope, and evaluation cost is scientifically necessary. -- notebook and user-document migration is tracked separately after this API - contract stabilizes. +- `misda.rank(...)` remains a view over an existing `MISSet`; its public default + is now `dominance_preservation`. +- `size_span` remains the canonical structural ordering owned by discovery and + remains explicitly selectable as a ranking policy. +- benchmark runners may use explicit policies and low-level primitives where + scientific instrumentation requires them. +- notebook and user-document migration remains tracked separately in #87. + +## Verification + +Contract tests must verify at least that: + +1. `discovery()` has no ranking-policy parameter; +2. `discovery(profile)` returns an `MISSet` and does not compute ranking + evidence; +3. `rank()` is the policy-bearing operation and defaults to + `dominance_preservation`; +4. ranking/evaluation do not change candidate membership, graph structure, + graph-derived dimensions, or canonical structural order; +5. profile reporting has no scientific side effects; +6. profile regimes retain candidate-specific support for all discovered MISs; +7. existing `MISSet`, `Ranking`, and `MISCandidate` report contracts are + unchanged. ## Research basis diff --git a/docs/adr/README.md b/docs/adr/README.md index 017720b..51c9240 100644 --- a/docs/adr/README.md +++ b/docs/adr/README.md @@ -33,11 +33,11 @@ Each record may contain: Context, Definitions, Decision, Formal specification, R - [0014 — Public diagnostics and reporting semantics](0014-public-diagnostics-and-reporting-semantics.md) - [0015 — Empirical null envelope for alpha-null estimation](0015-empirical-null-envelope-alpha-null.md) - [0016 — Public capability non-regression contract](0016-public-capability-non-regression.md) -- [0017 — Size-span canonical structural ranking](0017-size-span-canonical-ranking.md) +- [0017 — Size-span canonical structural ranking (public rank default superseded by ADR 0022)](0017-size-span-canonical-ranking.md) - [0018 — Ranking-selected visualization views](0018-ranking-selected-visualization-views.md) - [0019 — User-facing MIS, ranking, and evaluation workflow (superseded by ADR 0022)](0019-user-facing-mis-ranking-workflow.md) - [0020 — Experimental empirical-Pareto ranking](0020-experimental-empirical-pareto-ranking.md) -- [0021 — Conservative dominance-preservation reduction selection](0021-conservative-dominance-preservation-ranking.md) -- [0022 — Profile-to-discovery user workflow](0022-profile-to-discovery-user-workflow.md) +- [0021 — Conservative dominance-preservation reduction selection (accepted as public rank default)](0021-conservative-dominance-preservation-ranking.md) +- [0022 — Profile-to-discovery user workflow (corrected under #91 to restore ADR 0007 separation)](0022-profile-to-discovery-user-workflow.md) -All records below are retrospective unless explicitly stated otherwise. They document the current MISDA design, with later records superseding earlier decisions where explicitly stated. \ No newline at end of file +All records below are retrospective unless explicitly stated otherwise. They document the current MISDA design, with later records superseding earlier decisions where explicitly stated. diff --git a/misda/__init__.py b/misda/__init__.py index 05ede8c..30a0c70 100644 --- a/misda/__init__.py +++ b/misda/__init__.py @@ -3,14 +3,15 @@ """MISDA public API. -The canonical user workflow separates structural regime diagnosis from the -final representative choice:: +The canonical user workflow separates threshold-regime profiling, structural +discovery, and final representative ranking:: profile = misda.profile(Y) - result = misda.discovery(profile) + mis_set = misda.discovery(profile) + ranking = misda.rank(mis_set) -The lower-level ``discover`` / ``evaluate`` / ``rank`` primitives remain public -for scientific instrumentation and advanced use. +The lower-level ``discover`` / ``evaluate`` primitives remain public for +scientific instrumentation and advanced use. """ from ._metadata import __version__ @@ -28,6 +29,7 @@ _api.compute_correlation_statistics = _compute_correlation_statistics _api.estimate_null_positive_correlation = _estimate_null_positive_correlation _discover_impl = _api.discover +_rank_impl = _api.rank from .api import ( PARTIALLY_SUPPORTED, @@ -52,11 +54,8 @@ Ranking, ReductionAssessment, StructuralMetrics, - rank, ) from ._profile import ( - ABSTAINED, - DiscoveryResult, Profile, ProfileRegime, discovery as _discovery_high_level, @@ -128,23 +127,21 @@ def profile( def discovery( source, *, - rank_policy=DOMINANCE_PRESERVATION, seed=123, name=None, cancel_requested=None, correlation="pearson", experimental=False, ): - """Return a high-level reduction decision from observed Y or a Profile. + """Return the MISSet at the regime selected by ``profile``. When ``source`` is raw Y, profiling is performed first. When it is already - a :class:`Profile`, the stored selected regime is used directly. The - high-level default is ``dominance_preservation``; low-level ``rank()`` keeps - its historical ``size_span`` default. + a :class:`Profile`, the stored selected regime is used directly. Discovery + never ranks or selects an MIS. """ if isinstance(source, Profile): - return _discovery_high_level(source, rank_policy=rank_policy) + return _discovery_high_level(source) observed_profile = profile( source, seed=seed, @@ -153,7 +150,38 @@ def discovery( correlation=correlation, experimental=experimental, ) - return _discovery_high_level(observed_profile, rank_policy=rank_policy) + return _discovery_high_level(observed_profile) + + +def rank( + mis_set, + policy=DOMINANCE_PRESERVATION, + *, + candidates="all", + accept_cost=None, +): + """Create a policy-dependent ranking over an already discovered MISSet. + + ``dominance_preservation`` is the public default. The canonical structural + ordering stored by discovery remains ``size_span`` and can be requested + explicitly. Missing dominance evidence is evaluated by the default ranking + call; callers may pass ``accept_cost=False`` to require precomputed evidence. + Other non-structural policies retain the explicit-cost contract unless + ``accept_cost=True`` is supplied. + """ + + if accept_cost is None: + accept_cost = policy == DOMINANCE_PRESERVATION + return _rank_impl( + mis_set, + policy=policy, + candidates=candidates, + accept_cost=accept_cost, + ) + + +# Keep ``misda.api.rank`` and ``misda.rank`` aligned with the public default. +_api.rank = rank from ._pareto_stability import ParetoStabilityDiagnostics, evaluate @@ -178,7 +206,6 @@ def discovery( "UNSUPPORTED_REDUCTION", "STRUCTURAL_COVERAGE", "PARTIALLY_SUPPORTED", - "ABSTAINED", "StructuralMetrics", "JackknifeMetrics", "LinearMetrics", @@ -196,7 +223,6 @@ def discovery( "Ranking", "ProfileRegime", "Profile", - "DiscoveryResult", "profile", "discovery", "discover", diff --git a/misda/_profile.py b/misda/_profile.py index e4186d1..f82ec4b 100644 --- a/misda/_profile.py +++ b/misda/_profile.py @@ -17,9 +17,6 @@ from ._validation import normalize_input_matrix -ABSTAINED = "ABSTAINED" - - @dataclass(frozen=True) class ProfileRegime: """One distinct structural regime along the alpha/aggressiveness path.""" @@ -34,20 +31,31 @@ class ProfileRegime: def analysis(self): return self.mis_set.analysis - @property - def ranking(self): - return self.mis_set.structural_ranking - - @property - def assessment(self): - return self.ranking.assessment - @property def status(self): - return self.assessment.status if self.assessment is not None else ABSTAINED + """Aggregate discovery status for this structural regime. + + This is deliberately independent of any ranking policy. A regime with + no structural reduction is admissible by construction; otherwise the + status is the aggregate dimensional-support state of the complete first + canonical structural tie group. + """ + + if self.analysis.structural_dimension == self.analysis.original_dimension: + return _api.NO_REDUNDANCY + support = self.mis_set.support + if support is None: + return _api.UNSUPPORTED_REDUCTION + if support.status == "SUPPORTED": + return _api.SUPPORTED_REDUCTION + if support.status == _api.PARTIALLY_SUPPORTED: + return _api.PARTIALLY_SUPPORTED + return _api.UNSUPPORTED_REDUCTION @property def acceptable(self): + """Whether this regime is safe for automatic profile selection.""" + return self.status in {_api.NO_REDUNDANCY, _api.SUPPORTED_REDUCTION} @@ -106,74 +114,31 @@ def report(self): lines.append( "Regimes: idx aggressiveness alpha latent structural MISs assessment" ) + interpretations = { + _api.NO_REDUNDANCY: "no reduction", + _api.SUPPORTED_REDUCTION: "reduction supported", + _api.PARTIALLY_SUPPORTED: "mixed support; not auto-selected", + _api.UNSUPPORTED_REDUCTION: "reduction not supported", + } for regime in self._regimes: marker = "*" if self.selected_index == regime.index else " " analysis = regime.analysis + interpretation = interpretations.get(regime.status, "inspect regime") lines.append( f"{marker} {regime.index:>3} {regime.aggressiveness:>14.6f} " f"{regime.alpha:>10.6g} {analysis.latent_dimension:>6} " f"{analysis.structural_dimension:>10} {len(regime.mis_set):>4} " - f"{regime.status}" + f"{regime.status} — {interpretation}" ) if self.selected is None: - lines.append("Selected regime: none — no acceptable structural regime.") + lines.append("Selected regime: none — no fully supported admissible regime.") else: lines.append( - f"Selected regime: {self.selected.index} — most aggressive acceptable " + f"Selected regime: {self.selected.index} — most aggressive admissible " f"regime (aggressiveness={self.selected.aggressiveness:.6f}, " f"alpha={self.selected.alpha:.6g})." ) - return "\n".join(lines) - - -@dataclass(frozen=True) -class DiscoveryResult: - """High-level reduction decision derived from one selected profile regime.""" - - profile: Profile - regime: Optional[ProfileRegime] - ranking: Optional[_api.Ranking] - rank_policy: str - - @property - def mis_set(self): - return None if self.regime is None else self.regime.mis_set - - @property - def selected(self): - return None if self.ranking is None else self.ranking.selected - - @property - def assessment(self): - return None if self.ranking is None else self.ranking.assessment - - @property - def status(self): - return ABSTAINED if self.assessment is None else self.assessment.status - - @property - def analysis(self): - return None if self.regime is None else self.regime.analysis - - def mis(self): - return self.selected - - def report(self): - lines = [f"MISDA discovery: {self.profile.name or 'Untitled'}"] - if self.regime is None: - lines.append("Decision: ABSTAINED — profile found no acceptable regime.") - return "\n".join(lines) - lines.append( - f"Profile regime: {self.regime.index}; " - f"aggressiveness={self.regime.aggressiveness:.6f}; " - f"alpha={self.regime.alpha:.6g}" - ) - lines.append(f"Ranking policy: {self.rank_policy}") - objectives = ", ".join(map(str, self.selected.objectives)) if self.selected else "none" - lines.append(f"Selected MIS: {objectives}") - if self.assessment is not None: - reasons = ", ".join(self.assessment.reasons) or "none" - lines.append(f"Assessment: {self.assessment.status}; reasons={reasons}") + lines.append("This selects the threshold regime only; no MIS has been selected yet.") return "\n".join(lines) @@ -265,12 +230,12 @@ def _build_regime( for item in ranked ) - # Profiling needs support only for the canonical first structural group. - # Candidate-specific support for an alternative final ranking is evaluated - # lazily in discovery(). The null computation is cached whenever the same - # retained sets and latent dimension recur in another alpha regime. - first_group = groups[0] if groups else tuple() - selected_sets = tuple(candidates[index].indices for index in first_group) + # Profile is a structural scan, not a ranking decision. Store support for + # every discovered MIS exactly as low-level discover() does, while retaining + # the historical aggregate support over the complete first size-span tie + # group. Shared regimes reuse identical permutation work when possible. + all_indices = tuple(range(len(candidates))) + selected_sets = tuple(candidates[index].indices for index in all_indices) support_key = (int(structure.latent_dimension), selected_sets) raw_support = support_cache.get(support_key) if raw_support is None: @@ -281,11 +246,15 @@ def _build_regime( seed=seed, ) support_cache[support_key] = raw_support - support_results = tuple( + all_support_results = tuple( _api._candidate_support(raw, index) - for raw, index in zip(raw_support, first_group) + for raw, index in zip(raw_support, all_indices) ) - support_by_index = {item.candidate_index: item for item in support_results} + support_by_index = { + item.candidate_index: item for item in all_support_results + } + first_group = groups[0] if groups else tuple() + support_results = tuple(support_by_index[index] for index in first_group) analysis = _api.DiscoveryAnalysis( original_dimension=normalized.n_objectives, @@ -324,24 +293,6 @@ def _build_regime( return result -def _ensure_candidate_support(mis_set, candidate_index): - """Attach candidate-specific support if profiling did not need that MIS.""" - - candidate_index = int(candidate_index) - if candidate_index in mis_set._support_by_index: - return mis_set._support_by_index[candidate_index] - candidate = mis_set[candidate_index] - raw = evaluate_dimensional_support_group( - mis_set._data, - (candidate.indices,), - mis_set.analysis.latent_dimension, - seed=mis_set.seed, - )[0] - support = _api._candidate_support(raw, candidate_index) - mis_set._support_by_index[candidate_index] = support - return support - - def profile(Y, *, seed=123, name=None, cancel_requested=None): """Map distinct structural regimes over the calibrated alpha path.""" @@ -422,8 +373,13 @@ def signature(log_alpha): ) -def discovery(source, *, rank_policy=_api.DOMINANCE_PRESERVATION, **profile_kwargs): - """Return the recommended MIS from a profile or directly from observed Y.""" +def discovery(source, **profile_kwargs): + """Return the MISSet for the regime selected by a Profile. + + Raw observed Y is accepted as a convenience and is profiled first. This + operation never ranks or selects an MIS; ranking policy belongs exclusively + to :func:`misda.rank`. + """ if isinstance(source, Profile): if profile_kwargs: @@ -437,24 +393,8 @@ def discovery(source, *, rank_policy=_api.DOMINANCE_PRESERVATION, **profile_kwar regime = observed_profile.selected if regime is None: - return DiscoveryResult( - profile=observed_profile, - regime=None, - ranking=None, - rank_policy=rank_policy, + raise RuntimeError( + "profile has no selected regime; inspect profile.report() and the " + "individual regimes before requesting discovery." ) - - ranking = _api.rank( - regime.mis_set, - policy=rank_policy, - candidates="all", - accept_cost=True, - ) - if ranking.indices: - _ensure_candidate_support(regime.mis_set, ranking.indices[0]) - return DiscoveryResult( - profile=observed_profile, - regime=regime, - ranking=ranking, - rank_policy=rank_policy, - ) + return regime.mis_set diff --git a/tests/test_comparative_metrics.py b/tests/test_comparative_metrics.py index 750bb48..660e581 100644 --- a/tests/test_comparative_metrics.py +++ b/tests/test_comparative_metrics.py @@ -35,7 +35,7 @@ def test_misda_common_score_counts_preserved_objectives_as_exact(): x = np.linspace(-2.0, 2.0, 12) frame = pd.DataFrame({"f1": x, "f2": 2.0 * x, "f3": -3.0 * x}) result = misda.discover(frame, seed=123) - ranking = misda.rank(result) + ranking = misda.rank(result, policy=misda.SIZE_SPAN) misda.evaluate(result, metrics=("linear",), candidates=ranking[:1]) selected_candidate = ranking.selected diff --git a/tests/test_front_plot.py b/tests/test_front_plot.py index 664ac31..0141668 100644 --- a/tests/test_front_plot.py +++ b/tests/test_front_plot.py @@ -227,7 +227,7 @@ def test_terminal_fallback_writes_standalone_html(monkeypatch): def test_mis_front_plot_uses_already_selected_mis_without_rank_metadata(): result = _mis_set() - ranking = misda.rank(result) + ranking = misda.rank(result, policy=misda.SIZE_SPAN) selected = ranking.mis(0, 1) fig = selected.front_plot(show=False) @@ -244,7 +244,7 @@ def test_mis_front_plot_uses_already_selected_mis_without_rank_metadata(): def test_mis_graph_plot_highlights_already_selected_mis_without_rank_metadata(): result = _mis_set() - selected = misda.rank(result).mis(0, 1) + selected = misda.rank(result, policy=misda.SIZE_SPAN).mis(0, 1) fig = selected.graph_plot(show=False) try: diff --git a/tests/test_newapi.py b/tests/test_newapi.py index c70530f..126e4ac 100644 --- a/tests/test_newapi.py +++ b/tests/test_newapi.py @@ -30,9 +30,13 @@ def test_public_surface_is_discover_evaluate_rank(): assert not hasattr(misda, "heavy") -def test_public_ranking_policy_is_size_span(): +def test_public_structural_policy_is_size_span_and_rank_default_is_dominance(): assert misda.SIZE_SPAN == "size_span" assert misda.STRUCTURAL_COVERAGE == misda.SIZE_SPAN + assert ( + inspect.signature(misda.rank).parameters["policy"].default + == misda.DOMINANCE_PRESERVATION + ) def test_discover_has_no_policy_parameter(): @@ -79,11 +83,13 @@ def test_ranking_slice_returns_ranking_view(): def test_rank_does_not_reorder_mis_set(): result = misda.discover(_two_blocks(), seed=19) before = tuple(candidate.indices for candidate in result) + canonical_before = tuple(result.structural_ranking.indices) ranking = misda.rank(result) + assert ranking.mis_set is result assert tuple(candidate.indices for candidate in result) == before - assert tuple(candidate.indices for candidate in ranking) == before + assert tuple(result.structural_ranking.indices) == canonical_before def test_linear_evaluation_defaults_to_all_candidates(monkeypatch): @@ -257,7 +263,7 @@ def test_ranking_mis_selects_by_level_and_position_without_indices(): x = np.linspace(-1.0, 1.0, 20) data = np.column_stack([x, x, x, x]) result = misda.discover(data, seed=43) - ranking = misda.rank(result) + ranking = misda.rank(result, policy=misda.SIZE_SPAN) assert len(ranking.groups[0]) == 4 assert ranking.mis() is ranking.selected @@ -315,7 +321,7 @@ def fake_linear(data, selected_indices, labels): assert result.evaluation_scope("linear") == (1, "explicit MIS") -def test_ranking_remains_a_view_not_an_evaluator(): +def test_ranking_remains_a_view_over_the_discovered_universe(): result = misda.discover(_two_blocks(), seed=59) ranking = misda.rank(result) diff --git a/tests/test_profile_discovery.py b/tests/test_profile_discovery.py index f3a71e8..56bd39c 100644 --- a/tests/test_profile_discovery.py +++ b/tests/test_profile_discovery.py @@ -1,7 +1,10 @@ # SPDX-FileCopyrightText: 2026 Monaco F. J. # SPDX-License-Identifier: GPL-3.0-or-later +import inspect + import numpy as np +import pytest import misda @@ -42,10 +45,37 @@ def test_public_profile_exposes_ordered_regimes_and_selected_boundary(): assert "alpha_onset=" in text assert "alpha_null=" in text assert "Selected regime:" in text + assert "no MIS has been selected yet" in text -def test_profile_report_is_side_effect_free_for_candidate_evidence(): +def test_profile_regime_status_is_aggregate_discovery_support_not_ranking(): observed = misda.profile(_two_blocks(), seed=13) + + for regime in observed: + analysis = regime.analysis + if analysis.structural_dimension == analysis.original_dimension: + assert regime.status == misda.NO_REDUNDANCY + elif regime.mis_set.support.status == "SUPPORTED": + assert regime.status == misda.SUPPORTED_REDUCTION + elif regime.mis_set.support.status == misda.PARTIALLY_SUPPORTED: + assert regime.status == misda.PARTIALLY_SUPPORTED + assert not regime.acceptable + else: + assert regime.status == misda.UNSUPPORTED_REDUCTION + assert not regime.acceptable + + +def test_profile_stores_support_for_every_discovered_mis(): + observed = misda.profile(_two_blocks(seed=15), seed=17) + + for regime in observed: + for candidate in regime.mis_set: + support = regime.mis_set.support_for(candidate) + assert support.candidate_index >= 0 + + +def test_profile_report_is_side_effect_free_for_candidate_evidence(): + observed = misda.profile(_two_blocks(), seed=19) before = [ tuple(candidate.dominance for candidate in regime.mis_set) for regime in observed @@ -61,54 +91,87 @@ def test_profile_report_is_side_effect_free_for_candidate_evidence(): assert all(value is None for row in after for value in row) -def test_discovery_from_profile_defaults_to_dominance_preservation(): - observed = misda.profile(_two_blocks(), seed=17) - result = misda.discovery(observed) +def test_discovery_contract_has_no_ranking_policy_and_returns_mis_set(): + assert "rank_policy" not in inspect.signature(misda.discovery).parameters - assert isinstance(result, misda.DiscoveryResult) + observed = misda.profile(_two_blocks(), seed=23) if observed.selected is None: - assert result.status == misda.ABSTAINED - assert result.selected is None - else: - assert result.regime is observed.selected - assert result.rank_policy == misda.DOMINANCE_PRESERVATION - assert result.ranking.policy == misda.DOMINANCE_PRESERVATION - assert result.selected is result.ranking.selected - assert all(candidate.dominance is not None for candidate in result.mis_set) + pytest.skip("fixture produced no admissible profile regime") + + mis_set = misda.discovery(observed) + + assert isinstance(mis_set, misda.MISSet) + assert mis_set is observed.selected.mis_set + assert all(candidate.dominance is None for candidate in mis_set) def test_discovery_y_is_equivalent_to_profile_then_discovery(): - data = _two_blocks(seed=19) - direct = misda.discovery(data, seed=23) - staged_profile = misda.profile(data, seed=23) + data = _two_blocks(seed=29) + staged_profile = misda.profile(data, seed=31) + if staged_profile.selected is None: + with pytest.raises(RuntimeError, match="no selected regime"): + misda.discovery(data, seed=31) + return + + direct = misda.discovery(data, seed=31) staged = misda.discovery(staged_profile) - assert direct.status == staged.status - assert direct.rank_policy == staged.rank_policy - if direct.selected is None: - assert staged.selected is None - else: - assert direct.selected.indices == staged.selected.indices - assert direct.regime.analysis.structural_dimension == staged.regime.analysis.structural_dimension - assert direct.regime.aggressiveness == staged.regime.aggressiveness + assert isinstance(direct, misda.MISSet) + assert isinstance(staged, misda.MISSet) + assert tuple(candidate.indices for candidate in direct) == tuple( + candidate.indices for candidate in staged + ) + assert direct.analysis.structural_dimension == staged.analysis.structural_dimension + assert direct.analysis.aggressiveness == staged.analysis.aggressiveness -def test_size_span_remains_available_and_low_level_default_is_unchanged(): - observed = misda.profile(_two_blocks(seed=29), seed=31) +def test_rank_default_is_dominance_and_size_span_remains_explicit(): + observed = misda.profile(_two_blocks(seed=37), seed=41) if observed.selected is None: - return + pytest.skip("fixture produced no admissible profile regime") + mis_set = misda.discovery(observed) + + default_ranking = misda.rank(mis_set) + structural_ranking = misda.rank(mis_set, policy=misda.SIZE_SPAN) + + assert default_ranking.policy == misda.DOMINANCE_PRESERVATION + assert all(candidate.dominance is not None for candidate in mis_set) + assert structural_ranking.policy == misda.SIZE_SPAN + assert tuple(structural_ranking.indices) == tuple( + mis_set.structural_ranking.indices + ) + + +def test_ranking_does_not_change_discovery_universe_or_canonical_order(): + observed = misda.profile(_two_blocks(seed=43), seed=47) + if observed.selected is None: + pytest.skip("fixture produced no admissible profile regime") + mis_set = misda.discovery(observed) + + candidates_before = tuple(candidate.indices for candidate in mis_set) + canonical_before = tuple(mis_set.structural_ranking.indices) + dimensions_before = ( + mis_set.analysis.original_dimension, + mis_set.analysis.latent_dimension, + mis_set.analysis.structural_dimension, + ) + graph_before = frozenset(mis_set.analysis.structural_graph.edges()) - high_level = misda.discovery(observed, rank_policy=misda.SIZE_SPAN) - low_level = misda.rank(observed.selected.mis_set) + ranking = misda.rank(mis_set) - assert high_level.rank_policy == misda.SIZE_SPAN - assert high_level.ranking.policy == misda.SIZE_SPAN - assert high_level.selected.indices == low_level.selected.indices - assert low_level.policy == misda.SIZE_SPAN + assert ranking.mis_set is mis_set + assert tuple(candidate.indices for candidate in mis_set) == candidates_before + assert tuple(mis_set.structural_ranking.indices) == canonical_before + assert ( + mis_set.analysis.original_dimension, + mis_set.analysis.latent_dimension, + mis_set.analysis.structural_dimension, + ) == dimensions_before + assert frozenset(mis_set.analysis.structural_graph.edges()) == graph_before -def test_discovery_abstains_when_profile_has_no_selected_regime(): - base = misda.profile(_two_blocks(seed=37), seed=41) +def test_discovery_refuses_profile_without_selected_regime(): + base = misda.profile(_two_blocks(seed=53), seed=59) abstaining = misda.Profile( regimes=base.regimes, selected_index=None, @@ -121,10 +184,5 @@ def test_discovery_abstains_when_profile_has_no_selected_regime(): experimental=base.experimental, ) - result = misda.discovery(abstaining) - - assert result.status == misda.ABSTAINED - assert result.regime is None - assert result.ranking is None - assert result.selected is None - assert "ABSTAINED" in result.report() + with pytest.raises(RuntimeError, match="no selected regime"): + misda.discovery(abstaining) diff --git a/tests/test_ranking_policy_impact.py b/tests/test_ranking_policy_impact.py index bea7273..116fae9 100644 --- a/tests/test_ranking_policy_impact.py +++ b/tests/test_ranking_policy_impact.py @@ -1,4 +1,10 @@ -"""Contracts for the pre-default ranking policy impact audit.""" +"""Contracts for the historical ranking-policy impact audit. + +The audit artifacts retain their original baseline/candidate labels because they +record the pre-default experiment. The current public default, promoted after +that audit and the subsequent clean/noisy evidence, is +``dominance_preservation``. +""" from __future__ import annotations @@ -12,7 +18,7 @@ from misda.benchmarks import PROBLEM_BY_ID, diagnostic_truth -def test_audit_compares_rankings_without_changing_default(): +def test_audit_compares_rankings_without_mutating_discovery(): problem = PROBLEM_BY_ID["total_redundancy"] dataset = problem.generate(N=32, seed=123, sigma=0.0) truth = diagnostic_truth(problem, dataset.Z) @@ -40,7 +46,8 @@ def test_audit_compares_rankings_without_changing_default(): ) fresh = misda.discover(dataset.Y, seed=123) - assert misda.rank(fresh).policy == misda.SIZE_SPAN + assert fresh.structural_ranking.policy == misda.SIZE_SPAN + assert misda.rank(fresh).policy == misda.DOMINANCE_PRESERVATION def test_audit_summary_accounts_for_every_run(): @@ -127,7 +134,7 @@ def test_aggressiveness_state_records_both_policy_views(): } -def test_aggressiveness_probe_cli_writes_json_without_changing_default(tmp_path): +def test_aggressiveness_probe_cli_writes_json_without_mutating_discovery(tmp_path): output = tmp_path / "ranking-policy-aggressiveness.json" completed = subprocess.run( [ @@ -156,4 +163,5 @@ def test_aggressiveness_probe_cli_writes_json_without_changing_default(tmp_path) problem = PROBLEM_BY_ID["blocks_4x5"] dataset = problem.generate(N=32, seed=123, sigma=0.0) fresh = misda.discover(dataset.Y, seed=123) - assert misda.rank(fresh).policy == misda.SIZE_SPAN + assert fresh.structural_ranking.policy == misda.SIZE_SPAN + assert misda.rank(fresh).policy == misda.DOMINANCE_PRESERVATION diff --git a/tests/test_reporting_contract.py b/tests/test_reporting_contract.py index 55dcb8d..1f574ff 100644 --- a/tests/test_reporting_contract.py +++ b/tests/test_reporting_contract.py @@ -204,7 +204,7 @@ def test_benchmark_embeds_the_native_report_verbatim(): def test_ranking_report_is_complete_and_preserves_default_report_contract(): result = _evaluated_result() - ranking = misda.rank(result) + ranking = misda.rank(result, policy=misda.SIZE_SPAN) report = ranking.report() @@ -225,7 +225,7 @@ def test_ranking_report_is_complete_and_preserves_default_report_contract(): def test_mis_report_focuses_on_intrinsic_stored_evidence(): result = _evaluated_result() - ranking = misda.rank(result) + ranking = misda.rank(result, policy=misda.SIZE_SPAN) report = ranking.mis().report() @@ -243,7 +243,7 @@ def test_mis_report_focuses_on_intrinsic_stored_evidence(): def test_ranking_and_mis_reports_never_run_hidden_evaluation(monkeypatch): result = _evaluated_result() - ranking = misda.rank(result) + ranking = misda.rank(result, policy=misda.SIZE_SPAN) def fail(*args, **kwargs): raise AssertionError("report attempted a new scientific calculation") @@ -297,7 +297,7 @@ def test_report_explains_top_level_fields_without_losing_values(): def test_report_explains_support_and_intrinsic_mis_metrics(): result = _evaluated_result() - ranking = misda.rank(result) + ranking = misda.rank(result, policy=misda.SIZE_SPAN) complete = ranking.report() for explanation in ( @@ -326,10 +326,13 @@ def test_report_explains_support_and_intrinsic_mis_metrics(): assert explanation in intrinsic -def test_default_ranking_report_remains_exactly_the_complete_mis_set_report(): +def test_size_span_ranking_report_remains_exactly_the_complete_mis_set_report(): result = _evaluated_result() - assert misda.rank(result).report() == result.report() + assert ( + misda.rank(result, policy=misda.SIZE_SPAN).report() + == result.report() + ) def test_metric_annotations_keep_technical_and_intuitive_text_on_one_line():