Skip to content

docs(bss): fx rate provider module#8

Open
bit4flip wants to merge 1 commit into
mainfrom
bss/fx-provider-design
Open

docs(bss): fx rate provider module#8
bit4flip wants to merge 1 commit into
mainfrom
bss/fx-provider-design

Conversation

@bit4flip

@bit4flip bit4flip commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • Documentation
    • Added a complete technical design document for the FX Rate Provider adapter, detailing stateless fetch-only behavior, ordered source fallback, and direct-pair output.
    • Defined deterministic rate conversion rules (exact decimal parsing with banker's rounding), publication-based timestamp semantics, and provenance/serving-source reporting.
    • Documented operational constraints (sync job execution boundaries, strict configuration validation, and fail-safe error behavior) and end-to-end testing and monitoring expectations.
    • Added a product requirements document covering functional and non-functional requirements and acceptance criteria.

@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The PR adds product and technical design documents for a stateless FX Rate Provider adapter implementing RateProviderV1, with ordered source fallback, deterministic conversion, provenance tracking, ledger integration, operational constraints, and testing requirements.

Changes

FX rate-provider adapter

Layer / File(s) Summary
Adapter scope and contract
gears/bss/rate-provider/docs/DESIGN.md, gears/bss/rate-provider/docs/PRD.md
Defines the stateless fetch-only adapter, RateProviderV1 contract, direct-pair output, publication timestamp semantics, deterministic conversion, and responsibility boundaries with bss-ledger.
Source composition and wiring
gears/bss/rate-provider/docs/DESIGN.md, gears/bss/rate-provider/docs/PRD.md
Specifies configuration-driven sources, composite whole-document fallback, provenance reporting, source mappings, validation, and ClientHub registration.
Operations and delivery constraints
gears/bss/rate-provider/docs/DESIGN.md, gears/bss/rate-provider/docs/PRD.md
Documents sync interactions, failure handling, security, metrics, testing, acceptance criteria, companion ledger requirements, and traceability references.

Estimated code review effort: 2 (Simple) | ~15 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and accurately reflects the new BSS FX rate provider documentation module.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch bss/fx-provider-design

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

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 8

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@gears/bss/rate-provider/docs/DESIGN.md`:
- Around line 275-280: Update the init() configuration validation so any
mismatch between sources[] order and the ledger’s fx.provider_order is rejected
as an initialization error rather than merely warned about. Keep provider
construction through build_source unchanged, and ensure initialization fails
before the composite can be used when the configured ordering differs.
- Around line 95-96: Update the composite fetch design to enforce a shared total
deadline or explicit per-source time budget across sequential fallback attempts,
rather than allowing each source to consume the full timeout independently.
Ensure the configured budgets align with the p95 ≤ 2 s target and
one-bounded-attempt behavior, and add coverage for the worst-case path where
both sources are unavailable.
- Around line 301-310: Update the SourceConfig initialization and outbound
request design to validate base_url before use, requiring HTTPS and rejecting
loopback, private, link-local, or otherwise disallowed destinations. Add
redirect handling that validates every target and prevents api_key credentials
from crossing hosts or schemes; keep secrets excluded from logs and fail
initialization for invalid endpoints.
- Around line 369-375: Resolve the mismatch between ECB’s EUR→X publication
format and the ProviderRate functional-per-unit-base contract: update the ECB
adapter and its contract tests so USD→EUR-style transaction-to-functional legs
are available, using deterministic inverse pairs where appropriate. Preserve
direct published rates, ensure the planned X→EUR→Y triangulation can obtain both
legs, and revise the design documentation to match the implemented ownership
decision.
- Around line 397-408: The http-json provider’s fetch_latest path must not
return a successful empty or misleading partial result when the document cannot
be mapped. Update the mapping flow used by fetch_latest so an entirely
unmappable document returns RateProviderError::Internal, and enforce the
configured all-or-nothing behavior for structural mapping failures if that rule
is strict; preserve counted skips only for valid documents with individually
unresolvable entries.
- Around line 417-422: Clarify the rate-to-rate_micro conversion specification
to require an exact decimal or integer-scaled representation before rounding,
avoiding binary floating-point behavior. Define half-even rounding for exact
halfway values, perform explicit overflow and non-finite validation, and map any
invalid or overflowing input to RateProviderError::Internal without truncation.
- Around line 49-52: Resolve the v1 scope in DESIGN.md by choosing either
implemented ECB-plus-bank/PSP fallback or ECB-only with fallback deferred, then
make the architecture overview, wiring section, decision O-10, factory, sample
configuration, and tests consistently reflect that choice. If fallback remains
deferred, describe CompositeRateProvider as a future extension and remove
normative v1 fallback claims; otherwise update the implementation and coverage
to include the ordered fallback behavior.
- Around line 327-334: Require the composite rate provider configuration to
contain at least one source before registration. Validate sources[] during the
composite provider setup, rejecting empty configurations before provider_id() or
fallback logic can access sources[0] or require a missing last error.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 19a07908-fbdb-4db3-9150-9bbffc0947c7

📥 Commits

Reviewing files that changed from the base of the PR and between e7361e7 and d6793e0.

📒 Files selected for processing (1)
  • gears/bss/rate-provider/docs/DESIGN.md

Comment thread gears/bss/rate-provider/docs/DESIGN.md Outdated
Comment thread gears/bss/rate-provider/docs/DESIGN.md Outdated
Comment thread gears/bss/rate-provider/docs/DESIGN.md Outdated
Comment thread gears/bss/rate-provider/docs/DESIGN.md
Comment thread gears/bss/rate-provider/docs/DESIGN.md
Comment thread gears/bss/rate-provider/docs/DESIGN.md
Comment thread gears/bss/rate-provider/docs/DESIGN.md Outdated
Comment thread gears/bss/rate-provider/docs/DESIGN.md Outdated
@bit4flip
bit4flip force-pushed the bss/fx-provider-design branch from d6793e0 to 8f601c0 Compare July 17, 2026 12:44

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@gears/bss/rate-provider/docs/DESIGN.md`:
- Around line 437-446: Update the rate conversion flow described in DESIGN.md to
reject any parsed FX rate that is zero or negative before scaling and rounding.
Map non-positive values to RateProviderError::Internal, while preserving the
existing exact-decimal parsing, half-to-even rounding, and overflow handling for
strictly positive rates.
- Around line 560-566: Update the integration-test networking guidance around
the local HTTP server to use test-only HTTPS or a narrowly scoped
loopback/private-host allowlist. Ensure the exception is explicitly limited to
integration-test initialization and cannot alter production URL validation or
redirect credential policy, including the related sections at the referenced
locations.
- Around line 189-191: Define the canonical UTC conversion for date-only
provider publication dates in the `as_of` design, including the exact timezone
and time (or explicitly retain date-only precision), and apply it consistently
to the related sections. Add a golden test covering the conversion and resulting
ledger staleness behavior.
- Around line 41-43: Update the Status block in DESIGN.md to reflect that
decision O-12 was recorded on 2026-07-17, including a refreshed date or wording
that accurately represents the document’s current readiness state; preserve the
existing references to O-1, O-3, and the bss-ledger dependency.

In `@gears/bss/rate-provider/docs/PRD.md`:
- Around line 253-257: Update the posting-path isolation requirement in the PRD
to apply only to non-FX posts: state that provider outages must not affect
non-FX posting latency or availability, while explicitly allowing FX posts to
block through the ledger fail-safe. Align the threshold wording so it no longer
claims provider downtime cannot affect posting availability generally.
- Around line 61-62: Make the cross-currency business goal at
gears/bss/rate-provider/docs/PRD.md lines 61-62 conditional on supported
EUR-functional flows or the companion ledger capability, rather than claiming
unconditional success. Apply the same currency-scope precondition to the
acceptance criterion at gears/bss/rate-provider/docs/PRD.md lines 361-363,
preserving the direct-pair-only adapter scope.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: fd7a88f3-c104-4f61-859b-1c5c5bcecd52

📥 Commits

Reviewing files that changed from the base of the PR and between d6793e0 and 8f601c0.

📒 Files selected for processing (2)
  • gears/bss/rate-provider/docs/DESIGN.md
  • gears/bss/rate-provider/docs/PRD.md

Comment thread gears/bss/rate-provider/docs/DESIGN.md
Comment thread gears/bss/rate-provider/docs/DESIGN.md
Comment thread gears/bss/rate-provider/docs/DESIGN.md
Comment thread gears/bss/rate-provider/docs/DESIGN.md
Comment thread gears/bss/rate-provider/docs/PRD.md
Comment thread gears/bss/rate-provider/docs/PRD.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant