Skip to content

Author bare inbound many-to-many edges from either end (closes #2805) - #3064

Merged
malibio merged 2 commits into
mainfrom
issue-2805-inbound-many-add
Sep 26, 2026
Merged

malibio merged 2 commits into
mainfrom
issue-2805-inbound-many-add

Conversation

@malibio

@malibio malibio commented Sep 26, 2026

Copy link
Copy Markdown
Collaborator

Summary

A task's Blocked By, Related From and Duplicated By are the same stored edges as another task's Blocks, Relates To and Duplicates. The Relationships modal dropped empty inbound groups from + Add and rendered populated ones read-only, so recording "A is blocked by B" meant opening B and adding Blocks → A.

  • groupAcceptsEdgesHere (new, relationship-grouping.ts): an outbound group, or an inbound group with no declared edge fields, accepts add and remove on this node. Direction only decides which way round the edge is written: resolveEdgeEndpoints already transposes, so adding Blocked By → B on A stores B —blocks→ A.
  • partitionGroups: addable now includes empty bare inbound groups.
  • Modal rail: split by that predicate instead of by direction. Bare inbound groups sit with the editable relationships above + Add, and their rows get the remove control.
  • Edge-field inbound groups stay read-only: their values (an access level, a role) are authored at the declaring end, as groupSupportsEdgeEditing already requires. The modal's header docs are updated to state the rule.

Scope

Testing

  • relationship-grouping.test.ts:
    • Empty bare inbound groups are addable and labeled by reverseName (e.g. Blocked By).
    • Edge-field inbound groups are still dropped.
    • A task offers both Blocks and Blocked By.
    • groupAcceptsEdgesHere cases, and the hasModalContent gate.
  • relationship-viewer-modal.test.ts (new):
    • Add from Blocked By writes createRelationship('task-b', 'blocks', 'task-a').
    • Remove from a populated inbound row writes deleteRelationship('task-b', 'blocks', 'task-a').
    • An edge-field inbound group shows under "Incoming · read-only" with no remove button and no Add.
  • Full pre-push gate passed: unit, scripts, skill, Rust and e2e.
  • Not checked in the running app: coverage is at the component level.

🤖 Generated with Claude Code

A task's Blocked By / Related From / Duplicated By are the same stored edges
as another task's Blocks / Relates To / Duplicates, but the Relationships modal
dropped empty inbound groups from + Add and rendered populated ones read-only,
so recording "A is blocked by B" meant opening B.

- groupAcceptsEdgesHere: outbound groups, and inbound groups without edge
  fields, accept add/remove here. Writes transpose via resolveEdgeEndpoints.
- partitionGroups offers empty bare inbound groups in `addable`.
- The modal rail splits by authorability rather than direction, and the
  remove control follows the same predicate.
- Inbound groups with declared edge fields stay read-only: their values are
  authored at the declaring end.

The local-one half of the issue (assign/reassign as a form field) shipped in
#3050.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@malibio

malibio commented Sep 26, 2026

Copy link
Copy Markdown
Collaborator Author

Pragmatic Code Review — PR #3064 (Initial Review)

Summary

This is a small change and it makes the code better. A new predicate, groupAcceptsEdgesHere (outbound, or inbound with no edge fields), now answers "can this end author edges?" in one place. The + Add chooser, the rail split and the remove control all read from it, so the three surfaces can't disagree. Writes already go through resolveEdgeEndpoints, so the transposition needed no new code. Groups promoted to form fields (one + bare) are removed before this predicate runs. That means every bare inbound group that reaches the modal is effectively many, and + Add can't append a second edge to a single-valued end. Backend inbound groups report required: None, so the "remove last required" confirm can't fire wrongly on the inbound side.

Tests: the 2 changed files pass (53 tests). Modal tests 1 and 2 would fail on origin/main: Blocked By was missing from the chooser, and the bare inbound row had no Remove button and sat under "Incoming · read-only". Test 3 guards against regressions for the edge-field case.

Requirements check (scope as agreed with the author)

  • ✅ Empty bare inbound many groups offered under + Add (partitionGroups, unit and component tests)
  • ✅ Bare inbound rows get a remove control; add and remove write transposed (task-b —blocks→ task-a)
  • ✅ Inbound groups with declared edge fields stay read-only: no Add, no Remove, listed below the divider
  • ✅ Blocks/Relates To/Duplicates work from both ends
  • ✅ partitionGroups tests cover inbound groups: bare vs. edge-field, plus the promoted one interplay
  • ✅ Local-one assign/reassign, cardinality-driven verb and populated-One reassign: covered by Promote one-cardinality relationships to form fields; exclude them from the Relationships modal (closes #2806) #3050
  • ✅ One↔many stays editable from the declaring many side (Project → Tasks keeps its Add). This is intentional, not a gap.
  • ℹ️ The issue AC "an empty group surfaces a control regardless of direction" is deliberately narrowed: inbound groups with edge fields stay dropped. The author agreed to this, and the new doc comments explain why.

Findings

🟡 [Improvement] relationship-viewer-modal.svelte:770, 932 — footer text still branches on direction
{@const inbound = group.direction === 'in'} picks "Edit these from the node that owns this relationship." That text is now wrong for a bare inbound group whose edges carry ad-hoc (undeclared) keys. That group now shows under "On this node", right above a footer telling the user to go elsewhere. The declaring end can't edit those keys either, because they are undeclared there too. The right message is the "not declared on the schema" branch. Replace inbound with !groupAcceptsEdgesHere(group) (or inline it) so the footer uses the same predicate as the rail and the remove button. Principle: one source of truth for a rule. This is exactly the kind of leftover direction === 'in' branch the refactor set out to remove. This case is rare (bare inbound with ad-hoc keys), so it doesn't block.

🟢 Nit: relationship-viewer-modal.svelte:458-460 — openTarget doc comment is stale
"For an INBOUND row this is also the route to editing: that node's own panel declares the relationship outbound, which is the only place the edge can be changed." Bare inbound edges can now be added and removed here. Narrow it to inbound rows with edge fields.

🟢 Nit: relationship-grouping.ts:248-249 — groupSupportsEdgeEditing doc
"Inbound groups are never editable: the edge is owned by the other node's schema." This is still correct about edge properties, but next to the new predicate it reads as a contradiction. Consider "an inbound group's edge properties are never editable here…".

🟢 Nit (pre-existing, not introduced here): the target picker doesn't exclude the current node. Choosing it under Blocked By (or Blocks) creates a self-edge. Worth a follow-up only if self-links are invalid for these relationships.

Standards

No issue numbers in code comments. No new logging. No lint suppression. No compatibility shims. Test mocks follow the mockTauriCore / backendAdapter spy pattern.

Recommendation: APPROVE

Consider the 🟡 footer-predicate fix before merge; it's a one-line change.

@malibio malibio left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Automated pragmatic-code-review: APPROVE (posted as a comment — GitHub blocks self-approval). Full findings in the review comment above.

- The expanded-row footer used direction === 'in' to say "edit from the
  owning node"; a bare inbound group with undeclared edge keys is now
  authorable here, so the undeclared-keys message is the right one. The
  detail pane reads groupAcceptsEdgesHere once for both footer and remove.
- openTarget and groupSupportsEdgeEditing docs scoped to edge-field inbound
  groups / edge properties.

Skipped: excluding the current node from the target picker (self-edge). It
predates this PR, applies equally to outbound groups, and whether self-links
are invalid is a separate schema question.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@malibio

malibio commented Sep 26, 2026

Copy link
Copy Markdown
Collaborator Author

Address review — 97f246c

✅ Addressed (3)

  • 🟡 Row footer keyed on direction === 'in': the detail pane now reads groupAcceptsEdgesHere once (authorable) for both the footer and the remove control. A bare inbound group with undeclared edge keys now shows the undeclared-keys message.
  • 🟢 openTarget doc scoped to read-only (edge-field) inbound rows.
  • 🟢 groupSupportsEdgeEditing doc now says it's edge properties that are never editable here, and points to groupAcceptsEdgesHere.

⏭️ Skipped (1)

  • 🟢 Self-edge from the target picker: this predates the PR and affects outbound groups the same way. Whether self-links are invalid for blocks/relates_to is a schema question. Worth a follow-up only if they should be rejected, and then at the daemon.

Tests: the relationship unit and component tests pass (53), and the full pre-push gate passed.

Re-Review Decision

NO RE-REVIEW NEEDED. The changes are one branch condition swapped to the predicate the PR already introduced, plus comment wording. There is no new logic.

@malibio
malibio merged commit 65947ff into main Sep 26, 2026
@malibio
malibio deleted the issue-2805-inbound-many-add branch September 26, 2026 08:12
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