feat(location): entity movement + occupancy/collision (#146, #147)#152
Merged
Conversation
RFC 0001 lists "validate and apply movement" and "spatial queries and collision detection" as Viron responsibilities, but neither existed. Occupancy / collision (#147): - LocationRepository.getEntityIdsAtLocation — entity ids at a location. - GET /api/v1/locations/{id}/entities — entities at a location. - GET /api/v1/locations/{id}/occupied — whether a location is occupied. Movement (#146): - LocationRepository.moveEntityToLocation — a single atomic UPDATE that re-points an entity's placement (no remove-then-add window). - getGridIdOfLocation — supports same-grid validation. - PUT /api/v1/locations/{locationId}/entity/{entityId}/move — validates the entity is placed (404), the target exists (404) and is in the same grid (400), and the target is unoccupied (409 collision) before moving. - New ConflictException -> HTTP 409 in GlobalExceptionHandler. Tests: 9 new controller tests + 5 new repository tests covering each path. Full suite: 242 passing under JDK 21 (./mvnw test). Closes #146 Closes #147 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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
Closes #146 and #147 — two coupled Viron responsibilities from RFC 0001 that didn't exist: validate and apply movement, and spatial queries / collision detection. Movement validation is where the collision check lives, so they're delivered together.
Occupancy / collision (#147)
LocationRepository.getEntityIdsAtLocation(locationId)— the entity ids at a location.GET /api/v1/locations/{locationId}/entities— who's at a location.GET /api/v1/locations/{locationId}/occupied— boolean "is it occupied".Movement (#146)
LocationRepository.moveEntityToLocation(entityId, targetLocationId)— a single atomicUPDATEthat re-points the entity's placement (avoids the non-atomic remove-then-add the issue called out).getGridIdOfLocation— supports same-grid validation.PUT /api/v1/locations/{locationId}/entity/{entityId}/move— validates before moving:ConflictException→ HTTP 409 inGlobalExceptionHandler.Validation
./mvnw testunder JDK 21 (the CI command). +9 controller tests (each move/occupancy path) and +5 repository tests.Scoped out (noted for follow-up)
GET .../neighbors) — Add collision / occupancy detection, per RFC 0001 #147 lists it as an example; deferred to keep this PR focused. Grid geometry (orthogonal adjacency from x,y) can be a small follow-up.Closes #146
Closes #147
Opened by Claude on behalf of Daniel Stephenson; verified with ./mvnw test (242 passing) under JDK 21.