Repository navigation
docs(inventory): cite the declared sgw_inventory PK in bandolier TOCTOU comments - #603
BangRocket wants to merge 1 commit into
Conversation
…OU comments (#533) sgw_inventory.item_id has a declared primary key (sgw_inventory_pkey, db/sgw/_primary_keys.sql L39) — the instance_id doc comment and the update_bandolier_ammo doc wrongly attributed its uniqueness to the sgw_inventory_unique_slot index alone. The PK makes the #520 TOCTOU guard stronger than the comments claimed; also notes the local_id_check CHECK that keeps the instance_id:0 grant sentinel collision-free. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Warning Review limit reached
Next review available in: 55 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
Corrects two doc comments that understated the uniqueness guarantee behind the bandolier-ammo TOCTOU guard. Both claimed
sgw_inventory.item_idis unique only incidentally (sequence allocation + thesgw_inventory_unique_slotindex) with "no declared PK/UNIQUE constraint." That's wrong —db/sgw/_primary_keys.sqldeclares:sgw_inventory_base_pkey PRIMARY KEY (item_id)sgw_inventory_pkey PRIMARY KEY (item_id)The child table carries its own PK because a parent PK doesn't span
INHERITSchildren, andupdate_bandolier_ammotargetssgw_inventorydirectly — so the child PK applies and theWHERE … item_id = $5guard added in #520 matches at most one row by declared constraint, not just by construction.Changes
crates/entity/src/cell_entity/mod.rs—BandolierItem.instance_iddoc now citessgw_inventory_pkey, notes theINHERITSPK subtlety, and mentions thelocal_id_checkCHECK (item_id >= 10000) that keeps the optimistic-grantinstance_id: 0sentinel collision-free.crates/services/src/base/world_entry/methods/inventory/ammo.rs—update_bandolier_ammodoc keys the at-most-one-row claim on the declared PK instead of the slot-uniqueness index.Also settles #520's "defense-in-depth
UNIQUE INDEXonitem_id" follow-up note as moot — the PK already provides it; no migration needed.No runtime change — comment accuracy only.
cargo fmt+cargo clippy --all-targetsgreen on both touched crates.Closes #533
🤖 Generated with Claude Code