Skip to content

fix(loot): keep concurrent promotions on one live roll - #439

Merged
Mathih13 merged 1 commit into
mainfrom
fix/loot-roll-promotion
Sep 7, 2026
Merged

Mathih13 merged 1 commit into
mainfrom
fix/loot-roll-promotion

Conversation

@Mathih13

@Mathih13 Mathih13 commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

Two Gateways can promote the same staging Loot Roll before either clears it. Each promotion created a separate Realm-core roll and vote set, so party votes could split.

Reuse the existing roll for the corpse and slot through the by_corpse index. The Module transaction serializes the lookup and insertion. A repeat promotion preserves the first roll's votes, recipients, item, and deadline.

Refs #63. This satisfies #63's scoped acceptance: two concurrent realm_loot_op START calls for one corpse and slot now produce exactly one Loot Roll with one complete vote set. Resolution still deletes the roll and votes, so a delayed START after resolution can create another roll. That separate lifecycle decision is tracked by #441.

Verification:

  • The private Standalone regression failed before the fix with two rows for the same corpse and slot. Two concurrent real realm_loot_op START calls now produce one roll and three voter rows, checked through SQL.
  • A real NEED vote survives a repeated START with changed item, deadline, and recipients. Other corpse and slot pairs still create their own rolls.
  • cargo test -p lyracore-module --lib --features=debug_reducers: 1,477 passed.
  • ./lyracore preflight, formatting, and diff checks passed. The regression creates its own loopback node, storage, and CLI configuration. It does not access an existing Realm or production.

Authored by GPT-6 Astra through Codex. Current-head review completed by GPT-5.6 Sol in Codex/T3 Code.

@coderabbitai

coderabbitai Bot commented Sep 5, 2026 •

Copy link
Copy Markdown

Review Change Stack

Important

Review skipped

No new commits to review since the last review.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 6bcd873a-9c9d-4bfa-be7b-4dcd6554598f

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 921fcc21-2025-460e-a4ef-938a1d0f5581

📥 Commits

Reviewing files that changed from the base of the PR and between 7b11e68 and 94c5d5e.

📒 Files selected for processing (1)
  • module/tests/loot_roll_promotion.rs

Included review availability: Your plan provides up to 10 included reviews per hour; 2 remain after this review.


📝 Walkthrough

Walkthrough

Loot-roll promotion now reuses an unresolved roll for the same corpse and slot. The change preserves its votes and state, while resolved rolls can be recreated. An ignored integration test covers concurrent promotions and distinct roll inputs.

Changes

Loot-roll promotion

Layer / File(s) Summary
Idempotent roll creation
module/src/loot/rolls.rs
insert_roll_rows checks for an existing unresolved roll by corpse and slot. It returns that roll ID instead of inserting duplicate roll and vote rows.
Promotion concurrency validation
module/tests/loot_roll_promotion.rs
The ignored integration test validates concurrent promotions, preserved votes, conflicting duplicate promotions, and separate rolls for distinct corpse or slot inputs.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to 94c5d

Concurrent promotions now reuse one unresolved loot roll, preserving its votes and roll state. The covered behavior is ready to merge with no active current-head risk identified.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 2 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: preventing concurrent loot promotions from creating duplicate live rolls.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/loot-roll-promotion

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

@Mathih13

Mathih13 commented Sep 5, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Sep 5, 2026 •

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@Mathih13
Mathih13 force-pushed the fix/loot-roll-promotion branch from 7b11e68 to 94c5d5e Compare September 7, 2026 13:18
@Mathih13

Mathih13 commented Sep 7, 2026

Copy link
Copy Markdown
Contributor Author

Current-head review on 94c5d5e12ac3d9d45727e78b8977392230603ac3:

  • Rebased onto main at 49061fe2ec84412e1cce8484a6cf64f37aa1f022.
  • Updated the durable test for the current mutable Standalone publish API.
  • The isolated regression passed. Two simultaneous START calls produced one live Loot Roll and one complete three-vote set. A repeated START preserved the first vote, recipients, item, and deadline. Distinct corpse or slot pairs still produced distinct rolls.
  • Module library: 1,477 passed.
  • Formatting, diff checks, and offline preflight passed.

CodeRabbit's prior review found no actionable issue. I did not add comments to the small test helpers for its docstring-percentage warning because repository standards reserve comments for constraints and contracts.

This PR covers duplicate START calls while a Loot Roll is active. Issue #441 remains open for a delayed START after resolution and cleanup.

@Mathih13

Mathih13 commented Sep 7, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Sep 7, 2026 •

Copy link
Copy Markdown
⚠️ Action not completed

Already reviewed the last commit. Use @coderabbitai full review to rerun a review of the entire changeset.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@Mathih13
Mathih13 merged commit 918a057 into main Sep 7, 2026
7 checks passed
@Mathih13
Mathih13 deleted the fix/loot-roll-promotion branch October 11, 2026 18:20
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