Repository navigation
Conversation
…path A query's topics come from the rows its whole join returns. For a `data.ref` lookup, an entity that has the first links of the path but not the rest returns no row, so it wasn't subscribed to. A write that completed its path, e.g. a first invitation on a map, didn't refresh the query. Let a pattern group give the values its symbols may take, and build its topics from those instead of the rows. A ref lookup gives the entities it checks, so it watches their first link, and every change to the later links and the value. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HRKkuGrp63pNCgPK1hVdC7
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the reference-lookup subscription changes.
No open issues 🎉
What changed in this PR
Fixes #2952 by subscribing data.ref permission lookups to entities with incomplete reference paths, allowing live queries to refresh when a write completes a missing link.
Changes:
- Adds symbol-seeded topics for reference lookups while preserving coarse-topic precedence.
- Passes topic seeds through both direct and prefetched CEL reference lookups.
- Adds regression tests for missing links in one- and two-link paths and unrelated-field writes.
| File | Description |
|---|---|
server/test/instant/reactive/session_test.clj |
Adds subscription helpers and partial-path refresh regression tests. |
server/src/instant/db/datalog.clj |
Carries topic seeds through pattern groups and builds topics independently of joined rows. |
server/src/instant/db/cel.clj |
Seeds subscriptions with checked entity IDs and forwards them through both reference lookup paths. |
Review effort: Balanced
Fixes #2952.
A
data.reflookup joins from each checked entity, through the path's links, to the value. Its topics came from the rows that join returned. An entity with none of the path, or only part of it, returned no row, so it wasn't subscribed to. A write that completed its path, such as a bookshelf's first link to a user, didn't refresh the query.This lets a pattern group give the values its symbols may take (
:topic-symbol-values). Its topics are then built from those instead of from the rows: each listed symbol is limited to its values, and every other symbol is a wildcard (datalog/seeded-topics).cel/build-querysets the entity symbol to the eids being checked. The ref lookup therefore watches the first link of every entity it checks, plus every change to the later links and to the value. Bothget-ref-manyandprefetch-data-refspass it through. Coarse topics still take precedence when they're on.That is broader than the exact path, but only for these lookups. A rule that dereferences a link can't know which later entities will join until the earlier links exist.
Test:
session-test'sref-rule-paths-refresh-for-partial-matchescovers a one-link path, where the entity has no link yet, and a two-link path, at each link. It also checks that a write to a field the rule doesn't read still doesn't refresh the query. Without the change, it fails with 4 failures and 3 errors.It adds a few helpers to
session-test. They subscribe, make one write, and check whether the write marked the query stale. #2953 adds the same helpers. Whichever merges second needs a trivial rebase, and I'm happy to do that. With #2953, one more assertion holds: a write to a field of the book that the rule doesn't read doesn't refresh the query.I also ran the
instant.db.*,instant.reactive.*andinstant.admin.*suites: all 433 tests passed, with 21,824 assertions.🤖 Generated with Claude Code
https://claude.ai/code/session_013K45h1bruWQBs4zfS2PjtD