fix(compliance-bridge): honor zero balance in ledger providers - #93
Open
Nussu06 wants to merge 1 commit into
Open
fix(compliance-bridge): honor zero balance in ledger providers#93Nussu06 wants to merge 1 commit into
Nussu06 wants to merge 1 commit into
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.
Summary
GcsLedgerProvider.fetch_balanceandObjectStoreLedgerProvider.fetch_balanceresolve a per-account balance withbalances.get(account_id, balances.get("default_account", 0.0))and then fall back to the top-levelbalancefield underif not balance_value. That truthiness test treats a legitimate0.0as missing, so a drained account in a multi-account snapshot is reported with the top-level fallback instead of its real zero. The reconciler feeds the CBF an independent cash balance for the barrierh(x) = cash - min_cash, so an inflated balance lets a trade clear against an empty account. Both providers now resolve the balance with explicit membership checks, so a present0.0is kept while the absent-account fallback is unchanged.Type of Change
feat— new featurefix— bug fixdocs— documentation onlyrefactor— no feature/fix, code restructuringperf— performance improvementtest— test additions or correctionschore— build, deps, toolingci— CI/CD pipelineBREAKING CHANGE— existing behaviour changesRelated Issues / ADRs
N/A
Changes Made
src/compliance_bridge/reconciliation_worker.py— resolve the ledger balance in both cloud providers via explicitaccount_id in balances/default_account/ top-levelbalancechecks, so a real0.0is no longer overwritten by the fallback. Non-zero and absent-account behaviour is identical to before.tests/test_reconciliation_worker.py— regression coverage for both providers: a present0.0is preserved, a real per-account balance still wins over the fallback, and an absent account still uses the top-level balance.Testing
pytest tests/)make test-integration)Manual test steps (if applicable):
Compliance & Security Checklist
🔒 Universal — All contributors must verify (all regions affected)
cage_deployment_regionguard — the fix is region-agnostic🎯 Region-specific depth — Check only your target deployment
US_FED
EU_ECB
APAC_MAS
📋 Shared-module impact declaration
Cross-region impact summary (if applicable):
Deployment Notes
N/A