fix(compiler): reject direction both on aggregation relationships

Summary

  • Reject direction: "both" on aggregation relationship queries at both validation and JSON Schema level
  • No product use case exists for bidirectional aggregation (all ontology edges are directional)
  • Zero existing tests or known users affected

Relates to #320 (closed)

Problem

direction: "both" in aggregation generates OR join conditions:

JOIN gl_edge e0 ON (u.id = e0.source_id OR u.id = e0.target_id)

This defeats ClickHouse index and projection usage entirely. The by_source and by_target projections both require equality on their respective ID columns — OR prevents either from being selected.

Neighbors handles direction: "both" correctly via UNION ALL of two directional arms. Aggregation uses build_joins which produces OR instead. Rather than building UNION ALL lowering for a feature with no product use case, reject it.

What changed

  • validate.rs: reject direction: "both" when query_type == aggregation with a clear error message suggesting separate outgoing/incoming queries
  • graph_query.schema.json: conditional enum: ["outgoing", "incoming"] on relationship direction when query_type is aggregation, so agents hitting orbit/tools see the restriction before generating queries
  • 1 new unit test

Merge request reports

Loading