M4 physical stock authority: exact tick overlay, owner-bucket mapping and migration performance
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- typescript
- Domain
- database, performance
Research direction
Start by locating WorldState, its stock and wallet fields, and the existing native tests and save/restore paths; the issue does not name specific files. Map allowed actor and bucket pairs from current state fields, then review the exact posting bridge and numeric authority decision before proposing changes. Done means the listed round-trip, rollback, determinism, corruption, stress, replay, and browser performance checks pass; implementation is explicitly blocked on those decisions.
Written by the indexing model from the issue text.
Description
Goal
If the exact-accounting representation is approved, implement an efficient, actor-owned stock storage adapter that does not copy every wallet and inventory on every trade and never conflates separate physical warehouses.
Evidence
- Local unpublished R11 naive BigInt exact stock prototype cloned the entire book per transfer (~2000 transactions/s with ~5000 entries).
- Local R12 switched to a per-tick touched-endpoint overlay and measured about 37x speedup (1200 transactions / 5002 entries, isolated Node benchmark, not real browser engine).
- Local R13 uncovered unsafe restore of oversized BigInt values. R14/R15 exposed owner/bucket identity mistakes:
HOUSEHOLD,PUBLIC, and ProductionUnitINPUT/OUTPUT/INVESTMENTare different real stocks, and not every actor may own every bucket. - Existing future #724 and #725 cover broad M10 performance/retention; this is a narrow prerequisite of an approved M4 precision change.
Scope
Stage only changed physical endpoints within a tick; commit atomically in canonical deterministic order, with snapshot/replay/historical saves explicit. Resolve each owner/bucket strictly against current WorldState fields and one owner per stock. Audit missing/extra inventory and wallet slots without expensive JSON serialization in hot path. Define appropriate benchmark budgets from empirical browser and Node runs.
Non-goals
No second mutable canonical stock source, no unauthorized new warehouse types, no silent migration of legacy saves or bypass of exact receipt contract, no broad M10 performance rewrite.
Acceptance criteria
- All allowed actor/bucket pairs round-trip with independent stock identity; unknown pairs rejected before any write.
- Rollback and readback of failed tick leave underlying world, ledger, staged overlay and IDs unchanged.
- Repeated same-asset transfers remain correct and deterministic across 240+ ticks.
- Measured performance remains useful for Pages runtime without O(total stock count) cloning per trade; browser gate recorded.
Verification
Targeted native WorldState tests + fixtures for each bucket and 5k-stock stress, save/restore corruption/overflow negative controls, deterministic replay, CI TypeScript/.NET/Pages and independent QA.
Depends on: numeric authority decision and exact posting bridge; no code promotion until these are approved.
- Dominant language
- TypeScript
- Stars
- 4
- Forks
- 0
- Avg merge
- 7h 21m
- Merged PRs (30d)
- 144
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from drevendev/trade_simulation
-
area:docs priority:normal type:docs
Difficulty 3/5 1-2 days Newbie friendliness 74/100
drevendev/trade_simulation#963 · 1 comment ·
Maintainers usually reply within 1 day
-
qa status:needs-triage
Difficulty 5/5 Over a week Newbie friendliness 8/100
drevendev/trade_simulation#926 ·
Maintainers usually reply within 1 day
-
area:visualization priority:high status:in-progress type:feature
Difficulty 5/5 Over a week Newbie friendliness 25/100
drevendev/trade_simulation#863 · 1 comment ·
Maintainers usually reply within 1 day
-
area:tooling priority:normal status:in-progress type:bug
Difficulty 4/5 3-5 days Newbie friendliness 35/100
drevendev/trade_simulation#829 · 1 comment ·
Maintainers usually reply within 1 day
-
area:market priority:high status:blocked type:feature
Difficulty 5/5 Over a week Newbie friendliness 24/100
drevendev/trade_simulation#799 ·
Maintainers usually reply within 1 day
All issues in drevendev/trade_simulation
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Maintainers usually reply within 1 day
-
pending close triaging
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
anomalyco/opencode#62582 · 1 comment ·
Maintainers usually reply within 1 day
-
feature request
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
callstack/react-native-paper#5189 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
live-codes/livecodes#1079 · 1 comment ·
Maintainers usually reply within 1 day
-
Add: ESP 2 ROOpenapproved check:passed streams:add
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
Maintainers usually reply within 1 day