Repository navigation
json-rules 3.4.1: bridged sources over-fetch and re-check - #31
Merged
Merged
Conversation
A source across a bridge (where, carried grant, label or axis) now gets a
real query for the local side, with the bridged parts folded to TRUE, plus
a `recheck` condition the caller runs over candidate rows once the far side
is loaded. materializeSourceQuery({ lens }) applies it, with the round-11/12
misuse detection. SourceQuery.prisma is non-null again.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Per Aron (2026-10-08): "when you're doing an in-memory check, you have to overfetch. You shouldn't be pre-filtering because that way the rules break."
Change
toSourceQueriesreturns a real query for a source across a bridge. Its where, a carried grant, its label or an axis can be what crosses. What reads across the bridge compiles to TRUE, so the rows are a superset. The query carriesrecheck: the conjuncts ofcomposedWherethat read across a bridge, ortruewhen only the label or an axis does. Every bridged query carriesrecheck, and non-bridged queries carry none.recheckreads, and each bridge's localonkey. It has nodistinct.recheck.materializeSourceQuery(query, rows, { lens, …CheckOptions })appliesrecheckto candidate rows that hold the far side inline. It reads a bridged label or axis from the far side, in both row shapes. If the far side is missing or partial, or is a list where the bridge names one row, it throwsUsageError; so does a call withoutlens.SourceQuery.prismais non-null again (reverts the 3.4.0 null).materializeSourcesnow refuses every pointer, bridged ones included, because they all have a query.First consumer: rules-builder / Kingdom source pickers over bridged lenses. Before this they got
prisma: nulland had no query.Tests
test/lens.bridgeRecheck.test.tsuses PGlite users with in-memory CRM profiles. It runs both the Prisma and SQL rails and covers:notEqualswhere;In each case the DB rows are a superset, and candidates plus far side plus
recheckequal the hand oracle.materializeSourcesagrees. A non-bridged source has norecheckand is unchanged. Misuse cases each throwUsageError: no lens, far side not loaded, far side partial, far side as a list.The bridged tests in rounds 9, 10 and 11 and in
sourceFromMapDefaultswere updated to the new contract.bun run check: 2647 pass.🤖 Generated with Claude Code