Repository navigation
Description
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.rsresolves a reverse-direction path segment generically, for any relationship with areverse_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-awarepackages/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 identifierpackages/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
- Store relationship_type's reverse name as a queryable column on the relationship edge table #2638 (store reverse relationship name as a queryable column) — required first; there is no reverse name to resolve against until that column exists and is populated
Related Issues
- Seed a core Play that completes a parent task when all its children are done #2636 (seed a core Play that completes a parent task when all children are done) — the original motivating case; that issue's own "known implementation gap" section has been narrowed now that the resolver-level fix is tracked here instead, since the need turned out to be resolver-wide, not
has_child-specific - Add methodology recipe mechanism (TS source, generated CLI reference doc) with Linear-style as first recipe #2596 (Linear-style methodology recipe) — once this lands, every reverse-relationship Play condition the recipe needs (assignee, project, cycle, creator) becomes pure Play definition — data, not new engine work — with zero additional implementation per relationship
Non-Goals
- Deciding what specific Plays use this capability — that's each consuming issue's own scope (Seed a core Play that completes a parent task when all its children are done #2636, future recipe Plays)
- Any change to forward-direction resolution, which is already complete and unaffected
Activity
Address review: carry the declaration's reverse name onto instance edges
Store a relationship's reverse name as a queryable column (#2709)
malibio commentedon Sep 17, 2026
Frontend baseline: 251 test files passed, 5150 tests passed (59.72s)
Make graph_resolver direction-aware for Play conditions (closes #2641)