**Category:** data-layer | **Epic:** 0 | **Priority:** medium ## Summary Implement MongoDB collections for shared party inventory and party split tracking. Party inventory holds items owned collectively by the party (not individual characters). Party splits track when a party temporarily divides and later rejoins. Supports common RPG patterns like shared gold, party loot, and split-party adventures. ## Acceptance Criteria - [ ] mongodb_create_party_inventory creates inventory document for party - [ ] mongodb_add_inventory_item adds item with quantity and notes - [ ] mongodb_remove_inventory_item removes or decrements item quantity - [ ] mongodb_transfer_item moves item between party and character inventory - [ ] mongodb_get_party_inventory returns full inventory with categories - [ ] mongodb_create_party_split records split with member assignments - [ ] mongodb_get_active_splits returns current splits for party - [ ] mongodb_resolve_party_split marks split as rejoined - [ ] mongodb_get_split_history returns all splits for party - [ ] Inventory supports item categories (weapons, armor, consumables, treasure, misc) - [ ] Split tracking includes location and purpose per sub-party - [ ] Unit tests achieve >= 80% coverage ## Dependencies This use case depends on: - DL-15 - DL-2 ## Blocks This use case blocks: - P-13 ## Implementation **Layer:** 1 **Files to create:** - `packages/data-layer/src/monitor_data/schemas/party_inventory.py` - `packages/data-layer/tests/test_tools/test_party_inventory_tools.py` **Files to modify:** - `packages/data-layer/src/monitor_data/tools/mongodb_tools.py` - `packages/data-layer/src/monitor_data/schemas/__init__.py` **MONGODB Operations:** - `mongodb_create_party_inventory` (authority: Orchestrator, CanonKeeper) - `mongodb_get_party_inventory` (authority: *) - `mongodb_add_inventory_item` (authority: Orchestrator, CanonKeeper) - `mongodb_remove_inventory_item` (authority: Orchestrator, CanonKeeper) - `mongodb_update_party_gold` (authority: Orchestrator, CanonKeeper) - `mongodb_transfer_item` (authority: Orchestrator) - `mongodb_create_party_split` (authority: Orchestrator, CanonKeeper) - `mongodb_get_active_splits` (authority: *) - `mongodb_resolve_party_split` (authority: Orchestrator, CanonKeeper) - `mongodb_get_split_history` (authority: *) **Notes:** - Party inventory is separate from individual character inventories - Gold is tracked as integer (copper pieces) for precision - Transfer can be party->character, character->party, or character->character - Splits create virtual sub-parties that share the parent party_id - When split resolves, all members return to main party automatically ## Testing Requirements **Minimum coverage:** 80% **Unit tests:** - test_create_inventory_success: creates empty inventory - test_create_inventory_with_items: initial items stored - test_add_item_new: new item added to inventory - test_add_item_existing: quantity incremented - test_remove_item_partial: quantity decremented - ... and 7 more **Integration tests:** - test_inventory_lifecycle: create, add items, transfer, remove - test_split_lifecycle: create split, track sub-parties, resolve ## References **Documentation:** - [docs/ontology/ONTOLOGY.md#39-party-inventories](docs/ontology/ONTOLOGY.md#39-party-inventories) - [docs/DATA_LAYER_USE_CASES.md#dl-16](docs/DATA_LAYER_USE_CASES.md#dl-16) **Code:** - `packages/data-layer/src/monitor_data/db/mongodb.py` --- *Generated from `/home/sebas/monitor2/docs/use-cases/data-layer/DL-16.yml`*