Skip to content

fix(hottesting): let derived feeds observe mocked inputs (backport #3192) - #3210

Merged
kazo0 merged 11 commits into
servicing/7.4from
mergify/bp/servicing/7.4/pr-3192
Oct 7, 2026
Merged

kazo0 merged 11 commits into
servicing/7.4from
mergify/bp/servicing/7.4/pr-3192

Conversation

@mergify

@mergify mergify Bot commented Oct 6, 2026

Copy link
Copy Markdown

Refs unoplatform/studio.live#4074

PR Type

  • Bugfix

Current behavior

Generated MVUX mocks replace a state above the context-shared subscription. Derived feeds (Select, Where, Combine, list operators, Messages(), and dynamic feeds) therefore continue to read the real input, which can reach null-injected services and fail.

New behavior

  • FeedSubscription owns the optional HotSwapFeed and is the single source-replacement point shared by states and operators.
  • Hot reload and mocking use that same subscription-level mechanism.
  • Hot reload aliases a replacement feed identity to the existing subscription, so incremental updates keep the same shared stream.
  • StateImpl no longer owns a generic source hot-swap. Its narrow HotSwap(replacement) redirects future writes to the replacement state.
  • State and subscription caches remain separate, so local state edits do not leak into operator subscribers.
  • HotSwapFeed always enumerates its wrapped feed with GetSource; resolving it through the context would return the same subscription recursively.
  • Every subscription, including a state's internal UpdateFeed, uses the same wrapper. Eager states and updates without a subscriber explicitly connect their subscription.
  • Subscription identity aliases use the same StateStore insertion path as normal subscription creation.

Verification

  • Focused subscription/state/mocking coverage: 34 passed.
  • Every non-UI unit-test project: 1,652 passed, 19 skipped.
  • No public API changes.

Review notes

Start with FeedSubscription, HotSwapFeed, StateStore, StateImpl.HotSwap, MockingService, and BindableViewModelBase.HotReload. Given_FeedSubscription covers direct enumeration, explicit eager activation, existing-subscriber replacement, and feed-identity aliasing. Given_StateImpl covers updates without subscribers, including redirected lazy states. Spec 013 records the selected architecture and self-resolution guard.


This is an automatic backport of pull request #3192 done by [Mergify](https://mergify.com).

rajamatt and others added 11 commits October 6, 2026 19:59
- in a mocking context, SourceContext.GetOrCreateSource asks the mocking layer which source to subscribe to; core only gains that hook (IMockingSourceResolver, registered by MockingService next to the activation probe), also used by FeedDependency for dynamic feeds
- Uno.HotTesting.Reactive resolves each observed feed to one swap layer per state store, and SwapFeed/SwapListFeed swap it together with the state (a list feed under both its keys), so Select, Where, list operators and dynamic feeds see a mocked input
- derivations observe the layer below the state's own updates, so a state edit stays local as in a live app; the resolver takes none of the store's locks
- live (non-mocking) contexts never consult the resolver and keep the existing subscription path
- tests: derived member computes over the mock and recomputes on re-swap, list Where computes over the mock, override still wins, state edits stay local, dynamic feed recomputes over a swapped list, a live context subscribes to its input directly

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 745fc87)
… derived feeds

- spec 013 architecture, implementation and spec text now describe the resolver hook and the per-feed swap layer instead of the factory-cache wrap that was never built
- history v16 records the fix, the drafts dropped in review, and the D6 row update

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 63f36cb)
… of the resolver

- the state observes the layer of its feed like the feeds derived from it, so SwapFeed/SwapListFeed now point that one layer at the mock, through an UnroutedFeed; a list feed no longer needs a second key
- a mock that is the member's own feed now restores the real feed instead of making the layer observe itself, and a replacement no longer gets a layer of its own on every SetMock
- the resolver leaves every state as-is, list states included (IListState is not an IState<IImmutableList<T>>)
- the resolver is registered before the activation probe; its contract and the mocking behaviour of GetOrCreateSource are documented
- tests: a two-level scalar chain computes over the mock and recomputes on re-swap, the member's own feed restores the real input, the live-context guard now asserts the resolver is never consulted, and LongItems is classified optional

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 087c0c0)
…rivations observe

- spec 013 now says SetMock is a typed swap of the member's layer, lists the resolver in the seams table, and records the accepted costs (no completion under mocking, one layer per observed feed)
- the remaining "reflection over IHotSwapState" wording and the D6 row are aligned with the implementation

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 3255e7a)
- A member's state and the feeds derived from it already read the feed through one subscription of the context; the swap sat above it, in the state.
- In a mocking context, that subscription now reads its feed through a HotSwapFeed, and SetMock swaps it: the state and every derivation see the mock.
- A state input is still swapped as a state, and a state's UpdateFeed is never wrapped.
- Replaces the source resolver, so core no longer calls into the mocking package.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 93a3b6c)
- The state and every derivation read one subscription per feed, which a mocking context can swap.
- The source resolver moves to the dropped drafts in history v16.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit dc3a8a7)
Use the context shared FeedSubscription as the only source-replacement point for hot reload and mocking. Preserve state update handoff and alias replacement feed identities for incremental hot reload.

(cherry picked from commit 2d162f2)
Remove the transitional dual-mode hot-swap path and keep subscription identity aliases behind StateStore shared cache insertion logic. Cover direct enumeration and replacement identity continuity at the FeedSubscription boundary.

(cherry picked from commit eb70e36)
Name state replacement after the operation while keeping UpdateFeed subscriptions direct so state updates activate before the first subscriber. Add a focused guard test and document the invariant.

(cherry picked from commit 8dc291c)
Wrap UpdateFeed subscriptions consistently for hot reload and mocking. Connect eager subscriptions through FeedSubscription and activate the final redirected state before applying updates without a subscriber.

(cherry picked from commit 662dd22)
The SessionCurrentEnumerator GetSource wrapper only forwarded to the feed; fold it into GetEnumerator with a null-conditional call.

(cherry picked from commit a16a8c0)
@kazo0
kazo0 merged commit 3268fdd into servicing/7.4 Oct 7, 2026
21 checks passed
@kazo0
kazo0 deleted the mergify/bp/servicing/7.4/pr-3192 branch October 7, 2026 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants