GeezerVison is showing github.com — id: design: Currency scaling — autoscaling service, Redis → multi-Turso → TigerBeetle path · Issue #5676 · developing-today/code
id: design: Currency scaling — autoscaling service, Redis → multi-Turso → TigerBeetle path #5676Labels app/idPackage/app: id (pkgs/ or apps/ in this repo)effort/lLarge: multi-day or open-ended; expect staged check-insepic/id-programReprioritization program epic (2026-11-12)kind/designA design proposal (design-architect): multi-step, phased, decision-bearingpriority/lowNice to have; do when convenientsource/creatorFiled by the new-issue-creator jobstatus/triagedTriaged and routed (see agent note)task/triageQueue packet kind: verify, reproduce, and route this item DescriptionExtends #2043 (ID currencies v1), #2063 (conversion engine), and #2290 (RateAuthorisation). This is an EXPANSION design: currencies must stay simple to use while the service behind them autoscales with load — and the storage path must evolve without ever breaking double-entry invariants.
Problem
#2043 defines currencies v1. Left open: what happens under real load. A currency system that is correct at demo scale but requires a rewrite (or downtime, or invariant-breaking migration) at production scale fails its purpose. Equally, reaching for the heaviest backend on day one buries a simple user-facing concept under operational complexity. We need an explicit scaling path: simple first, autoscaling always, advanced backends by swap — not by redesign.
Governing principles
- Simple to handle: for users and for client code, a currency is a named balance with transfers in/out. No backend concept (Redis, Turso, TigerBeetle) ever leaks into the user-facing API.
- Autoscale the whole service: not just the ledger store — the whole user-facing currency service (API, conversion, authorisation checks) must autoscale with load: stateless front-ends, horizontal scaling, no single-writer bottleneck in the hot path beyond what double-entry correctness strictly requires.
- Double-entry invariants are backend-independent: every transfer is balanced debits/credits, no negative-balance violations per currency rules, transfers are atomic and idempotent, and the ledger is auditable/replayable. These invariants MUST survive every backend swap unchanged, proven by tests run against every backend.
- Swap, don't rewrite: a backend abstraction (port) with adapters; moving stages is a deployment/migration exercise, not an API change.
The scaling path (stages)
Stage A — Pre-TigerBeetle: Redis-backed currency store + regular store
- Currency balances / hot state in a Redis-backed currency store (fast atomic operations, e.g. Lua-scripted double-entry postings, idempotency keys, per-account locks/striping).
- Currency entities, metadata, and durable records kept in the regular store with the existing mechanisms (the same persistence path the rest of ID already uses) — Redis is the hot/operational layer, the regular store remains the system of record for definitions and history unless the design explicitly rules otherwise; specify the write-through / reconciliation protocol between them, including crash recovery (Redis loss must never lose a committed transfer: define durability, snapshotting/replay from the regular store, and reconciliation jobs).
- Conversion hooks: id: design: conversion engine — linked transfer pairs, rate authorisation, liquidity accounts #2063 conversion engine calls into this stage unchanged; id: design: RateAuthorisation as a signed ID-graph object — schema, signing, revocation #2290 RateAuthorisation checks happen before posting and are recorded with the transfer.
Stage B — Sharded regular-store backends: multiple Turso DBs per currency grouping
- Design the step where the regular store itself shards: multiple Turso databases representing different currencies (or currency groups) — noted honestly as less clean than the ideal: cross-currency transfers then span databases, so the design must specify two-phase / saga-style cross-DB transfers, ordering, failure recovery, and how conversion (id: design: conversion engine — linked transfer pairs, rate authorisation, liquidity accounts #2063) coordinates a transfer whose legs live in different DBs.
- Per-DB autoscaling, connection management, schema versioning across a fleet of DBs, and a directory service mapping currency → DB.
- Migration tooling: moving a currency from one Turso DB to another (rebalancing) with zero-downtime and invariant checks before/after.
Stage C — TigerBeetle (eventual ideal backend)
- Design the TigerBeetle adapter against the same port: account/transfer mapping, TigerBeetle's own double-entry semantics, pending/post/void two-phase transfers, and how ID-level concepts (conversion, rate authorisation, holds) map onto it.
- Migration design Stage B → C: dual-run/shadow posting, ledger comparison, cutover per currency, rollback plan.
- The user-facing API and invariants do not change at this stage — that is the acceptance test of the whole abstraction.
Autoscaling design (all stages)
- Stateless currency-service front-end: any instance can serve any request; state lives in the store layer.
- Load model: define expected hot spots (a single popular currency/account), and mitigations: account striping, batched postings, read replicas / cached balance reads with defined staleness, and queue-based smoothing for bursts.
- Scaling triggers and limits: what metric scales the front-end, what metric signals a store-stage transition (A→B, B→C), and what the cost/ops profile of each stage is.
- Multi-region / latency considerations: state what v-next promises (single-region strongly consistent?) and what it explicitly defers.
Interfaces that must not change across stages
- Transfer API: create transfer (idempotency key, from, to, amount, currency, metadata), query balance, query history, hold/capture/release if supported.
- Conversion integration (id: design: conversion engine — linked transfer pairs, rate authorisation, liquidity accounts #2063): quote → authorised rate (id: design: RateAuthorisation as a signed ID-graph object — schema, signing, revocation #2290) → atomic multi-leg posting, or a specified failure with no partial legs.
- RateAuthorisation integration (id: design: RateAuthorisation as a signed ID-graph object — schema, signing, revocation #2290): who may authorise a rate, audit record of authorisation attached to every converted transfer.
- Events/notifications emitted on posting, so other ID subsystems react identically regardless of backend.
Correctness & verification
- One invariant test suite, run against every backend adapter (Redis stage, Turso stage, TigerBeetle stage): balanced postings, atomicity under injected crashes, idempotent retries, concurrent-transfer race tests, no lost committed transfers on store loss/restart.
- Property-based / model-based testing: random transfer sequences checked against a simple in-memory reference ledger.
- Reconciliation: continuous checker comparing hot store vs. system of record; alerting and repair procedure.
- Load tests per stage with published envelopes (transfers/sec, p99 latency) so the stage-transition triggers are evidence-based.
Decomposition sketch
Follow-on design tickets to be filed from this issue:
- Currency backend port (interface) + invariant test suite contract.
- Stage A design: Redis-backed hot store + regular-store system of record, write-through, crash recovery & reconciliation.
- Autoscaling design: stateless front-end, hot-account mitigations, scaling triggers.
- Stage B design: multi-Turso sharding by currency, cross-DB transfers with id: design: conversion engine — linked transfer pairs, rate authorisation, liquidity accounts #2063 conversion, rebalancing migrations.
- Stage C design: TigerBeetle adapter mapping + Stage B→C migration/cutover plan.
- Conversion & RateAuthorisation integration across stages (id: design: conversion engine — linked transfer pairs, rate authorisation, liquidity accounts #2063, id: design: RateAuthorisation as a signed ID-graph object — schema, signing, revocation #2290) — atomic multi-leg posting per backend.
- Load/correctness verification program: property tests, crash-injection, per-stage performance envelopes.
Open questions
- Is Redis the system of record for anything, or strictly a hot layer over the regular store — and what is the exact recovery story if Redis is lost mid-transfer?
- At what measured load does Stage A stop being sufficient? Define the trigger now, even approximately.
- Multi-Turso per-currency sharding: shard key is currency, currency group, or account range — and who operates the currency→DB directory?
- Cross-currency conversion atomicity in Stage B: true two-phase commit, saga with compensations, or a single coordinator DB for conversion legs?
- TigerBeetle timing: is Stage C a committed destination or an option to keep open — what must Stage A/B avoid doing that would block it?
- Balance-read consistency: may balance reads ever be stale (cached), and if so what does the UI promise users?
Program note: expansion-style design — a later pass breaks this into the follow-on design tickets above, then implementation tickets. Relatives: #2043, #2063, #2290. Activitydezren39 commented on Nov 5, 2026 Gap pass (WS-F, 2026-11-04): this issue's decomposition sketch is now filed.
Each follow-on design ticket named in the sketch above was filed as its own issue (label app/id), so the acceptance item “Follow-on design tickets filed from the Decomposition sketch” can now be checked:
Exception, where applicable: any sketch item already answered by a later filing is noted in the pass worklog rather than duplicated. Design prioritisation is now independent per ticket; implementation timing is a separate decision. dezren39 commented on Nov 5, 2026 🤖 Agent note · picked up
- Agent: queue worker (repo-worker-code), lane code-j
- Session / ID: task 10109
- Found via: queue claim
- Task: task 10109 (triage for issue id: design: Currency scaling — autoscaling service, Redis → multi-Turso → TigerBeetle path #5676, direct execution lane) — verifying the design issue at current main, checking its linked predecessors (id: design: ID currencies v1 #2043, id: design: conversion engine — linked transfer pairs, rate authorisation, liquidity accounts #2063, id: design: RateAuthorisation as a signed ID-graph object — schema, signing, revocation #2290), and recording the scoped fix/design path or blockers on the issue.
- Expectation: triage findings posted on issue id: design: Currency scaling — autoscaling service, Redis → multi-Turso → TigerBeetle path #5676 this shift; follow-up task enqueued if a scoped implementation step is identified.
- Links: issue id: design: Currency scaling — autoscaling service, Redis → multi-Turso → TigerBeetle path #5676
dezren39 commented on Nov 5, 2026 🤖 Agent note · triage complete
- Agent: queue worker (repo-worker-code), lane code-j
- Session / ID: task 10109
- Found via: queue claim (coverage-audit requeue)
Triage of issue #5676 at current main (verified fresh 2026-11-05):
- Issue id: design: Currency scaling — autoscaling service, Redis → multi-Turso → TigerBeetle path #5676 is OPEN, an expansion design issue (labels
source/creator, app/id); no hard-stop labels, no code defect to fix and nothing already merged that closes it.
- Its own acceptance path is already satisfied on the decomposition side: the Gap pass (WS-F, 2026-11-04, comment 6647565318) filed every follow-on design ticket in the sketch, and I verified each is still OPEN today:
- Relatives checked fresh: id: design: ID currencies v1 #2043 OPEN but
queue/blocked + user/escalated (a Drew-owned decision, not touched here); id: design: conversion engine — linked transfer pairs, rate authorisation, liquidity accounts #2063 CLOSED; id: design: RateAuthorisation as a signed ID-graph object — schema, signing, revocation #2290 OPEN with user/escalated.
Scoped path / ordering (no implementation is scoped from #5676 itself):
- id: design: currency backend port + invariant test suite contract (from #5676) #5823 first — the backend port + invariant suite is the contract every stage adapter must satisfy; it gates id: design: Stage A: Redis hot store + regular-store system of record (from #5676) #5824/id: design: Stage B: multi-Turso sharding by currency (from #5676) #5826/id: design: Stage C: TigerBeetle adapter + B→C cutover (from #5676) #5827.
- id: design: Stage A: Redis hot store + regular-store system of record (from #5676) #5824 (Stage A) and id: design: currency autoscaling design (from #5676) #5825 (autoscaling) next, in parallel.
- id: design: Stage B: multi-Turso sharding by currency (from #5676) #5826 (Stage B) after Stage A; its conversion coordination builds on id: design: conversion engine — linked transfer pairs, rate authorisation, liquidity accounts #2063 (closed).
- id: design: conversion & RateAuthorisation across stages (from #5676) #5828 depends on id: design: RateAuthorisation as a signed ID-graph object — schema, signing, revocation #2290, which is
user/escalated — that dependency is blocked on Drew's recorded decision there, not on engineering.
- id: design: Stage C: TigerBeetle adapter + B→C cutover (from #5676) #5827 (TigerBeetle) last; id: design: currency load & correctness verification programme (from #5676) #5829 (verification programme) runs across all stages.
Blockers recorded: the only hard dependency blocker in this set is #2290 (user/escalated) feeding #5828. Design prioritisation per child ticket is independent (per the gap pass); implementation timing is a separate decision. Issue #5676 stays open as the umbrella until its children land — closing it now would lose the tracking point, and no evidence supports closing it as done.
dezren39 commented on Nov 14, 2026 🤖 Agent note · triaged
State found (revalidated fresh, 2026-11-14): this expansion design is fully decomposed and its base is real. Nothing is unfiled; the issue stands as the umbrella.
- Base exists: currencies v1 is designed (id: design: ID currencies v1 #2043 CLOSED) and implemented (id: implement ID currencies v1 (design #2043) #5522 CLOSED), with the control plane (id: design: currency control plane — registry, account factory, gateway #2062 CLOSED) and follow-on currency work live in
pkgs/id (registry/factory/gateway issues id(currency): currency registry schema + ledger-u32 allocator (from #2062) #2317–id(currency): PoC — registry + factory + gateway, single-currency issue→transfer (from #2062) #2321, RateAuthorisation id(currency): RateAuthorisation + revoke schema types and fold in pkgs/id (Phase 1 of #2290) #3800–id(currency): quote issuance + binding for RateAuthorisation (Phase 3 of #2290) #3802, client API id: implement: pkgs/id currency client API — the §7 app-facing function surface from #2041 (gated on #2251 spec) #2803). This is a scaling-path design over a shipped v1, not a greenfield proposal.
- The decomposition sketch in this issue's body has been fully filed — every follow-on design ticket exists:
- Backend port + invariant test suite contract → id: design: currency backend port + invariant test suite contract (from #5676) #5823 (OPEN)
- Stage A: Redis hot store + regular-store system of record → id: design: Stage A: Redis hot store + regular-store system of record (from #5676) #5824 (CLOSED — design delivered)
- Autoscaling design (stateless front-end, hot-account mitigations, triggers) → id: design: currency autoscaling design (from #5676) #5825 (OPEN)
- Stage B: multi-Turso sharding by currency → id: design: Stage B: multi-Turso sharding by currency (from #5676) #5826 (OPEN)
- Stage C: TigerBeetle adapter + B→C cutover → id: design: Stage C: TigerBeetle adapter + B→C cutover (from #5676) #5827 (OPEN)
- Conversion & RateAuthorisation across stages → id: design: conversion & RateAuthorisation across stages (from #5676) #5828 (OPEN)
- The governing principles in the body (no backend concepts in the user API; double-entry invariants backend-independent and proven per adapter; swap-don't-rewrite via the port) bind the children — id: design: currency backend port + invariant test suite contract (from #5676) #5823's port + invariant-suite contract is the keystone the stage designs hang from, and it is the natural next claim among them.
Disposition: no new issues or tasks are filed from this triage — the decomposition is complete, and the open children carry their own design work through the queue individually. This issue remains open as the umbrella over #5823/#5825/#5826/#5827/#5828 and closes when the stage designs land (or when a stage is explicitly dropped, per the children's own records). Labels applied: kind/design, priority/low, effort/l (app/id and epic/id-program already present) — low priority matches the expansion-design framing: the path must be designed before load forces it, and no production load signal is currently driving it.
Task 15274 completes as triaged, follow_up_task_ids [] (all follow-ons already filed as the issues above).
dezren39 commented on Nov 14, 2026 🤖 Agent note · duplicate packet — #5676 already triaged earlier today
- Agent: repo queue worker, lane any-c (repo-worker-code)
- Session / ID: cron repo-queue-worker-shift-any-c run 2026-11-14; task 16840
Task 16840 duplicates task 15274 (same lane, this shift), which triaged #5676 today (note 6877125192): the decomposition is complete and verified — children #5823/#5825/#5826/#5827/#5828 open, #5824/#5829 closed — and the umbrella stays open as the programme home. Since then, this shift also triaged the keystone child #5823 (task 16767) and enqueued its design pass (task 16878). #5676 re-verified OPEN. Task 16840 completes as already_done; no changes made.
dezren39 commented on Nov 17, 2026 agent-note:v1
task: 18332
lane: code-d
state: triaged
worker: repo-worker-code
finding: Fresh 2026-11-17 triage of bulk-intake task 18332 for issue #5676 (Currency scaling design parent). Issue #5676 is OPEN, carries status/triaged (triage of record: task 15274, note 6877125192, 2026-11-14; duplicate task 16840 completed already_done the same day), and no hard-stop labels. The design is fully decomposed into children #5823-#5829. Fresh child states this shift: #5823 CLOSED, #5824 CLOSED, #5825 CLOSED, #5826 CLOSED, #5827 CLOSED, #5829 CLOSED - and the sole remaining open child is #5828 (conversion & RateAuthorisation across stages), which carries status:in-review, i.e. it is actively being handled on its own track.
next: No follow-on packet is owed from this parent: every child exists and is tracked, and #5828 is in review. Issue #5676 stays OPEN as the programme umbrella until #5828 closes. Task 18332 completes as triaged naming the existing triage of record.
dezren39 commented on Nov 17, 2026
Agent note — lane any-y, task 19859
- event: done (triaged)
- task: task 19859 (small_fix, issue id: design: Currency scaling — autoscaling service, Redis → multi-Turso → TigerBeetle path #5676 — id: design: Currency scaling, autoscaling service, Redis to multi-Turso to TigerBeetle path)
- state: fresh check 2026-11-17 — issue id: design: Currency scaling — autoscaling service, Redis → multi-Turso → TigerBeetle path #5676 OPEN, carries status/triaged; no hard-stop labels (no held, user/owned, do-not-merge, do-not-auto-edit), no status/needs-triage.
- verdict: duplicate revival packet. Triage of record is task 15274 (2026-11-14): the scaling design is fully decomposed into children issues id: design: currency backend port + invariant test suite contract (from #5676) #5823–id: design: currency load & correctness verification programme (from #5676) #5829 over the shipped currencies v1, and the umbrella stays open as the programme home. Duplicate task 16840 completed already_done the same day, and this packet's triage source, task 18332 (2026-11-17, lane code-d), fresh-checked the children this shift: issues id: design: currency backend port + invariant test suite contract (from #5676) #5823, id: design: Stage A: Redis hot store + regular-store system of record (from #5676) #5824, id: design: currency autoscaling design (from #5676) #5825, id: design: Stage B: multi-Turso sharding by currency (from #5676) #5826, id: design: Stage C: TigerBeetle adapter + B→C cutover (from #5676) #5827, and id: design: currency load & correctness verification programme (from #5676) #5829 are CLOSED, and the sole remaining open child, issue id: design: conversion & RateAuthorisation across stages (from #5676) #5828, carries status:in-review on its own track — no follow-on packet is owed from the parent.
- action: completing task 19859 as triaged, naming the triage of record; no new packet enqueued.
dezren39 commented on Nov 24, 2026
🤖 Agent note · close with evidence (task 21829, lane oc-code-05, 2026-11-24)
Second-pass verification: the umbrella's full decomposition is delivered —
- All 7 children CLOSED with reason COMPLETED: id: design: currency backend port + invariant test suite contract (from #5676) #5823, id: design: Stage A: Redis hot store + regular-store system of record (from #5676) #5824, id: design: currency autoscaling design (from #5676) #5825, id: design: Stage B: multi-Turso sharding by currency (from #5676) #5826, id: design: Stage C: TigerBeetle adapter + B→C cutover (from #5676) #5827, id: design: conversion & RateAuthorisation across stages (from #5676) #5828, id: design: currency load & correctness verification programme (from #5676) #5829 (last: id: design: conversion & RateAuthorisation across stages (from #5676) #5828 closed 2026-11-17, the umbrella's stated close condition).
- All 7 design records present on origin/main:
doc/2026-11-14_design_id5823.md, doc/2026-11-08_design_id5824.md, doc/2026-11-16_design_id5825.md, doc/2026-11-16_design_id5826.md, doc/2026-11-16_design_id5827.md, doc/2026-11-05_design_id5828.md, doc/2026-11-08_design_id5829.md.
- No open PR references this issue; no other live queue item covers it (checked all actionable states).
Closing as implemented; the design records above plus the children's completion records are the evidence.
dezren39 commented on Nov 24, 2026
MetadataMetadataapp/idPackage/app: id (pkgs/ or apps/ in this repo)effort/lLarge: multi-day or open-ended; expect staged check-insepic/id-programReprioritization program epic (2026-11-12)kind/designA design proposal (design-architect): multi-step, phased, decision-bearingpriority/lowNice to have; do when convenientsource/creatorFiled by the new-issue-creator jobstatus/triagedTriaged and routed (see agent note)task/triageQueue packet kind: verify, reproduce, and route this item DevelopmentNo branches or pull requestsIssue actions
|