feat(relationship): editable relationships with LocalDate+DatePrecision dates and notes #841
Reference in New Issue
Block a user
Delete Branch "feat/issue-837-relationship-edit-dates"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #837
Makes
PersonRelationshipfully editable (type, related person, dates, notes), migrates its dates fromInteger fromYear/toYeartoLocalDate + DatePrecision(mirroring the #773 person pattern, ADR-039 / V76), activates the previously-deadnotescolumn, and gives the Zeitstrahl's derived Heirat events full date precision for free.Both Open Decisions confirmed as adopted: no
@Version(last-write-wins, single-writer archive) andDELETEownership-mismatch aligned 403 → 404 (anti-enumeration, matching the newPUT).What's in it
person_relationships.from_year/to_year→from_date/to_date+ NOT-NULL*_date_precision(defaultUNKNOWN); pre-check abort on corrupt years,YYYY-01-01/YEARbackfill, 5 named CHECK constraints, year columns dropped.PUT /api/persons/{id}/relationships/{relId}(@RequirePermission(WRITE_ALL)) re-runs every create invariant (self / coherence / order / reverse-PARENT_OF / duplicate) and re-flags family membership; orientation preserved per viewpoint.ErrorCode.INVALID_RELATIONSHIP_DATESregistered in all four sites (§3.6).TimelineEventServicesources the derived marriage date fromSPOUSE_OF.fromDate+ precision.RelationshipDateField(DAY/MONTH/YEAR), upsert-capableAddRelationshipForm(pre-fill + notes + in-flight submit lock),RelationshipChipEdit affordance,updateRelationshipserver action, read-view date range + notes,formatRelationshipDateRangehelper.api.tsregenerated.Requirements
All 19 EARS requirements implemented red/green and marked
Donein.specify/rtm.md.Test plan
RelationshipMigrationTest(Testcontainers pg16, 8),RelationshipServiceTest(22),RelationshipControllerTest(15),RelationshipServiceIntegrationTest(real DB, 10),DerivedEventsAssemblyTest(17),ArchitectureTest(14);clean packagebuilds.relationshipDates.spec.ts,AddRelationshipForm.svelte.spec.ts,RelationshipChip.svelte.spec.ts,PersonRelationshipsCard.svelte.test.ts,page.server.spec.ts,messages.spec.ts.npm run check= 798 (below the ~834 baseline);npm run lintclean.Notes for reviewers
AddRelationshipFormupsert-capable rather than a duplicateEditRelationshipForm(DRY); RTM rows referenceAddRelationshipForm.svelte.spec.ts.api.tsregenerated from the live spec; only relationship-relevant hunks remain (one springdocPageableObjectfield-reorder pruned).pg_restore -t person_relationshipsfor rollback. No maintenance window.🤖 Generated with Claude Code
New 400 error code for a relationship whose toDate precedes its fromDate, registered in all four sites at once (ErrorCode.java, errors.ts, getErrorMessage, messages/{de,en,es}.json) per constitution §3.6. Thrown by the relationship date validation introduced in the following commit. Refs #837 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>PUT /api/persons/{id}/relationships/{relId} (@RequirePermission WRITE_ALL) updates a relationship's type, related person, dates and notes in place, preserving the original createdAt. The update re-runs every create invariant — self-relation (VALIDATION_ERROR), date coherence/order, reverse PARENT_OF (CIRCULAR_RELATIONSHIP) and the (person, relatedPerson, type) unique constraint via saveAndFlush (DUPLICATE_RELATIONSHIP) — and re-flags both endpoints as family members when edited into a family type. The directed orientation is preserved per viewpoint, so a PARENT_OF edge stays parent->child whether edited from either person's page. Ownership mismatch now returns 404 RELATIONSHIP_NOT_FOUND (shared loadOwned helper) for both PUT and DELETE — anti-enumeration, replacing DELETE's former 403. No @Version: last-write-wins, matching person edit (single-writer archive). REQ-004, REQ-005, REQ-006, REQ-007, REQ-008, REQ-009, REQ-012, REQ-013, REQ-018 Refs #837 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>feat/issue-837-relationship-edit-datesto feat(relationship): editable relationships with LocalDate+DatePrecision dates and notes