Type: simplification (DRY) · Difficulty: medium
packages/sqlite/src/aggregateStats.ts and packages/mongo/src/aggregateStats.ts build an identical StatsResponse and share logic, including the same magic Math.round(totalCost * 1_000_000) / 1_000_000 cost-rounding (sqlite:90, mongo:94). The activity.ts files in both adapters are similarly parallel (same slice(0, 500) snippet cap).
Do: extract the shared shaping (and a roundCostUsd/COST_PRECISION_FACTOR helper) into one place both adapters call, leaving each adapter to provide only its raw query results.
Done when: the StatsResponse shape and cost-rounding exist once; both adapters reuse them.
Type: simplification (DRY) · Difficulty: medium
packages/sqlite/src/aggregateStats.tsandpackages/mongo/src/aggregateStats.tsbuild an identicalStatsResponseand share logic, including the same magicMath.round(totalCost * 1_000_000) / 1_000_000cost-rounding (sqlite:90,mongo:94). Theactivity.tsfiles in both adapters are similarly parallel (sameslice(0, 500)snippet cap).Do: extract the shared shaping (and a
roundCostUsd/COST_PRECISION_FACTORhelper) into one place both adapters call, leaving each adapter to provide only its raw query results.Done when: the StatsResponse shape and cost-rounding exist once; both adapters reuse them.