Context
Found while checking the cross-window primitive for D#18224 (addendum, edge 3) at dev@2ee23d7801. A component that resolves its state provider implicitly — no stateProvider of its own, bindings resolved through the closest ancestor — keeps whichever provider it resolved FIRST across any later parent change or cross-window move, and nothing declares that this is the rule. The operator's idiom stateProvider: {parent: me.getStateProvider()} (explicit parent, chosen at creation) is unaffected; this is the fallback path only.
The Problem
component/Abstract#getStateProvider (src/component/Abstract.mjs:399–422) caches the closest provider under the closestProvider symbol and returns the cached value on every later call. manager.Component#onParentIdChange (src/manager/Component.mjs:515–540) maintains only childMap on a parent change — it never clears that cache (nor closestController, src/component/Base.mjs:1404–1414).
After a move, container.Base#createItem (src/container/Base.mjs:437) runs item.getStateProvider?.()?.createBindings(item):
- warm cache (the component resolved a provider before the move): the bindings are re-created on the ORIGINAL provider, where
createBinding dedupes by ${componentId}-${configKey} (src/state/Provider.mjs:447–455) — idempotent, and the component keeps binding to its first provider from any window. That is why cross-window bindings work today.
- cold cache (never resolved before the move): the NEW chain's provider is resolved and bindings are created there, while the old chain's provider — if it had bound this component through a parent-created binding — keeps its effect alive, because
#bindingEffects is per provider. Two providers may write the same config, decided by whether anything called getStateProvider() before the move.
Neither behaviour is documented; which one a component gets is a function of call history.
The Architectural Reality
state/Provider#getParent (src/state/Provider.mjs:607–624): explicit _parent first, tree walk only as fallback — so explicit chains are deterministic; only implicit resolution is affected.
getConfigInstanceByNtype walks parent links; the cache exists to avoid that walk on every data read.
- The multi-window examples (
examples/stateProvider/multiWindow/ViewportController.mjs:46–80) chain providers explicitly and never hit the fallback.
The Fix
Declare the rule and make the cache honour it — one of two, decided at review:
- Provider follows the tree (the intuitive reading of "closest"): clear
closestProvider / closestController in afterSetParentId (or in onParentIdChange) and cascade to descendants, and have createBindings on the new provider remove the component's bindings from the old one (a removeBindings(componentId) seam keyed like createBinding).
- Provider follows the instance (today's warm-cache behaviour): document it on
getStateProvider, and make the cold-cache path consistent by resolving the provider at construction (or at first bind) so a later move never re-resolves.
Either way the two-writer state becomes impossible: a component's bindings live on exactly one provider at a time.
Decision Record impact
none — no ADR governs provider resolution; the fix declares behaviour the engine already has.
Acceptance Criteria
Out of Scope
- Controller resolution (
closestController) beyond the same cache-clear if rule 1 is chosen.
- The dock owner design's group provider (D#18224), which sidesteps this by giving every Workspace an explicit parent.
Related
- D#18224 DC_kwDODSospM4BFxRT (edge 3) ·
examples/stateProvider/multiWindow · Memory Core 2026-07-04 (topology: all worker state is window-agnostic; the provider is a shared-binding surface).
Live latest-open sweep: checked the latest 40 open issues (created-desc) at 2026-09-04 13:37Z; no equivalent found. A2A claim sweep (last 60 min, all read-states): no claim on this scope. Memory Core sweep: one 2026-02 datum (a top-level binding failing after a provider was inserted between) — adjacent, not this. Own-assignment sweep: none.
unowned-rationale: engine-wide, measured but not yet reproduced as a spec; claimable; the two rules need a maintainer decision at review, not a lane.
Origin Session ID: ee061205-8271-4458-b73b-b132c1bec310
Retrieval Hint: query_raw_memories("closestProvider cache onParentIdChange createBindings move cold cache two writers")
Context
Found while checking the cross-window primitive for D#18224 (addendum, edge 3) at
dev@2ee23d7801. A component that resolves its state provider implicitly — nostateProviderof its own, bindings resolved through the closest ancestor — keeps whichever provider it resolved FIRST across any later parent change or cross-window move, and nothing declares that this is the rule. The operator's idiomstateProvider: {parent: me.getStateProvider()}(explicit parent, chosen at creation) is unaffected; this is the fallback path only.The Problem
component/Abstract#getStateProvider(src/component/Abstract.mjs:399–422) caches the closest provider under theclosestProvidersymbol and returns the cached value on every later call.manager.Component#onParentIdChange(src/manager/Component.mjs:515–540) maintains onlychildMapon a parent change — it never clears that cache (norclosestController,src/component/Base.mjs:1404–1414).After a move,
container.Base#createItem(src/container/Base.mjs:437) runsitem.getStateProvider?.()?.createBindings(item):createBindingdedupes by${componentId}-${configKey}(src/state/Provider.mjs:447–455) — idempotent, and the component keeps binding to its first provider from any window. That is why cross-window bindings work today.#bindingEffectsis per provider. Two providers may write the same config, decided by whether anything calledgetStateProvider()before the move.Neither behaviour is documented; which one a component gets is a function of call history.
The Architectural Reality
state/Provider#getParent(src/state/Provider.mjs:607–624): explicit_parentfirst, tree walk only as fallback — so explicit chains are deterministic; only implicit resolution is affected.getConfigInstanceByNtypewalksparentlinks; the cache exists to avoid that walk on everydataread.examples/stateProvider/multiWindow/ViewportController.mjs:46–80) chain providers explicitly and never hit the fallback.The Fix
Declare the rule and make the cache honour it — one of two, decided at review:
closestProvider/closestControllerinafterSetParentId(or inonParentIdChange) and cascade to descendants, and havecreateBindingson the new provider remove the component's bindings from the old one (aremoveBindings(componentId)seam keyed likecreateBinding).getStateProvider, and make the cold-cache path consistent by resolving the provider at construction (or at first bind) so a later move never re-resolves.Either way the two-writer state becomes impossible: a component's bindings live on exactly one provider at a time.
Decision Record impact
none— no ADR governs provider resolution; the fix declares behaviour the engine already has.Acceptance Criteria
bindand no own provider, resolved once, moved under a parent whose chain holds a different provider — under rule 1 its bindings move (old provider holds none for it); under rule 2 they stay and the new chain is never consulted. The spec asserts the chosen rule and the absence of the two-writer state in both warm and cold orders.stateProvider: {parent}keeps that parent through a move (unchanged behaviour, pinned).getStateProviderdocblock states the rule in one sentence;Provider#getParentcross-references it.Out of Scope
closestController) beyond the same cache-clear if rule 1 is chosen.Related
examples/stateProvider/multiWindow· Memory Core 2026-07-04 (topology: all worker state is window-agnostic; the provider is a shared-binding surface).Live latest-open sweep: checked the latest 40 open issues (created-desc) at 2026-09-04 13:37Z; no equivalent found. A2A claim sweep (last 60 min, all read-states): no claim on this scope. Memory Core sweep: one 2026-02 datum (a top-level binding failing after a provider was inserted between) — adjacent, not this. Own-assignment sweep: none.
unowned-rationale: engine-wide, measured but not yet reproduced as a spec; claimable; the two rules need a maintainer decision at review, not a lane.
Origin Session ID: ee061205-8271-4458-b73b-b132c1bec310
Retrieval Hint:
query_raw_memories("closestProvider cache onParentIdChange createBindings move cold cache two writers")