Skip to content

feat: record the materials each mage weapon was crafted from - #36

Merged
XxFran10xX merged 2 commits into
mainfrom
feat/stamp-gear-craft-inputs
Sep 30, 2026
Merged

XxFran10xX merged 2 commits into
mainfrom
feat/stamp-gear-craft-inputs

Conversation

@XxFran10xX

@XxFran10xX XxFran10xX commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Recycler returns the current cost of a weapon's stamped parts. That is wrong when a part's cost changed after crafting, and it returns materials for weapons staff crafted for free (magic.bypass_crafting_cost).

  • GearInventoryManager.tryPrepare stamps the charged map (already computed for abort refunds) onto the prepared weapon: magic:gear_craft_inputs, JSON item path to amount. Empty for staff bypass crafts.
  • Both copyGearPdc helpers (socket rewrite after charging, and GearRefresher) carry the stamp to the rebuilt item, like gear_parts.
  • GearProvenance.readInputs(ItemStack) returns the map, or null for weapons crafted before this change.

Recycler will read this in a follow-up PR.

Testing

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Crafted gear now keeps a record of the materials charged during its creation.
    • This crafting information remains available when gear is refreshed or rewritten, including items crafted without material charges.

@coderabbitai

coderabbitai Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: dd9f7c3b-eaa1-4c41-a769-04a69c93c8fb

📥 Commits

Reviewing files that changed from the base of the PR and between b5956c7 and 9565aaa.

📒 Files selected for processing (7)
  • src/main/java/net/tfminecraft/magic/gear/GearItemBuilder.java
  • src/main/java/net/tfminecraft/magic/gear/GearKeys.java
  • src/main/java/net/tfminecraft/magic/gear/GearProvenance.java
  • src/main/java/net/tfminecraft/magic/gear/GearRefresher.java
  • src/main/java/net/tfminecraft/magic/gear/gui/GearInventoryManager.java
  • src/test/java/net/tfminecraft/magic/GearItemCoverageTest.java
  • src/test/java/net/tfminecraft/magic/GearProvenanceCoverageTest.java

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.


📝 Walkthrough

Walkthrough

Gear crafting records charged materials as JSON metadata on the prepared item. Gear copy and refresh operations preserve this metadata.

Changes

Craft input provenance

Layer / File(s) Summary
Craft input metadata
src/main/java/net/tfminecraft/magic/gear/GearKeys.java, src/main/java/net/tfminecraft/magic/gear/GearProvenance.java, src/test/java/net/tfminecraft/magic/GearProvenanceCoverageTest.java
Adds the craftInputs key and methods to store charged materials as JSON and read them as a map. Tests cover absent items, empty and populated maps, and malformed JSON.
Stamp and preserve craft inputs
src/main/java/net/tfminecraft/magic/gear/gui/GearInventoryManager.java, src/main/java/net/tfminecraft/magic/gear/GearItemBuilder.java, src/main/java/net/tfminecraft/magic/gear/GearRefresher.java, src/test/java/net/tfminecraft/magic/GearItemCoverageTest.java
Stamps the prepared item with the charged-cost map after costs are taken. Copy and refresh paths copy the stored value when present. Tests check copying absent and stamped input data.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Feature

Suggested reviewers: drefvelin

Merge Risk: ⚪ Minimal · up to 9565a

The change records crafting inputs and preserves them through gear rebuilds and refreshes. No actionable merge-blocking issue is established; merge after normal checks pass.

Security Architecture Review

Security architecture risk: 🔵 Low · up to 9565a

The change records crafting history without adding new refund authority. Recorded amounts come from server-defined costs, and free staff crafts receive an empty record. Remaining uncertainty concerns exceptional crafting failures and how a future recycler will validate and consume this metadata.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The demonstrated change affects crafted gear and its server-side station lifecycle. Its persistence extends provenance lifetime across rebuilds and restarts; the inspected new APIs do not themselves grant inventory-credit authority.

Security Findings and Attack Paths

  • observed — The added reader only deserializes item metadata. The existing abort refund path reads station-owned charged data, with a legacy recipe-cost fallback, rather than calling readInputs. A Recycler attack path cannot be assessed from this PR because that consumer is outside the supplied change.

Trust Boundaries and Controls

  • observed — Preparation checks station presence, occupancy, recipe validity, and material availability. For newly owned station items, abort rejects other players unless they have magic.admin, then removes occupancy before refunding the stored charged map.

Resilience and Maintainability Implications

  • observed — The normal preparation caller is an inventory-event handler, and charging uses a synchronous Bukkit timer. Disconnect, charging exceptions, and shutdown attempt completion without removing station occupancy; reconstruction preserves the new provenance. This supports normal serialized recovery, not a guarantee of crash-atomic persistence or arbitrary cross-thread safety.

Hardening Proposals

  • proposed — Before a future refund consumer treats this metadata as authority, define validation for item paths, amounts, and payload size, and distinguish missing legacy provenance from invalid provenance. Its ownership and one-time consumption controls require separate assessment.
  • proposed — For stronger material-accounting recovery, stage provenance creation before deduction where feasible and establish compensation for failures before successful station ownership transfer. This is hardening of the preparation transition, not an observed exploitation finding.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 15 functions across 7 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: recording the materials used to craft each mage weapon.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

A rabbit checks the forge at night,
The charged materials are set right.
A JSON map is tucked away,
It travels when the gear takes shape.
Through copy and refresh, records stay,
Then hops contentedly away.

Comment @coderabbitai help to get the list of available commands.

coderabbitai[bot]
coderabbitai Bot previously approved these changes Sep 29, 2026
XxFran10xX and others added 2 commits September 30, 2026 16:26
The weapon now carries what the craft actually charged (gear_craft_inputs
PDC, item path to amount; empty for staff bypass crafts). Socket rewrites
and refreshes copy it along with the part list. Recycler reads it with
GearProvenance.readInputs instead of today's part costs.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@XxFran10xX
XxFran10xX merged commit e54d57c into main Sep 30, 2026
2 checks passed
@XxFran10xX
XxFran10xX deleted the feat/stamp-gear-craft-inputs branch September 30, 2026 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant