fix(indexer): widen trader rolling volume to NUMERIC(38, 0) (#1277) #1292

Merged
PlasticDigits merged 3 commits from fix/1277-trader-rolling-numeric into main 2026-09-21 05:27:39 +00:00

Summary

  • Widen traders.volume_24h / volume_7d / volume_30d / total_volume to NUMERIC(38, 0) so 18-dec SUM(offer_amount) no longer overflows the rolling UPDATE (Failed to refresh rolling trader volumes).
  • Cap upsert_trader lifetime raw volume at 10^38-1. Keep total_volume_usd as NUMERIC(38, 18) with the existing 10^20 USD cap.
  • Emit unscoped rolling JSON via bd_plain_string. Add make verify-issue-1277, invariants R1277-1–R1277-8, and skill AGENTS_INDEXER_TRADER_ROLLING_NUMERIC.md.

Fixes #1277

Test plan

  • make verify-issue-1277 (passed, then retested)
  • Isolated dex_indexer_test_1277 migrate + indexer_trader_rolling_numeric (I1–I9 / A1)
  • #577 indexer_volume_window_decay still green
  • #548 volume_usd_catalog + api_traders

Issue criteria

  • R1 In-window 10^21 offer: refresh_rolling_volumes Ok; volume_24h stores the integer; JSON plain decimal
  • R2 Mixed 6-dec + 18-dec senders in one refresh; 6-dec rolling matches decay seed (5000)
  • R3 Idle 31d zeros rolling only; lifetime raw intact (#577 D2)
  • R4 upsert_trader 10^21 succeeds; A1 caps 10^38 at 10^38-1
  • R5 total_volume_usd stays (38, 18); huge raw refresh does not smash USD
  • R6 Docs/skill + make verify-issue-1277
  • R7 refresh_all_volume_windows still runs pair/global with the I1 fixture

Out of scope (unchanged)

  • Coolify leftover migrate of this sqlx version on production (operator; not #1276 leftover-complete)
  • Pair-scoped leaderboard GET SUM(offer_amount) (A9 / #666)
  • Positions (78, 18) (#676)
  • Trailing-window copy (#576) and decay behavior (#577) except the type/cap hole
  • Frontend compact-format of raw rolling fields (API-only)
## Summary - Widen `traders.volume_24h` / `volume_7d` / `volume_30d` / `total_volume` to `NUMERIC(38, 0)` so 18-dec `SUM(offer_amount)` no longer overflows the rolling UPDATE (`Failed to refresh rolling trader volumes`). - Cap `upsert_trader` lifetime raw volume at `10^38-1`. Keep `total_volume_usd` as `NUMERIC(38, 18)` with the existing `10^20` USD cap. - Emit unscoped rolling JSON via `bd_plain_string`. Add `make verify-issue-1277`, invariants **R1277-1–R1277-8**, and skill `AGENTS_INDEXER_TRADER_ROLLING_NUMERIC.md`. Fixes #1277 ## Test plan - [x] `make verify-issue-1277` (passed, then retested) - [x] Isolated `dex_indexer_test_1277` migrate + `indexer_trader_rolling_numeric` (I1–I9 / A1) - [x] `#577` `indexer_volume_window_decay` still green - [x] `#548` `volume_usd_catalog` + `api_traders` ## Issue criteria - [x] **R1** In-window `10^21` offer: `refresh_rolling_volumes` Ok; `volume_24h` stores the integer; JSON plain decimal - [x] **R2** Mixed 6-dec + 18-dec senders in one refresh; 6-dec rolling matches decay seed (5000) - [x] **R3** Idle 31d zeros rolling only; lifetime raw intact (#577 D2) - [x] **R4** `upsert_trader` `10^21` succeeds; A1 caps `10^38` at `10^38-1` - [x] **R5** `total_volume_usd` stays `(38, 18)`; huge raw refresh does not smash USD - [x] **R6** Docs/skill + `make verify-issue-1277` - [x] **R7** `refresh_all_volume_windows` still runs pair/global with the I1 fixture ## Out of scope (unchanged) - Coolify leftover migrate of this sqlx version on production (operator; not #1276 leftover-complete) - Pair-scoped leaderboard GET `SUM(offer_amount)` (A9 / #666) - Positions `(78, 18)` (#676) - Trailing-window copy (#576) and decay behavior (#577) except the type/cap hole - Frontend compact-format of raw rolling fields (API-only)
Raw SUM(offer_amount) into NUMERIC(38, 18) overflowed at 10^20 and failed
the whole rolling UPDATE. Match pair/global integer columns, cap lifetime
raw at 10^38-1, and emit plain-decimal JSON.
fix(hooks): pre-push only scans new commits on new branches
All checks were successful
ci/woodpecker/pr/woodpecker Pipeline was successful
35256d6f3c
A first push of a branch used git rev-list on the tip alone, which
walked all ancestors and blocked every new branch after a published
policy-violating body on main.
Author
Owner

drain skip: no occupying job for rebase/fix-pr/CI-wait; remaining continue

drain skip: no occupying job for rebase/fix-pr/CI-wait; remaining continue
Author
Owner

cl8y-agent-control: queued implement job 42b356df-b7a5-41fe-8bfb-e621be5bb0ab (not executed; no Hetzner VM).

cl8y-agent-control: queued `implement` job `42b356df-b7a5-41fe-8bfb-e621be5bb0ab` (not executed; no Hetzner VM).
Merge origin/main into fix/1277-trader-rolling-numeric
All checks were successful
ci/woodpecker/pr/woodpecker Pipeline was successful
f1e7ecc2d8
Keep combined pre-push range with trader rolling NUMERIC(38, 0) widening.
PlasticDigits deleted branch fix/1277-trader-rolling-numeric 2026-09-21 05:27:39 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
code/cl8y-dex-terraclassic!1292
No description provided.