Repository navigation
MC-2 follow-ups: refuse reference cycles and duplicate keys, no name guess for described tables, guide() description, v10 golden (#631) - #632
Conversation
…guess for described tables, guide() description, v10 golden (#631) - The experiment block's references must not form a cycle (A -> B -> A, or longer): refused as experiment_block_malformed, naming the cycle. - read_coverage parses coverage.json with an object_pairs_hook: a key named twice in one JSON object is refused as experiment_block_malformed, never read last-wins. - Tables that carry condition_id get no control guessed from the names, with or without their coverage.json; the scan says the controls come from the description or are declared by ID, and the guided session proposes no control by name either. With a description, its control is listed first (it was first only when it was also the name guess). - guide(description=...): the control questions are skipped when the description gives the controls; its target suggestions are shown and the user confirms, edits or leaves them (Enter leaves them). An export without the block is asked until a control is declared. The confirmed targets are saved with the answers; answers saved with a description are not reused without it. - described_setup takes its description positionally only, so Setup's own experiment field (the correction families) reaches the Setup (it raised a TypeError from a described scan). - Golden export of Spec fixture v10 (a reference chain), from MorphoFeature main d33c628 with preprocessing 0.5.1, CellPatcher 0.4.0, normalization 0.4.0; the other four re-made byte-identical. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01G3qp9AxjpGPw9xfWAUJNqc
The control order moves to _conditions and the described-table lookup to _described; behaviour unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01G3qp9AxjpGPw9xfWAUJNqc
) - Owner question 3 (2026-11-12): for tables that carry condition_id, the scan's "Several conditions are compared" suggestion points to the experiment description's target suggestions (or a grouping declared by condition ID), not to a 'target' column. Undescribed tables keep the 'target' column hint. - _refuse_cycles walks each condition once (conditions already known to reach a root are not walked again), so a deep chain no longer costs O(n^3): a 3000-condition chain took ~35 s, now well under 1 s, with the same acceptance and the same cycle messages. - Regression tests: test_a_described_table_is_pointed_to_the_descriptions_targets, test_a_deep_chain_is_read_and_a_long_cycle_named (also a chain running into a cycle names only the cycle). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WX6rdMV1r5jUPUR94kxV5a
Independent review: approve, with one fix commit (6381376)Owner answers (2026-11-12): all four recommendations accepted.
What I checked
Fix commit 6381376
Gate on 6381376
Minor note, not blocking. Take a description that has a block but no references, where the user answers "no control". The saved answers then read "Control: the experiment description's references". That is true, since there are none, but it reads less plainly than "none". 🤖 Generated with Claude Code Generated by Claude Code |
Fixes #631. These are the follow-ups to MC-2 (#630, merged 60cb7c4). The block's rules come from MorphoFeature's design note
docs/restart/designs/coverage-experiment-block-2026-11-12.md(branchclaude/restart-doc). Nothing is inferred from a folder name.Owner questions (each with my recommendation first)
scan.setup()still refuses until a control is declared. The alternative iscoverage.jsonfrom ✅ toreagent_groups(names likesiX#1/siX#2). The guided "several controls" path: members by name stem, a parent when a name extends another (VEC_SiNCunderVEC), and treatment keys. This PR suppresses only the control guess: the scan'scontrol_guess, and the guided session'sproposed_controls, which is the same guess. Recommend suppressing the rest too whenever the tables carrycondition_id, in a follow-up. Design note §4.2 already forbids reagent groups from names once a run is described.condition_idtables it point to the description's target suggestions rather than atargetcolumn."targets": nullin every guided session. Older files still load because the field defaults toNone. Recommend noANSWERS_VERSIONbump.What changes
experiment_block_malformed, and the message names the cycle (experiment.references form a cycle (VEC -> VEC_SiCol6a1 -> VEC_SiNC -> VEC)). Chains that end at a root, as in v10, are accepted. Code:_described_shape._refuse_cycles.read_coveragenow parses with anobject_pairs_hook. A key named twice in one object, anywhere incoverage.json, is refused asexperiment_block_malformedand never read last-wins.condition_id. This holds with or withoutcoverage.json. The column is read wherenamed_by_idreads it: the FOV table, or the observation table when there is no FOV table.scan.setup()without a control says "declare the control by its condition_id, or give the scan the experiment description".proposed_controls).guide(description=...).Answers.targets) and from there intoSetup(targets=...).experiment_block_missing), the session asks for a control until one is declared, instead of crashing later inSetup.workflows/_guided_described.py.tests/morphofeature_exports/v10, a reference chain) was made withmake_exports.py.d33c6284e4a860eff08cbdfcc098c8069e963234(recorded inprovenance.json), preprocessing 0.5.1, CellPatcher 0.4.0, normalization 0.4.0, numpy 2.5.4, pandas 3.1.1, Python 3.13.18.NAMESnow includes v10.Bug found on the way:
described_setup(experiment, **fields)clashed withSetup's ownexperimentfield (the correction families). As a result,scan.setup(..., experiment=...)on a described scan raisedTypeError, and every guidedAnswers.setupdoes exactly that. The first parameter is now positional-only. Regression test:test_a_described_scan_takes_the_setups_own_experiment_field.Regression tests (
tests/test_described_followups.py)I ran the new file against main's
src, with the v10 folder copied in: 19 failed, 6 passed.test_references_that_form_a_cycle_are_refused×3 (2-cycle, 3-cycle, a second chain's 2-cycle)test_a_key_named_twice_is_refused×3 (inreferences, inexperiment, top-levelschema_version)test_without_the_coverage_json_no_control_is_guessed_by_name×3,test_condition_id_in_the_observation_table_alone_is_a_described_table,test_the_scan_lists_the_descriptions_control_firsttest_guide_*tests. On mainguidehas nodescriptionparameter.test_every_fixture_has_an_exportandtest_the_v10_golden_is_the_chain_of_its_descriptionfailtest_a_described_scan_takes_the_setups_own_experiment_fieldThese 6 pass on main and stay as guards: chain accepted, goldens have no duplicate keys, declared control gets no finding, blockless + description, v10 golden (folder copied in), and one more.
I updated three existing assertions that encoded the old behaviour:
test_described.py: the blockless scan's guess is nowNone.test_morphofeature_exports.pyv33: the conditions are["DrugA", "ctrl"]with no guess, and the image table'sctrlrow comes second.Before/after on v03/v27/v30/v33 (main 60cb7c4 vs this branch)
Byte-identical for all four fixtures:
read_coveragerepr;DescribedExperiment.summary();scan_design(..., description=...).summary();described_setup;Setuprepr from the described scan.Changed, by design (item 3):
scan_design(objects, fovs)without a description, on tables that carrycondition_id. Exactly, for v33:The other three fixtures change the same way:
CTRL (named like a control; not declared)becomesCTRL. v03 also saysrep1 and rep2: CTRLwhere it saidthe control only, because the repeat lines no longer know a control.These changes are intended. Without the description, the only way to call
CTRL/ctrla control was to read it as a name. #631 item 3 and design note §3.4/§4.2 forbid that once a run is described. The target suggestion is owner question 3.Guided session without a description (item 3 again): all four still guess no control. The control default becomes "no control", so the positive-control question is not offered, and the tests line reads "No control is declared…". In v03, the gate no longer proposes "several controls" from
CTRL's name. The saved answers gain"targets": null(owner question 4).Guided session with a description (new): no control question. The tests come from the description. For v27, the suggestions
SRC: DrugA and DrugC/src: DrugBare asked with "leave them unconfirmed" as the default.Gate (on 7eb5caf, Python 3.13.18; venv inside the work folder)
pytest -n 0 tests/test_guards.py tests/test_function_guards.py tests/test_function_tools.py: 102 passed, 1 warning.python tools/audit.py --check-against origin/main: baselines only tightened against origin/main.python -m ruff check src tests data: All checks passed.python -m ruff format --check src tests data: 534 files already formatted.pytest -n 3 -rs: 4647 passed, 2 skipped, 6 xfailed (16 min 56 s). Both skips aretests/test_morphobricks_constants.py:21: "morphobricks-preprocessing is not installed (MorphoCoverage does not depend on it, D-g)".checksuccess,spec-pinsuccess.data/reference). No committed dataset carriescondition_id(grep ofdata/), so item 3 cannot change any of their outputs.🤖 Generated with Claude Code
https://claude.ai/code/session_01G3qp9AxjpGPw9xfWAUJNqc