Repository navigation
Closed
Labels
Description
Overview
Introduce one typed RelationshipPath, compiled to CTE SQL, shared by query relationship filters, play for_each and CEL dot-paths. Let plays select nodes the way queries do. Type play rules, including per-action parameters (ADR-086 §11, §4 "Structured").
Problem Statement
- Plays walk the graph one hop at a time.
GraphResolver(packages/core/src/playbook/graph_resolver.rs) callsget_related_nodesfor each hop, per node. A scheduled rule over N nodes with a k-hop path makes about N×k round trips. - Query has its own model. Query relationship filters (
QueryFilterwithRelationshipTypeinpackages/nodespace-types/src/query.rs) cover onlyparent/children/mentions/mentioned_byplusrelated, while play also follows schema-declared relationships and reverse names. - Scheduled play triggers scan every node of a type and filter in CEL, rather than using query's typed filters and SQL.
- Play rules are stringly typed and live only in core.
RuleDefinition,TriggerDefinitionandActionDefinitionare inpackages/core/src/playbook/types.rs, notnodespace-types.trigger_type,onandaction_typeareString.- Action
paramsis open JSON, so a play using parameter names the engine never reads saves without error.
Proposed Solution
RelationshipPathinnodespace-types: a list of hops, each a relationship name (built-in, schema-declared or reverse) and a direction, optionally open-ended. It is resolved against the schemas when saved, so every name becomes a concreterelationship_typeand direction.- One store method compiles and runs a path:
- one correlated subquery per hop (never a JOIN; the JOIN form measured about 50× slower);
WITH RECURSIVEfor open-ended walks;- results keyed by (root id, path);
- batched across all the roots of a scan.
It serves query relationship filters, playfor_each, and CEL dot-paths (resolved before CEL evaluation, as today).
- Delete
GraphResolver's per-hop walking, keeping its root-scoped result keying. - Play rules move to
nodespace-typesas typed wire types: a taggedTriggerenum, a taggedActionenum with typed per-action params (deny_unknown_fields), and open JSON only for thepropertiesandedge_databeing written. A play's scheduled selector is aQueryFieldsvalue or a reference to a savedquerynode. CEL stays for conditions. - Wire it end to end: a typed
PlayNodeand update through the shared pipeline, with generated TypeScript. - No migration: reset the database. Update the bundled plays and docs to the typed params.
Architecture Impact
Implements decisions/086-core-node-types-defined-once-typed-by-category.md §11 and §4 for play and query (nodespace-docs). Update architecture/playbook-system.md (teach the real param names), architecture/playbook-engine.md and components/query-node.md in the same PR. Keep the tests that pin the (root, path) keying and the correlated-subquery form.
Acceptance Criteria
-
RelationshipPathexists innodespace-types; query filters, playfor_eachand CEL dot-paths all use it (tests) - A path compiles to one SQL statement (correlated subqueries per hop;
WITH RECURSIVEfor open-ended walks), and a scheduled scan resolves a path for all roots in one statement (tests, including a query-plan assertion) - Results are keyed by (root id, path); one root's answer is never returned for another (test)
-
GraphResolverno longer callsget_related_nodesper hop - Play rules are typed wire types; an unknown action param is rejected when the play is saved (test per action)
- A scheduled trigger can select with
QueryFieldsor a saved query id (tests) - The bundled playbooks and core plays use the typed params
- Follows
development/node-type-sequence.md; thenode-types.mdplay and query sheets updated in the same PR -
bun run test:changedpasses;bun run quality:fixclean
Technical Specifications
Reference Files
packages/core/src/playbook/graph_resolver.rs,types.rs,validation.rs,cel.rs,cron_runner.rs,actions.rs,engine.rspackages/nodespace-types/src/query.rs,packages/core/src/ops/query_ops.rspackages/core/src/db/sqlite_store/relationships.rs,packages/core/src/db/sqlite_store/nodes.rs(existing recursive CTEs)packages/core/src/playbook/core_plays.rs,packages/core/src/methodology/(bundled plays)
Dependencies
- Add the core node type registry, shared envelope, closed schemas and extends-aware rules #3439 (registry), Generate the frontend's wire types from nodespace-types and gate them for drift #3440 (generated TypeScript)
Related Issues
- Give plays a user-owned enabled switch and persist engine suspensions #3444 (play
enabledand suspension)
Non-Goals
- Changing CEL as the condition language
Activity
malibio commentedon Oct 1, 2026
Baseline on main 4903a70 — Frontend: 301 test files passed, 5560 tests passed
Address review: subtype sort, cycle-safe open-ended walk, batched nod…
Address re-review: pin filter strictness, decline related filters in …
Share one RelationshipPath compiled to SQL between queries and plays,…
Share one RelationshipPath compiled to SQL between queries and plays,…