Skip to content

Make graph_resolver.rs direction-aware so Play conditions can walk any relationship's reverse side #2641

Closed

Description

@malibio

Overview

The playbook engine's Play-condition path resolver (graph_resolver.rs) supports rich forward-direction graph traversal — arbitrary-depth multi-hop dot-paths (node.story.epic.status) and collection comprehensions (node.tasks.any(t, t.status == "done")) are both fully implemented and exercised by existing tests. What it cannot do, for any relationship, is walk backwards: read a relationship from the end that did not declare it. fetch_related_nodes (packages/core/src/playbook/graph_resolver.rs, ~line 188) calls NodeService::get_related_nodes(node_id, relationship_name, "out") with direction hardcoded to the literal string "out" — every one of the ~11 existing test fixtures in this file also only exercises "out" declarations, confirming this is the resolver's actual, complete current ceiling, not an untested edge.

This is a resolver-wide gap, not specific to any one relationship. It surfaced while scoping a core auto-complete-parent Play (needing has_child's reverse direction — tracked separately, see Related Issues) but the same limitation blocks a Play condition from reading, from a task, its project (declared as project.tasks → reverse project), its assignee (declared as person.tasks → reverse assignee), or — for a forthcoming Linear-style recipe — its cycle (if cycle declares tasks the way project does) or its creator (person.reported_tasks → reverse creator, tracked in #2637). Every one of these is unreachable from a Play condition today, for the same underlying reason.

Problem Statement

get_related_nodes already supports both directions at the service layer (packages/core/src/services/node_service/relationship.rs, ~line 1053, validates direction as "out" or "in") — the gap is entirely that graph_resolver.rs never passes anything but "out", and has no path-segment syntax for a Play author to request the reverse direction. Once #2638 (store the reverse relationship name as a real, queryable reverse_relationship_type column) lands, every relationship — built-in and schema-declared alike — will have a real name for its reverse side to resolve against; this issue is what teaches the resolver to actually use that name.

Proposed Solution

Extend resolve_path/fetch_related_nodes to recognize a reverse-direction path segment (exact syntax to be decided during implementation — e.g. a segment matching a known reverse_relationship_type value resolves via direction: "in" against the relationship whose relationship_type reverse-name matches it, rather than requiring a distinct sigil like ^name). This must be resolved generically against whatever relationship declares that reverse name — not hardcoded per relationship — so it works uniformly for has_child/child_of, project.tasks/project, person.tasks/assignee, person.reported_tasks/creator, and any future schema-declared relationship, with zero additional resolver changes per relationship once this lands.

Concretely: node.assignee (a task reading its assignee) should resolve the same way node.project already implicitly could once project targeting is set up — via a single, direction-aware fetch_related_nodes that looks up whichever relationship row has reverse_relationship_type == "assignee" targeting task, then queries with direction: "in".

Architecture Impact

No existing ADR documents Play-condition graph traversal as scoped to forward-direction-only, or asserts this is a deliberate limitation — this is closing a real capability gap, not reversing a decision. Directly builds on #2638's reverse-name column.

Acceptance Criteria

  • graph_resolver.rs resolves a reverse-direction path segment generically, for any relationship with a reverse_relationship_type (from Store relationship_type's reverse name as a queryable column on the relationship edge table #2638), not hardcoded per relationship name
  • Multi-hop paths and collection comprehensions work through a reverse-direction segment the same as they already do forward (e.g. node.assignee.email, node.project.tasks.any(...))
  • Regression: all existing forward-direction path/collection tests continue passing unmodified
  • New test coverage: reverse traversal for at least one built-in (has_child → child_of) and one schema-declared relationship (person.tasks → assignee)
  • Tests pass (bun run test:all)
  • Code passes bun run quality:fix

Technical Specifications

Reference Files

  • packages/core/src/playbook/graph_resolver.rs — resolve_path (~line 63), fetch_related_nodes (~line 188, direction hardcoded "out") — the resolver logic to make direction-aware
  • packages/core/src/playbook/path_extractor.rs — confirms path/collection extraction from CEL ASTs is already relationship-name-agnostic; no changes expected here, but verify a reverse-name segment parses the same as any other identifier
  • packages/core/src/services/node_service/relationship.rs — get_related_nodes (~line 1053) — already generic over "out"/"in", no change needed here
  • ../nodespace-docs/decisions/078-schema-extends-relationship-for-field-composition.md (ADR-078) — subtype-aware query/trigger precedent for "implement once at a single choke point, every caller benefits automatically," the same shape this issue follows

Dependencies

Related Issues

Non-Goals

Activity

  1. malibio commented on Sep 17, 2026

    @malibio
    CollaboratorAuthor

    Frontend baseline: 251 test files passed, 5150 tests passed (59.72s)

  2. self-assigned this
    on Sep 17, 2026
  3. added a commit that references this issue on Sep 17, 2026
    5626e5f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions