feat(rust): Economics — pay coins, balances, staff adjust, the richest (PLAN_REDESIGNS §11.2) #40

Merged
whitlocktech merged 1 commits from feat/protocol-14-economics into edge 2026-10-12 07:40:56 -05:00
Member

What & why

The site half of PLAN_REDESIGNS.md §11.2.2 on protocol 14 (spec: docs/rust-link/PROTOCOL.md §20.3).

The step: rust.coins.pay ("Pay coins").

  • It is risk: 'irreversible', reversible: 'none' (D335), like uo.item.grant.
  • Recipients use the modes of rust.kit.entitle, including linked, with one payment per website user (D103's rule).
  • An optional message takes {amount} and goes by chat or popup.
  • It spends a new rust.coins budget: the amount times the count, or times the recipient bound.
  • It refuses with "Economics is not installed on this server", in the dry run too (D199).
  • Core's idempotency key goes to the plugin, so a retried step answers repeat and pays nobody twice.

Balances.

  • rust_player_wipe_stats.balance is DECIMAL(14,2) NULL and is written as a value, never summed.
  • A balance frame with no name is an offline player's. Its balance is written without moving anybody's last-seen.
  • economics.wiped clears the wipe's balances after ecowipe, and leaves them alone at a new save.

The richest.

  • A Coins leaderboard column appears on one wipe of a server that reports Economics, with sort=balance.
  • A richest title category, Magnate, is added.
  • Both rank only balances above the starting balance (D336), which is read from the hello and assumed to be 1000 when unread.

Routes.

  • GET /player/rust/economics reads live, falls back to the last known balance, and lists servers without Economics with the reason.
  • GET/POST /admin/users/:id/rust/economics lets staff deposit, withdraw or set.
    • Scoped to the user's own links.
    • Keyed per submission.
    • An activity row with before and after: "Deposited 500 coins to Wanderer on Main: 1,000 → 1,500".

Client.

  • The account page gets a Coins section.
  • The admin user page gets a Coins panel with a form per server.
  • The leaderboard gets its column.
  • Economics appears in a server's mod line, saying so when its config couldn't be read.

How it was tested

  • npm test --prefix server: 535/535, 14 of them new in test/economics.test.js. They cover the value write, the offline frame, the wipe rule, the D336 SQL, the step's payee rules, repeat and retry, the price, and the staff refusals. Three inventory tests were updated.
  • check:imports, check:bundle, check:swagger (fragment regenerated, 77 paths) and check:engagement all pass.
  • Client: build, npm test 74/74 (a coins formatter test is new), check:externals clean.
  • Frozen manifest against the pinned core (website ca7ec53): routes.manifest.json regenerated (87 routes, all documented) and --check passes. The real core registered the module with 8 actions and 6 budgets, so it accepted rust.coins.pay and rust.coins.
  • The site and in-game walk is deferred to the end of the plan (D331), with rows in §11.2.3.

Six points the design left open were settled here. They are listed in docs PLAN_REDESIGNS §11.2.4 so they can be overruled: newSave, the nameless-frame rule, the Coins column being per wipe, the failed reasons, separate key namespaces, and the rust.coins budget.

Checklist

  • I have read CONTRIBUTING.md.
  • The change builds and existing tests/checks pass locally.
  • I have added or updated tests/docs where it makes sense.
  • My commits are reasonably scoped with clear messages.

AI-assisted contributions (required)

  • No AI tools were used to produce this contribution.
  • AI tools were used. Tool(s): Claude Code (Claude Opus 5.5). I have reviewed and understand
    every change, and take responsibility for it. AI-authored commits are
    marked with a Co-Authored-By / Assisted-By trailer.

License

  • I agree that my contribution is licensed under this project's license
    (GNU GPL v3.0 or later), and I have the right to contribute it.

🤖 Generated with Claude Code

https://claude.ai/code/session_01E14m6SuuY6i1vASFeGDBeY

## What & why The site half of `PLAN_REDESIGNS.md` §11.2.2 on protocol 14 (spec: `docs/rust-link/PROTOCOL.md` §20.3). **The step: `rust.coins.pay` ("Pay coins").** - It is `risk: 'irreversible'`, `reversible: 'none'` (D335), like `uo.item.grant`. - Recipients use the modes of `rust.kit.entitle`, including `linked`, with one payment per website user (D103's rule). - An optional message takes `{amount}` and goes by chat or popup. - It spends a new `rust.coins` budget: the amount times the count, or times the recipient bound. - It refuses with "Economics is not installed on this server", in the dry run too (D199). - Core's idempotency key goes to the plugin, so a retried step answers `repeat` and pays nobody twice. **Balances.** - `rust_player_wipe_stats.balance` is `DECIMAL(14,2) NULL` and is written as a value, never summed. - A balance frame with no `name` is an offline player's. Its balance is written without moving anybody's last-seen. - `economics.wiped` clears the wipe's balances after `ecowipe`, and leaves them alone at a new save. **The richest.** - A **Coins** leaderboard column appears on one wipe of a server that reports Economics, with `sort=balance`. - A `richest` title category, **Magnate**, is added. - Both rank only balances above the starting balance (D336), which is read from the hello and assumed to be 1000 when unread. **Routes.** - `GET /player/rust/economics` reads live, falls back to the last known balance, and lists servers without Economics with the reason. - `GET`/`POST /admin/users/:id/rust/economics` lets staff deposit, withdraw or set. - Scoped to the user's own links. - Keyed per submission. - An activity row with before and after: *"Deposited 500 coins to Wanderer on Main: 1,000 → 1,500"*. **Client.** - The account page gets a Coins section. - The admin user page gets a Coins panel with a form per server. - The leaderboard gets its column. - Economics appears in a server's mod line, saying so when its config couldn't be read. ## How it was tested - `npm test --prefix server`: **535/535**, 14 of them new in `test/economics.test.js`. They cover the value write, the offline frame, the wipe rule, the D336 SQL, the step's payee rules, repeat and retry, the price, and the staff refusals. Three inventory tests were updated. - `check:imports`, `check:bundle`, `check:swagger` (fragment regenerated, 77 paths) and `check:engagement` all pass. - Client: build, `npm test` 74/74 (a `coins` formatter test is new), `check:externals` clean. - **Frozen manifest against the pinned core** (website `ca7ec53`): `routes.manifest.json` regenerated (87 routes, all documented) and `--check` passes. The real core registered the module with 8 actions and 6 budgets, so it accepted `rust.coins.pay` and `rust.coins`. - The site and in-game walk is deferred to the end of the plan (D331), with rows in §11.2.3. **Six points the design left open were settled here.** They are listed in docs PLAN_REDESIGNS §11.2.4 so they can be overruled: `newSave`, the nameless-frame rule, the Coins column being per wipe, the `failed` reasons, separate key namespaces, and the `rust.coins` budget. ## Checklist - [x] I have read [CONTRIBUTING.md](CONTRIBUTING.md). - [x] The change builds and existing tests/checks pass locally. - [x] I have added or updated tests/docs where it makes sense. - [x] My commits are reasonably scoped with clear messages. ## AI-assisted contributions (required) - [ ] No AI tools were used to produce this contribution. - [x] AI tools were used. Tool(s): `Claude Code (Claude Opus 5.5)`. I have reviewed and understand every change, and take responsibility for it. AI-authored commits are marked with a `Co-Authored-By` / `Assisted-By` trailer. ## License - [x] I agree that my contribution is licensed under this project's license (**GNU GPL v3.0 or later**), and I have the right to contribute it. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01E14m6SuuY6i1vASFeGDBeY
wtclaude added 1 commit 2026-10-12 07:16:15 -05:00
feat(rust): Economics — pay coins, balances, staff adjust, the richest (PLAN_REDESIGNS §11.2)
All checks were successful
PR Checks / server-tests (pull_request) Successful in 31s
PR Checks / client-build (pull_request) Successful in 29s
PR Checks / frozen-manifest (pull_request) Successful in -1m29s
845caef817
The site half of §11.2.2, on protocol 14:

- `rust.coins.pay` ("Pay coins"): irreversible, reversible none (D335). The
  recipient modes of rust.kit.entitle including `linked`, one payment per
  website user (D103's rule), an optional message with {amount}, a new
  `rust.coins` budget. Refused with "Economics is not installed on this
  server" in the dry run too (D199). Core's key goes to the plugin, so a
  retried step answers `repeat` and pays nobody twice.
- `rust_player_wipe_stats.balance`: the tally's balance, written as a value.
  A nameless balance frame (an offline player) moves nobody's last-seen.
  `economics.wiped` clears the wipe's balances, except at a new save.
- The richest: a Coins leaderboard column on one wipe of a server that
  reports Economics, `sort=balance`, and a `richest` title category
  (Magnate); both rank only above the starting balance (D336).
- GET /player/rust/economics (live, falling back to the last known), and
  GET/POST /admin/users/:id/rust/economics for staff — scoped to the user's
  own links, keyed per submission, an activity row with before and after.
- Client: the account page's Coins, the admin user page's Coins panel with
  its form, the leaderboard column, and Economics in the server's mod line
  (saying when its config could not be read).

Server 535/535 (14 new in test/economics.test.js), client 74/74,
routes.manifest regenerated against the pinned core (87 routes), swagger
fragment regenerated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01E14m6SuuY6i1vASFeGDBeY
whitlocktech merged commit 69ec0f6c46 into edge 2026-10-12 07:40:56 -05:00
whitlocktech deleted branch feat/protocol-14-economics 2026-10-12 07:40:57 -05:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: RunicGateway/Module-Rust#40
No description provided.