fix(trades): limit reaches every array that grows with the world #276

Merged
coilysiren merged 1 commit from coilyco-ops/trades-bounds-every-growing-array into main 2026-08-13 22:55:15 +00:00 AGit
Member

closes #286 - topBuyers and topSellers are sorted but never sliced, so the name promises a bound the data does not keep

One of five pull requests against #286. Supersedes the closed PR 275. Slice of #267, which stays open.

closes #286 - topBuyers and topSellers are sorted but never sliced, so the name promises a bound the data does not keep One of five pull requests against #286. Supersedes the closed PR 275. Slice of #267, which stays open.
Supersedes PR 275, which bounded byItem alone. A derived audit of the
payload found three more, so this lands them together rather than leaving
one line to be edited twice.

Deriving each surface's list-valued keys from its own to_dict, rather than
reading the handler, gives get_trades five arrays and one bound:

  trades       bounded
  byItem       grows with the item catalogue
  byCurrency   grows with the currency roster
  topBuyers    one row per trading citizen
  topSellers   one row per trading citizen

topBuyers and topSellers are the surprise. They are sorted descending and
never sliced, so the names promise a top-N that the data does not keep: a
server with 400 trading citizens returns 400 rows from a field called
topBuyers. I expected them to be capped at construction, checked, and they
are not.

counts, totalCurrencyVolume and counts_note are untouched. Those are the
scalar summaries rule 5 protects, and the test asserts
totalCurrencyVolume survives a limit of 5.

Mutation: naming only "trades" again fails the new test.

Slice of #267, which stays open. get_social has seven arrays and bounds
none, get_currency's holder cap is shadowed behind a cached fetch, and the
generic invariant test still wants a should-bound judgement per array.

Refs #267

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-authored-by: Kai Siren <coilysiren@gmail.com>
Co-authored-by: Claude <noreply@anthropic.com>
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
coilyco-gaming/eco-app!276
No description provided.