GeezerVison is showing github.com — Add atomic player-stack replacement with XP-level debit · Issue #51 · devmogged/moddedMC-rust
Add atomic player-stack replacement with XP-level debit #51
Description
Proposal (maintainer approval required)
Add an append-only moddedmc:player_stack_data ABI extension that atomically replaces a uniquely identified one-count player item stack's mod data/lodestone target while debiting XP levels exactly once.
Intended contract
- Preserve the existing V1 prefix and append a size-negotiated V2 function; older hosts must fail closed for paid actions.
- Match exactly one stack across main inventory and offhand using item ID, count=1 and complete expected mod-data bytes. Missing, duplicate, stale or malformed matches do nothing.
- Validate the replacement/target before mutation. Debit XP and replace the stack as one host-owned transaction; insufficient levels, stale preimage, lock contention or any failure leave both inventory and XP unchanged. Creative players pay zero.
- Avoid lock inversion with menu/enchant/anvil XP writers; sync the changed hand slot only after commit.
- Requires a Pumpkin-fork ry_with_experience_debit primitive or equivalent reviewed transaction fence; this is an engine change and must follow the Pumpkin fork workflow.
Why
Compass paid-search/teleport flows need to charge XP without the old read-then-write race. Clean-main Compass draft PR #45 currently fails compilation because PlayerStackDataDebit and
equire_player_stack_data_debit are absent from origin/main; the shared dirty checkout contains a prototype but it is mixed with unrelated work and must be reconciled.
Acceptance
- Maintainer approval here before public ABI/engine changes are delivered.
- Tests for exact single match, duplicate matching stacks, offhand, stale preimage, insufficient XP, creative zero-cost, lock contention and concurrent XP writers.
- Forced failure at each mutation boundary proves either both stack+XP change or neither.
- Current-main API/host/Pumpkin build, clippy and paid-search scenario pass; artifact identity and logs recorded.
- Document the V1/V2 compatibility boundary and ensure the mod checks full table size before calling V2.
No direct push to the Pumpkin fork or ABI merge without approval. Preserve the existing shared dirty checkout; isolate the API/host/Pumpkin slice only after approval.
Metadata
Metadata
Development
No branches or pull requestsIssue actions