Skip to content

Refuse results without an acquisition identity; redundancy records one (Q-MC-a) - #637

Merged
guijacquemet merged 3 commits into
mainfrom
claude/mc-acquisition-identity
Nov 18, 2026
Merged

guijacquemet merged 3 commits into
mainfrom
claude/mc-acquisition-identity

Conversation

@guijacquemet

@guijacquemet guijacquemet commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Implements owner decision Q-MC-a (compat-sweep inventory 2026-11-13, §5 and §12). This makes the no-mixing-of-acquisitions refusal stronger. It does not weaken it.

Before

check_one_acquisition returned the names of results that "record no identity (rebuilt or older)". microscopist_report then assembled them with a note instead of checking them. A result without an identity was also accepted when it was the only result passed. redundancy was a plain pd.DataFrame and recorded no identity.

Now

  • redundancy_distance returns a RedundancyResult. It is a frozen, owned dataclass, the same pattern as EfficiencyResult. It has two fields:

    • table: the per-group DataFrame, unchanged.
    • settings: acquisition (acquisition_identity(data)), feature_cols, stage_cols, bin_edges, share, stage_unit, n_permutations, random_state, observation_unit and observation_unit_declared.

    It is exported from morphocoverage.retrospective. microscopist_report(redundancy=...) now takes this type and refuses a DataFrame with TypeError. optimise(..., redundancy_bins=...) stores it in Plan.results["redundancy"].

  • Any result without an acquisition identity is refused (ValueError), on its own or beside other results. check_one_acquisition now returns None. _acquisition.unchecked_note and the note path in _report_assembly._first_notes are removed. Results from two different acquisitions are still refused, as before.

  • representation_control with no positive control (the "not assessed" result) now validates the tables and records their identity before its early return. Before this fix it returned before the identity was added, so the report would have refused a valid result.

  • Tests:

    • The tests/unrecorded.py helper only removed a result's identity, which is no longer allowed. It is replaced by tests/one_acquisition.py:stamped, which stamps one declared test identity. That identity is not a SHA-256, so it can never collide with a real one.
    • Hand-made ControlResult builders now record that test identity.
    • New tests in tests/test_acquisition_identity.py:
      • One parametrised test runs every result producer that microscopist_report takes and asserts that result_identity(r) equals the identity of the tables. Not-assessed and empty paths are included: controls without a positive control, contrast, ranking and discovery with the control only, and redundancy with no pair of fields within the bins. Derived results are included: calibration, adequacy, efficiency and protocol. A second test checks that every report result type has a producer under test.
      • a result without an identity is refused, alone and beside others;
      • redundancy records its identity, which equals fov_variability's;
      • redundancy computed on another acquisition is refused;
      • a not-assessed control is accepted by the report;
      • a bare DataFrame passed as redundancy raises TypeError.
    • tests/test_workflows.py::test_optimise_measures_the_redundancy_distance_with_stage_coordinates covers optimise(..., redundancy_bins=...) end to end. It also checks that redundancy's identity equals efficiency's. The table it compares is unchanged.
    • The p8_2 report test used to compare a table with itself. It now checks the settings the redundancy result records.
  • Docs: AGENTS.md (a new scientific rule, "One report, one acquisition"), docs/report/questions.md, docs/optimise/optimise.md, CHANGELOG.md (Unreleased, Changed) and the regenerated function index. data/crick_idr/report_steps_idr0028.py now writes redundancy.table.

Verification (head acd6d65)

Run in a fresh venv with pip install --no-cache-dir -e ".[dev]" on Python 3.13:

  • pytest -n 4: 4688 passed, 2 skipped, 6 xfailed, 0 failed. Both skips are tests/test_morphobricks_constants.py, because morphobricks-preprocessing is not installed.
  • python tools/audit.py --check-against origin/main: "baselines only tightened against origin/main" (exit 0).
  • ruff check src tests data: all checks passed.
  • ruff format --check src tests data: 534 files already formatted.
  • The two new controls tests fail when the controls.py fix is reverted.

I did not merge or tag.

🤖 Generated with Claude Code

https://claude.ai/code/session_01WX6rdMV1r5jUPUR94kxV5a

…e (Q-MC-a)

Owner decision Q-MC-a: every result microscopist_report assembles must record
the acquisition it was computed on, and a result that records none is refused,
alone or beside others, instead of being assembled with a note.

- redundancy_distance returns a RedundancyResult (table, settings) whose
  settings carry the acquisition identity, like the other 18 result types;
  microscopist_report(redundancy=...) takes it and optimise stores it in
  Plan.results["redundancy"].
- check_one_acquisition raises on a missing identity; unchecked_note and the
  note path in _first_notes are removed.
- Tests: refusal of a result without identity (alone and with others),
  redundancy identity, refusal of mixed acquisitions via redundancy, optimise
  end to end. The tests' unrecorded helper becomes one_acquisition.stamped,
  which stamps one declared test identity instead of dropping it.
- Docs, AGENTS.md, CHANGELOG (Unreleased) and the function index updated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WX6rdMV1r5jUPUR94kxV5a
…eview)

Review of #637:
- representation_control without a positive control returned "not assessed"
  before validating the tables, so it recorded no acquisition identity and the
  report refused a valid result. It now validates and records the identity
  before the early return. Regression test added.
- One parametrised test runs every result producer microscopist_report takes,
  including the not-assessed and empty paths (controls without a positive,
  contrast/ranking/discovery with the control only, redundancy with no pair in
  the bins) and the derived results (calibration, adequacy, efficiency,
  protocol), and asserts result_identity equals the tables' identity; another
  checks every report result type is covered.
- The p8_2 report test compared a table with itself; it now checks the
  settings the redundancy result records.
- A bare DataFrame passed as redundancy is refused with TypeError (test).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WX6rdMV1r5jUPUR94kxV5a
Each producer case now asserts it returns exactly the report type of its keyword, and the
completeness test compares the case keywords with the report's keywords; it previously
compared a set with itself. Mutation check: an adequacy case returning a protocol result
now fails.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WX6rdMV1r5jUPUR94kxV5a
@guijacquemet
guijacquemet merged commit 209b9be into main Nov 18, 2026
2 checks passed
@guijacquemet
guijacquemet deleted the claude/mc-acquisition-identity branch November 18, 2026 20:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants