Conversation
…rency
Package structure:
- Remove #if canImport(Darwin) gate; DHKit and DHKitTests are now
unconditional, cross-platform targets
- Update Linux CI to build DHKit and run DHKitTests
Slot type redesign:
- Extract AdversarySlot and EnvironmentSlot from EncounterSession.swift
into Sources/DHModels/ alongside PlayerSlot
- Make all mutable slot properties `let`; types are now read-only
value projections
- Remove nonisolated annotation from all three structs (was a no-op)
- Remove AdversarySlot.make(from:customName:) public factory; construction
from Adversary now happens internally in EncounterSession
- EncounterSession stores private _adversarySlots/_playerSlots/_environmentSlots
and exposes public read-only computed properties; mutations use
copy-with-update (no more in-place var mutation footgun)
- Remove modifying(in:id:_:) helper (required { get set }; no longer needed)
Protocol changes + mutation API:
- CombatParticipant is now { get } only — pure read/display contract
- All combat mutation methods take UUID instead of some CombatParticipant
- spotlight(_:) keeps its EncounterParticipant-based signature
- heal renamed to applyHealing for consistency
API naming:
- DifficultyBudget.cost(for:) internal param type → role
- Compendium.searchAdversaries(query:) → adversaries(matching:)
Concurrency:
- Add @Concurrent to Compendium.decodeArray
- Add reentrancy guards (in-flight Sets/flag) to all four async
EncounterStore methods
- EncounterStoreError stores String descriptions instead of Error
payloads; conforms to Sendable
- Add applying(...) copy-with-update helpers to AdversarySlot and PlayerSlot; refactor all EncounterSession mutation methods to use them (removes ~70 lines of repetitive full-struct reconstruction) - Add logger.warning for unmatched-ID mutations in EncounterSession - Rename removeAdversary(id:)/removePlayer(id:) → removeAdversary(withID:)/removePlayer(withID:) - Rename Compendium.adversaries(ofType:) → adversaries(ofRole:) - Rename DifficultyBudget.Rating.totalCost → .cost to avoid shadowing the static method - Strengthen EncounterStore.save(_:) doc comment re: dropped concurrent saves
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
AdversarySlotandEnvironmentSlotextracted fromEncounterSession.swiftintoSources/DHModels/, alongsidePlayerSlot. All three now havelet-only properties (immutable read-only projections); mutations flow throughEncounterSessionvia copy-with-update.#if canImport(Darwin)conditional fromPackage.swift;DHKitandDHKitTestsare now unconditional cross-platform targets. Linux CI updated to build and test them.CombatParticipantis now{ get }only (pure display contract). All combat mutation methods onEncounterSessiontakeUUIDinstead ofsome CombatParticipant.healrenamed toapplyHealing.DifficultyBudget.cost(for:)internal paramtype→role;Compendium.searchAdversaries(query:)→adversaries(matching:).@concurrentonCompendium.decodeArray; reentrancy guards on all four asyncEncounterStoremethods;EncounterStoreErrorstoresStringdescriptions and conforms toSendable.Test plan
swift build— all targets compile cleanswift test— 140 tests pass (0 failures)./Scripts/format.sh— no lint warnings