Skip to content

Slice E: relationship mutation (remove_relationship / update_relationship)#51

Merged
david-w-t merged 9 commits into
davidwt-com:mainfrom
david-w-t:develop
Jun 29, 2026
Merged

Slice E: relationship mutation (remove_relationship / update_relationship)#51
david-w-t merged 9 commits into
davidwt-com:mainfrom
david-w-t:develop

Conversation

@david-w-t

Copy link
Copy Markdown
Contributor

Slice E — Relationship mutation (remove_relationship / update_relationship)

Completes the connection-arc write-path: the exact mirror of add_relationship,
plus per-direction AVP editing. Connection-arcs only — these never touch the
parents/classes caches, so there is no cache work.

What's added

API Behaviour
remove_relationship/3,4 Atomically deletes both directed rows of a logical connection edge
update_relationship/4,5 AVP-only edit of the single directed row named by (S, C, T)
update_relationship_both/4,5 Edits both directions with independent {Fwd, Rev} lists
mutate/1 Three new batch grammar kinds wiring the above (with/without template)

Key design points

  • Remove is edge-level; AVP update is directed-row-level. The (S, C, T)
    triple names one directed row — name (T, R, S) to edit the reverse. Removal
    always takes both rows (a half-edge is invalid); a missing symmetric partner
    aborts {dangling_half_edge, Id} before any delete.
  • Ambiguity contract. Nothing dedups connection edges at write time, so a key
    matching more than one logical edge → {ambiguous_relationship, Templates}
    (templates carried so a /3 caller can re-issue as /4); zero matches →
    relationship_not_found.
  • ?ARC_TEMPLATE is protected from edit in both directions (changing scope is
    a structural rewire, not metadata).
  • Reuses slice B's validate_avp_updates/1 + apply_avp_updates/2 unchanged.
    One tier-1 update primitive; *_both is pure composition above it.
  • Transaction-seam compliant: tier-1 in-txn primitives are gen_server-free and
    never open their own transaction; tier-2 own one transaction/1; tier-3
    (mutate/1) composes tier-1 directly.

Scope / deferred (recorded in TASKS.md)

Structural rewiring (characterization/target_nref/reciprocal — expressible
as mutate([remove, add])) and a rel-id-keyed form (the only disambiguator for a
genuine duplicate edge) are deferred. Compositional-arc mutation
(add_parent/add_child/remove_parent/remove_child, which do maintain the
parents cache) is recorded as a separate follow-up.

Tests

Full suite green: 501 CT + 135 EUnit = 636, 0 failures, 0 compile warnings.
New: 2 EUnit (has_template_update/1) + 10 instance CT (remove ×5, update single
×4, _both ×1) + 3 mgr CT (mutate remove / update / mixed-rollback). Coverage
includes duplicate-edge ambiguity, /4 disambiguation, dangling-half-edge
rollback, direction independence, Template-AVP protection and survival, and
whole-batch atomic rollback. verify_caches/0 clean after every case.

Design: docs/designs/slice-e-relationship-mutation-design.md
Plan: docs/superpowers/plans/2026-06-28-slice-e-relationship-mutation.md

🤖 Generated with Claude Code

david-w-t and others added 9 commits June 28, 2026 10:30
Connection-only remove_relationship / update_relationship (AVP-only),
edge-level remove vs directed-row update, ambiguity contract; records the
add_parent/add_child/remove_parent/remove_child compositional follow-up.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EWukKCbrN8GybaScJGU2kF
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EWukKCbrN8GybaScJGU2kF
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EWukKCbrN8GybaScJGU2kF
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EWukKCbrN8GybaScJGU2kF
…ves edit

Final-review minors: update_relationship_both now checks the symmetric
partner before editing (same {dangling_half_edge, Id} arm as remove, keeping
the documented contract accurate); single-direction CT now asserts the
protected Template AVP survives an ordinary edit.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EWukKCbrN8GybaScJGU2kF

@david-w-t david-w-t left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@david-w-t david-w-t merged commit 7c463b7 into davidwt-com:main Jun 29, 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