Skip to content

feat: query mode — let agents issue structured queries against the block ontology via MCP #74

Description

@rajnavakoti

Description

CB has one retrieval mode today: ask mode — an agent sends a natural-language question, CB retrieves + synthesizes an answer. This adds a second, complementary query mode — if an agent can see the block's ontology (schema) via MCP, it can generate a precise structured query and get exact, composable, auditable results.

Two modes, different jobs:

  • Ask mode (exists): NL question → retrieve → synthesize. Fuzzy, semantic, good for exploration.
  • Query mode (new): agent reads the ontology → writes a typed query → exact structured results. Deterministic, good for "list all P1 incidents affecting service X in Q2." The query is explicit, so the answer is auditable — important for regulated/trust use cases.

This is the natural extension of the typed-retrieval thesis (DCR): instead of CB guessing the traversal, the agent that knows the schema drives it. Inspired by CyKG-RAG (LLM generates SPARQL/Cypher against a KG, with fallback to vector search when the query is invalid/empty).

No triple store required to start. CB already loads entities into an in-memory typed relationship graph — a Cypher-lite traversal over that is feasible without RDF/Neo4j.

Composes with the cache/router model: structured queries run over the cached graph; anything not cached returns a route to the system-of-record.

Acceptance Criteria

  • Expose the block ontology (entity types, relationship fields, layers) as an MCP resource the agent can read
  • Add a structured-query tool over the in-memory relationship graph (typed traversal / Cypher-lite) — no triple store
  • Query results are precise and include the executed query (auditable)
  • Fallback to ask/vector retrieval when a query is invalid or returns empty (CyKG-RAG robustness pattern)
  • Tests: ontology-resource exposure, a few representative typed queries, and the fallback path

Out of Scope

  • Full RDF/SPARQL or Neo4j/Cypher triple-store backend (can come later if needed)
  • The cache/router live-fetch mechanics (separate concern — this issue only queries cached knowledge and returns routes)

Metadata

Metadata

Assignees

No one assigned

    Labels

    frameworkScientific frameworks

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions