Files
DumiFlex 2cf7f7e8c3 fix(axes,internal): fix the inline accessor warn+colour and internal last-write-wins
Two bugs the modal-only testing missed, both verified in the live canvas.

1. Assembler template (and every inline `.wp-rt-var` render) mis-parsed an
   index-first accessor. `varSpanAttrs` hand-rolled the axis extraction with a
   `.replace(/\.\d+$/,"")` that only strips a TRAILING index, so
   `$outfit.0.SHOES` produced axis "0.SHOES", matched no declared axis, and
   painted a valid reference with the unknown-axis warning — the yellow
   squiggle in the screenshot. Replaced with the one shared `varAccessorParts`
   grammar (index + axis, either order), and split the inline tail into a
   neutral index span and an amber axis span to match the settled chip. The
   canvas CSS copy (rich-text-canvas.css) had no accessor rule at all, so the
   amber never applied there — added it.

2. `instance.internal` was add-only in three places (engine pipeline, the
   graph.ts kinds walk, the static resolver), so a var written internal then
   overridden by a PUBLIC module stayed hidden from the assembler forever.
   Made all three last-write-wins: whichever module writes the var LAST decides
   its internal-ness, exactly like its value. Verified both directions live —
   internal→public shows "public value", public→internal hides it.
2026-08-19 03:27:25 +03:00

48 lines
1.8 KiB
Python

"""`instance.internal` is last-write-wins, exactly like the value.
A var written first by an internal module and then overridden by a PUBLIC
module must end up public — the assembler renders it. The flag map used to be
add-only: once any writer marked a var internal it stayed hidden forever, even
when its final value came from a public module. Reported from the canvas:
"mark first $outfit internal, mark the second $outfit not internal, and the
assembler still can't see it."
"""
from engine.context import strip_internals
from engine.pipeline import PipelineEngine
def _fixed(binding: str, value: str, *, internal: bool) -> dict:
return {
"type": "fixed_values",
"id": binding.ljust(8, "0")[:8],
"payload": {"values": [{"id": "v1", "name": binding, "value": value}]},
"instance": {"internal": internal},
}
def test_public_override_of_internal_var_is_visible():
ctx = PipelineEngine().run([
_fixed("outfit", "hidden one", internal=True),
_fixed("outfit", "public one", internal=False),
])
assert ctx["outfit"] == "public one"
assert ctx["__wp_internal_flags__"].get("outfit") in (None, False)
# The render boundary must now KEEP it.
assert strip_internals(ctx).get("outfit") == "public one"
def test_internal_override_of_public_var_hides_it():
# The mirror: last writer internal -> hidden, even if an earlier writer
# was public.
ctx = PipelineEngine().run([
_fixed("outfit", "public one", internal=False),
_fixed("outfit", "hidden one", internal=True),
])
assert ctx["__wp_internal_flags__"].get("outfit") is True
assert "outfit" not in strip_internals(ctx)
def test_a_lone_internal_var_still_hides():
ctx = PipelineEngine().run([_fixed("scratch", "x", internal=True)])
assert "scratch" not in strip_internals(ctx)