Skip to content

[EDIFIKANA] Add parent-unit guard to createOccupant - #577

Merged
CRamsan merged 5 commits into
mainfrom
cr/ds-x-004-create-occupant-unit-guard
Jul 27, 2026
Merged

[EDIFIKANA] Add parent-unit guard to createOccupant#577
CRamsan merged 5 commits into
mainfrom
cr/ds-x-004-create-occupant-unit-guard

Conversation

@CRamsan

@CRamsan CRamsan commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Closes another cross-datastore gap (DS-X-004): createOccupant had no parent-active check at all, unlike createUnit (checks parent Property) and createProperty (checks parent Organization, DS-X-002). Adds a shallow, immediate-parent-only guard checking the unit is active, mirroring the existing pattern exactly.
  • Scope decision made explicit, not silently assumed: the existing DS-X-004 test soft-deleted the grandparent Property rather than the immediate parent Unit. Since the established pattern in this codebase only checks the immediate parent (createUnit itself doesn't check its Property's own parent Organization either), this fix mirrors that shallow pattern and rewrites DS-X-004's arrangement to soft-delete the Unit directly, matching DS-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.
  • A broader "walk the full ancestor chain" redesign (affecting createUnit too, not just this method) is noted as a follow-up, not attempted here.

Demo

N/A — no UI changes.

References

  • Plan: ~/.claude/plans/ds-x-004-create-occupant-unit-guard.md
  • Verification: ~/.claude/plans/ds-x-004-create-occupant-unit-guard-verification.md

Test plan

  • ./gradlew :edifikana:back-end:release --quiet — PASS
  • ./gradlew :edifikana:back-end:integTest --tests "*CrossDatastoreIntegrationTest*" --tests "*SupabaseOccupantDatastoreIntegrationTest*" — 11/11 + 14/14 PASS, including DS-X-004 (the fix, also confirmed in isolation) and DS-X-001/DS-X-002 (unaffected)
  • Full backend integration suite — 261/261 PASS, confirming no regression anywhere from adding this guard

@CRamsan
CRamsan force-pushed the cr/ds-x-002-create-property-org-guard branch from 94f54e6 to 6371508 Compare July 27, 2026 07:10
@CRamsan
CRamsan changed the base branch from cr/ds-x-002-create-property-org-guard to main July 27, 2026 07:12
Cramsan 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
CRamsan force-pushed the cr/ds-x-004-create-occupant-unit-guard branch from ac84e64 to 07a0fa5 Compare July 27, 2026 07:12
@CRamsan
CRamsan merged commit dde4614 into main Jul 27, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant