Repository navigation
Description
Problem
Node properties (schema fields) are visible and editable in the UI, but relationships between nodes are not surfaced at all. A user can see that a Task has a status and a priority, but has no way to see — let alone set or remove — that the Task is assigned to a Person and belongs to a Project.
The data model already supports this. The UI does not expose any of it.
Scope note: this is not about the primitive structural relationships (has_child / parent-child, mentions, collection membership). Those already have their own UI affordances. This is about schema-declared, typed relationships between node types.
Current state
Backend modeling is largely in place:
relationshipedge table within_node,out_node,relationship_type, and a JSONpropertiescolumn for edge data (packages/core/src/db/schema.sql:43)SchemaRelationshipon schema nodes, carryingname,target_type,direction,cardinality,reverse_name,reverse_cardinality,edge_fields,description(packages/nodespace-types/src/schema.rs:122)RelationshipCardinality { One, Many }andRelationshipDirection { Out, In }(packages/nodespace-types/src/schema.rs:109-119)- CRUD ops:
create_relationship,delete_relationship,get_related_nodes(packages/core/src/ops/rel_ops.rs) - Store-level generic edge ops:
create_generic_relationship,delete_generic_relationship,get_nodes_by_relationship,get_relationship_count(packages/core/src/db/sqlite_store/relationships.rs) RelationshipCacheresolving inbound/outbound relationship definitions per type (packages/core/src/services/relationship_cache.rs)
Gaps found while scoping:
- No frontend surface whatsoever. No Svelte component reads schema
relationships; the schema forms (packages/desktop-app/src/lib/components/schema/generic-schema-form.svelte,property-forms/) handle fields only. - No Tauri command surface.
commands/nodes.rsexposes only mention relationship commands. There is no command to create/delete/list a schema-declared relationship, so the frontend cannot reachrel_opseven if it wanted to. - Cardinality is stored and cached but never enforced.
RelationshipCardinalityappears in the type definitions and the cache, but no write path inrel_ops.rsorschema/mod.rschecks it. Nothing today prevents aOnerelationship from accumulating many edges.
So this is primarily a UI + command-surface issue, with a validation component.
Proposal
A relationship management modal, opened from a node, that lets the user view and edit that node's typed relationships.
Viewing
- List relationships grouped by relationship name (e.g.
assignedTo,belongsTo), showing the related node(s) with enough identity to be recognizable (title/content preview + node type). - Show both directions: outbound relationships declared on this node's schema, and inbound ones where another type declares this node as its
target_type.RelationshipCachealready resolves both sides — surfacereverse_nameas the label for the inbound side. - Show relationships that cross node types. A Task's modal should show its Person assignee and its Project parent side by side; these are different
target_types and must not be flattened into one list. - Relationship properties (edge attributes) are first-class here, not an afterthought. An edge carries its own data — a Task→Person
assignedToedge might carryassignedAtandrole; a Task→Project edge might carryorder. The viewer must display these alongside the related node, not just the target's identity.SchemaRelationship.edge_fields: Option<Vec<EdgeField>>declares them; therelationship.propertiesJSON column (schema.sql:48) stores the values.EdgeFieldcarries the same shape vocabulary asSchemaField(field_type,required,default,description) — so edge properties should render with the same property-form controls already used for node fields, rather than a parallel bespoke editor. Reuseproperty-forms/rather than duplicating it.- Edges with no declared
edge_fieldsrender as a plain target row with no property section.
View settings
The viewer needs configurable presentation, and those settings must cover edge properties as sortable/filterable/displayable columns in their own right — not only the target node's own fields.
- Column selection: choose which columns show per relationship group. The candidate set spans three sources: the target node's schema fields, the edge's
edge_fields, and intrinsic values (target type, created/modified). Edge properties must be selectable columns, since for many relationships (role,assignedAt) the edge data is the interesting content. - Sort: by any displayed column, including edge properties. Ordered relationships should be able to sort by the edge's
order. - Filter: narrow a relationship group by target field or edge property value.
- Grouping / layout: at minimum a table view for relationships carrying edge properties, and a compact chip/list view for bare edges with no edge data. A one-to-one relationship with no edge fields shouldn't render as a one-row table.
- Persistence: settings should stick per relationship (per schema-declared relationship name), not reset each time the modal opens. Where these are stored — schema node, user preferences, or per-node — is an open question below.
Prior art to reuse rather than reinvent: packages/desktop-app/src/lib/components/query/table-view.svelte already derives columns from schema field definitions (deliberately, rather than enumerating result keys) and renders rows via table-row.svelte. The relationship viewer's table mode should extend that pattern — the main addition being that its column set draws from two schemas (target node fields + edge fields) instead of one.
Editing
This modal populates relationships; it does not define them. Declaring a SchemaRelationship (its name, target_type, cardinality, edge_fields) is schema editing and belongs with the schema editor. The schema definition is the input that drives this viewer: it determines which relationship groups appear, what target types are pickable, which edge properties render, and which controls each one gets. Users here change values, not structure.
- Set/add: choose a target node — see target selection below.
- Modify: change the target of an existing edge; edit
edge_fieldsvalues where declared. - Delete: remove an edge. Confirm when the relationship is
required.
Target selection (the hard part)
Picking the other end of an edge needs to accept a target three ways, in one control:
-
Dropdown / enumerated — when the candidate set is small and bounded, list the targets directly. Cheapest interaction, and the right default for small types.
-
Search — when the set is too large to enumerate, type-ahead search matching on node title, filtered to the relationship's declared
target_type.The exact query already exists.
query_nodescombinestitle_contains(LOWER(title) LIKE ?) withnode_type = ?in a single statement (packages/core/src/db/sqlite_store/nodes.rs:819-829) — title match AND type filter, which is precisely this requirement. It needs a Tauri command wrapper, not new query logic.Use this rather than
search_semantic. Semantic/vector search is the wrong tool for picking a known entity by name: it's approximate, embedding-dependent, threshold-sensitive, and will happily return conceptually-similar-but-wrong people. Picking "Sarah Chen" from a list of Persons is an exact prefix/substring problem. (search_semanticalso carries anode_typesfilter, but its ranking is similarity-based — good for discovery, wrong for identity.) -
Direct UUID — paste a node id and resolve it. Needed for precision, for cross-referencing from elsewhere, and as an escape hatch when search doesn't surface the node.
Design notes:
- These are one control with three input modes, not three separate pickers. Recommend a single combobox: typing free text searches, typing something that parses as a UUID resolves it directly, and a bounded candidate set renders as a plain dropdown.
- Enumerate-vs-search should be automatic, not configured. Pick a threshold on candidate count and switch modes below/above it, so schema authors don't have to declare which mode a relationship gets.
- A pasted UUID must be validated before the edge is written: the node must exist, and it must match the declared
target_type. Silently creating an edge to a nonexistent or wrong-typed node is the main failure mode here. Reject with a clear message rather than writing a dangling edge. - When
target_typeisNone(the untyped case the cache handles via its"*"sentinel), the picker is unconstrained and search/UUID become the only viable modes.
Caveat — titles are derived, and some nodes have none. title is not user-entered: compute_title interpolates the type's titleTemplate against the node's properties and persists the result to an indexed title column on write (packages/core/src/services/node_service/crud.rs:2015, schema.sql:20). Because it's persisted and indexed, LIKE search over it is cheap. But three cases follow:
- A type with no
titleTemplatefalls back to content-based titling, so what the user searches may not be what they see on the node. dateandschemanodes are explicitly never given titles (titlestays NULL), and the query requirestitle IS NOT NULL— so they are unreachable by title search by construction. Fine for typical relationship targets; only a problem if a relationship legitimately targets one of those types.- Title changes when properties change. Renaming a person's
first_namechanges their title, but the edge stores only the node id — so relationship rows must render the current title at read time, never a title snapshotted when the edge was created.
Recommend the picker searches title as specified, but falls back to content match for types lacking a titleTemplate, so untitled nodes remain findable rather than silently absent from results.
Bi-directional view
Yes — the viewer shows both ends of the edge, and the infrastructure for it already exists.
An edge is stored once (in_node / out_node in one relationship row) but is meaningful from both sides. If a Task declares assignedTo → Person, then opening the Person should show the tasks assigned to them, even though Person's own schema declares no relationship at all. RelationshipCache exists precisely for this: it indexes every schema's relationships keyed by target_type, so get_inbound_relationships(type) answers "who points at me?" without scanning all schemas (packages/core/src/services/relationship_cache.rs:128). InboundRelationship already carries reverse_name and reverse_cardinality — the label and the cardinality for the far side.
So the viewer resolves its groups from two sources:
- Outbound: relationships declared on this node's own schema.
- Inbound:
RelationshipCache::get_inbound_relationships(this_type), plus the"*"sentinel entries for untyped relationships that apply to any target.
Consequences to decide:
- Labeling. The inbound side displays as
reverse_namewhen set (Person shows "tasks", not "assignedTo — inverse"). Whenreverse_nameis absent — it'sOptionand the cache preserves that — there is no good human label. Recommend falling back to something derived like "{source_type} ({relationship_name})" rather than hiding the group, since hiding it makes edges invisible from one side. - Cardinality flips. Reading from the inbound side,
reverse_cardinalitygoverns, notcardinality. AMany/Onerelationship is an add/remove list from one end and a single replace-slot from the other. Getting this backwards is the likeliest bug in this issue — the same edge must render as a list on one side and a single slot on the other. - Editability from the far side. Recommend yes, editable from both ends — a user on the Person node should be able to unassign a task. Read-only inbound would be an arbitrary restriction, since it's the same edge either way. This does mean the write path must accept "remove this edge" expressed from the target's perspective.
- Symmetry. An edit from either end mutates the one underlying row, so both views must reflect it. Nothing should make it look like there are two independent edges.
Cardinality behavior
The four combinations fall out of cardinality × reverse_cardinality:
| Forward | Reverse | Meaning | UI behavior |
|---|---|---|---|
| One | One | one-to-one | Single slot; setting a new target replaces the existing edge |
| One | Many | many-to-one (e.g. Task → Project) | Single slot on this side; replace on set |
| Many | One | one-to-many (e.g. Project → Tasks) | Add/remove list; adding steals the target from any prior owner |
| Many | Many | many-to-many (e.g. Task ↔ Tag) | Add/remove list, no exclusivity |
The "replace" and "steal" behaviors are the ones that need explicit decisions — they mutate an edge the user isn't directly looking at. Recommend: perform them, but tell the user what happened rather than silently rewriting.
required: true should block removal of the last edge.
Decided
- Populate, don't define. The modal edits relationship values; schema-level declaration of relationships is out of scope and belongs to the schema editor. The schema definition drives everything this viewer renders.
- Bi-directional. Edges are visible and editable from both ends, resolved via
RelationshipCacheinbound lookup.
Open questions
- Where does the modal open from? Options: a node's context menu, an affordance in the properties panel next to the fields, or a dedicated icon on the node. Recommend the properties area, since relationships are conceptually siblings of fields — but this is a UX call.
- Enforce cardinality in the backend, or only in the UI? Recommend backend, in
rel_ops::create_relationship, so the agent's tool calls are bound by the same rules as the UI. That makes this issue span both layers. - Relationship types beyond one-to-one / one-to-many / many-to-many? The current model covers these three via the cardinality pair. Things not modeled today that may be worth considering: ordered relationships (an explicit
ordercolumn exists on some edge paths), and self-referential relationships (a Task blocking another Task) wheretarget_typeequals the source type. Self-referential is worth an explicit answer, since the bi-directional view means such a relationship surfaces twice on the same node — once outbound ("blocks"), once inbound ("blocked by"). - Where do view settings persist? Storing them on the schema node makes them shared across every node of that type (consistent, but one user's column choice affects everyone). Storing them in user preferences makes them personal. Recommend schema node for now, matching how field presentation is already schema-driven — revisit if multi-user editing lands.
- Enumerate-vs-search threshold. What candidate count flips the picker from dropdown to type-ahead? Recommend starting around 20 and tuning.
Acceptance criteria
- Tauri command surface for schema-declared relationships: list (both directions), create, update edge fields, delete
- Modal lists a node's relationships grouped by name, showing related node identity and type
- Inbound relationships resolved via
RelationshipCache::get_inbound_relationships, including"*"untyped entries - Inbound relationships labeled with
reverse_name, with a derived fallback when it is absent - Inbound side governed by
reverse_cardinality— same edge renders as a list from one end and a single slot from the other - Edges editable from both ends; an edit from either side mutates the single underlying row and both views reflect it
- Target picker supports dropdown, type-ahead search, and direct UUID entry in one control
- Free-text search matches on node title and is filtered to the declared
target_type, viaquery_nodes' existingtitle_contains+node_typecombination — not semantic search - Types without a
titleTemplateremain findable via content fallback - Relationship rows render the target's current title, never a value snapshotted at edge-creation time
- Pasted UUIDs validated for existence and type match before an edge is written; dangling edges rejected with a clear message
- Modal does not expose schema-level relationship declaration
- Cross-type relationships displayed distinctly (not flattened)
- Node picker constrained to declared
target_type, with search - Add / change / remove edges from the modal
-
edge_fieldsvalues viewable and editable where declared, rendered with the existingproperty-forms/controls rather than a parallel editor - Edge properties selectable as columns, and sortable/filterable, on equal footing with target-node fields
- View settings: column selection, sort, filter, and table-vs-compact layout per relationship
- View settings persist across modal opens
- Bare relationships with no
edge_fieldsrender compactly, not as a one-row table - Cardinality respected:
Onesides replace rather than accumulate; user is informed when a replace displaces an existing edge -
requiredrelationships cannot have their last edge removed - Cardinality enforced in
rel_ops::create_relationshipso agent tool calls obey the same constraints - Primitive relationships (
has_child,mentions, collection membership) excluded from this modal - Tests: cardinality enforcement, both-direction listing, cross-type display, edge-field round-trip
Activity
mstomar125 commentedon Aug 6, 2026
Pragmatic code review (first slice, pre-PR)
Review Type: Initial · read-only relationship LIST command + viewer modal (scope: no editing / cardinality enforcement / target selection / view-settings — those are correctly deferred; #1918 stays open for them).
Requirements check (this slice)
rel_ops::get_node_relationships+ modalNodeService::get_inbound_relationships; self-referential intentionally shows twicetarget_type: None) declarationsget_inbound_relationshipsmatchesNone => truereverse_name, derived fallback when absentgroupDisplayLabel→"{SourceType} ({Relationship Name})"reverse_cardinalityget_related_nodes_with_edges→ table columnshas_child/mentions/member_of/has_role) excludedRelatedNodeView.titlefrom live node rowThe slice does what it sets out to do, and the aggregation/read path is consistent with the write path:
create_relationship→create_generic_relationshipalways storesin_node = source,out_node = target, and the outbound reader queriesdirection="out"(node asin_node→ targets), inbound queriesdirection="in"(node asout_node→ sources). Symmetric. Good separation of the pure grouping logic (relationship-grouping.ts, unit-tested) from the Tauri transport.Findings
🔴 None.
🟡 Inbound groups mis-attribute and duplicate edges when two schemas share a relationship name targeting the same type —
📁 packages/core/src/ops/rel_ops.rs:305-322+📁 packages/core/src/db/sqlite_store/relationships.rs:1160(principle: correctness of the primary feature)The inbound loop iterates
(source_type, rel)fromget_inbound_relationships(node_type), butcollect_related(node_id, &rel.name, "in")queries only onrelationship_type(... WHERE r.out_node = ?1 AND r.relationship_type = ?2) — it never constrains the far-end node tosource_type.Failure scenario (this is the marquee bi-directional case, not an exotic one):
taskandbugboth declareassigned_to → person(reverseName"tasks" / "bugs"). Open a Person that has one task and one bug assigned:get_inbound_relationships("person")→[("task", assigned_to), ("bug", assigned_to)]... relationship_type = "assigned_to"→ returns both the task and the bug.Result: the bug is listed under "Tasks", the task under "Bugs", and every count is doubled. Shared verbs across work-item types (
assigned_to,owned_by,belongs_to) are common, so this hits the headline inbound view under normal modeling. The olderget_related_nodesdidn't attribute by source type, so this mis-attribution is new to this aggregation.Fix is small and local: filter the inbound
relatedtonode.node_type == source_type(the declaring schema id equals the source node type; correct for typed and untyped alike), and add a two-source-schema test — the current test only exercises a single source schema, so it can't catch this. (Outbound has the same "keys only onrelationship_type, nottarget_type" shape, but only bites if one schema declares the same name twice — degenerate — so it's a far lower priority; worth the same one-line guard for symmetry.)🟢
SchemaRelationship.directionis ignored on both write and read —📁 packages/core/src/ops/rel_ops.rs:277. Outbound is always queried"out"regardless of a declareddirection: In. This is currently correct becausecreate_relationshipalso ignoresdirectionand always stores source asin_node— read matches write. Flagging only so the write follow-up is aware: if a future write path ever honorsdirection: Inby flippingin_node/out_node, this reader must flip with it. No action now.🟢
row.get(10)positional edge-props read is correct but silently fragile —📁 packages/core/src/db/sqlite_store/relationships.rs:1177. Verified:nodehas exactly 10 columns (id, node_type, content, properties, title, lifecycle_status, version, sync_seq, created_at, modified_at), son.*= indices 0–9 andr.properties= index 10. The doc comment even calls this out. The risk is that a future migration adding anodecolumn shifts index 10 and this reads the wrong column with no error. Consider aliasing (SELECT n.*, r.properties AS edge_props) with a name-based read, or at least adebug_asserton column count, in the write follow-up.unwrap_or_else(|_| json!({}))on the JSON parse is fine — the column isNOT NULL DEFAULT '{}'.🟢 AC named
RelationshipCache::get_inbound_relationshipsbut the impl uses the non-cachedNodeService::get_inbound_relationships—📁 packages/core/src/ops/rel_ops.rs:300. This is actually the right deviation: the cache'sInboundRelationshipstruct dropsedge_fields/description, which this viewer needs, whereas theNodeServicevariant returns the fullSchemaRelationship. It also can't serve stale data. The per-openget_all_schemas()scan is acceptable for an on-demand modal. No change; noting the intentional divergence from the AC wording.🟢
generic-schema-form.svelteguard relaxation is safe —📁 packages/desktop-app/src/lib/components/schema/generic-schema-form.svelte:125.{#if node && schema.fields.length > 0}→{#if node}with the inner{#if schema.fields.length > 0}preserved around theCollapsible. No empty Collapsible renders for zero-field schemas; the change purely lets the Relationships trigger appear when a schema has relationships but no fields. Correct. Minor UX note: the trigger renders for every schema node even when the node has zero typed relationships (opens → "no typed relationships"); unavoidable without a pre-query, acceptable.🟢 Minor frontend nits —
📁 packages/desktop-app/src/lib/components/relationships/relationship-viewer-modal.svelte. (a) table<th>lacksscope="col"(small a11y nit; Dialog otherwise handles focus/aria). (b) group headings usehumanizeNamewhile column headers useformatColumn+ CSScapitalize— two humanization paths for the same kind of token; harmless but worth unifying later. Noany/console/{@html};unknown+ logger throughout; stale-response guard vialoadedKeyis correct. Clean.Notes on strengths
content_previewis char-safe;titleis read live (satisfies the "never snapshot the title" AC).reverseName+ fallback, edge-column ordering (declared-first then ad-hoc keys), table-vs-chips classification, and id-fallback labeling. The one gap is the multi-source-schema case (F1).GetRelatedNodesResponsepattern; camelCase serde on the Rust structs lines up with the hand-written TS interfaces (nodeType/edgeProperties/reverseName/edgeFieldsall verified).Recommendation: REQUEST CHANGES
Everything is well-structured, well-documented, and correctly scoped — the single blocker is F1, because it mis-displays data in exactly the bi-directional inbound scenario that is this issue's headline value, under a common modeling pattern (shared relationship verbs). It's a ~3-line filter plus a two-source-schema test. The 🟢 items are non-blocking; address
row.get(10)fragility opportunistically in the write follow-up.mstomar125 commentedon Aug 6, 2026
/address-review — F1 fixed
🟡 F1 (blocker) — resolved. Inbound groups now
retainonly related nodes whose type equals the declaringsource_type, so two schemas declaring the same relationship name targeting one type (e.g.taskandbugbothassigned_to → person) land in separate groups with correct, un-doubled counts instead of cross-attributing. Added a focused Rust regression test (test_get_node_relationships_inbound_multiple_sources_not_duplicated) — it fails without the filter. Both relationship tests green.🟢 (non-blocking, left for a follow-up):
row.get(10)positional edge-props read (verified correct — node has exactly 10 columns — but could aliasr.properties AS edge_props);<th scope="col">; two humanization paths. None affect correctness.Scope reminder: this is the read-only first slice. Editing (create/update/delete edges), cardinality enforcement +
requiredlast-edge protection, target selection, and view-settings (the persistence open question) stay as follow-ups — #1918 remains OPEN.Re-review: not needed — the fix is a targeted source-type filter proven by a new regression test; the rest was APPROVE-quality.
Read-only relationship viewer + LIST command (first slice of #1918) (#…
Address review: classify relationship rejections + harden edit path (#…
Relationship editing command surface + required last-edge protection (#…
mstomar125 commentedon Aug 7, 2026
Slice progress (issue stays open): the backend command surface for editing typed relationships is merged via PR #1993 — the second slice after the read-only viewer (PR #1992).
Shipped (slices a-backend + b):
create_relationship,delete_relationship,update_relationship_propertiesTauri commands (registered inlib.rs), backed by newDeleteRelationship+UpdateRelationshipPropertiesdaemon RPCs and arel_ops/NodeService/storeupdate_relationship_propertiespath (editsrelationship.propertiesJSON wholesale).One-rejection on create was already enforced on main; this adds required last-edge protection indelete_relationship(rejects removing the final edge of arequiredrelationship; only blocks the last existing edge,direction: outonly).INVALID_ARGUMENT(notINTERNAL), so the modal can surface "add another target first". 6 integration tests; adversarially reviewed.Remaining (frontend — needs a machine that can run the desktop app / browser tests to verify):
relationship-viewer-modal.svelteeditable — add/remove edges + editedge_fieldvalues reusingproperty-forms/.target_type/ by id / UUID).generic-schema-form).The frontend slices are cleanly unblocked now — every command they need exists.
mstomar125 commentedon Aug 7, 2026
Reopened — merging PR #1993 auto-closed this via a branch-name development link, but the issue stays open until the last frontend slice (a-UI / c / d / e above) lands.
Expose the Relationships trigger in the task and person schema forms (#…
1 remaining item
mstomar125 commentedon Aug 7, 2026
Reopened (branch-name auto-close). Slice (e) landed via PR #2001 — the Relationships trigger is now on the task and person forms too. Remaining: editable modal (a), target picker (c), view-settings (d). Note: the relationship viewer service uses Tauri
invokedirectly, so those slices need the real app /dev:taurito validate (or a refactor to route the service through the dual-mode backend-adapter).Editable relationship modal + dual-mode relationship transport (#1918) (
mstomar125 commentedon Aug 7, 2026
Reopened (branch-name auto-close). Slices a (editing) + c (target selection) shipped via PR #2002 — the modal is now editable (add/remove edges, edit edge-field values, target picker by title/UUID), including adding the first edge of an empty relationship, all live-validated end-to-end. Also routed the relationship feature through the dual-mode backend-adapter so it's browser-dev testable now. Remaining: slice d (view-settings — column selection/sort/filter + persistence). Persistence direction: user-preferences keyed per (nodeType, relationshipName, direction) — a per-user presentation preference per schema-declared relationship, not schema-node data nor per-instance. Will confirm before building.
View settings: build (slice d) + address review (#1918) (#2003)
mstomar125 commentedon Aug 7, 2026
Closed — all slices shipped. Read-only viewer (PR #1992) → backend editing surface + cardinality/required guards (#1993) → trigger on task/person forms (#2001) → editable modal + target picker (#2002) → view settings/columns/sort/filter + persistence (#2003). The relationship feature is also now routed through the dual-mode backend-adapter, so it works in browser dev mode. Every slice was live-validated end to end against a running daemon and adversarially reviewed.
Reword remaining GitHub issue-number provenance comments in packages/…
Address review: correct four fixture types, extract shared fixtures
Filter system-protected fields out of relationship columns (closes #2408
Address re-review: carry the row's label, document the group-wide union
Browse relationships in two panes instead of stacked tables (closes #…
Address re-review: carry the row's label, document the group-wide union
Browse relationships in two panes instead of stacked tables (closes #…