Skip to content

Quick fixes B: channel QC, previews, notebook cards and state, results lifecycle - #530

Merged
guijacquemet merged 17 commits into
mainfrom
claude/quick-fixes-b
Nov 25, 2026
Merged

guijacquemet merged 17 commits into
mainfrom
claude/quick-fixes-b

Conversation

@guijacquemet

@guijacquemet guijacquemet commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Second half of the quick-fix batch from the 24 November 2026 triage (groups 7 to 11). One commit per issue, each with a regression test that fails on main (75cde57) and passes here. Groups 1 to 6 are in a separate PR.

Closes #395
Closes #428
Closes #433
Closes #469
Closes #481
Closes #514
Closes #521
Closes #523
Closes #524
Closes #527

Summary (by module)

Decisions / notes for review

Tests

Review fixes (24 Nov)

This section supersedes the #395 lines of the summary and decisions above (and the note "No new refusal codes": ambiguous_channel_swap is a new warning code, documented in the contract and user guide).

#395 rewritten: mutual swaps are chosen by strength, never by channel name. The first version ("first pair in sorted channel-name order wins") was misleading: with A ref (1000,125,5000), B ref (4000,500,20000), C ref (800,100,4000) and a unit where A shows B's content, B shows exactly C's reference and C shows B's content, it reported "A and B look swapped", although B <-> C is the swap (distance 0 both ways), and renaming the channels flipped the answer.

  • Ranking rule. A candidate mutual pair is found as before (a reported channel whose nearest channel c' is in its unit, both leaning on each other by partner_ratio, within outlier_limit). Its strength is the larger of its two cross distances max(d(u, c -> c'), d(u, c' -> c)); smaller is stronger. Pairs are taken greedily from the strongest, each channel in one pair at most. A channel not in a chosen pair keeps its plain "does not look like X but like Y" finding (unchanged message format for clear single swaps).
  • Tolerance. When the strongest remaining pair shares a channel with other remaining pairs of the unit (directly or through each other) whose strengths are within PAIR_TOLERANCE = 0.5 (distance units; now the recorded limit pair_tolerance, see "Owner decision" below), none is chosen: a new warning code ambiguous_channel_swap names every channel of the group, each with its own distance and its distances to the channels it could be swapped with, says no pair is named, and its action says to check every channel named. ChannelFinding.alternatives holds (channel, distance) per alternative. The answer does not depend on channel names or input order (equal-strength pairs either do not share a channel or are in one ambiguous group).
  • Notebook: row label "Swap, pair unclear", its own "What to do"; the plot labels an ambiguous point with every alternative (no arrow). Contract §14.1 (new table row, warning list), user guide (codes table and CLI paragraph), AGENTS.md repo map, module docstring and CHANGELOG updated.
  • Tests (tests/test_channel_identity_pairs.py, new file because tests/test_channel_identity.py would exceed the 600-line rule): the review's unequal case (B <-> C mutual, A plain possible_channel_swap look-alike of B); the same data under all 6 permutations of channel names, each also with the images reversed; an exact tie (A and C identical references, B swapped with both) giving one ambiguous_channel_swap naming A, B and C; plus a notebook test of the ambiguous row. The earlier test_a_channel_keeps_one_swap_partner (that same tie) was replaced by the ambiguous test.
  • Fail before, pass after: against 475c06e's source, the unequal-case test, the permuted-names test (ABC, ACB fail; the other 4 permutations happened to be right) and the tie test fail (4 failed, 4 passed); all 8 pass after.

#433: NumPy whole numbers accepted. header_preview.checked_shown (shared by ViewRequest and header_channels) accepts numbers.Integral but not bool (nor numpy.bool_) and returns an int. New test with np.int64(1), np.uint8(2), np.int32(6) (all 3 fail before: the check refused them), and False, np.bool_(True), np.int64(0) added to the refusals. notebook_viewer.py:305 builds ViewRequest without shown, so it uses CHANNELS_SHOWN = 6, a valid int.

Verification (local, Python 3.13, .[dev,zarr,notebook]): tests/test_channel_identity.py, tests/test_channel_identity_pairs.py, tests/test_channel_identity_run.py, tests/test_notebook_channel_identity.py, tests/test_image_viewer.py, tests/test_preview.py and the other tests that use the viewer or the channel card (test_notebook_axes_example, test_notebook_debt, test_notebook_projection, test_notebook_row_fold, test_run_page_labels): 163 passed, 0 skipped. ruff check ., ruff format --check . and python tools/check.py --rules are clean. Not run: the full suite and tools/check.py.

Owner decision (24 Nov): the pair tolerance is a recorded limit (84b96a5)

PAIR_TOLERANCE becomes ChannelIdentitySettings.pair_tolerance (default 0.5; PAIR_TOLERANCE is that default). It is written to the run manifest's channel_identity with the seven other limits and read back, so a clean-vs-ambiguous verdict can be reproduced from the manifest. _choose takes the tolerance from the settings; the ambiguous warning ("within X robust deviations …") and the printed limits name the tolerance used. Validation: a finite number of at least 0 (negative, NaN, infinite, boolean, string or None refused; 0 means only exact ties are ambiguous).

  • Absent key: option (a), read as 0.5, explicitly. from_dict still requires every key, with one documented exception: limits recorded without pair_tolerance are read with 0.5, because earlier code used 0.5 as a constant. No released version recorded these limits or produced ambiguous_channel_swap (the channel check is not in v0.8.0; the ambiguity rule is new and unreleased in this PR), so an absent key only means that no ambiguity rule was recorded. Stated in the from_dict docstring, contract §9 (channel_identity row) and CHANGELOG. An unknown key, or any other missing key, is still refused. The manifest version does not change.
  • v0.8.0 runs still open: a run written by v0.8.0 (installed from the tag in a separate venv) has no channel_identity key; with this branch read_manifest gives channel_identity = None and RunInputs.open succeeds.
  • Exposure: settings API only. None of the channel-check limits (mad_floor, outlier_limit, partner_ratio …) has a CLI option or notebook field (the CLI's --outlier-limit is the intensity checks'), so pair_tolerance is set through check_channel_identity(summaries, ChannelIdentitySettings(pair_tolerance=…)), documented in contract §14.1 and the user guide.
  • Tests: recorded round-trip (to_dict/from_dict and through run_manifest.json); the near-tie cases parametrized by the recorded setting (strengths 0 vs ~0.46 and 0 vs ~0.63 with tolerance 0.3 / 0.5 / 0.8: 0.3 makes both clean, 0.8 makes both ambiguous); limits without the key read as 0.5; a manifest without channel_identity reads as None; invalid values refused in the settings and when the manifest is read; the limits text names the tolerance.
  • Fail before, pass after: with the new tests against e660cbf's source, 11 failed / 47 passed (the 9 new tests and cases, plus the 2 existing near-tie tests whose spy now passes the tolerance); after, all pass.
  • Verification (local, Python 3.13, .[dev,zarr,notebook]): tests/test_channel_identity*.py + tests/test_notebook_channel_identity.py: 63 passed, 0 skipped; tests/test_manifest*.py, tests/test_run_inputs_manifest_sha256.py, tests/test_cli.py: 224 passed, 0 skipped. ruff check ., ruff format --check ., python tools/check.py --rules clean. Not run: the full suite and tools/check.py.

🤖 Generated with Claude Code

https://claude.ai/code/session_01G3qp9AxjpGPw9xfWAUJNqc

A third channel whose nearest channel is already paired in a mutual swap no
longer overwrites that partner's pairing; it stays a plain swap finding, so
one channel is never reported in two incompatible swaps.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01G3qp9AxjpGPw9xfWAUJNqc
The same file read through other roles names other pixels for the same
coordinates, so the roles (axes, roles, singleton roles) are now part of the
PreviewCache key, for reads and for the discard after a rewrite.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01G3qp9AxjpGPw9xfWAUJNqc
ViewRequest and header_channels now raise a ValueError naming the value when
the number of channels to draw is not a whole number of at least 1, instead
of an IndexError, AttributeError or ZeroDivisionError after reading.

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

The tissue-mask preview and write, and the tissue-mask command, now catch
PlaneReadError (PlaneMemoryError, CompressionNotBoundedError) and OSError
with the other refusals: the card replaces its working status with the
message and hides an earlier preview, and the command prints the image's
refusal and exits 1 instead of a traceback.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01G3qp9AxjpGPw9xfWAUJNqc
The Convert a mask card showed a green 'The mask is converted.' for a source
with no recorded files. It now shows a red card naming the mask ID and source
type and writes nothing. The button is not disabled ahead of time: the card
refreshes on the description only, so the manifest is read at the click,
never a stale copy.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01G3qp9AxjpGPw9xfWAUJNqc
RowFold.arrange returned early when no row folded and kept the previous
fold's rows (and their images and callbacks) in its hidden box and its line.
It now empties both first.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01G3qp9AxjpGPw9xfWAUJNqc
The row was rebuilt only for other axis letters, so an image with the same
letters and other lengths kept the previous image's lengths in its labels.
It is now keyed by the letters and the shape; the roles chosen for the
letters are kept.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01G3qp9AxjpGPw9xfWAUJNqc
_LogCapture.lines is now a deque of the latest 500 lines, the ones the panel
showed; older records are dropped instead of held for the whole session.
Direct appends of tracebacks keep working.

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

The results were cleared only when the table's path changed, so a rerun to
the same path kept the old statistics, tiles, plot and the 'use the planes
that have the channel' answer for a new table. The clearing is now
_forget_comparison(), called by a path change and by every run that wrote
its table.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01G3qp9AxjpGPw9xfWAUJNqc
An invalid percentile list (out of 0-100, NaN, inf) returned before the old
table, tiles and plot were hidden, so they stayed on screen under a choice
they were not calculated with. The refusal and the missing-table branch now
hide them with _hide_statistics(); the table's checks and the partial-presence
answer are kept, since the table did not change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01G3qp9AxjpGPw9xfWAUJNqc
, #524, #527)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01G3qp9AxjpGPw9xfWAUJNqc
Candidate mutual pairs are ranked by the larger of their two cross
distances and taken greedily from the strongest, each channel in one
pair at most. Pairs sharing a channel within PAIR_TOLERANCE (0.5) are
one ambiguous_channel_swap warning naming every channel, no pair picked.
The review's case now reports B and C, whatever the channel names.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01G3qp9AxjpGPw9xfWAUJNqc
checked_shown accepts numbers.Integral (not bool) and returns an int;
ViewRequest and header_channels share it. Changelog for #395 and #433.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01G3qp9AxjpGPw9xfWAUJNqc
Tests: a near-tie just inside and just outside PAIR_TOLERANCE (strengths
computed in the test and asserted to straddle it), two independent swaps,
an ambiguous group beside a clean swap, a 3-cycle (three plain look-alikes,
locked), name and image-order independence of the ambiguous case, and
units/conditions that do not interact.

Wording: the ambiguous warning says the pairs are within the tolerance in
robust deviations of the larger cross distance, and that look-alike
alternatives are why no pair can be chosen. Contract 14.1, user guide and
CHANGELOG updated. PAIR_TOLERANCE and its computation are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01G3qp9AxjpGPw9xfWAUJNqc
PAIR_TOLERANCE, which decides between a clean possible_channel_swap and an
ambiguous_channel_swap, becomes ChannelIdentitySettings.pair_tolerance
(default 0.5; finite and at least 0), written to the run manifest's
channel_identity with the seven other limits and read back, so a verdict
can be reproduced from the manifest. The ambiguous warning and the printed
limits name the tolerance used.

Limits recorded without pair_tolerance are read with 0.5, explicitly:
earlier code used 0.5 as a constant, and no released version recorded
these limits or produced ambiguous_channel_swap (v0.8.0 manifests have no
channel_identity at all and still read as None). Every other key stays
required. No CLI option or notebook field exists for any channel-check
limit, so it is exposed through the settings API only.

Contract §9 and §14.1, user guide, CHANGELOG.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01G3qp9AxjpGPw9xfWAUJNqc
@guijacquemet
guijacquemet marked this pull request as ready for review November 25, 2026 08:14
@guijacquemet
guijacquemet merged commit 5b54d0a into main Nov 25, 2026
3 checks passed
@guijacquemet
guijacquemet deleted the claude/quick-fixes-b branch November 25, 2026 08:14
guijacquemet pushed a commit that referenced this pull request Nov 25, 2026
guijacquemet pushed a commit that referenced this pull request Nov 25, 2026
…547, #546) into the v0.9.0 release branch

No conflicts. The notebooks' RELEASE_REF, the RELEASE_CALLS entry and the pin assertion are
put back to their pre-pin values (the release branch carried commit B's pins), so that the
next commit is the preparation commit A and commit B moves them. CHANGELOG: #543 and #544
were not in the v0.9.0 section and are added; the others already were.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WX6rdMV1r5jUPUR94kxV5a
guijacquemet pushed a commit that referenced this pull request Nov 25, 2026
The full python tools/check.py on the tree of the merge commit 5e11bc9 (main at c8c3808 with
#528, #534, #543, #545, #544, #530, #548, #547 and #546): Ruff clean, 760 files formatted,
pytest 8813 passed and 12 skipped, code rules passed; the Spec modules 2122 passed, 0 skipped;
the notebook pin and version tests 49 passed. Docs only: this commit is the v0.9.0 preparation
commit A that commit B pins.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WX6rdMV1r5jUPUR94kxV5a
@guijacquemet guijacquemet mentioned this pull request Nov 25, 2026
3 of 9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants