fix(entry): support EC account sets in entry listing query#706
Closed
HonestMajority wants to merge 7 commits into
Closed
fix(entry): support EC account sets in entry listing query#706HonestMajority wants to merge 7 commits into
HonestMajority wants to merge 7 commits into
Conversation
…listing Replace cala_balance_history join with cala_account_set_member_accounts in list_for_account_set_id_by_created_at so it returns entries for eventually_consistent account sets. The old query returned empty results because cala_balance_history is only populated during synchronous posting (non-EC path). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Look up the eventually_consistent flag internally in the repo so the public API is unchanged. Only EC sets use the new member_accounts-based query; non-EC sets continue to use the original balance_history query. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The UNIQUE(account_set_id, member_account_id) constraint on cala_account_set_member_accounts guarantees each account appears at most once per set, so the join cannot produce duplicate entry rows. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
📊 Performance ReportCommit: b5cb31e Cala Performance Benchmark Results (non-representative)Criterion Benchmark Results (single-threaded)
Load Testing Results (parallel-execution)
Note: Performance results may vary based on system resources and database state. Last updated by commit b5cb31e |
The membership-based query returned entries from all journals, unlike the original balance_history query which was implicitly journal-scoped. Look up the journal_id from cala_account_sets alongside the EC flag and filter entries to the correct journal. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The journal_id is only needed for the EC query path. Keep the shared lookup lightweight — only fetch the eventually_consistent flag for all callers, and defer the journal_id lookup to the EC branch. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The eventually_consistent prelude used fetch_one, which errors with RowNotFound if the account set does not exist. This changed the error surface for the non-EC path, which previously returned an empty list for unknown ids via an empty JOIN. Switch to fetch_optional and short-circuit with an empty result when the id is absent, restoring prior semantics for both paths. Co-Authored-By: Claude Opus 4.6 (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.
Summary
The
list_for_account_set_id_by_created_atquery in the entry repo joined throughcala_balance_history, which is never populated for eventually-consistent (EC) account sets during normal posting. This meantcala.entries().list_for_account_set_id(...)always returned empty results for EC sets.The fix introduces a dual-path query strategy based on the account set's
eventually_consistentflag:cala_account_set_member_accountswith aLEFT JOIN cala_account_sets ... IS NULLfilter to resolve leaf accounts — the same pattern used inbalance/repo.rsforfetch_batch_member_historyandfetch_member_account_mappingscala_balance_historyjoin, which remains correct and well-testedAn integration test (
ec_account_set_entry_listing) covers EC entry listing with pagination and DESC ordering.🤖 Generated with Claude Code
Note
Medium Risk
Changes the DB query path used to list entries for account sets based on the
eventually_consistentflag, which could affect correctness/performance of pagination and ordering for entry listings.Overview
Fixes
entries.list_for_account_set_idreturning empty results for eventually-consistent (EC) account sets by switching to a new listing query that resolves leaf member accounts viacala_account_set_member_accounts(and filters out nested sets), while keeping the existingcala_balance_historyjoin for non-EC sets.Adds an integration test
ec_account_set_entry_listingthat validates EC entry listing returns results and that pagination cursors and descending ordering behave as expected. Regeneratessqlxquery metadata files for the updated queries.Reviewed by Cursor Bugbot for commit b5cb31e. Bugbot is set up for automated code reviews on this repo. Configure here.