feat(prices): balance.service prices section + rate-limit + tests #156
Labels
No labels
autopilot:pending-human
source:analyste
source:defenseur
source:human
source:medic
status:approved
status:blocked
status:in-progress
status:needs-clarification
status:needs-fix
status:ready
status:review
status:triage
type:bug
type:feature
type:infra
type:refactor
type:schema
type:security
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: maximus/Simpl-Resultat#156
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Goal
Extend
src/services/balance.service.tswith apricessection that wraps thefetch_priceTauri command with rate-limiting, dedup, and a hard session cap.Contract reference
docs/api-contract-prices.md§6.2 (client rate-limit), §12.1 (tests), Annexe B (i18n mapping).Fichiers concernés
src/services/balance.service.ts(addpricessection, ~150 lines new)src/services/balance.service.test.ts(add new test suite, ~200 lines new)Depends on
Scope
balance.service.ts, add namespace exportprices:prices.fetchPrice(symbol: string, date: string): Promise<PriceResult>— callsinvoke('fetch_price', {...})FetchPriceError(string discriminant) to TS discriminated unionPriceErrorPriceError → balance.priceFetching.errors.<key>per Annexe BlastFiredAttimestamp +setTimeoutfor delay.Map<string, Promise<PriceResult>>keyed by${symbol}|${date}. Calls during in-flight return the same promise.provider_unavailable: 2s, 4s, 8s. Max 3 retries. Pas de retry sur 429 (cf. décision ce soir) — surface immédiat à l'UI.PriceError.SessionCapReached.vi.useFakeTimers():retry_afterawait prices.fetchPrice('AAPL', '2026-04-25')in parallel → 1 underlying invoke callCritères d'acceptation
npm test src/services/balance.service.test.tsgreen (≥ 8 tests onpricessection)vi.useFakeTimers()— non flakymsw,nock) — uniquementvi.fn()surinvoketsc --noEmit)Décisions prises ce soir
retry_after.vi.fn()natif surinvoke(pas demsw).Spec source
docs/api-contract-prices.mdmaximus referenced this issue2026-05-04 00:38:30 +00:00