Repository navigation
fix(client): scalar-only path — case-insensitive lookup + tier='scalar' sentinel (#368, #370) - #371
Merged
Merged
Conversation
…r' sentinel (#368, #370) Two related bugs broke the scalar-only render path; both surface in pymat's BERNHARD_SCALAR_ONLY visual regression case (rendered as default-grey because every PBR scalar was silently dropped). Bug A (#368): _scalars_for did a case-sensitive entry["id"] != material_id comparison. Substrate stores normalized lowercase ids; callers (pymat, downstream) routinely pass capitalised display names ("Aluminum", "Plastic (Acrylic)"). Result: silent {} return. Fix: match canonical id exactly OR casefold-normalized id OR casefold-normalized mat_vis.name, using the existing _normalize_name helper. Bug B (#370): _resolve_material_id raised MaterialNotStagedError when tier="scalar" was passed for scalar-only sources (physicallybased + the 18 gpuopen scalar-only entries). "scalar" is the convention sentinel (cf. pymat TIERS_SCALAR = ["scalar"]), not a missing bake. Fix: special-case tier="scalar" inside _is_staged so the membership check is skipped; every entry counts as staged for the sentinel tier. Mirrored both fixes to mat_vis_client_standalone.py to keep the single-file mirror in sync (drift test passes). Tests (9 new, mocked indexes, no network): - case-insensitive _scalars_for("physicallybased", "Aluminum") - lowercase id still works (regression) - display-name lookup with punctuation ("Plastic (Acrylic)") - silent-on-miss contract preserved - _resolve_material_id(..., "Aluminum", "scalar") returns "aluminum" - gpuopen Chrome scalar-only path returns the UUID - direct lowercase id with tier="scalar" resolves - regression: tier="1k" still raises MaterialNotStagedError on missing bake - regression: tier="1k" + staged entry still returns canonical id Suite: 442 → 451 passing in clients/python.
This was referenced May 8, 2026
This was referenced May 8, 2026
Closed
gerchowl
added a commit
that referenced
this pull request
May 8, 2026
) (#375) Three call sites in mat-vis-client were doing variations of the "match an entry by canonical id OR display name OR normalized id" lookup, with subtle drift: | Site | Pattern | Strength | |-------------------------------------|------------------------|----------| | _scalars_for | inline 3-way (post #371)| strong | | VisAsset._is_scalar_only_entry | inline 2-way | weaker | | _resolve_material_id | by_id+by_name w/ ambig.| separate | The 2-way pattern in `_is_scalar_only_entry` skipped the "normalized id" leg — a silent #367-class gap that would surface the moment a caller constructs `VisAsset(source="physicallybased", material_id="Aluminum")` (substrate id is `"aluminum"`, lowercase). Fix: extract one static predicate `_entry_matches_id_or_name` on MatVisClient. Three-way match (canonical id exact / norm id / norm name). Replace the inline blocks in `_scalars_for` and `_is_scalar_only_entry`. `_resolve_material_id` keeps its own logic (ambiguity detection + typed errors is a different responsibility). Standalone single-file client mirrors the same predicate — drift test (test_standalone_drift.py) keeps both surfaces in sync. Net: 56 lines added, 36 removed. Existing #367/#368/#370 tests cover the matching contract — no new tests needed. Closes #367 in passing (the silent strengthening of `_is_scalar_only_entry` is the missing leg from the pre-#371 surface).
This was referenced May 8, 2026
Open
Closed
gerchowl
added a commit
that referenced
this pull request
May 15, 2026
…r' sentinel (#368, #370) (#371) Two related bugs broke the scalar-only render path; both surface in pymat's BERNHARD_SCALAR_ONLY visual regression case (rendered as default-grey because every PBR scalar was silently dropped). Bug A (#368): _scalars_for did a case-sensitive entry["id"] != material_id comparison. Substrate stores normalized lowercase ids; callers (pymat, downstream) routinely pass capitalised display names ("Aluminum", "Plastic (Acrylic)"). Result: silent {} return. Fix: match canonical id exactly OR casefold-normalized id OR casefold-normalized mat_vis.name, using the existing _normalize_name helper. Bug B (#370): _resolve_material_id raised MaterialNotStagedError when tier="scalar" was passed for scalar-only sources (physicallybased + the 18 gpuopen scalar-only entries). "scalar" is the convention sentinel (cf. pymat TIERS_SCALAR = ["scalar"]), not a missing bake. Fix: special-case tier="scalar" inside _is_staged so the membership check is skipped; every entry counts as staged for the sentinel tier. Mirrored both fixes to mat_vis_client_standalone.py to keep the single-file mirror in sync (drift test passes). Tests (9 new, mocked indexes, no network): - case-insensitive _scalars_for("physicallybased", "Aluminum") - lowercase id still works (regression) - display-name lookup with punctuation ("Plastic (Acrylic)") - silent-on-miss contract preserved - _resolve_material_id(..., "Aluminum", "scalar") returns "aluminum" - gpuopen Chrome scalar-only path returns the UUID - direct lowercase id with tier="scalar" resolves - regression: tier="1k" still raises MaterialNotStagedError on missing bake - regression: tier="1k" + staged entry still returns canonical id Suite: 442 → 451 passing in clients/python.
gerchowl
added a commit
that referenced
this pull request
May 15, 2026
) (#375) Three call sites in mat-vis-client were doing variations of the "match an entry by canonical id OR display name OR normalized id" lookup, with subtle drift: | Site | Pattern | Strength | |-------------------------------------|------------------------|----------| | _scalars_for | inline 3-way (post #371)| strong | | VisAsset._is_scalar_only_entry | inline 2-way | weaker | | _resolve_material_id | by_id+by_name w/ ambig.| separate | The 2-way pattern in `_is_scalar_only_entry` skipped the "normalized id" leg — a silent #367-class gap that would surface the moment a caller constructs `VisAsset(source="physicallybased", material_id="Aluminum")` (substrate id is `"aluminum"`, lowercase). Fix: extract one static predicate `_entry_matches_id_or_name` on MatVisClient. Three-way match (canonical id exact / norm id / norm name). Replace the inline blocks in `_scalars_for` and `_is_scalar_only_entry`. `_resolve_material_id` keeps its own logic (ambiguity detection + typed errors is a different responsibility). Standalone single-file client mirrors the same predicate — drift test (test_standalone_drift.py) keeps both surfaces in sync. Net: 56 lines added, 36 removed. Existing #367/#368/#370 tests cover the matching contract — no new tests needed. Closes #367 in passing (the silent strengthening of `_is_scalar_only_entry` is the missing leg from the pre-#371 surface).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes two related bugs in
MatVisClientthat broke the scalar-only render path. The surface symptom was pymat'stests/test_visual_regression.py::BERNHARD_SCALAR_ONLYcase rendering as default-grey, because every PBR scalar was silently dropped for the typical display-name input.Bug A — #368:
_scalars_forwas case-sensitiveMatVisClient._scalars_for(source, material_id)comparedentry["id"] != material_iddirectly. Substrate stores normalized lowercase ids ("aluminum"); callers (pymat, downstream tests) routinely pass capitalised display names ("Aluminum","Plastic (Acrylic)"). Result: silent{}return — every PBR scalar dropped, every scalar-only material rendered as default grey.Fix: match against the canonical
idexactly, OR casefold-normalizedid, OR casefold-normalizedmat_vis.name. Reuses the existing_normalize_namehelper (NFKC + casefold).Bug B — #370:
_resolve_material_idraised fortier="scalar"_resolve_material_idraisedMaterialNotStagedErrorwhentier="scalar"was passed for scalar-only sources (physicallybased + the 18 gpuopen scalar-only entries)."scalar"is the convention sentinel for scalar-only callers (cf. pymatTIERS_SCALAR = ["scalar"]), not a missing bake — the resolver should accept it.Fix: special-case
tier == "scalar"inside the inner_is_stagedpredicate so theavailable_tiersmembership check is skipped; every entry counts as staged for the sentinel tier. Direct-id, single-name-match, and disambiguation paths all continue to work.Standalone mirror
Both fixes mirrored to
clients/python/mat_vis_client_standalone.py. Thetests/test_standalone_drift.pysuite stays green.Tests
Added 9 unit tests in
clients/python/tests/test_scalar_only_lookup.py, all using mockedindex()returns (no network):_scalars_for("physicallybased", "Aluminum")returns full PBR"Plastic (Acrylic)"resolves{}for unknowns)_resolve_material_id("physicallybased", "Aluminum", "scalar")returns"aluminum"_resolve_material_id("gpuopen", "Chrome", "scalar")returns the UUIDtier="scalar"also resolvestier="1k"still raisesMaterialNotStagedErroron missing baketier="1k"+ staged entry still returns canonical idSuite: 442 → 451 passing in
clients/python(29 skipped, 2 xfailed unchanged).Out of scope
available_tiers: null) — that's a baker-layer concern, separate work.Test plan
cd clients/python && uv run pytest --tb=short -q— 451 passinguv run pytest tests/test_standalone_drift.py— drift test greenuv run pytest tests/— 604 passingBERNHARD_SCALAR_ONLYvisual regression should now render with the actual PBR scalars instead of default grey.