Search & retrieval

Aggregate queries

Computes counts, sums, averages, minima and maxima over stored entities, so a dashboard needs no export to a separate analytics store.

RoadmapEngine edition 5f8ea3af

What it does

The engine has an aggregation function for count, sum, avg, min and max over the entities of one kind. No route, command, KynQL clause or MCP tool calls it, so a running server cannot be asked for a rollup today. It has engine tests and is used by the materialised-view module, which is also unwired.

How it works

An aggregate is described by a kind, an operation and, for everything except count, a dotted field path. The engine takes a consistent snapshot, copies the entities of that kind and folds them in a single scan. Numeric fields support sum, avg, min and max; string fields support min and max by ordering; entities missing the field are skipped, and an empty set returns null with a zero count.

The function refuses while the engine is fenced for recovery and propagates a scan failure instead of aggregating over a partial scan. It does not group: the registry label mentions group-by, but grouping exists solely in the materialised-view module, which groups by one field.

Where you reach it

  • LibraryEngine::aggregate(AggregateSpec { kind, field, op }) (Rust engine API; not exposed by the server)

Limits

  • Not reachable through any route, command or query clause of the private-preview server.
  • A single scan over all entities of the kind, with a copy held in memory; cost grows with the kind size.
  • No grouping, filtering or time bucketing in the function itself.
  • A field that mixes numbers and strings returns null for sum and avg.

Evidence

  • Tests3 in-module tests plus engine tests that run aggregates on healthy, fenced and failing stores

Test coverage is listed as present in the engine repository at this edition. This page does not report test results.

KynetraDB is in private preview

This is not available in the preview. Request a preview to discuss the current scope.