From 5e7129861ba08f9bb73421cacde9f2b8e559156d Mon Sep 17 00:00:00 2001 From: Antoni Ivanov <262547018+tony-xmelon@users.noreply.github.com> Date: Thu, 3 Sep 2026 23:53:19 +0300 Subject: [PATCH 1/8] Resolve cloned ModelRepo parameters --- pyquadcortex/protocol/catalog.py | 62 ++++++++++++++++++++++- tests/test_catalog.py | 85 ++++++++++++++++++++++++++++++++ 2 files changed, 145 insertions(+), 2 deletions(-) diff --git a/pyquadcortex/protocol/catalog.py b/pyquadcortex/protocol/catalog.py index 30777f81..7d93ccb6 100644 --- a/pyquadcortex/protocol/catalog.py +++ b/pyquadcortex/protocol/catalog.py @@ -634,10 +634,66 @@ def _parameter(index: int, p, model_name: str) -> Parameter: ) +def _effective_parameter_elements( + model, + models: dict[int, ET.Element], + resolving: tuple[int, ...] = (), +) -> tuple[tuple[int, ET.Element], ...]: + """Return a model's parameters at their effective wire indexes. + + ModelRepo models may ``clone`` another model and publish only the + parameters they replace. Each child parameter's ``replaces`` attribute is + the inherited wire index; child parameters without one extend the inherited + list. This is used heavily by cabs, whose visible entries otherwise appear + to contain only two local parameters instead of the 21 controls on the + wire. + + A missing clone target is treated like an ordinary model. That preserves + the parser's tolerance of partial repositories while cycles are rejected: + there is no safe parameter layout to infer from a cycle. + """ + model_id = _as_int(model.get("id")) + if model_id is not None and model_id in resolving: + chain = " -> ".join(str(ident) for ident in (*resolving, model_id)) + raise ValueError(f"ModelRepo clone cycle: {chain}") + + clone_id = _as_int(model.get("clones")) + base = models.get(clone_id) if clone_id is not None else None + if base is None: + effective = list(enumerate(model.findall("Parameter"))) + else: + inherited = _effective_parameter_elements( + base, + models, + (*resolving, model_id) if model_id is not None else resolving, + ) + by_index = dict(inherited) + next_index = max(by_index, default=-1) + 1 + for parameter in model.findall("Parameter"): + replaced = _as_int(parameter.get("replaces")) + index = next_index if replaced is None else replaced + by_index[index] = parameter + next_index = max(next_index, index + 1) + effective = sorted(by_index.items()) + + indexes = [index for index, _ in effective] + if indexes != list(range(len(indexes))): + raise ValueError( + f"ModelRepo model {model_id} resolves to non-contiguous parameter " + f"indexes {indexes}" + ) + return tuple(effective) + + def parse_model_repo(payload: bytes) -> ModelCatalog: """Parse a device ModelRepo payload into a :class:`ModelCatalog`.""" root = ET.fromstring(_extract_xml(payload)) catalog = ModelCatalog() + elements = { + model_id: element + for element in root.iter("Model") + if (model_id := _as_int(element.get("id"))) is not None + } for category in root.findall("Category"): category_id = _as_int(category.get("id")) category_name = category.get("name", "") @@ -647,8 +703,10 @@ def parse_model_repo(payload: bytes) -> ModelCatalog: if model_id is None: continue parameters = tuple( - _parameter(i, p, element.get("name", "")) - for i, p in enumerate(element.findall("Parameter")) + _parameter(index, parameter, element.get("name", "")) + for index, parameter in _effective_parameter_elements( + element, elements + ) ) catalog.models[model_id] = Model( id=model_id, diff --git a/tests/test_catalog.py b/tests/test_catalog.py index ad35b557..27e334ef 100644 --- a/tests/test_catalog.py +++ b/tests/test_catalog.py @@ -125,6 +125,91 @@ def test_parameters_are_ordered_and_carry_metadata(cat): assert cat[5005].parameters[0].units == "dB" +def test_cloned_models_inherit_and_replace_parameters_at_wire_indexes(): + xml = SAMPLE_XML.replace("", """ + + + + + + + + +""") + + cab = catalog.parse_model_repo(make_payload(xml))[12001] + + assert [p.index for p in cab.parameters] == [0, 1, 2, 3, 4] + assert [p.name for p in cab.parameters] == [ + "BYPASS", "CHILD IR 1", "LEVEL", "CHILD IR 2", "EXTRA" + ] + assert cab.parameters[1].default == 0.0 # string defaults remain lenient + assert cab.parameters[2].units == "dB" # untouched inherited metadata + assert cab.parameters[4].default == 5.0 + + +def test_clone_inheritance_is_recursive(): + xml = """ + + + + + + + + + + + """ + + leaf = catalog.parse_model_repo(make_payload(xml))[3] + + assert [(p.index, p.name) for p in leaf.parameters] == [ + (0, "LEAF A"), (1, "MIDDLE B") + ] + + +def test_missing_clone_target_falls_back_to_local_parameters(): + xml = """ + + + + """ + + model = catalog.parse_model_repo(make_payload(xml))[1] + + assert [(p.index, p.name) for p in model.parameters] == [(0, "LOCAL")] + + +def test_clone_cycles_are_rejected(): + xml = """ + + + """ + + with pytest.raises(ValueError, match=r"clone cycle: 1 -> 2 -> 1"): + catalog.parse_model_repo(make_payload(xml)) + + +def test_non_contiguous_clone_indexes_are_rejected(): + xml = """ + + + + + + + """ + + with pytest.raises(ValueError, match="non-contiguous parameter indexes"): + catalog.parse_model_repo(make_payload(xml)) + + def test_lookup_parameter_by_name_is_case_insensitive(cat): assert cat[1].parameter("gain").index == 0 assert cat[1].parameter("TREBLE").index == 1 From 0490350835acbc6287afbdccb4193dbdda95932e Mon Sep 17 00:00:00 2001 From: Antoni Ivanov <262547018+tony-xmelon@users.noreply.github.com> Date: Tue, 8 Sep 2026 21:31:43 +0300 Subject: [PATCH 2/8] fix: resolve ModelRepo clone layouts defensively --- changelog.md | 7 ++ docs/domain-model.md | 16 +++- docs/protocol.md | 19 ++-- pyquadcortex/protocol/catalog.py | 69 +++++++++----- .../protocol/catalogs/coros_4_0_1/params.py | 28 +++--- pyquadcortex/protocol/targets.py | 82 +++-------------- scripts/generate_params.py | 45 +++++----- tests/fixtures/catalog_clones.json | 10 +++ tests/test_catalog.py | 89 +++++++++++++++++-- tests/test_client.py | 4 +- tests/test_targets.py | 73 +++++---------- 11 files changed, 249 insertions(+), 193 deletions(-) create mode 100644 tests/fixtures/catalog_clones.json diff --git a/changelog.md b/changelog.md index d8b2b27f..1b24adcf 100644 --- a/changelog.md +++ b/changelog.md @@ -20,6 +20,13 @@ correction. ## Unreleased +### ModelRepo clone layouts are resolved + +Models that declare `clones` now expose the inherited wire layout with numeric +parameter replacements applied before child-only extensions. This fixes both +ordinary and PCOM cab addressing and the cloned reverb families. A malformed +model falls back locally without discarding the rest of the device catalog. + ### The first hardware run of the profile seam, and what it corrected Run 2026-09-07 on Quad Cortex, CorOS 4.0.1 / d14e, straight after the seam diff --git a/docs/domain-model.md b/docs/domain-model.md index 1655684b..aeb979f0 100644 --- a/docs/domain-model.md +++ b/docs/domain-model.md @@ -1397,24 +1397,32 @@ the n/a rows below where they intersect the API at all. ## Catalog attributes we can see and cannot yet explain -The device puts **24** distinct attributes on its `` elements. Fourteen -are parsed. These are the other ten, recorded so the next person does not have to +The CorOS 4.0.1 catalog puts **24** distinct attributes on its 3,809 +`` elements. Fourteen are published on `Parameter`, and numeric +`replaces` is consumed while clone layouts are resolved. These are the other nine, +recorded so the next person does not have to rediscover that they exist. None is guessed at, per the rule that a control we do not understand is omitted with the reason written down. -The counts are from the shipped catalog, 3,809 parameters. +The counts below are from that CorOS 4.0.1 catalog. | attribute | on | what it looks like, and what is unknown | |---|---|---| | `displayPos` | 1446 | The order the unit lays knobs out on screen, which is not wire order. Nothing here needs it; a UI would. | | `hidden` | 650 | Present on a parameter, distinct from the `hidden` we already read on a ``. Whether it means "not shown on screen" or "not writable" is untested, and the two have very different consequences for a host. | -| `replaces` | 462 | Also distinct from the `` attribute of the same name, which we do parse. On a parameter it presumably names a superseded index, which would matter for reading an old preset - untested. | | `toggleOn`, `toggleOff`, `toggleStep` | 132 / 83 / 13, **212 parameters between them** | `toggleOn` carries a number (`4`, `5`, `6`) on `float` parameters such as a tremolo's `LEVEL`, and `toggleStep` sometimes carries a PAIR (`"0,1"`, `"1,2"`). The obvious reading is the two values a footswitch toggle alternates between - obvious, and untested. Driving one and watching the screen would settle it. | | `tooltip` | 126 | The help text the unit shows. Real prose, occasionally load-bearing: a Vibrato's `MODE` warns that changing it causes a brief mute. Note the values contain HTML (`
`), which is where an `align` "attribute" appears - it is markup inside the tooltip, not an attribute of the parameter. | | `selfTestValue` | 66 | A value the unit uses during its self test. Sometimes an IR name (`"NG_412 Plini Cab_Dynamic 57"`), sometimes a token (`"eltron_self_test"`). | | `mid_string` | 36 | The sibling of `min_string` and `max_string`, which we do read. Presumably a label at some middle position, but WHICH position is not stated anywhere, so it cannot be used. | | `isplayPos` | 1 | `displayPos` with the `d` missing. The device's own typo. Recorded rather than silently accepted as an alias, because a parser that took both would hide that the catalog has a defect. | +Numeric parameter `replaces` values are inherited wire indexes on a model that +declares `clones`; the parser now resolves those before publishing the model. +`Model/@clones` names the parent layout. A separate nonnumeric shape remains: +model 7029, `MX Vibe`, has `replaces="INTENSITY"` on a parameter while the model +itself supersedes another model. That name is not treated as an index; the model +falls back to its local parameter order until its meaning is understood. + On ``, `blob` is also unexplained: a same-length string of letters that **changes between fetches**. Two dumps of one unit taken minutes apart differed on 338 models and on nothing else. A per-fetch token of some kind, not content. diff --git a/docs/protocol.md b/docs/protocol.md index cc166d7d..84dbd8af 100644 --- a/docs/protocol.md +++ b/docs/protocol.md @@ -3095,11 +3095,19 @@ Two things make it valuable: per-category counters: category 4 (Equalizer) holds 4000-4007, category 21 (Cabsim Bass) holds 21001-21009. So hash 21003 resolves directly to "810 Amped VT Aln 70s (M)". -- **`` children are in wire-index order**, each with `min`, `max`, - `defaultValue` and `units`. This is what gives a parameter index meaning, and - it explains a puzzle from earlier work: writing index 0 of a cab moved no - visible knob because a cab's only parameters are internal `ir selector` - entries. +- **Resolved `` children are in wire-index order**, each with `min`, + `max`, `defaultValue` and `units`. A model may declare `clones`; numeric + parameter `replaces` values place the child's metadata at inherited indexes, + and child-only parameters extend the layout. + +Clone evidence is profile-specific. On 2026-09-08, a contributed CorOS 4.1.0 +catalog showed four cab parents: 12000 and 32000 have 21 catalog parameters, +while PCOM parents 12100 and 32100 have 31. Their corresponding wire records +carry 22 and 32 values. The same catalog has reverb children cloning model 8015; +`Gojira REV` resolves to 29 catalog parameters and 30 wire values. Read-only live +checks on that 4.1.0 unit confirmed the inherited indexes. The maintainer +independently confirmed the same layout shapes on CorOS 4.0.1, including child +replacement spans and `Gojira REV` parameter ordering. Parameter values on the wire are **normalized 0..1**, confirmed on hardware: sending `1.0` to a `THRESHOLD` whose catalog range is -60..+12 dB made the unit @@ -3315,6 +3323,7 @@ Attributes that classify a model: | `sku`, `plugin_id` | purchasable plugin content (the Archetype models); a given unit may not have it | | `hidden`, `internal` | not user-facing; `hidden` also appears on whole categories | | `replaces` | this model supersedes the listed id(s). Both stay in the catalog and they can share a display name - there are two "Graphic-9" equalizers, 4005 replacing 4002 | +| `clones` | this model inherits another model's parameter layout; numeric parameter-level `replaces` values override inherited wire indexes | Because the catalog comes FROM the device it also covers Neural Captures (categories 14 and 20), which are user content. That is why the library ships diff --git a/pyquadcortex/protocol/catalog.py b/pyquadcortex/protocol/catalog.py index 7d93ccb6..c701da3a 100644 --- a/pyquadcortex/protocol/catalog.py +++ b/pyquadcortex/protocol/catalog.py @@ -642,18 +642,19 @@ def _effective_parameter_elements( """Return a model's parameters at their effective wire indexes. ModelRepo models may ``clone`` another model and publish only the - parameters they replace. Each child parameter's ``replaces`` attribute is - the inherited wire index; child parameters without one extend the inherited - list. This is used heavily by cabs, whose visible entries otherwise appear - to contain only two local parameters instead of the 21 controls on the - wire. - - A missing clone target is treated like an ordinary model. That preserves - the parser's tolerance of partial repositories while cycles are rejected: - there is no safe parameter layout to infer from a cycle. + parameters they replace. Each child's numeric ``replaces`` attribute is the + inherited wire index; child parameters without one extend the resolved + list. On a contributed CorOS 4.1.0 catalog (2026-09-08), cabs clone four + different 21- or 31-parameter layouts and a reverb family clones model + 8015. The maintainer confirmed the same shapes on CorOS 4.0.1. + + A missing clone target is treated like an ordinary model. A malformed + clone (including a cycle) raises here so :func:`parse_model_repo` can fall + that model back to its local parameters without discarding the catalog. """ model_id = _as_int(model.get("id")) - if model_id is not None and model_id in resolving: + assert model_id is not None + if model_id in resolving: chain = " -> ".join(str(ident) for ident in (*resolving, model_id)) raise ValueError(f"ModelRepo clone cycle: {chain}") @@ -662,18 +663,36 @@ def _effective_parameter_elements( if base is None: effective = list(enumerate(model.findall("Parameter"))) else: - inherited = _effective_parameter_elements( - base, - models, - (*resolving, model_id) if model_id is not None else resolving, - ) + inherited = _effective_parameter_elements(base, models, (*resolving, model_id)) by_index = dict(inherited) - next_index = max(by_index, default=-1) + 1 + replacements = [] + extensions = [] for parameter in model.findall("Parameter"): - replaced = _as_int(parameter.get("replaces")) - index = next_index if replaced is None else replaced + raw = parameter.get("replaces") + if raw is None: + extensions.append(parameter) + continue + replaced = _as_int(raw) + if replaced is None: + raise ValueError( + f"ModelRepo model {model_id} has non-numeric parameter " + f"replaces={raw!r}" + ) + replacements.append((replaced, parameter)) + + seen = set() + for index, parameter in replacements: + if index in seen: + raise ValueError( + f"ModelRepo model {model_id} replaces parameter index " + f"{index} more than once" + ) + seen.add(index) by_index[index] = parameter - next_index = max(next_index, index + 1) + next_index = max(by_index, default=-1) + 1 + for parameter in extensions: + by_index[next_index] = parameter + next_index += 1 effective = sorted(by_index.items()) indexes = [index for index, _ in effective] @@ -702,11 +721,17 @@ def parse_model_repo(payload: bytes) -> ModelCatalog: model_id = _as_int(element.get("id")) if model_id is None: continue + try: + effective = _effective_parameter_elements(element, elements) + except ValueError: + # A catalog can include purchased content and player-created + # models this build has never seen. One malformed clone must + # not discard every other model; preserve its local parameters + # in published order, as the parser did before clone support. + effective = tuple(enumerate(element.findall("Parameter"))) parameters = tuple( _parameter(index, parameter, element.get("name", "")) - for index, parameter in _effective_parameter_elements( - element, elements - ) + for index, parameter in effective ) catalog.models[model_id] = Model( id=model_id, diff --git a/pyquadcortex/protocol/catalogs/coros_4_0_1/params.py b/pyquadcortex/protocol/catalogs/coros_4_0_1/params.py index 6c9c9070..6d0d6e87 100644 --- a/pyquadcortex/protocol/catalogs/coros_4_0_1/params.py +++ b/pyquadcortex/protocol/catalogs/coros_4_0_1/params.py @@ -16,9 +16,10 @@ (ADR-0018). The runtime check is unchanged and still covers every other caller - a string, a bare index, or anyone not running a checker. -**Cabs share one layout.** The catalog lists two parameters for a cab - -its two mic selectors - while the wire carries 22. So a cab is CHOSEN by -its `models.*` id and DRIVEN through :class:`Cabsim`:: +**Cabs use multiple layouts.** :class:`Cabsim` names the ordinary +21-parameter layout; PCOM cabs have 31 catalog parameters and should be +resolved through the connected device's catalog. A cab is chosen by its +`models.*` id:: cab = Block(0, 5, models.CabsimGuitarM.N412_CA_STAND_OS_S_V30_90S_M) qc.set_block(cab) @@ -157,27 +158,30 @@ class TempoParam(ParamSet): STEPSTATE12: Param[NoUnit] = Param(22, 'STEPSTATE12') # empty -# -- cabs: one layout, shared by every cab model ------------------------------ +# -- ordinary 21-parameter cab layout --------------------------------------- class Cabsim(ParamSet): - """Every cab model's parameters. The catalog under-describes these. + """The ordinary 12000-family cab layout (21 catalog parameters). - Measured on four cabs across all four categories: the wire carries - 22 parameters in the `Default Cabsim` layout regardless of which cab - is loaded, or whether it is mono or stereo. `MIC_1_PAN` is labelled - BALANCE on a stereo cab and PAN on a mono one - one wire index, two - screen names. + The wire carries one additional undocumented value at index 21. PCOM + cabs instead clone a 31-parameter layout (and carry 32 wire values), + so resolve their extra controls through the live catalog. + + Catalog evidence: index 3 is PAN over 0..10 on mono layouts but + BALANCE over -1..1 on stereo layouts. Therefore `Real(0.0)` means + hard left on mono and centre on stereo. Stereo screen behaviour has + not yet been verified. The mic-to-index mapping was confirmed against the unit's own - editor. Index 21 exists on the wire, is absent from the catalog and + editor on mono cabs. Index 21 exists on the wire, is absent from the catalog and reads 0.0 everywhere, so it is omitted rather than guessed at. """ MIC_1_BYPASS: Param[NoUnit] = Param(0, 'MIC_1_BYPASS') # switch MIC_1_IR_SELECTOR: Param[NoUnit] = Param(1, 'MIC_1_IR_SELECTOR') # string MIC_1_LEVEL: Param[DbUnit] = Param(2, 'MIC_1_LEVEL') # float dB - MIC_1_PAN: Param[NoUnit] = Param(3, 'MIC_1_PAN') # float + MIC_1_PAN: Param[NoUnit] = Param(3, 'MIC_1_PAN') # mono PAN 0..10; stereo BALANCE -1..1 MIC_1_DISTANCE: Param[NoUnit] = Param(4, 'MIC_1_DISTANCE') # float MIC_1_POSITION: Param[NoUnit] = Param(5, 'MIC_1_POSITION') # float MIC_1_PHI: Param[NoUnit] = Param(6, 'MIC_1_PHI') # switch diff --git a/pyquadcortex/protocol/targets.py b/pyquadcortex/protocol/targets.py index 7da0d9ec..18a7cf54 100644 --- a/pyquadcortex/protocol/targets.py +++ b/pyquadcortex/protocol/targets.py @@ -34,15 +34,6 @@ from pyquadcortex.protocol.errors import ControlNotDrivable -#: Catalog model ids for the containers whose model never varies. -CABSIM_LAYOUT = 12000 -#: The categories whose models use the `Default Cabsim` layout. Enumerated -#: rather than matched on a "Cabsim" prefix: this repo's precedent is -#: `LANE_OUTPUT_UNASSIGNABLE` - "a MEASURED LIST, not a rule" - and a prefix -#: would silently sweep in a future category whose layout may differ. -#: `tests/hardware/test_generated_constants.py` holds the same four names. -CABSIM_CATEGORIES = ("Cabsim Guitar (M)", "Cabsim Guitar (ST)", - "Cabsim Bass (M)", "Cabsim Bass (ST)") LANE_OUTPUT_CONTROL = 23000 INPUT_GATE_CONTROL = 28000 TEMPO_CONTROL = 25000 @@ -133,10 +124,8 @@ def index_of(self, param, get_catalog, model=None): spoken to a device. Ask for :meth:`spec_at` when the spec is actually needed. - The name resolves against :meth:`wire_model`, not against the model's - own entry, because the index this returns is a WIRE index. On a cab - those are different lists - see that method - and resolving against the - model's own one returned a number that addressed a different knob. + The name resolves against :meth:`wire_model`; ModelRepo clone + inheritance has already made that model's parameters wire-indexed. """ if isinstance(param, str): source = self.wire_model(get_catalog, model) @@ -156,11 +145,9 @@ def index_of(self, param, get_catalog, model=None): def spec_at(self, index, get_catalog, model=None): """The catalog :class:`~pyquadcortex.protocol.catalog.Parameter` at ``index``. - ``index`` is a WIRE index, so this reads :meth:`wire_model` rather than - the model's own entry. There is one answer to "what sits at wire index - N" and every caller wants the same one - the unit check, the string - guard, the bool guard and the conversion. Two methods answering it two - ways is what ADR-0016's triage found twice. + ``index`` is a WIRE index, so this reads :meth:`wire_model`. There is + one answer to "what sits at wire index N" and every caller wants the + same one. ``None`` when the catalog does not describe it, which is a real case: the wire carries more parameters than the catalog documents on several @@ -173,60 +160,13 @@ def spec_at(self, index, get_catalog, model=None): return source.parameters[index] def wire_model(self, get_catalog, model=None): - """The catalog :class:`Model` whose parameter list is WIRE-INDEXED here. - - Usually the block's own model. The exception is a cab, and the reason is - not that the catalog under-describes it - it is that a cab's own entry - is a LOCAL list, numbered from zero over the parameters that model - contributes, and those numbers do not address the wire. - - `Plini Cab (M)` (12053) is the whole argument. Its own entry reads - ``0:ir selector 1:ir selector 2:POSITION 3:DISTANCE 4:POSITION - 5:DISTANCE``, and the shared `Default Cabsim` layout reads - ``0:bypass 1:ir selector 2:LEVEL 3:PAN 4:DISTANCE 5:POSITION``. They are - not the same list with holes in it; they are different numberings of - overlapping parameters. Writing wire index 2 on that block and reading - the screen settled which one the wire speaks: it showed ``LEVEL - -3.0 dB``, the layout's answer, with the block's own POSITION untouched - beside it. Recorded in `tests/test_scales.py`. 12 cabs name their own - index 2 that way - 8 call it DISTANCE and 4 POSITION - and on the other - 157 it is absent, which is why the disagreement was invisible for so - long: 157 of 174 fail quietly rather than wrongly. - - So the test is whether the model's own list can be wire-indexed at all, - and LENGTH answers it. 169 of the 174 cab models describe 2, 4 or 6 - parameters against the layout's 21, and a list that short cannot be - numbering wire positions from 0 - if it were, index 2 would have read - POSITION on the unit, and it read LEVEL. The other 5 describe 21 or 31 - and start at ``0:bypass`` exactly as the layout does, so they number the - wire themselves and are left alone. - - Leaving those 5 alone matters beyond tidiness: the three 31-parameter - cabs DIVERGE from the layout at index 19, where the layout says - `IR NAME` and they say `ROOM MIX`. Borrowing for a model that already - numbers the wire would be this same bug facing the other way. - - What the catalog adds beyond the reading: of the 16 LEVEL parameters - the 5 self-describing cabs carry between them, every one has - ``MIN_CABSIM_DB`` and ``skew="4.9594844"``, and those 5 include stereo - models. So the device states the law wherever it states anything, and - the 169 that state nothing are exactly the ones that borrow. Applying it - across the category is still an EXTRAPOLATION and saying otherwise would - overstate it - all four blocks read on hardware are mono, and 86 of the - 174 are stereo. - - Only cabs need this. `Parallax` is a Bass Overdrive carrying a cab - section and describes that section itself, which is why it is outside - CABSIM_CATEGORIES and why its own LEVEL carries the cab law - see - `tests/test_scales.py`. + """This target's wire-indexed catalog model. + + :func:`parse_model_repo` resolves the device's declared ``clones`` and + parameter ``replaces`` relationships. Targets therefore need no cab + category heuristic or shared-layout borrowing. """ - source = self.model(get_catalog, model) - if source is None or source.category not in CABSIM_CATEGORIES: - return source - layout = get_catalog().get(CABSIM_LAYOUT) - if layout is None or len(source.parameters) >= len(layout.parameters): - return source - return layout + return self.model(get_catalog, model) def normalize(self, index, real, get_catalog, spec=None): """Convert ``real``, in the parameter's own units, to the wire's 0..1. diff --git a/scripts/generate_params.py b/scripts/generate_params.py index d988bdf3..0d92445d 100644 --- a/scripts/generate_params.py +++ b/scripts/generate_params.py @@ -17,13 +17,12 @@ python scripts/generate_params.py --snapshot coros_4_1_0 \ --payload model_repo_payload.bin -Three things this generator knows that the catalog does not: +Three things this generator knows beyond the raw catalog rows: -1. **The catalog UNDER-DESCRIBES cabs.** It lists two parameters for a cab - model - the two mic selectors - while the wire carries 22. Measured on four - cabs across all four categories (Bass/Guitar, M/ST): every one is the - ``Default Cabsim`` layout. So the 140 cab models share ONE layout and get one - enum, rather than 140 two-member enums that would each hide 20 parameters. +1. **Cab layouts are families, not one universal layout.** Clone resolution + exposes 21-parameter ordinary and 31-parameter PCOM layouts. The legacy + ``Cabsim`` constants intentionally describe the ordinary 12000 family; + PCOM-only controls must be resolved from the connected device's catalog. 2. **A cab's repeated block is a MICROPHONE**, not an IR slot or a channel. Confirmed against the unit's own editor: mic 1 read POSITION 2.9 / DIST 3.0 and mic 2 read POSITION 5.6 / DIST 3.3, matching wire indices 5 and 13 at @@ -56,8 +55,8 @@ / "pyquadcortex" / "protocol" / "catalogs") -#: The cab layout every cab model actually uses on the wire. Its repeated -#: eight-parameter block is a microphone. +#: The ordinary 21-parameter cab layout used for the backward-compatible +#: ``Cabsim`` constants. PCOM cabs clone a different 31-parameter layout. CABSIM_LAYOUT = 12000 CABSIM_CATEGORIES = ("Cabsim Guitar (M)", "Cabsim Guitar (ST)", "Cabsim Bass (M)", "Cabsim Bass (ST)") @@ -139,7 +138,10 @@ def members(model, group: str = None) -> list[tuple[str, int, str]]: else: name = base units = f" {p.units}" if p.units else "" - out.append((name, p.index, f"{p.type}{units}")) + comment = f"{p.type}{units}" + if model.id == CABSIM_LAYOUT and name == "MIC_1_PAN": + comment += "; mono PAN 0..10, stereo BALANCE -1..1" + out.append((name, p.index, comment)) return out @@ -205,9 +207,10 @@ def render(cat: catalog.ModelCatalog, snapshot: str) -> str: "(ADR-0018). The runtime check is unchanged and still covers every other", "caller - a string, a bare index, or anyone not running a checker.", "", - "**Cabs share one layout.** The catalog lists two parameters for a cab -", - "its two mic selectors - while the wire carries 22. So a cab is CHOSEN by", - "its `models.*` id and DRIVEN through :class:`Cabsim`::", + "**Cabs use multiple layouts.** :class:`Cabsim` names the ordinary", + "21-parameter layout; PCOM cabs have 31 catalog parameters and should be", + "resolved through the connected device's catalog. A cab is chosen by its", + "`models.*` id::", "", f" cab = Block(0, 5, {example_cab(cat)})", " qc.set_block(cab)", @@ -269,17 +272,19 @@ def render(cat: catalog.ModelCatalog, snapshot: str) -> str: for cls, model_id, doc in CONTAINERS: lines += render_enum(cls, doc, cat[model_id]) - lines += ["", "", "# -- cabs: one layout, shared by every cab model " + "-" * 30] + lines += ["", "", "# -- ordinary 21-parameter cab layout " + "-" * 39] lines += render_enum( "Cabsim", - "Every cab model's parameters. The catalog under-describes these.\n\n" - " Measured on four cabs across all four categories: the wire carries\n" - " 22 parameters in the `Default Cabsim` layout regardless of which cab\n" - " is loaded, or whether it is mono or stereo. `MIC_1_PAN` is labelled\n" - " BALANCE on a stereo cab and PAN on a mono one - one wire index, two\n" - " screen names.\n\n" + "The ordinary 12000-family cab layout (21 catalog parameters).\n\n" + " The wire carries one additional undocumented value at index 21. PCOM\n" + " cabs instead clone a 31-parameter layout (and carry 32 wire values),\n" + " so resolve their extra controls through the live catalog.\n\n" + " Catalog evidence: index 3 is PAN over 0..10 on mono layouts but\n" + " BALANCE over -1..1 on stereo layouts. Therefore `Real(0.0)` means\n" + " hard left on mono and centre on stereo. Stereo screen behaviour has\n" + " not yet been verified.\n\n" " The mic-to-index mapping was confirmed against the unit's own\n" - " editor. Index 21 exists on the wire, is absent from the catalog and\n" + " editor on mono cabs. Index 21 exists on the wire, is absent from the catalog and\n" " reads 0.0 everywhere, so it is omitted rather than guessed at.\n ", cat[CABSIM_LAYOUT], group="MIC") diff --git a/tests/fixtures/catalog_clones.json b/tests/fixtures/catalog_clones.json new file mode 100644 index 00000000..1364aa51 --- /dev/null +++ b/tests/fixtures/catalog_clones.json @@ -0,0 +1,10 @@ +{ + "source": "Distilled from a contributed Quad Cortex CorOS 4.1.0 ModelRepo on 2026-09-08; layout shapes independently confirmed by the maintainer on CorOS 4.0.1.", + "families": [ + {"parent": 12000, "parent_name": "Default Cabsim", "parent_parameters": 21, "child": 12001, "child_name": "412 CA Stand OS S V30 90s (M)", "replacement": {"index": 1, "name": "ir selector", "default": 0}}, + {"parent": 12100, "parent_name": "PCOM Default Cabsim", "parent_parameters": 31, "child": 12050, "child_name": "PCOM Cab (M)", "replacement": {"index": 5, "name": "POSITION", "default": 0.5}}, + {"parent": 32000, "parent_name": "Default Cabsim (ST)", "parent_parameters": 21, "child": 32001, "child_name": "412 CA Stand OS S V30 90s (ST)", "replacement": {"index": 3, "name": "BALANCE", "default": 0}}, + {"parent": 32100, "parent_name": "PCOM Default Cabsim (ST)", "parent_parameters": 31, "child": 32050, "child_name": "PCOM Cab (ST)", "replacement": {"index": 3, "name": "BALANCE", "default": 0}}, + {"parent": 8015, "parent_name": "Default Reverb", "parent_parameters": 29, "child": 8016, "child_name": "Gojira REV", "replacement": {"index": 8, "name": "PRE 1 FREQ", "default": 0.5}} + ] +} diff --git a/tests/test_catalog.py b/tests/test_catalog.py index 27e334ef..0879e463 100644 --- a/tests/test_catalog.py +++ b/tests/test_catalog.py @@ -7,6 +7,8 @@ import gzip import io +import json +import pathlib import tarfile import pytest @@ -186,17 +188,19 @@ def test_missing_clone_target_falls_back_to_local_parameters(): assert [(p.index, p.name) for p in model.parameters] == [(0, "LOCAL")] -def test_clone_cycles_are_rejected(): +def test_clone_cycle_falls_back_locally_without_discarding_the_catalog(): xml = """ """ - with pytest.raises(ValueError, match=r"clone cycle: 1 -> 2 -> 1"): - catalog.parse_model_repo(make_payload(xml)) + cat = catalog.parse_model_repo(make_payload(xml)) + + assert cat[1].parameters == () + assert cat[2].parameters == () -def test_non_contiguous_clone_indexes_are_rejected(): +def test_non_contiguous_clone_indexes_fall_back_to_local_parameters(): xml = """ @@ -206,8 +210,81 @@ def test_non_contiguous_clone_indexes_are_rejected(): """ - with pytest.raises(ValueError, match="non-contiguous parameter indexes"): - catalog.parse_model_repo(make_payload(xml)) + model = catalog.parse_model_repo(make_payload(xml))[2] + + assert [(p.index, p.name) for p in model.parameters] == [(0, "C")] + + +def test_clone_replacements_are_applied_before_extensions(): + xml = """ + + + + + + + + + """ + + model = catalog.parse_model_repo(make_payload(xml))[2] + + assert [(p.index, p.name) for p in model.parameters] == [ + (0, "A"), (1, "CHILD B"), (2, "C") + ] + + +def test_non_numeric_clone_replacement_is_isolated_to_that_model(): + xml = """ + + + + + + + + + + """ + + cat = catalog.parse_model_repo(make_payload(xml)) + + assert [(p.index, p.name) for p in cat[2].parameters] == [(0, "Intensity")] + assert [(p.index, p.name) for p in cat[3].parameters] == [(0, "GAIN")] + + +def test_distilled_real_catalog_clone_families_resolve_at_wire_indexes(): + """Pin the clone shapes observed on the contributed CorOS 4.1 catalog.""" + path = pathlib.Path(__file__).parent / "fixtures" / "catalog_clones.json" + facts = json.loads(path.read_text(encoding="utf-8")) + models = [] + for family in facts["families"]: + params = "".join( + f'' + for i in range(family["parent_parameters"]) + ) + models.append( + f'' + f"{params}" + ) + replacement = family["replacement"] + models.append( + f'' + ) + xml = '' + "".join(models) + \ + "" + + cat = catalog.parse_model_repo(make_payload(xml)) + + for family in facts["families"]: + child = cat[family["child"]] + replacement = family["replacement"] + assert len(child.parameters) == family["parent_parameters"] + assert child.parameters[replacement["index"]].name == replacement["name"] + assert child.parameters[replacement["index"]].default == replacement["default"] def test_lookup_parameter_by_name_is_case_insensitive(cat): diff --git a/tests/test_client.py b/tests/test_client.py index daa43778..0b9d2b75 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -4077,7 +4077,7 @@ def test_a_number_on_a_string_parameter_is_refused(): """ from tests.test_targets import _diverging_cab_catalog - for param in (1, "ir"): # by index and by name + for param in (1, "ir selector"): # by index and by name qc = client.QuadCortex(FakeTransport()) qc._catalog = _diverging_cab_catalog()() with pytest.raises(TypeError, match="is a string parameter"): @@ -4102,7 +4102,7 @@ def test_an_indexed_encoded_write_still_costs_no_catalog(): qc = client.QuadCortex(FakeTransport()) qc._catalog = _diverging_cab_catalog()() with pytest.raises(TypeError, match="is a string parameter"): - qc.set_param(Block(0, 5, 12001), "ir", Encoded(0.5)) + qc.set_param(Block(0, 5, 12001), "ir selector", Encoded(0.5)) def test_a_unit_check_reads_the_spec_the_conversion_uses_on_a_cab(monkeypatch): diff --git a/tests/test_targets.py b/tests/test_targets.py index b8452847..acfde3ce 100644 --- a/tests/test_targets.py +++ b/tests/test_targets.py @@ -246,8 +246,8 @@ def _scale_catalog(): - - + + """ + "") @@ -346,17 +346,10 @@ def test_real_on_a_bare_block_names_the_missing_model_not_the_catalog(): Block(0, 1).normalize(0, 6.0, _Exploding()) -def test_a_cab_converts_through_the_shared_cabsim_layout(): - """A cab's own entry is a LOCAL list, so the layout is what numbers the wire. - - The taper it borrows is confirmed on three blocks in three different - categories, and the catalog agrees: every one of those LEVEL entries carries - the same skew and the same MIN_CABSIM_DB bound. - """ +def test_a_cloned_cab_converts_through_its_resolved_wire_layout(): + """Clone resolution retains inherited scale metadata at wire indexes.""" get = _scale_catalog() - # 21005 describes ONE parameter against the layout's several, so its own - # list cannot be numbering the wire and `spec_at` reads the layout's. - assert Block(0, 5, 21005).wire_model(get).id == 12000 + assert Block(0, 5, 21005).wire_model(get).id == 21005 assert Block(0, 5, 21005).spec_at(2, get).name == "MIC 1 LEVEL" assert Block(0, 5, 21005).normalize(2, -3.0, get) == pytest.approx(0.3400, abs=5e-4) @@ -372,22 +365,7 @@ def test_a_non_cab_does_not_borrow_the_cabsim_layout(): def _diverging_cab_catalog(): - """The three shapes a cab comes in, at the proportions the device ships. - - Not hypothetical, and not "the catalog under-describes them". A cab's own - entry is a LOCAL list, numbered from zero over the parameters that model - contributes, and those numbers do not address the wire: - - * 157 of the 174 list two mic selectors and nothing else; - * 11 more add their mics' POSITION and DISTANCE, so their own index 2 names - a knob the wire carries at 5; - * 6 describe the whole layout starting at ``0:bypass``, and those DO number - the wire - three of them carry parameters past the layout's end, where - borrowing would be a fresh version of the same bug. - - The layout here is deliberately longer than the short models, because that - length difference is what `wire_model` reads. - """ + """A distilled catalog with declared short and full cab clone shapes.""" from tests.test_catalog import SAMPLE_XML, make_payload xml = SAMPLE_XML.replace("", """ @@ -398,15 +376,19 @@ def _diverging_cab_catalog(): + + + + - - - + + + - - - - + + + + @@ -423,12 +405,10 @@ def _diverging_cab_catalog(): return lambda: cat -def test_a_short_cabs_own_list_cannot_be_numbering_the_wire(): - """157 describe two parameters against a layout of many, so `spec_at` reads - the layout - the short list is local, and index 2 is not in it at all.""" +def test_a_short_cab_resolves_its_declared_parent_layout(): get = _diverging_cab_catalog() bare = Block(0, 5, 12001) - assert bare.wire_model(get).id == 12000 + assert bare.wire_model(get).id == 12001 assert bare.spec_at(2, get).name == "LEVEL" @@ -446,19 +426,11 @@ def test_a_cab_that_describes_the_whole_layout_numbers_the_wire_itself(): assert full.spec_at(2, get).name == "LEVEL" # and agreeing before it -def test_the_layout_wins_over_the_cabs_own_disagreeing_entry(): - """12 cabs call index 2 POSITION while the wire carries LEVEL in dB. - - Confirmed on hardware 2026-08-27, because guessing this backwards would - have been worse than the bug it fixes. A `Plini Cab (M)` took a wire value - the two specs read differently and the screen showed `LEVEL -3.0 dB` - the - layout's answer - with its own `POSITION` untouched at 0.50. The reading is - in `tests/test_scales.py`. - """ +def test_a_replacement_keeps_its_declared_wire_index(): get = _diverging_cab_catalog() named = Block(0, 5, 12053) - assert named.model(get).parameters[2].name == "POSITION" # its own list - assert named.spec_at(2, get).name == "LEVEL" # the wire's + assert named.spec_at(2, get).name == "LEVEL" + assert named.spec_at(5, get).name == "POSITION" def test_a_name_on_a_cab_resolves_to_the_wire_index_not_the_models_own(): @@ -475,7 +447,6 @@ def test_a_name_on_a_cab_resolves_to_the_wire_index_not_the_models_own(): """ get = _diverging_cab_catalog() named = Block(0, 5, 12053) - assert named.model(get).parameters[2].name == "POSITION" # its own list index, spec = named.index_of("POSITION", get) assert index == 5 and spec.name == "POSITION" From 181f5675d886aa9e638b99ba73391ebfe0607bad Mon Sep 17 00:00:00 2001 From: Antoni Ivanov <262547018+tony-xmelon@users.noreply.github.com> Date: Thu, 10 Sep 2026 00:44:05 +0300 Subject: [PATCH 3/8] fix: address ModelRepo clone review --- docs/STEERING.md | 6 +++ pyquadcortex/protocol/catalog.py | 14 ++++++- .../protocol/catalogs/coros_4_0_1/params.py | 10 ++--- scripts/generate_params.py | 8 ++-- tests/fixtures/catalog_clones.json | 8 ++-- tests/hardware/test_generated_constants.py | 24 ++++++------ tests/test_catalog.py | 38 +++++++++++++++---- tests/test_scales.py | 9 ++--- 8 files changed, 78 insertions(+), 39 deletions(-) diff --git a/docs/STEERING.md b/docs/STEERING.md index b11fc339..d8ceae17 100644 --- a/docs/STEERING.md +++ b/docs/STEERING.md @@ -351,6 +351,12 @@ the lane family, and that mistake shipped twice. nothing at the call site said which. The pair that forced the issue: on a lane VOLUME, `real=0.0` is unity and `value=0.0` is silence. +**Later correction (2026-09-08):** the account below predates understanding +`Model.clones` and numeric `Parameter.replaces`. Clone resolution now expands a +cab's local contribution into its effective 21- or 31-parameter layout, so the +shared-layout borrowing described there has been removed. See the 2026-09-08 +ModelRepo clone entry. + **What to watch:** everything that asks "what sits at this wire index" must get the SAME answer. It did not at first, and the reason was deeper than a duplicated lookup: on 169 of the 174 cab models the model's OWN catalog entry is diff --git a/pyquadcortex/protocol/catalog.py b/pyquadcortex/protocol/catalog.py index c701da3a..821d0d81 100644 --- a/pyquadcortex/protocol/catalog.py +++ b/pyquadcortex/protocol/catalog.py @@ -24,12 +24,16 @@ from __future__ import annotations +from dataclasses import dataclass, field, replace import gzip import io +import logging import math import tarfile import xml.etree.ElementTree as ET -from dataclasses import dataclass, field, replace + + +logger = logging.getLogger(__name__) # The numbers behind the catalog's symbolic bounds. `units` imports nothing from # this module, so this direction is the only one and there is no cycle. @@ -723,11 +727,17 @@ def parse_model_repo(payload: bytes) -> ModelCatalog: continue try: effective = _effective_parameter_elements(element, elements) - except ValueError: + except ValueError as exc: # A catalog can include purchased content and player-created # models this build has never seen. One malformed clone must # not discard every other model; preserve its local parameters # in published order, as the parser did before clone support. + logger.debug( + "ModelRepo model %s clone resolution failed; using its local " + "parameter order: %s", + model_id, + exc, + ) effective = tuple(enumerate(element.findall("Parameter"))) parameters = tuple( _parameter(index, parameter, element.get("name", "")) diff --git a/pyquadcortex/protocol/catalogs/coros_4_0_1/params.py b/pyquadcortex/protocol/catalogs/coros_4_0_1/params.py index 6d0d6e87..1608e474 100644 --- a/pyquadcortex/protocol/catalogs/coros_4_0_1/params.py +++ b/pyquadcortex/protocol/catalogs/coros_4_0_1/params.py @@ -168,10 +168,10 @@ class Cabsim(ParamSet): cabs instead clone a 31-parameter layout (and carry 32 wire values), so resolve their extra controls through the live catalog. - Catalog evidence: index 3 is PAN over 0..10 on mono layouts but - BALANCE over -1..1 on stereo layouts. Therefore `Real(0.0)` means - hard left on mono and centre on stereo. Stereo screen behaviour has - not yet been verified. + The catalog declares index 3 as PAN over 0..10 on mono layouts and + BALANCE over -1..1 on stereo layouts. Neither span matches the + screen: on CorOS 4.0.1 both layouts displayed wire values 0, 0.5, + 0.75 and 1 as 50 L, C, 25 R and 50 R. See issue #55. The mic-to-index mapping was confirmed against the unit's own editor on mono cabs. Index 21 exists on the wire, is absent from the catalog and @@ -181,7 +181,7 @@ class Cabsim(ParamSet): MIC_1_BYPASS: Param[NoUnit] = Param(0, 'MIC_1_BYPASS') # switch MIC_1_IR_SELECTOR: Param[NoUnit] = Param(1, 'MIC_1_IR_SELECTOR') # string MIC_1_LEVEL: Param[DbUnit] = Param(2, 'MIC_1_LEVEL') # float dB - MIC_1_PAN: Param[NoUnit] = Param(3, 'MIC_1_PAN') # mono PAN 0..10; stereo BALANCE -1..1 + MIC_1_PAN: Param[NoUnit] = Param(3, 'MIC_1_PAN') # float; mono PAN 0..10, stereo BALANCE -1..1 MIC_1_DISTANCE: Param[NoUnit] = Param(4, 'MIC_1_DISTANCE') # float MIC_1_POSITION: Param[NoUnit] = Param(5, 'MIC_1_POSITION') # float MIC_1_PHI: Param[NoUnit] = Param(6, 'MIC_1_PHI') # switch diff --git a/scripts/generate_params.py b/scripts/generate_params.py index 0d92445d..e9407a4b 100644 --- a/scripts/generate_params.py +++ b/scripts/generate_params.py @@ -279,10 +279,10 @@ def render(cat: catalog.ModelCatalog, snapshot: str) -> str: " The wire carries one additional undocumented value at index 21. PCOM\n" " cabs instead clone a 31-parameter layout (and carry 32 wire values),\n" " so resolve their extra controls through the live catalog.\n\n" - " Catalog evidence: index 3 is PAN over 0..10 on mono layouts but\n" - " BALANCE over -1..1 on stereo layouts. Therefore `Real(0.0)` means\n" - " hard left on mono and centre on stereo. Stereo screen behaviour has\n" - " not yet been verified.\n\n" + " The catalog declares index 3 as PAN over 0..10 on mono layouts and\n" + " BALANCE over -1..1 on stereo layouts. Neither span matches the\n" + " screen: on CorOS 4.0.1 both layouts displayed wire values 0, 0.5,\n" + " 0.75 and 1 as 50 L, C, 25 R and 50 R. See issue #55.\n\n" " The mic-to-index mapping was confirmed against the unit's own\n" " editor on mono cabs. Index 21 exists on the wire, is absent from the catalog and\n" " reads 0.0 everywhere, so it is omitted rather than guessed at.\n ", diff --git a/tests/fixtures/catalog_clones.json b/tests/fixtures/catalog_clones.json index 1364aa51..2525ce8e 100644 --- a/tests/fixtures/catalog_clones.json +++ b/tests/fixtures/catalog_clones.json @@ -1,10 +1,10 @@ { - "source": "Distilled from a contributed Quad Cortex CorOS 4.1.0 ModelRepo on 2026-09-08; layout shapes independently confirmed by the maintainer on CorOS 4.0.1.", + "source": "Distilled ModelRepo clone records. Layout sizes were measured on Quad Cortex CorOS 4.0.1 by the maintainer on 2026-09-09; names and replacement fields below match that catalog.", "families": [ {"parent": 12000, "parent_name": "Default Cabsim", "parent_parameters": 21, "child": 12001, "child_name": "412 CA Stand OS S V30 90s (M)", "replacement": {"index": 1, "name": "ir selector", "default": 0}}, - {"parent": 12100, "parent_name": "PCOM Default Cabsim", "parent_parameters": 31, "child": 12050, "child_name": "PCOM Cab (M)", "replacement": {"index": 5, "name": "POSITION", "default": 0.5}}, + {"parent": 12100, "parent_name": "PCOM Default Cabsim", "parent_parameters": 31, "child": 12050, "child_name": "Gojira Cab 1 (M)", "replacement": {"index": 5, "name": "POSITION", "default": 0.3}}, {"parent": 32000, "parent_name": "Default Cabsim (ST)", "parent_parameters": 21, "child": 32001, "child_name": "412 CA Stand OS S V30 90s (ST)", "replacement": {"index": 3, "name": "BALANCE", "default": 0}}, - {"parent": 32100, "parent_name": "PCOM Default Cabsim (ST)", "parent_parameters": 31, "child": 32050, "child_name": "PCOM Cab (ST)", "replacement": {"index": 3, "name": "BALANCE", "default": 0}}, - {"parent": 8015, "parent_name": "Default Reverb", "parent_parameters": 29, "child": 8016, "child_name": "Gojira REV", "replacement": {"index": 8, "name": "PRE 1 FREQ", "default": 0.5}} + {"parent": 32100, "parent_name": "PCOM Default Cabsim (ST)", "parent_parameters": 31, "child": 32050, "child_name": "Gojira Cab 1 (ST)", "replacement": {"index": 3, "name": "BALANCE", "default": 0}}, + {"parent": 8015, "parent_name": "Default Reverb", "parent_parameters": 29, "child": 8016, "child_name": "Gojira REV", "replacement": {"index": 8, "name": "PRE 1 FREQ", "default": 40.0}} ] } diff --git a/tests/hardware/test_generated_constants.py b/tests/hardware/test_generated_constants.py index b49975bd..f31e593a 100644 --- a/tests/hardware/test_generated_constants.py +++ b/tests/hardware/test_generated_constants.py @@ -74,25 +74,25 @@ def test_the_committed_snapshot_matches_this_unit(live_catalog, profile, name): def test_the_cab_layout_claim_still_holds(qc, live_catalog): - """`params.Cabsim` asserts every cab shares the Default Cabsim layout. + """Cab clones resolve to the two layouts measured on CorOS 4.0.1. - That is the one claim in the generated file the catalog cannot support - - the catalog lists two parameters per cab and the wire carries 22 - so it is - held against the catalog entry the layout is taken FROM, and against the - cab models still being under-described in the way that made this necessary. + The ordinary families publish 21 catalog parameters and PCOM families + publish 31. The wire carries one additional value in both cases. This + tripwire replaces the old claim that every cab published only two local + parameters and therefore needed to borrow one shared layout. """ from pyquadcortex.protocol import params - reference = live_catalog[12000] - assert len(reference.parameters) == len(params.Cabsim), ( - "the Default Cabsim layout changed size; params.Cabsim is derived from it") + assert len(live_catalog[12000].parameters) == len(params.Cabsim) == 21 + assert len(live_catalog[12100].parameters) == 31 + assert len(live_catalog[32000].parameters) == 21 + assert len(live_catalog[32100].parameters) == 31 cabs = [m for m in live_catalog if m.category in ("Cabsim Guitar (M)", "Cabsim Guitar (ST)", "Cabsim Bass (M)", "Cabsim Bass (ST)") and m.is_factory] assert cabs, "no factory cabs on this unit" - assert all(len(m.parameters) == 2 for m in cabs), ( - "a cab now publishes more than its two mic selectors - the catalog may " - "have started describing cabs properly, which would make the shared " - "params.Cabsim layout unnecessary") + assert {len(m.parameters) for m in cabs} == {21, 31}, ( + "factory cabs no longer resolve exclusively to the measured ordinary " + "and PCOM layouts") diff --git a/tests/test_catalog.py b/tests/test_catalog.py index 0879e463..44bb4546 100644 --- a/tests/test_catalog.py +++ b/tests/test_catalog.py @@ -254,7 +254,7 @@ def test_non_numeric_clone_replacement_is_isolated_to_that_model(): def test_distilled_real_catalog_clone_families_resolve_at_wire_indexes(): - """Pin the clone shapes observed on the contributed CorOS 4.1 catalog.""" + """Pin measured CorOS 4.0.1 facts independently of the input fixture.""" path = pathlib.Path(__file__).parent / "fixtures" / "catalog_clones.json" facts = json.loads(path.read_text(encoding="utf-8")) models = [] @@ -279,12 +279,36 @@ def test_distilled_real_catalog_clone_families_resolve_at_wire_indexes(): cat = catalog.parse_model_repo(make_payload(xml)) - for family in facts["families"]: - child = cat[family["child"]] - replacement = family["replacement"] - assert len(child.parameters) == family["parent_parameters"] - assert child.parameters[replacement["index"]].name == replacement["name"] - assert child.parameters[replacement["index"]].default == replacement["default"] + expected = { + 12001: (21, 1, "ir selector", 0.0), + 12050: (31, 5, "POSITION", 0.3), + 32001: (21, 3, "BALANCE", 0.0), + 32050: (31, 3, "BALANCE", 0.0), + 8016: (29, 8, "PRE 1 FREQ", 40.0), + } + assert set(expected) == {family["child"] for family in facts["families"]} + for child_id, (size, index, name, default) in expected.items(): + child = cat[child_id] + assert len(child.parameters) == size + assert child.parameters[index].name == name + assert child.parameters[index].default == default + + +def test_clone_resolution_fallback_logs_model_and_reason(caplog): + xml = """ + + + + + + + """ + + with caplog.at_level("DEBUG", logger="pyquadcortex.protocol.catalog"): + catalog.parse_model_repo(make_payload(xml)) + + assert "model 2 clone resolution failed" in caplog.text + assert "non-contiguous parameter indexes" in caplog.text def test_lookup_parameter_by_name_is_case_insensitive(cat): diff --git a/tests/test_scales.py b/tests/test_scales.py index 4927afb6..f7c85f5b 100644 --- a/tests/test_scales.py +++ b/tests/test_scales.py @@ -366,12 +366,11 @@ def test_the_same_knob_is_floored_under_both_of_its_spellings(): def test_parallax_carries_the_cab_law_itself(): - """It is a Bass Overdrive with a cab section, so it cannot borrow the layout. + """Parallax publishes both cab LEVEL laws in its own catalog entry. - `targets.wire_model` only borrows for models in CABSIM_CATEGORIES, and - Parallax is not one. It works only because its own catalog entry carries - MIN_CABSIM_DB and the same skew - which is also the evidence the - layout-borrowing design cites, so it is worth pinning where it is claimed. + It is a Bass Overdrive with two embedded cab sections rather than a cab + clone. Both controls therefore have to carry their own MIN_CABSIM_DB bound + and skew, independently of clone resolution. """ for index in (16, 24): spec = SCALES[(3008, index)] From 66c399688e77e24760e957893d06af54b03aa77f Mon Sep 17 00:00:00 2001 From: Antoni Ivanov <262547018+tony-xmelon@users.noreply.github.com> Date: Sat, 19 Sep 2026 22:44:11 +0300 Subject: [PATCH 4/8] Follow documentation typography rules --- docs/domain-model.md | 2 +- docs/protocol.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/domain-model.md b/docs/domain-model.md index 940436de..2136a68e 100644 --- a/docs/domain-model.md +++ b/docs/domain-model.md @@ -1211,7 +1211,7 @@ omitted with the reason written down. Numeric parameter `replaces` values are inherited wire indexes on a model that declares `clones`; the parser resolves them before publishing the model. `Model/@clones` names the parent layout. The nonnumeric `replaces="INTENSITY"` -on MX Vibe remains unexplained and makes only that model fall back to its local +on `MX Vibe` remains unexplained and makes only that model fall back to its local parameter order. ### `type` names the widget, and two of its values are readouts diff --git a/docs/protocol.md b/docs/protocol.md index 28b3eb7b..3d805879 100644 --- a/docs/protocol.md +++ b/docs/protocol.md @@ -1962,7 +1962,7 @@ The XML is ``. what gives a parameter index meaning. A model may declare `clones`; numeric parameter `replaces` values place child metadata at inherited indexes and child-only parameters extend the layout. Read-only CorOS 4.1 checks confirmed - the 21/31-parameter cab parent layouts and the cloned Gojira REV ordering; the + the 21/31-parameter cab parent layouts and the cloned `Gojira REV` ordering; the maintainer independently confirmed the same shapes on CorOS 4.0.1. - **Parameter values on the wire are normalized 0..1.** Sending `1.0` to a `THRESHOLD` whose catalog range is -60..+12 dB made the unit display +12.0 dB. From bc9df0d73a7da0e78a9d6a9c35b0cee81649bb3a Mon Sep 17 00:00:00 2001 From: Antoni Ivanov <262547018+tony-xmelon@users.noreply.github.com> Date: Wed, 23 Sep 2026 00:14:29 +0300 Subject: [PATCH 5/8] Regenerate 4.0.1 option usage from captured catalog --- changelog.md | 12 ++++++------ docs/domain-model.md | 12 ++++++------ .../protocol/catalogs/coros_4_0_1/options.py | 18 +++++++++--------- tests/test_option_audit.py | 6 +++--- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/changelog.md b/changelog.md index 8b521f0b..28deb747 100644 --- a/changelog.md +++ b/changelog.md @@ -58,7 +58,7 @@ the only enum whose names are known to differ from what the screen shows. `OPTION_AUDIT` tells you whether anybody has held a list against the unit's screen. It does not tell you how much rides on the answer, and that is the other -half of the question: `Off,On` decides 222 parameters and `CHO1,CHO2` decides +half of the question: `Off,On` decides 278 parameters and `CHO1,CHO2` decides two, so 94 unread lists are not 94 equal jobs. `OPTION_USAGE` publishes the count for every fixed list, keyed by the labels @@ -70,11 +70,11 @@ from pyquadcortex.protocol import options unread = [labels for labels, status in options.OPTION_AUDIT.items() if status is None] unread.sort(key=lambda labels: (-options.OPTION_USAGE[labels], len(labels), labels)) -options.OPTION_USAGE[unread[0]] # 14 parameters - the biggest unread list +options.OPTION_USAGE[unread[0]] # 40 parameters - the biggest unread list ``` -On the CorOS 4.0.1 snapshot that is 527 parameters across 113 lists, of which -190 across 94 lists are unread. `tests/test_option_audit.py` holds +On the CorOS 4.0.1 snapshot that is 611 parameters across 113 lists, of which +218 across 94 lists are unread. `tests/test_option_audit.py` holds `docs/domain-model.md` to those numbers, so they cannot be carried in prose from a count taken once. @@ -267,9 +267,9 @@ covering all 533 models, and the readings that built it are now tests units needs a catalog, which comes from the unit; `protocol.bpm_to_tempo` and the other standalone helpers still work without one. -**Option names were in the catalog all along.** 527 parameters use 113 distinct +**Option names were in the catalog all along.** 611 parameters use 113 distinct lists, so `pyquadcortex.protocol.options` publishes them as enums -(`options.DynMode3.GATE`, `options.HpfSlope.MINUS_12`); 247 parameters are plain +(`options.DynMode3.GATE`, `options.HpfSlope.MINUS_12`); 303 parameters are plain Off/On and take a `bool`. `set_param_option` needs `source=` only for the twelve dynamic lists. The unit's own spelling stays on the wire (`Noral`). diff --git a/docs/domain-model.md b/docs/domain-model.md index 6923436b..817f78a3 100644 --- a/docs/domain-model.md +++ b/docs/domain-model.md @@ -1380,23 +1380,23 @@ against `Return 1/2`, `USB 5` against `USB input 5`). So every list's names are a hypothesis until a person reads them off the unit. `options.OPTION_AUDIT` publishes which have been, keyed by the labels rather than by the enum so the two Off/On lists and the metronome list, which get no enum -and are 260 parameters between them, can be recorded too. The readings are in +and are 316 parameters between them, can be recorded too. The readings are in `tests/fixtures/catalog/option_readings.json`, one row per position, and `scripts/generate_options.py` stamps each enum's docstring from them. **Where it stands (2026-09-16, CorOS 4.0.1): 13 audited, 1 drawn, 5 not drawn, -94 unread**, of 113 fixed lists. The fourteen read lists cover 301 of the 527 -parameters that carry a fixed list. The 94 unread cover 190. +94 unread**, of 113 fixed lists. The nineteen read lists cover 357 of the 611 +parameters that carry a fixed list. The 94 unread cover 218. What is left is not 94 equal jobs. Ranked by how many parameters each list -decides, the tail falls away fast: the biggest five cover 54 of the 190. +decides, the tail falls away fast: the biggest five cover 82 of the 218. `options.OPTION_USAGE` publishes the count for every list, so a session at the unit can be planned from the library rather than from a count taken once. | parameters | positions | list | somewhere it appears | |---|---|---|---| +| 40 | 3 | `Small,Med,Large` | Ambience / `SIZE` | | 14 | 17 | a 17-entry `SYNC NOTE` | Vibrato / `SYNC NOTE` | -| 12 | 3 | `Small,Med,Large` | Ambience / `SIZE` | | 11 | 3 | `Off,Duck,Gate` | Digital Delay (ST) / `DYN MODE` | | 9 | 14 | a 14-entry `SYNC NOTE` | Dual Chorus / `SYNC NOTE` | | 8 | 3 | `Normal,Thick,Thicker` | CA 1Star Clean 50W Normal / `EQ` | @@ -1416,7 +1416,7 @@ defines. | list | parameters | how it was read | |---|---|---| -| `Off,On` | 222 | a Circular Delay's `SYNC` and `TRAILS`, each position driven | +| `Off,On` | 278 | a Circular Delay's `SYNC` and `TRAILS`, each position driven | | `SYNC NOTE` (21 entries) | 28 | the dial in order, anchored at 0 and 13 | | `OFF,ON` | 25 | the same block's `VINTAGE MODE`, each position driven | | `OFF,MUTE,DOWN,ON` | 13 | the metronome cells, re-driven as the control | diff --git a/pyquadcortex/protocol/catalogs/coros_4_0_1/options.py b/pyquadcortex/protocol/catalogs/coros_4_0_1/options.py index 31ade1ca..d7c63f73 100644 --- a/pyquadcortex/protocol/catalogs/coros_4_0_1/options.py +++ b/pyquadcortex/protocol/catalogs/coros_4_0_1/options.py @@ -7,11 +7,11 @@ qc.set_param_option(block, 'DYN MODE', options.DynMode.GATE) -110 enums cover 267 parameters, because the same list means +110 enums cover 295 parameters, because the same list means the same thing wherever it appears - the note-length list is shared by ``SYNC NOTE``, ``SYNC NOTE L``, ``SYNC NOTE R`` and two more. -**A two-option Off/On parameter gets no enum.** 247 parameters +**A two-option Off/On parameter gets no enum.** 303 parameters offer exactly those, and ``True`` says everything ``OffOn.ON`` would:: qc.set_param(block, 'SYNC', True) @@ -1361,9 +1361,9 @@ class Scale(IntEnum): class Size(IntEnum): - """12 parameters use this list: SIZE + """40 parameters use this list: SIZE - On 12 models, among them Ambience, Dual (M), Dual (M) Lite. + On 40 models, among them Ambience, Cory Wong Cab 1 (M), Cory Wong Cab 1 (ST). NOT audited against the screen. These names are the catalog's ``stepNames``, which is not known to be the @@ -2203,14 +2203,14 @@ class VoiceMode(IntEnum): #: LABELS, like the audit, so the three lists with no enum are in #: it too. #: -#: Totals on this snapshot: 527 -#: parameters across 113 lists, of which 190 across +#: Totals on this snapshot: 611 +#: parameters across 113 lists, of which 218 across #: 94 lists nobody has read. The work is long-tailed - the -#: five biggest unread lists cover 54 of those 190. +#: five biggest unread lists cover 82 of those 218. OPTION_USAGE = { ('OFF', 'MUTE', 'DOWN', 'ON'): 13, # no enum ('OFF', 'ON'): 25, # no enum - ('Off', 'On'): 222, # no enum + ('Off', 'On'): 278, # no enum ('Bypass', '90°', '180°'): 2, # Adjust ('1/16', '1/8T', '1/16D', '1/8', '1/4T', '1/8D', '1/4', '1/2T', '1/4D', '1/2', '1/1T', '1/2D', '1/1'): 2, # AnalogDelayMSyncNote ('Up', 'Down', 'Up & Down', 'Down & Up', 'Random'): 1, # ArpPattern @@ -2291,7 +2291,7 @@ class VoiceMode(IntEnum): ('MULTI', 'HP', 'OUT 1/2', 'OUT 3/4', 'SEND 1/2'): 1, # Routing ('Grid', 'In 1', 'In 2', 'Ret 1', 'Ret 2', 'In 1/2', 'Ret 1/2', 'Out1', 'Out2', 'Out3', 'Out4', 'Out1/2', 'Out3/4', 'Multi'): 1, # RoutingMode ('Major', 'Minor'): 1, # Scale - ('Small', 'Med', 'Large'): 12, # Size + ('Small', 'Med', 'Large'): 40, # Size ('1/64T', '1/64', '1/32T', '1/64D', '1/32', '1/16T', '1/32D', '1/16', '1/8T', '1/16D', '1/8'): 2, # SlapbackDelayMSyncNote ('6dB/Oct', '12dB/Oct', '18dB/Oct', '24dB/Oct'): 1, # Slope ('Clean', 'Crunch', 'Lead'): 1, # SoldanoSlo100Channel diff --git a/tests/test_option_audit.py b/tests/test_option_audit.py index e0f5680a..b9efd4b7 100644 --- a/tests/test_option_audit.py +++ b/tests/test_option_audit.py @@ -382,13 +382,13 @@ def test_the_document_quotes_the_same_parameter_counts(): per_status = collections.defaultdict(int) for labels, status in options.OPTION_AUDIT.items(): per_status[status] += options.OPTION_USAGE[labels] - assert sum(per_status.values()) == 527 + assert sum(per_status.values()) == 611 text = " ".join( (pathlib.Path(__file__).parents[1] / "docs" / "domain-model.md") .read_text(encoding="utf-8").split()) read = per_status["audited"] + per_status["drawn"] - for phrase in (f"cover {read} of the 527", f"unread cover {per_status[None]}"): + for phrase in (f"cover {read} of the 611", f"unread cover {per_status[None]}"): assert phrase in text, ( f"docs/domain-model.md does not say {phrase!r}. The parameter " f"counts moved and the document did not.") @@ -408,7 +408,7 @@ def test_the_unread_work_is_long_tailed_and_the_document_says_so(): key=lambda labels: (-options.OPTION_USAGE[labels], len(labels), labels)) total = sum(options.OPTION_USAGE[labels] for labels in unread) top5 = sum(options.OPTION_USAGE[labels] for labels in unread[:5]) - assert (len(unread), total) == (94, 190) + assert (len(unread), total) == (94, 218) text = " ".join( (pathlib.Path(__file__).parents[1] / "docs" / "domain-model.md") From aa35e7f72b03f8dbebbc358ec2cb21fab9c5d73d Mon Sep 17 00:00:00 2001 From: Antoni Ivanov <262547018+tony-xmelon@users.noreply.github.com> Date: Sun, 27 Sep 2026 02:30:58 +0300 Subject: [PATCH 6/8] Address ModelRepo clone review findings --- changelog.md | 3 ++- docs/domain-model.md | 2 +- pyquadcortex/protocol/catalog.py | 24 +++++++++++++------- tests/hardware/test_generated_constants.py | 13 ++++++----- tests/test_catalog.py | 26 +++++++++++++++++----- tests/test_targets.py | 11 +-------- 6 files changed, 48 insertions(+), 31 deletions(-) diff --git a/changelog.md b/changelog.md index 28deb747..81865290 100644 --- a/changelog.md +++ b/changelog.md @@ -20,7 +20,8 @@ sustained stretch without a correction. Models that declare `clones` now expose the inherited wire layout with numeric parameter replacements applied before child-only extensions. This fixes both ordinary and PCOM cab addressing and the cloned reverb families. A malformed -model falls back locally without discarding the rest of the device catalog. +model logs the model and reason, then falls back locally without discarding the +rest of the device catalog. ### Rename the unit, drive undo/redo, and read inhibited modules `set_device_name()` sends a sparse Version update. `undo()` and `redo()` drive diff --git a/docs/domain-model.md b/docs/domain-model.md index 817f78a3..94cb4612 100644 --- a/docs/domain-model.md +++ b/docs/domain-model.md @@ -1385,7 +1385,7 @@ and are 316 parameters between them, can be recorded too. The readings are in `scripts/generate_options.py` stamps each enum's docstring from them. **Where it stands (2026-09-16, CorOS 4.0.1): 13 audited, 1 drawn, 5 not drawn, -94 unread**, of 113 fixed lists. The nineteen read lists cover 357 of the 611 +94 unread**, of 113 fixed lists. The fourteen read lists cover 357 of the 611 parameters that carry a fixed list. The 94 unread cover 218. What is left is not 94 equal jobs. Ranked by how many parameters each list diff --git a/pyquadcortex/protocol/catalog.py b/pyquadcortex/protocol/catalog.py index 46178cc3..e706d178 100644 --- a/pyquadcortex/protocol/catalog.py +++ b/pyquadcortex/protocol/catalog.py @@ -896,13 +896,15 @@ def _effective_parameter_elements( ModelRepo models may ``clone`` another model and publish only the parameters they replace. Each child's numeric ``replaces`` attribute is the inherited wire index; child parameters without one extend the resolved - list. On a contributed CorOS 4.1.0 catalog (2026-09-08), cabs clone four - different 21- or 31-parameter layouts and a reverb family clones model - 8015. The maintainer confirmed the same shapes on CorOS 4.0.1. - - A missing clone target is treated like an ordinary model. A malformed - clone (including a cycle) raises here so :func:`parse_model_repo` can fall - that model back to its local parameters without discarding the catalog. + list. On the contributed CorOS 4.1.0 catalog (2026-09-08, Antoni Ivanov), + cabs clone four different 21- or 31-parameter layouts and a reverb family + clones model 8015. Jonathan Stokes confirmed the same 4.0.1 layout sizes + on 2026-09-09. + + A missing clone target is diagnosed and treated like an ordinary model. A + malformed clone (including a cycle) raises here so :func:`parse_model_repo` + can fall that model back to its local parameters without discarding the + catalog. """ model_id = _as_int(model.get("id")) assert model_id is not None @@ -912,6 +914,12 @@ def _effective_parameter_elements( clone_id = _as_int(model.get("clones")) base = models.get(clone_id) if clone_id is not None else None + if clone_id is not None and base is None: + model_name = model.get("name", "") + raise ValueError( + f"ModelRepo model {model_id} ({model_name!r}) declares missing " + f"clone parent {clone_id}" + ) if base is None: effective = list(enumerate(model.findall("Parameter"))) else: @@ -987,7 +995,7 @@ def parse_model_repo(payload: bytes) -> ModelCatalog: # models this build has never seen. One malformed clone must # not discard every other model; preserve its local parameters # in published order, as the parser did before clone support. - logger.debug( + logger.warning( "ModelRepo model %s clone resolution failed; using its local " "parameter order: %s", model_id, diff --git a/tests/hardware/test_generated_constants.py b/tests/hardware/test_generated_constants.py index f31e593a..1f14d83d 100644 --- a/tests/hardware/test_generated_constants.py +++ b/tests/hardware/test_generated_constants.py @@ -90,9 +90,10 @@ def test_the_cab_layout_claim_still_holds(qc, live_catalog): cabs = [m for m in live_catalog if m.category in ("Cabsim Guitar (M)", "Cabsim Guitar (ST)", - "Cabsim Bass (M)", "Cabsim Bass (ST)") - and m.is_factory] - assert cabs, "no factory cabs on this unit" - assert {len(m.parameters) for m in cabs} == {21, 31}, ( - "factory cabs no longer resolve exclusively to the measured ordinary " - "and PCOM layouts") + "Cabsim Bass (M)", "Cabsim Bass (ST)")] + factory = [m for m in cabs if m.is_factory] + assert factory, "no factory cabs on this unit" + assert {len(m.parameters) for m in factory} == {21}, ( + "a factory cab no longer resolves to the ordinary 21-parameter layout") + assert all(m.sku or m.plugin_id for m in cabs if len(m.parameters) == 31), ( + "a 31-parameter PCOM cab is no longer purchased content") diff --git a/tests/test_catalog.py b/tests/test_catalog.py index b974fd17..a9d1abe4 100644 --- a/tests/test_catalog.py +++ b/tests/test_catalog.py @@ -188,6 +188,19 @@ def test_missing_clone_target_falls_back_to_local_parameters(): assert [(p.index, p.name) for p in model.parameters] == [(0, "LOCAL")] +def test_missing_clone_target_logs_model_and_parent(caplog): + xml = """ + + + + """ + + catalog.parse_model_repo(make_payload(xml)) + + assert "ModelRepo model 1 ('Partial')" in caplog.text + assert "missing clone parent 999" in caplog.text + + def test_clone_cycle_falls_back_locally_without_discarding_the_catalog(): xml = """ @@ -1210,14 +1223,17 @@ def test_a_model_marked_internal_false_is_not_internal(): #: Attributes the parser may legitimately read by PRESENCE, each with the reason. #: -#: Empty, and that is the point - there is nowhere in this parser today where -#: "the attribute exists" is the question. The list exists because the failure -#: message offers this escape and a test that offers one without implementing it -#: sends a contributor in a circle. Same shape as `BOUNDARY_MODULES` in +#: `replaces` is read by presence: on a cloned parameter, a numeric value gives +#: the inherited wire index to replace, while an absent attribute means append +#: it after the inherited layout. The value `"0"` is meaningful, so truthiness +#: is not a substitute. Same shape as `BOUNDARY_MODULES` in #: `tests/test_translation.py` and `UNMARKED_OPERATIONS` in #: `tests/test_hardware_markers.py`: a name gets on it with a written reason, and #: a reviewer judges the reason. -PRESENCE_IS_RIGHT: dict[str, str] = {} +PRESENCE_IS_RIGHT: dict[str, str] = { + "replaces": "a present numeric value replaces that inherited wire index; " + "absence means append the child parameter", +} def _presence_reads(source: str) -> list[str]: diff --git a/tests/test_targets.py b/tests/test_targets.py index 4d9456c4..2846d37b 100644 --- a/tests/test_targets.py +++ b/tests/test_targets.py @@ -357,18 +357,11 @@ def test_real_on_a_bare_block_names_the_missing_model_not_the_catalog(): def test_a_cloned_cab_converts_through_its_resolved_wire_layout(): """Clone resolution retains inherited scale metadata at wire indexes.""" get = _scale_catalog() - assert Block(0, 5, 21005).wire_model(get).id == 21005 assert Block(0, 5, 21005).spec_at(2, get).name == "MIC 1 LEVEL" assert Block(0, 5, 21005).normalize(2, -3.0, get) == pytest.approx(0.3400, abs=5e-4) -def test_a_non_cab_does_not_borrow_the_cabsim_layout(): - """The alias is not a back door into every model near a cab.""" - get = _scale_catalog() - assert Block(0, 1, 5005).wire_model(get).id == 5005 - - # -- the check and the conversion must read the SAME spec --------------------- @@ -416,11 +409,10 @@ def _diverging_cab_catalog(): def test_a_short_cab_resolves_its_declared_parent_layout(): get = _diverging_cab_catalog() bare = Block(0, 5, 12001) - assert bare.wire_model(get).id == 12001 assert bare.spec_at(2, get).name == "LEVEL" -def test_a_cab_that_describes_the_whole_layout_numbers_the_wire_itself(): +def test_a_cab_with_full_layout_keeps_parameters_beyond_the_shared_layout(): """The 6 full-form cabs are left alone, and it is not tidiness. Three of them carry parameters PAST the layout's end - the layout says @@ -429,7 +421,6 @@ def test_a_cab_that_describes_the_whole_layout_numbers_the_wire_itself(): """ get = _diverging_cab_catalog() full = Block(0, 5, 12100) - assert full.wire_model(get).id == 12100 assert full.spec_at(6, get).name == "ROOM MIX" # past the layout's end assert full.spec_at(2, get).name == "LEVEL" # and agreeing before it From 43cfbe4a5c6720076760086d8cd4401e82c67bd7 Mon Sep 17 00:00:00 2001 From: Antoni Ivanov <262547018+tony-xmelon@users.noreply.github.com> Date: Sun, 27 Sep 2026 03:21:10 +0300 Subject: [PATCH 7/8] Address catalog review count and hardware assumptions --- docs/domain-model.md | 7 ++++--- docs/protocol.md | 7 ++++--- tests/hardware/test_generated_constants.py | 5 ++++- tests/test_option_audit.py | 15 +++++++++++++-- 4 files changed, 25 insertions(+), 9 deletions(-) diff --git a/docs/domain-model.md b/docs/domain-model.md index 94cb4612..d1622441 100644 --- a/docs/domain-model.md +++ b/docs/domain-model.md @@ -1384,9 +1384,10 @@ and are 316 parameters between them, can be recorded too. The readings are in `tests/fixtures/catalog/option_readings.json`, one row per position, and `scripts/generate_options.py` stamps each enum's docstring from them. -**Where it stands (2026-09-16, CorOS 4.0.1): 13 audited, 1 drawn, 5 not drawn, -94 unread**, of 113 fixed lists. The fourteen read lists cover 357 of the 611 -parameters that carry a fixed list. The 94 unread cover 218. +**Where it stands (2026-09-16, CorOS 4.0.1): 13 audited, 1 drawn, 5 absent, +94 unread**, of 113 fixed lists. The 14 assessed lists cover 357 +parameters; 5 lists looked for and not drawn account for 36, and the 94 +unread lists account for 218 of the 611 parameters that carry a fixed list. What is left is not 94 equal jobs. Ranked by how many parameters each list decides, the tail falls away fast: the biggest five cover 82 of the 218. diff --git a/docs/protocol.md b/docs/protocol.md index 61d69a2f..d21bfffa 100644 --- a/docs/protocol.md +++ b/docs/protocol.md @@ -1974,9 +1974,10 @@ The XML is ``. `defaultValue`, `units`, `skew`, `steps`, `stepNames`, `type` and more. This is what gives a parameter index meaning. A model may declare `clones`; numeric parameter `replaces` values place child metadata at inherited indexes and - child-only parameters extend the layout. Read-only CorOS 4.1 checks confirmed - the 21/31-parameter cab parent layouts and the cloned `Gojira REV` ordering; the - maintainer independently confirmed the same shapes on CorOS 4.0.1. + child-only parameters extend the layout. Read-only CorOS 4.1.0 checks by + Antoni Ivanov on 2026-09-08 confirmed the 21/31-parameter cab parent layouts + and the cloned `Gojira REV` ordering; Jonathan Stokes independently confirmed + the same shapes on CorOS 4.0.1 on 2026-09-09. - **Parameter values on the wire are normalized 0..1.** Sending `1.0` to a `THRESHOLD` whose catalog range is -60..+12 dB made the unit display +12.0 dB. diff --git a/tests/hardware/test_generated_constants.py b/tests/hardware/test_generated_constants.py index 1f14d83d..5468313f 100644 --- a/tests/hardware/test_generated_constants.py +++ b/tests/hardware/test_generated_constants.py @@ -92,7 +92,10 @@ def test_the_cab_layout_claim_still_holds(qc, live_catalog): if m.category in ("Cabsim Guitar (M)", "Cabsim Guitar (ST)", "Cabsim Bass (M)", "Cabsim Bass (ST)")] factory = [m for m in cabs if m.is_factory] - assert factory, "no factory cabs on this unit" + if not factory: + pytest.skip( + "this unit exposes no factory cab for the hardware layout check; " + "the available 31-parameter PCOM cabs are purchased content") assert {len(m.parameters) for m in factory} == {21}, ( "a factory cab no longer resolves to the ordinary 21-parameter layout") assert all(m.sku or m.plugin_id for m in cabs if len(m.parameters) == 31), ( diff --git a/tests/test_option_audit.py b/tests/test_option_audit.py index b9efd4b7..48c1821b 100644 --- a/tests/test_option_audit.py +++ b/tests/test_option_audit.py @@ -301,7 +301,7 @@ def test_the_document_quotes_the_same_counts(): text = " ".join(doc.read_text(encoding="utf-8").split()) counts = collections.Counter(options.OPTION_AUDIT.values()) phrase = (f"{counts['audited']} audited, {counts['drawn']} drawn, " - f"{counts['absent']} not drawn, {counts[None]} unread") + f"{counts['absent']} absent, {counts[None]} unread") assert phrase in text, ( f"docs/domain-model.md does not say {phrase!r}. The audit moved and the " f"document did not; they are updated in the same commit.") @@ -388,7 +388,18 @@ def test_the_document_quotes_the_same_parameter_counts(): (pathlib.Path(__file__).parents[1] / "docs" / "domain-model.md") .read_text(encoding="utf-8").split()) read = per_status["audited"] + per_status["drawn"] - for phrase in (f"cover {read} of the 611", f"unread cover {per_status[None]}"): + read_lists = sum(status in ("audited", "drawn") + for status in options.OPTION_AUDIT.values()) + absent = per_status["absent"] + absent_lists = sum(status == "absent" + for status in options.OPTION_AUDIT.values()) + unread = per_status[None] + unread_lists = sum(status is None + for status in options.OPTION_AUDIT.values()) + for phrase in ( + f"{read_lists} assessed lists cover {read} parameters", + f"{absent_lists} lists looked for and not drawn account for {absent}", + f"{unread_lists} unread lists account for {unread} of the 611"): assert phrase in text, ( f"docs/domain-model.md does not say {phrase!r}. The parameter " f"counts moved and the document did not.") From 0d2bbe870d318333f64e579b8557c6d7eeaa8079 Mon Sep 17 00:00:00 2001 From: Antoni Ivanov <262547018+tony-xmelon@users.noreply.github.com> Date: Sun, 27 Sep 2026 11:16:00 +0300 Subject: [PATCH 8/8] docs: refresh generated option counts --- scripts/generate_options.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/generate_options.py b/scripts/generate_options.py index 623e83b9..f3d5abc8 100644 --- a/scripts/generate_options.py +++ b/scripts/generate_options.py @@ -18,12 +18,12 @@ Four decisions this generator makes: -1. **One enum per distinct LIST, not per parameter.** 527 parameters carry a +1. **One enum per distinct LIST, not per parameter.** 611 parameters carry a fixed list and they use only 113 distinct ones, of which 110 get an enum, because the same list means the same thing everywhere: the note-length list is shared by ``SYNC NOTE``, ``SYNC NOTE L``, ``SYNC NOTE R``, ``SYNC NOTE A`` and ``SYNC NOTE B``. One enum per list is one enum per concept. -2. **``Off,On`` gets no enum.** 247 of those 527 offer exactly "Off" and "On", +2. **``Off,On`` gets no enum.** 303 of those 611 offer exactly "Off" and "On", and ``OffOn.ON`` says nothing that ``True`` does not. Those parameters take a bool. 3. **The device's spelling is kept on the wire and corrected in the name.** @@ -542,7 +542,7 @@ def collect_all(cat: catalog.ModelCatalog) -> dict: Every one, including the two that become a bool and the one already published by hand. ``OPTION_AUDIT`` covers these rather than only the enums: a list with no enum is still a list whose words nobody has checked, - and the Off/On pair alone is 247 parameters. Counting only the enums would + and the Off/On pair alone is 303 parameters. Counting only the enums would report the job as smaller than it is. """ lists = collections.defaultdict(list)