Skip to content

fix: Preserve exact cash and native balance currency - #514

Merged
Pigbibi merged 1 commit into
mainfrom
fix/f07-native-cash-currency
Nov 2, 2026
Merged

Pigbibi merged 1 commit into
mainfrom
fix/f07-native-cash-currency

Conversation

@Pigbibi

@Pigbibi Pigbibi commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

AI assistance

Implemented with OpenAI Codex (gpt-6.1-sol).

What changed

Preserve native cash and currency semantics in cached account facts (F07-D1/F07-D2):

  • Publish cash_balance only from exact provider cash. Missing cash produces an empty cash list, even when available cash is present; zero, negative cash and decimal text are preserved.
  • Require explicit native balance currency. Missing/invalid currency raises the existing fixed provider_currency_unavailable error before archive or publication; USD and configured position currency cannot replace it.
  • Add balance_metrics.currency to both existing cached archive records, preserving native currency or JSON null. Keep exact cash, available cash and buying power separate.
  • Document the contract and cover nullable/missing fields, native non-USD currency, JSON persistence and endpoint side effects with synthetic regressions.

How verified

  • Fail-before regression run: 10 failed / 61 passed on unchanged production code.
  • Focused offline tests: 152 passed.
  • Full offline suite: 1,803 passed and 118 subtests passed; one existing exchange-calendar deprecation warning.
  • Installed-lock shared dependency provenance: 3 passed.
  • Ruff, documentation style (zero blocking, one existing README advisory), diff check, dependency compatibility and frozen offline lock validation passed.
  • Offline isolated sdist/wheel build passed.

Tests and build ran under an inherited seccomp network-denial filter. The first full run was interrupted during automatic Google Auth metadata detection; the successful full run used NO_GCE_CHECK=true, retaining network denial and all assertions. An initial non-isolated build lacked setuptools; the final isolated build used cached build dependencies. Hosted CI and deployed runtime behavior have not been verified.

Why

Available cash previously became a fact tagged provider.cash_balance when exact cash was missing; missing native currency was asserted as USD. The cached archive also omitted currency even when the collector had it. These paths could misstate the financial facts needed for forward reconciliation.

Risk

Bounded change to application/account_facts_publisher.py and application/session_check_service.py, with related tests and documentation. Missing native currency deliberately returns 503 from the existing sync endpoint. The archive helper retains null independently; the endpoint still validates publication before archiving. Existing archive writes remain non-atomic, and the separate older saved-history route keeps its existing currency policy.

Forward-only scope starts 2026-11-03; no history backfill or archive rewrite. No trading gate, live/Kelly/stop-loss switch, workflow, dependency pin, deployment or broker/cloud operation changed. Authentic accounting reconciliation and runtime adoption remain UNRECONCILED / NOT_PROVEN.

@coderabbitai

coderabbitai Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f665e423-2211-4416-9bdd-14f9e3a3c4fc
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@Pigbibi Pigbibi added the owner-approved Owner approval for high-risk PRs. AI agents must never apply this label. label Nov 2, 2026
@Pigbibi
Pigbibi marked this pull request as ready for review November 2, 2026 20:22
@Pigbibi
Pigbibi merged commit af3bba0 into main Nov 2, 2026
11 of 12 checks passed
@Pigbibi
Pigbibi deleted the fix/f07-native-cash-currency branch November 2, 2026 20:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

owner-approved Owner approval for high-risk PRs. AI agents must never apply this label.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants