fix: restore exact PostgreSQL list counts at scale - #160
Merged
Merged
Conversation
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.
Fixes #159.
Default PostgreSQL lists on large collections timed out while counting every matching row through Cedar. Generated Read policies can now use exact database counts after comparison of the applicable policy ASTs and storage certification establish equivalent authorization, including tenant isolation. Default totals remain exact and enabled.
Custom applicable Read predicates, explicit operator policies, unsupported storage shapes, and other backends retain the exact authorized scan. Each list captures its policy snapshot and prepares principal/action state once; the default Cedar adapter is no longer evaluated twice.
count=falseskips storage certification and stops after filling the readable page. Projection, field restrictions, filters, offsets, sorting, and relation enrichment keep their existing behavior.The storage proof checks schema identity, physical columns, strict Cedar representation, and decoder limits under one PostgreSQL transaction snapshot. Unproven shapes fall back; I/O failures remain errors. Conservative string checks avoid the expensive regular expressions found during scale testing.
Validation completed:
Residual custom-policy work remains proportional to matching rows. A debug-build sparse-policy query over 20,000 candidates returned an exact total of 20, while the 202,628-candidate custom scan reached the request deadline. This patch does not claim globally bounded exact counts or infer release-build custom-policy timing from the debug build.
Includes CLI v0.44.1, integration crate v0.43.1, backend v0.17.1, PostgreSQL v0.12.1, and release notes so the fix needs only one PR validation cycle before tagging.