[BTAPI-77] Source sync status from wealthsimple-api #95
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feature/BTAPI-77"
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?
Ticket
BTAPI-77 Source sync status from wealthsimple-api
Summary
fetchStatus()tolib/wealthsimple/activity-feed-client, reading wealthsimple-api'sGET /status(WSAPI-7) and validating it with zod, following the module's existingfetchActivityFeedconventions (sharedTIMEOUT_MS,WealthsimpleApiClientErroron every failure).lib/sync-status'swealthsimpleStatus()now branches onConfig.wealthsimpleApiEnabled: flag off keeps today's contract byte-identical (local session + local sync-state, always 200); flag on sourcessession/lastSyncedAt/lastResult/lastErrorfrom wealthsimple-api instead, wideningsessionto a fourth value ('unreachable') and letting/sync/statusanswer 503 whensession !== 'ok'.consecutiveFailures/cooldownUntil/cooldownReason/lastDoorbellTriggerAtstay locally sourced in both branches (no wealthsimple-api equivalent), factored into one shared helper so the branches can't drift.tick()halt (fromgetSessionHaltReason(), unconditional regardless of the flag) always wins over the flag-on path — a locally-halted engine reportslastResult: 'halted'even if wealthsimple-api's own cron is succeeding independently.fetchStatus()failure on the flag-on path is logged (including the operator-facingWS_API_KEY/INTERNAL_API_KEY-mismatch hint on a 401) before folding down to the generic, non-leaking'unreachable'the app sees.server/lib/wealthsimple/CLAUDE.md("BTAPI-77: the status source") and a short pointer in rootCLAUDE.md.WS_API_ENABLED=falsein every environment until deliberately turned on, so this PR changes no production behavior on its own.session: 'unreachable'. Not a merge blocker for this PR, per the approved plan — tracked as app-side follow-up work, no Plane ticket created here.Test plan
bun --cwd=./server run verify(type-check, lint, format, format:check, full test suite) — all greenGET /sync/statusis byte-identical to today's production behaviorsession: 'ok'; stop it, confirm 503/session: 'unreachable'with a non-leakinglastError; confirmlastDoorbellTriggerAtstill populates after a doorbell ring in both branches🤖 Generated with Claude Code