Skip to content

feat: Cypher-style query DSL (Phase 3C.4)#13

Merged
Emperiusm merged 21 commits intomainfrom
feature/phase3c4-cypher-dsl
Apr 15, 2026
Merged

feat: Cypher-style query DSL (Phase 3C.4)#13
Emperiusm merged 21 commits intomainfrom
feature/phase3c4-cypher-dsl

Conversation

@Emperiusm
Copy link
Copy Markdown
Owner

Summary

  • Cypher-style query DSL with lark LALR parser, query planner (predicate pushdown), virtual heterogeneous graph (entities as first-class nodes), and binding-table executor with configurable resource limits (timeout, row cap, intermediate binding cap)
  • CLI surface: opentools chain query run, explain, repl (stateful sessions with named result sets), and preset (migrated existing preset runner)
  • Web surface: POST /api/chain/query endpoint with full execution, standalone query page (/chain/query) with CodeMirror 6 editor + autocomplete, and inline collapsible query panel on the chain graph view with node highlighting
  • Plugin API: scalar + aggregation functions registrable by plugins, namespaced with dotted names
  • Both store backends implement fetch_all_mentions_in_scope for building the virtual graph

Test plan

  • 96 cypher module tests passing (parser, planner, virtual graph, executor, session, builtins, plugins, integration)
  • 7 existing CLI command tests passing (no regressions from query→preset rename)
  • Manual: start web dev server, navigate to /chain/query, run a query, verify results render
  • Manual: open engagement chain view, expand inline query panel, run query, verify node highlighting
  • Manual: opentools chain query run 'MATCH (a:Finding) RETURN a' in CLI
  • Manual: opentools chain query repl — test multi-line, session variables, :help

🤖 Generated with Claude Code

Emperiusm and others added 21 commits April 13, 2026 03:48
…n plan

17 tasks: calibration model + migration, export service, subgraph global mode
with pivotality scoring, calibrate/export endpoints, tests, global chain view
page, engagement filter chips, timeline scrubber, ForceGraphCanvas extensions
(kill chain layout, time filter, pivotality glow, engagement colors), CLI commands.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
15 tasks covering parser, planner, virtual graph, executor,
CLI commands, web endpoints, and inline overlay.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Implements builtins.py (length, nodes, relationships, has_entity, has_mitre, collect)
and PluginFunctionRegistry with dotted-name enforcement and scalar/aggregation separation.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Implements plan_query() converting CypherQuery AST into QueryPlan with
PlanStep sequence (scan, expand, var_length_expand, filter) and pushes
WHERE predicates down to the earliest bound-variable scan/expand step.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Implements VirtualGraph, VirtualGraphBuilder, and VirtualGraphCache that overlay entity nodes (Host, IP, CVE, Domain, Port, MitreAttack, Entity) and MENTIONED_IN edges on top of the MasterGraph's finding nodes and LINKED edges, enabling the Cypher DSL executor to traverse both node types in a single graph walk.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add fetch_all_mentions_in_scope to ChainStoreProtocol (with optional
engagement_ids filter) and wire up 2 end-to-end integration tests that
exercise the full parse→plan→VirtualGraphCache→execute pipeline via mocks.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Rename existing `query` command to `query preset` under a new `query_app`
sub-typer, and add `query run`, `query explain`, and `query repl` commands
backed by CypherSession. Update existing tests to use the new `query preset`
path and add test_cli_query.py covering all four subcommands.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add /api/chain/query POST endpoint that validates Cypher queries
(parse + plan) and returns proper 400 errors; GET /functions lists
builtins. Full store execution deferred until PostgresChainStore
implements fetch_all_mentions_in_scope.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds ChainQueryView, CypherEditor, and QueryResultsPane components plus the /chain/query route for the standalone Cypher DSL query UI.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…xecution

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Combines 3C.4 Cypher DSL with 3C.3 additions:
- cli.py: keep both query sub-app and calibrate command
- ForceGraphCanvas: merge highlightedNodeIds with timeRange/layoutMode/colorMode props
- router: add both /chain/query and /chain/global routes
- ChainGraphView: merge InlineQueryPanel with ChainTimelineScrubber imports

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@Emperiusm Emperiusm merged commit d2e85e0 into main Apr 15, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant