Repository navigation
Refuse results without an acquisition identity; redundancy records one (Q-MC-a) - #637
Merged
Merged
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_acquisitionreturned the names of results that "record no identity (rebuilt or older)".microscopist_reportthen assembled them with a note instead of checking them. A result without an identity was also accepted when it was the only result passed.redundancywas a plainpd.DataFrameand recorded no identity.Now
redundancy_distancereturns aRedundancyResult. It is a frozen, owned dataclass, the same pattern asEfficiencyResult. 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_unitandobservation_unit_declared.It is exported from
morphocoverage.retrospective.microscopist_report(redundancy=...)now takes this type and refuses a DataFrame withTypeError.optimise(..., redundancy_bins=...)stores it inPlan.results["redundancy"].Any result without an acquisition identity is refused (
ValueError), on its own or beside other results.check_one_acquisitionnow returnsNone._acquisition.unchecked_noteand the note path in_report_assembly._first_notesare removed. Results from two different acquisitions are still refused, as before.representation_controlwith 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:
tests/unrecorded.pyhelper only removed a result's identity, which is no longer allowed. It is replaced bytests/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.ControlResultbuilders now record that test identity.tests/test_acquisition_identity.py:microscopist_reporttakes and asserts thatresult_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.fov_variability's;redundancyraisesTypeError.tests/test_workflows.py::test_optimise_measures_the_redundancy_distance_with_stage_coordinatescoversoptimise(..., redundancy_bins=...)end to end. It also checks that redundancy's identity equals efficiency's. The table it compares is unchanged.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.pynow writesredundancy.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 aretests/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.controls.pyfix is reverted.I did not merge or tag.
🤖 Generated with Claude Code
https://claude.ai/code/session_01WX6rdMV1r5jUPUR94kxV5a