[EDIFIKANA] Add parent-unit guard to createOccupant - #577
Merged
Conversation
CRamsan
force-pushed
the
cr/ds-x-002-create-property-org-guard
branch
from
July 27, 2026 07:10
94f54e6 to
6371508
Compare
CRamsan
changed the base branch from
cr/ds-x-002-create-property-org-guard
to
main
July 27, 2026 07:12
added 5 commits
July 27, 2026 00:12
createOccupant had no check that its parent unit was active, unlike createUnit's guard against its own parent Property and (as of this batch) createProperty's guard against its parent Organization (DS-X-002). Mirrors the same shallow, immediate-parent-only fetch-and-throw pattern: fetch the unit filtered deletedAt isExact null, throw NotFoundException if missing/soft-deleted, before proceeding with the original insert.
Rewrites the test to soft-delete the unit directly (matching the shallow, immediate-parent-only guard actually added) instead of its grandparent property, and asserts createOccupant now refuses to create against it. The deeper "unit active, property soft-deleted" scenario is a documented, deliberately deferred gap -- consistent with createUnit not checking its own parent's parent either.
CRamsan
force-pushed
the
cr/ds-x-004-create-occupant-unit-guard
branch
from
July 27, 2026 07:12
ac84e64 to
07a0fa5
Compare
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
DS-X-004):createOccupanthad no parent-active check at all, unlikecreateUnit(checks parent Property) andcreateProperty(checks parent Organization,DS-X-002). Adds a shallow, immediate-parent-only guard checking the unit is active, mirroring the existing pattern exactly.DS-X-004test soft-deleted the grandparent Property rather than the immediate parent Unit. Since the established pattern in this codebase only checks the immediate parent (createUnititself doesn't check its Property's own parent Organization either), this fix mirrors that shallow pattern and rewritesDS-X-004's arrangement to soft-delete the Unit directly, matchingDS-X-001's shape. The deeper "unit active, property soft-deleted" scenario remains a documented, deliberately deferred gap — consistent with, not worse than, the existing architecture.createUnittoo, not just this method) is noted as a follow-up, not attempted here.Demo
N/A — no UI changes.
References
~/.claude/plans/ds-x-004-create-occupant-unit-guard.md~/.claude/plans/ds-x-004-create-occupant-unit-guard-verification.mdTest plan
./gradlew :edifikana:back-end:release --quiet— PASS./gradlew :edifikana:back-end:integTest --tests "*CrossDatastoreIntegrationTest*" --tests "*SupabaseOccupantDatastoreIntegrationTest*"— 11/11 + 14/14 PASS, includingDS-X-004(the fix, also confirmed in isolation) andDS-X-001/DS-X-002(unaffected)