Rewrite LoadDerivationSnapshot with set-based aggregation - #41
Merged
Conversation
The per-scope correlated aggregation scaled linearly in scopes toward the deriver's 500-scope cap (32.6ms for one scope, 578.6ms at 500 in the issue's EXPLAIN evidence). Following the 0005 drift keyset pattern, the query now resolves the scope key set first and hydrates with grouped set-based aggregation. Row-for-row equivalence with the prior shape is proven over adversarial seeds (duplicate scopes, unknown scopes, empty scopes, tombstoned entities, every entity kind) via EXCEPT ALL in both directions, with the jsonb payloads compared both parsed and textually since downstream consumers may hash snapshot text; explicit ordering is preserved. A plan-shape assertion pins the set-based form. No deriver behavior change. Fixes #38 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
ewhauser
force-pushed
the
derivation-snapshot-query
branch
from
August 5, 2026 01:42
71ed18e to
0283da0
Compare
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 #38 — the deriver snapshot query drops per-scope correlated aggregation for the 0005-style keyset + grouped hydration shape (issue's EXPLAIN evidence: 578ms at the 500-scope cap). Row-for-row equivalence proven over adversarial seeds (
EXCEPT ALLboth directions, payloads compared parsed and textually), ordering explicit, plan shape pinned. No deriver behavior change.Built and adversarially reviewed by paired Codex sol-xhigh agents in a dedicated worktree (parallel batch #33–#38). Full gate green locally.
🤖 Generated with Claude Code