Add Gameplay bounded context model#140
Conversation
📝 WalkthroughWalkthroughThis PR establishes the Gameplay bounded context by introducing contract types for cross-context messaging, core domain types (GameId, NationId, PlayerIds, PlayerRoster), game state model (GameStatus, GameplayState), command and event message shapes with contract transformations, dependency injection infrastructure, and public facade entry points (currently stubbed). ChangesGameplay Bounded Context Implementation
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
There was a problem hiding this comment.
Actionable comments posted: 4
🧹 Nitpick comments (1)
src/Imperium/Gameplay/Dependencies.fs (1)
9-18: ⚡ Quick winAdd XML docs to the new public dependency/effect types in the implementation file.
These public declarations are currently undocumented in
.fs. Add///comments so the implementation file meets the repository doc standard consistently.As per coding guidelines,
src/Imperium/**/*.{fs,fsi}must “Use XML documentation comments (///) for all public types and functions.”🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/Imperium/Gameplay/Dependencies.fs` around lines 9 - 18, Add XML documentation comments (///) above the public declarations LoadGameplayState, GameplayEffects, CommitGameplayEffects, and GameplayDependencies describing their purpose and parameters/fields: document that LoadGameplayState is a function taking a GameId and returning Async<GameplayState option>; describe each field on GameplayEffects (State, IntegrationEvents, OutboundCommands) and their meanings; document CommitGameplayEffects as an async function that commits GameplayEffects; and document GameplayDependencies as a record containing Load and Commit. Keep comments concise and follow the repository's XML doc style.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/Imperium/Gameplay/Commands.fs`:
- Around line 15-16: The fromContract function currently throws with failwith
which converts contract conversion failures into exceptions; change it to return
a Result<StartGameCommand, string> instead by replacing failwith with a
Result.Error carrying a descriptive error string (or use Result.Ok when
conversion succeeds). Locate the fromContract function in the Gameplay.Commands
module and implement conversion logic that validates
Contract.Gameplay.StartGameCommand fields and returns Result.Ok <constructed
StartGameCommand> on success or Result.Error "<reason>" on any validation/parse
failure so all failures stay in the Result channel.
In `@src/Imperium/Gameplay/Events.fs`:
- Around line 26-27: The function fromContract (accepting
Contract.Rondel.PositionedAtStart) must not throw; replace the failwith with a
Result.Error returning an appropriate error string (e.g., "fromContract:
unhandled Contract.Rondel.PositionedAtStart" or include relevant contract data)
so the signature Result<RondelPositionedAtStartInboundEvent, string> is honored;
ensure you construct and return Ok with a RondelPositionedAtStartInboundEvent
when valid transformations are implemented or return Error with a descriptive
message otherwise.
In `@src/Imperium/Gameplay/Gameplay.fs`:
- Around line 10-12: The implementations of Gameplay.execute and Gameplay.handle
currently call failwith which throws immediately; instead return an Async
workflow that completes (or will raise inside the async if needed). Replace the
synchronous throws in the functions named execute and handle in module Gameplay
with async workflows (e.g. async { return () } as a placeholder) so both
functions have type Async<unit> and do not throw at call time.
In `@src/Imperium/Gameplay/Types.fs`:
- Line 79: PlayerRoster.create currently calls failwith even though its
signature is Result<PlayerRoster, string>; replace the exception with a
Result-returning implementation: for now return Error with a descriptive string
(e.g., "PlayerRoster.create not implemented") instead of throwing, or implement
the real creation logic to return Ok<PlayerRoster> on success and Error<string>
on failure; ensure the function signature (let create (_ids: Id list) :
Result<PlayerRoster, string>) is honored and use PlayerRoster.create as the
location to change.
---
Nitpick comments:
In `@src/Imperium/Gameplay/Dependencies.fs`:
- Around line 9-18: Add XML documentation comments (///) above the public
declarations LoadGameplayState, GameplayEffects, CommitGameplayEffects, and
GameplayDependencies describing their purpose and parameters/fields: document
that LoadGameplayState is a function taking a GameId and returning
Async<GameplayState option>; describe each field on GameplayEffects (State,
IntegrationEvents, OutboundCommands) and their meanings; document
CommitGameplayEffects as an async function that commits GameplayEffects; and
document GameplayDependencies as a record containing Load and Commit. Keep
comments concise and follow the repository's XML doc style.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: eac0b17d-bc88-4b8d-a338-a000a5da68a1
📒 Files selected for processing (17)
AGENTS.mddocs/gameplay.mdsrc/Imperium/Contract/Contract.fssrc/Imperium/Contract/Gameplay.fssrc/Imperium/Gameplay/Commands.fssrc/Imperium/Gameplay/Commands.fsisrc/Imperium/Gameplay/Dependencies.fssrc/Imperium/Gameplay/Dependencies.fsisrc/Imperium/Gameplay/Events.fssrc/Imperium/Gameplay/Events.fsisrc/Imperium/Gameplay/Gameplay.fssrc/Imperium/Gameplay/Gameplay.fsisrc/Imperium/Gameplay/State.fssrc/Imperium/Gameplay/State.fsisrc/Imperium/Gameplay/Types.fssrc/Imperium/Gameplay/Types.fsisrc/Imperium/Imperium.fsproj
💤 Files with no reviewable changes (1)
- src/Imperium/Contract/Contract.fs
Part of #51.
Summary
Notes
This is the first PR in the Gameplay initiative. Follow-up PRs should add behavior specs, handler implementation, and terminal host wiring.
Verification
Summary by CodeRabbit
New Features
Documentation