Skip to content

Repro: unconstrained liveArray never receives membership events from query subscriptions - #44

Closed
jimmy-phantom wants to merge 1 commit into
mainfrom
live-array-event-source-routing
Closed

Repro: unconstrained liveArray never receives membership events from query subscriptions#44
jimmy-phantom wants to merge 1 commit into
mainfrom
live-array-event-source-routing

Conversation

@jimmy-phantom

Copy link
Copy Markdown
Collaborator

What

Adds a passing test that pins current behavior of the "live list" pattern: a REST list query whose result is a sorted, unconstrained liveArray, with getConfig().subscribe pushing update events for upserted rows and delete events ({ id, data: id }) for removals.

Event Expected by the pattern Actual
update on existing row's fields merge, re-render works
update changing a sort field re-sort works
update for unseen id insert no-op
create for unseen id insert no-op
delete for existing row remove no-op

So only rows present at fetch time ever update; membership never changes.

Why

An unconstrained liveArray registers under the default constraint [[EVENT_SOURCE_FIELD, parent.key]], where parent is the query result's root entity (createLiveCollection in LiveCollection.ts). Query subscriptions stamp events with __eventSource = queryKey (reconcileSubscription in QueryResult.ts). The two keys are derived differently and never agree, so ConstraintMatcher.routeEvent never delivers membership events to the binding.

Field updates still work because they flow through the entity merge path in applyMutationEvent, which does not depend on constraint routing.

Behavior is identical in the published 0.2.1 dist and current source. The existing suite doesn't catch this: the only unconstrained-liveArray test asserts initial parse only, and every membership test uses explicit constraints.

Notes

The test asserts the current broken behavior (with the broken cases marked BROKEN in comments) so it runs green as documentation. Once the routing is fixed, flipping those assertions turns it into the regression test.

🤖 Generated with Claude Code

…rship events

Pins current behavior of the live list pattern (REST list query with an
unconstrained sorted liveArray plus config.subscribe): field updates to
existing rows merge and re-sort, but create/update for unseen ids never
insert and delete never removes. The default event-source constraint
registers under the result root entity key while query subscriptions stamp
events with the query key, so routing never matches.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.

1 participant