Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions docs/adr/0011-public-api-and-object-model.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ADR 0011 — Public API and object model

- Status: Accepted
- Status: Accepted; public-flow section partially superseded by ADR 0022
- Recorded: 2026-09-11 (retrospective)

## Context
Expand All @@ -17,7 +17,9 @@ misda.evaluate(mis_set, metrics=(...), candidates=...)
ranking = misda.rank(mis_set, policy="size_span")
```

The canonical ranking policy name is governed by ADR 0017.
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)`.

The canonical low-level structural ranking policy name is governed by ADR 0017.

### MISSet

Expand Down
2 changes: 1 addition & 1 deletion docs/adr/0019-user-facing-mis-ranking-workflow.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ADR 0019 — User-facing MIS, ranking, and evaluation workflow

- Status: Accepted
- Status: Superseded by ADR 0022
- Recorded: 2026-09-20

## Context
Expand Down
165 changes: 165 additions & 0 deletions docs/adr/0022-profile-to-discovery-user-workflow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
# ADR 0022 — Profile-to-discovery user workflow

- Status: Accepted
- Recorded: 2026-10-01
- 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

## Context

The low-level MISDA API deliberately separated structural discovery,
candidate evaluation, and ranking:

```python
mis_set = misda.discover(Y)
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.

Two logically distinct decisions were being exposed as if they were one:

1. which alpha/aggressiveness regime should be used for the observed `Y`;
2. which MIS should represent the chosen regime.

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.

## Decision

The canonical user-facing workflow is:

```python
profile = misda.profile(Y)
profile.report()

result = misda.discovery(profile)
result.report()
```

The convenience form

```python
result = misda.discovery(Y)
```

is equivalent to profiling first and then discovering from the resulting
profile.

The low-level `discover`, `evaluate`, and `rank` functions remain public and
retain their existing semantics for scientific and advanced use.

## Profile semantics

`profile(Y)` is a diagnostic map over the calibrated alpha/aggressiveness path.
It enumerates distinct structural regimes induced by threshold changes and
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;
- `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.report()` must remain observational: reporting does not trigger
additional candidate evaluation.

## Selected regime

`profile.selected` is the **most aggressive acceptable regime**.

A regime is acceptable when the canonical structural selection at that regime
has assessment:

```text
NO_REDUNDANCY
SUPPORTED_REDUCTION
```

A regime whose canonical structural selection is
`UNSUPPORTED_REDUCTION` is not acceptable for automatic selection.

If no acceptable regime exists, `profile.selected` is `None` and the high-level
workflow abstains rather than silently using `aggressiveness=1`.

Selection does not hide alternatives: all regimes remain available for
inspection in the profile.

## Discovery semantics

`discovery(profile)` operates only on `profile.selected` and then chooses a
representative MIS within that regime.

The default high-level ranking policy 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.

Users may request the structural policy explicitly:

```python
result = misda.discovery(profile, rank_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.

## Abstention and assessment

If `profile.selected is None`, `discovery(profile)` returns an abstaining result
rather than inventing a reduction.

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.

## Data-quality boundary

`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.

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.

## Compatibility

- `misda.discover(Y, aggressiveness=...)` remains available.
- `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.

## Research basis

The default-policy and data-quality rationale is recorded in:

- `docs/research-notes/2026-10-ranking-policy-optimization.md`;
- `docs/research-notes/2026-10-noisy-ranking-safety.md`;
- `docs/research-notes/2026-10-noisy-ranking-supported-stress.md`;
- `docs/research-notes/2026-10-ranking-policy-noise-scale-and-default-hypothesis.md`.
7 changes: 4 additions & 3 deletions docs/adr/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,17 @@ Each record may contain: Context, Definitions, Decision, Formal specification, R
- [0008 — Canonical structural coverage ordering (superseded by ADR 0017)](0008-canonical-structural-coverage-ordering.md)
- [0009 — Explicit evaluation scope](0009-explicit-evaluation-scope.md)
- [0010 — Decision-stable sequential alpha-null estimation](0010-decision-stable-alpha-null.md)
- [0011 — Public API and object model](0011-public-api-and-object-model.md)
- [0011 — Public API and object model (public-flow section partially superseded by ADR 0022)](0011-public-api-and-object-model.md)
- [0012 — Reproducibility and stochastic computation](0012-reproducibility-and-stochastic-computation.md)
- [0013 — Benchmark and validation contract](0013-benchmark-and-validation-contract.md)
- [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)
- [0018 — Ranking-selected visualization views](0018-ranking-selected-visualization-views.md)
- [0019 — User-facing MIS, ranking, and evaluation workflow](0019-user-facing-mis-ranking-workflow.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)

All records below are retrospective unless explicitly stated otherwise. They document the current MISDA design, with later records superseding earlier decisions where explicitly stated.
All records below are retrospective unless explicitly stated otherwise. They document the current MISDA design, with later records superseding earlier decisions where explicitly stated.
99 changes: 84 additions & 15 deletions misda/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,21 @@

"""MISDA public API.

The alpha-stage public surface is intentionally small. Static analysis keeps
three responsibilities separate:
The canonical user workflow separates structural regime diagnosis from the
final representative choice::

``discover`` -> structural inference and MIS universe
``MISSet.evaluate`` -> candidate-level evidence
``rank`` -> an ordered view whose ``mis()`` selector exposes one MIS
profile = misda.profile(Y)
result = misda.discovery(profile)

The module-level ``evaluate(mis_set, ...)`` form remains public and equivalent.
Adaptive analysis and the previous ``analyze``/``heavy`` result model are not
part of this API.
The lower-level ``discover`` / ``evaluate`` / ``rank`` primitives remain public
for scientific instrumentation and advanced use.
"""

from ._metadata import __version__

# The canonical discovery implementation lives in ``api``. Correlation
# selection is injected only at the statistics boundary so Pearson and the
# experimental Spearman backend share the complete downstream pipeline.
# The canonical low-level discovery implementation lives in ``api``.
# Correlation selection is injected only at the statistics boundary so Pearson
# and the experimental Spearman backend share the complete downstream pipeline.
from . import api as _api
from ._correlation_backend import (
compute_correlation_statistics as _compute_correlation_statistics,
Expand Down Expand Up @@ -53,8 +51,17 @@
ParetoMetrics,
Ranking,
ReductionAssessment,
StructuralMetrics,
rank,
)
from ._profile import (
ABSTAINED,
DiscoveryResult,
Profile,
ProfileRegime,
discovery as _discovery_high_level,
profile as _profile_impl,
)


def discover(
Expand All @@ -67,9 +74,9 @@ def discover(
correlation="pearson",
experimental=False,
):
"""Discover the complete static structural MIS universe.
"""Low-level discovery of the complete static structural MIS universe.

Pearson is the canonical MISDA correlation backend. Spearman is retained
Pearson is the canonical MISDA correlation backend. Spearman is retained
for reproducible research and requires the explicit opt-in
``experimental=True``.
"""
Expand All @@ -82,8 +89,6 @@ def discover(
name=name,
cancel_requested=cancel_requested,
)
# MISSet is intentionally a mutable result container for evaluation state;
# record the discovery backend so experimental results remain auditable.
result.correlation = backend
result.experimental = backend != "pearson"
return result
Expand All @@ -93,6 +98,64 @@ def discover(
# that import the implementation module directly.
_api.discover = discover


def profile(
Y,
*,
seed=123,
name=None,
cancel_requested=None,
correlation="pearson",
experimental=False,
):
"""Map distinct structural regimes across the calibrated alpha path."""

with _correlation_backend(correlation, experimental) as backend:
result = _profile_impl(
Y,
seed=seed,
name=name,
cancel_requested=cancel_requested,
)
result.correlation = backend
result.experimental = backend != "pearson"
for regime in result:
regime.mis_set.correlation = backend
regime.mis_set.experimental = backend != "pearson"
return result


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.

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.
"""

if isinstance(source, Profile):
return _discovery_high_level(source, rank_policy=rank_policy)
observed_profile = profile(
source,
seed=seed,
name=name,
cancel_requested=cancel_requested,
correlation=correlation,
experimental=experimental,
)
return _discovery_high_level(observed_profile, rank_policy=rank_policy)


from ._pareto_stability import ParetoStabilityDiagnostics, evaluate
from . import _reporting as _reporting # installs the legacy-complete MISSet report
from . import _front_plotting as _front_plotting # installs graph/front plot views
Expand All @@ -115,6 +178,7 @@ def discover(
"UNSUPPORTED_REDUCTION",
"STRUCTURAL_COVERAGE",
"PARTIALLY_SUPPORTED",
"ABSTAINED",
"StructuralMetrics",
"JackknifeMetrics",
"LinearMetrics",
Expand All @@ -130,6 +194,11 @@ def discover(
"DiscoveryAnalysis",
"MISSet",
"Ranking",
"ProfileRegime",
"Profile",
"DiscoveryResult",
"profile",
"discovery",
"discover",
"evaluate",
"rank",
Expand Down
Loading
Loading