Restore CMS item publication and seal official treasury routing

This commit is contained in:
Dev 2026-11-29 13:10:55 +01:00
commit 484f121fcc

View file

@ -0,0 +1,88 @@
# Restore official item publication and seal its payment destination
## Objective and bounded scope
Restore the existing staff publication and gift-key flow, then extend its
item-definition key with immutable official-sale terms. Official `cms.item`
listings pay the existing In-game Bank Treasury (`sys_game_treasury`); player
resales, including custom items, continue paying the player. No backend JAR,
account identity, permission rank, balance or earned progression is replaced.
## Recovered source
The source was found on the owner's PC in the project checkout
`work/finished-site/website`, also present in other local saved checkouts.
Original commits include `6aaa7eae` (signed HQ offers and redeemable gifts),
`adbb1943` (publication receipt replay) and `e3a14460` (published catalogue).
The GitHub fresh baseline had the same Publication placeholder as web/main;
it did not contain this working publisher. The local reference checkout and
its unrelated dirty work were left unchanged.
Restored components are the existing `hq-exchange.mjs`, `item-gifts.mjs`,
Publication tab, `/internal/game/item-redeem` and `itemGifts` delivery adapter.
The installed JARVIS already implements `/redeem ITM-…` and signed native
gift receipt delivery; this restoration does not require rebuilding it.
Staff gifts remain free grants to their named recipient. Priced Exchange
sales use the existing atomic bank/stock/sales/delivery transaction.
## Publication and checkout
1. Staff save a versioned definition through the existing item editor.
2. Publication verifies current item management and issuance permissions,
saved revision, price, quantity and confirmation. The existing HQ publisher
signs the definition and writes stock and its unique publication receipt.
3. In that same transaction an extension record binds the existing key to
`cms.item`, listing, seller, material, signed payload hash, unit price,
initial quantity, and the exact active treasury account ID/number.
4. The binding is signed server-side and has no editing endpoint. Checkout
verifies it and the original unrevoked item-definition key/revision.
Origin, name, category or an item model alone cannot establish a payee.
5. Payment, stock reduction and native paid delivery still commit together.
The original purchase reference and payload fingerprint provide replay
protection. Ordinary resale listings use their linked personal seller.
6. Published definitions cannot be edited. Withdrawal revokes the original
publication key and removes unsold stock. A correction requires saving a
new revision. Existing paid receipts replay and remain deliverable.
## Existing listing repair and deployment
Paul's Chopper is existing listing 9, saved definition
`c4247cbd-ec62-4883-83b0-624b48ae1d7d` revision 3, key
`7d249ee4-30ed-4002-a6b9-0e55422d22a3`. Read-only inspection verified its HQ
seller identity, signed payload and existing key. Its seller is not a personal
player account. No live purchase or cash test was executed for diagnosis.
After the exact reviewed build is live, run the built
`ops/cms-publication-access.mjs` in plan mode, then `--apply` to restore only
the scoped SQL privileges needed by the recovered publisher and new binding.
It verifies both databases share one MySQL server and backs up current grants
privately before applying them. It grants no global or delegation privileges.
Use built `ops/seal-cms-publication.mjs --key <key> --listing 9
--actor <authorised-staff-name>` first as a read-only plan, then `--apply`.
This verifies the exact signed existing listing and current staff authority,
backs up its original classification privately, and seals metadata only.
It invokes no schema initializer, item issuer or financial executor. Do not
delete/recreate the owner's pending purchase reference or manufacture a bank
payment. Existing publication can also be sealed by the authenticated API's
`seal-publication` action.
## Acceptance and checks
- Staff can publish price/stock from the existing Publication tab and receive
recipient-bound `/redeem` gift commands; ordinary users cannot issue them.
- Published terms and treasury destination reject tampering; drafts remain
editable. Player resale proceeds remain personal.
- Publication faults roll back stock, key binding and receipt together.
- Payment fixtures verify balanced entries, exactly-once treasury credit,
stock consumption and paid delivery replay, including after withdrawal.
- Named recipient, expiry and native receipt tests prevent gift replay.
- Real client acceptance and actual paid delivery are separate from fixture
success. Do not claim payment was tested live without its actual receipt.
Local website build passed. The full Windows suite reported 1,863 passed,
6 skipped, zero failures; the two later publication UI tests also passed.
Focused tests were rerun after sealing the exact destination account and
restoring the publisher. Canonical CI, merge, scoped permission installation,
existing-listing sealing and live acceptance remain pending. This document is
not deployment evidence.