Repository navigation
Description
Overview
Implement QueryNode as a first-class node type following NodeSpace's current architecture. QueryNode stores query definitions using hub-and-spoke pattern: plain text description in hub (node.content), structured query fields in spoke table.
Architecture References
- How to Add a New Node Type:
docs/architecture/development/how-to-add-new-node-type.md - Node Behavior System:
docs/architecture/business-logic/node-behavior-system.md - SurrealDB Schema Design:
docs/architecture/data/surrealdb-schema-design.md - Persistence Architecture:
docs/architecture/persistence-architecture.md
Problem Statement
NodeSpace needs a way to create, store, and execute queries that filter/search nodes. QueryNodes can be created by AI chat (primary use case) or manually via slash command for testing/development. QueryNode must integrate with the hub-and-spoke SurrealDB architecture using record links and graph edges for relationships.
Implementation Summary
Hub-and-Spoke Storage Pattern
Following TaskNode/SchemaNode pattern:
- Hub (
node.content): Plain text description (e.g., "All open high-priority tasks") - Spoke (
querytable): Structured query fields (filters, sorting, limit, metadata) - NOT JSON in content - complex data lives in spoke fields
Core Components Implemented
- QueryNodeBehavior (
packages/core/src/behaviors/mod.rs) - Validation, embedding exclusion - Query Schema (
packages/core/src/models/core_schemas.rs) - 8 fields with indexing - TypeScript Types (
packages/desktop-app/src/lib/types/query.ts) - QueryNode, QueryFilter interfaces - Plugin Definition (
packages/desktop-app/src/lib/plugins/core-plugins.ts) - Includes/queryslash command - Icon Registration (
packages/desktop-app/src/lib/design/icons/registry.ts) - Circle with filter symbol - Component (
packages/desktop-app/src/lib/components/query-node.svelte) - With "open" button navigation
Slash Command
/query slash command added for manual testing and user-initiated queries:
- Enables development/testing before full MCP integration
- Provides value for users who want to manually create saved queries
- Creates query node with empty content template
- Command shortcut: 'q'
Acceptance Criteria
-
QueryNodeBehaviorimplemented and registered inpackages/core/src/behaviors/mod.rs - Query schema added to
get_core_schemas()inpackages/core/src/models/core_schemas.rs - TypeScript types defined in
packages/desktop-app/src/lib/types/query.ts - Plugin defined in
packages/desktop-app/src/lib/plugins/core-plugins.ts -
/queryslash command registered for manual query creation - Icon registered in
packages/desktop-app/src/lib/design/icons/registry.ts - Hub stores plain text description, spoke stores structured fields
- Spoke table auto-generated with indexed fields (target_type, generated_by, generator_context)
- "Open" button for navigation to query viewer
- Backend tests for behavior validation
- Frontend tests for plugin registration
- Tests pass (
bun run test:all) - Code passes
bun run quality:fix
Design Notes
Query vs View Separation:
QueryNode stores ONLY the query definition (what nodes to find). View type and configuration are specified at render time via QueryPreferencesService (#443), enabling:
- Different users to view same query differently
- Same query embedded multiple times with different views
- Future inline embeds:
\![[nodespace://query-123|view=table]]
AI Query Ownership:
AI-generated queries use graph edges for hierarchical organization:
has_childedge from chat → query establishes parent-child relationship- Cascade delete: delete chat → automatically deletes query via edge cleanup
- Query attribution tracked in
query.generated_byfield - Context tracking via
query.generator_context(parent chat ID)
Hybrid Storage Benefits:
- Spoke table: Fast indexed queries ("show all task queries", "show AI queries")
- Hub content: Plain text description for semantic search and display
- Record links: Type-safe references, automatic join optimization
- Graph edges: Natural parent-child representation, recursive queries
Testing Requirements
- Backend: Behavior validation tests (valid/invalid patterns)
- Backend: Schema field definitions correct
- Frontend: Plugin registration and slash command
- Frontend: Icon renders correctly
- Integration: Node can be created via slash command
- Integration: Node persists and loads from database
Non-Goals
- Query execution (covered in QueryService with SQL Query Execution #440)
- Query UI/viewer (covered in QueryNodeViewer with Multi-View Rendering Support #441)
- Query editor (covered in QueryEditor with JSON Textarea Interface #442)
- Query optimization/caching (future enhancement)
Activity
Update how-to-add-new-node-type.md to reflect current architecture
malibio commentedon Dec 2, 2025
Starting implementation of QueryNode (Issue #439).
Test Baseline:
Implementation approach:
Following TaskNode and SchemaNode patterns for hub-and-spoke architecture with auto-generated spoke table.
Implement QueryNode foundation (Issue #439)
QueryNode Behavior and Core Type Definitions (#719)
Update how-to-add-new-node-type.md to reflect current architecture
QueryNode Behavior and Core Type Definitions (#719)
Update how-to-add-new-node-type.md to reflect current architecture
QueryNode Behavior and Core Type Definitions (#719)
QueryNode Behavior and Core Type Definitions (#719)