Skip to content

query_graph Cypher evaluator: labels(), count(*), AS alias, and LIMIT all broken #305

@jjoos

Description

@jjoos

Summary

Four functional bugs in the hand-rolled Cypher subset evaluator (src/cypher/cypher.c) prevent query_graph from handling common Cypher patterns correctly. All observed against a v0.6.0 index on macOS arm64.


D1. labels(n) always returns empty string

Repro:

MATCH (n) WHERE n.project = 'my-project' RETURN labels(n) LIMIT 1

Expected: {"labels(n)": ["Class"]} (or the node's actual label)
Actual: {"labels(n)": ""}

Likely cause: labels() function returns the raw label column (a single string) without wrapping it in a JSON array, or is unimplemented and returns the empty default.


D2. count(*) aggregation dropped — empty result set

Repro:

MATCH (n:Function) WHERE n.project = 'my-project' RETURN count(*)

Expected: One row: {"count(*)": 12096}
Actual: Empty result set (0 rows).

The aggregate expression is either not recognized by the evaluator or its result is discarded during projection.


D3. AS <alias> in RETURN clause ignored

Repro:

MATCH (n) RETURN n.name AS fn_name LIMIT 3

Expected: {"fn_name": "..."}
Actual: {"n.name": "..."}

The alias is parsed but not propagated to the output projection.


D4. LIMIT ignored when paired with aggregate

Repro:

MATCH (n:Function) RETURN n.name, count(*) LIMIT 10

Expected: 10 rows (or fewer) with group counts.
Actual: All rows returned (or 0 rows per D2, depending on which bug fires first).

LIMIT appears to only apply on the non-aggregating execution path.


Impact

These bugs make query_graph unreliable for agent use. We currently document Cypher limitations in our tool schemas rather than relying on query_graph for anything beyond simple MATCH (n:Label) WHERE ... RETURN n.name patterns.

Environment

  • CBM v0.6.0, commit bebc6d8
  • macOS arm64 (Apple Silicon), also reproduced on Linux x86_64 Lambda
  • Index mode: full, repos from 2K to 215K nodes

Suggested approach

Each sub-bug is likely in a different part of the evaluator and could be fixed independently. Separate PRs per sub-bug would be easiest to review.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcypherCypher query language parser/executor bugs

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions