Repository navigation
feat: add token comparison queries - #10
Merged
Merged
Conversation
- Add validated bucketed token aggregation with dimension and session filters. - Implement owner-scoped comparison queries for SQLite and PostgreSQL. - Document the endpoint and cover its HTTP contract with black-box tests. Signed-off-by: chunchi.che@lexmount.com Co-Authored-By: GPT-6 <noreply@openai.com>
SKTT1Ryze
marked this pull request as ready for review
October 23, 2026 08:08
- Use typed Diesel joins, filters, grouping, and facets in PostgreSQL and SQLite. - Share a bound VALUES CTE extension across both storage backends. - Remove raw comparison statements, column strings, and JSON-encoded filters. - Verify microsecond boundaries, large totals, literal filters, DST, and 400 buckets. Signed-off-by: chunchi.che@lexmount.com Co-Authored-By: GPT-6 <noreply@openai.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a comparison endpoint that aggregates token totals and request counts into client-provided time buckets, grouped by Agent, model, provider, or platform. It supports exact-value filters, including session IDs, and preserves owner scoping in SQLite and PostgreSQL.
Joins, optional filters, grouping, aggregates, and facet queries use typed Diesel expressions and typed result mappings. The only custom SQL syntax is a small QueryFragment extension for a bound VALUES CTE, which Diesel does not provide as a built-in query source. Bucket values remain parameters; the implementation does not load events into application memory for aggregation or issue a query per bucket.
Ranges and bucket continuity are validated, and a comparison dimension cannot also be filtered. Diesel's minimum version is 2.3 for aggregate filters. The endpoint, filter semantics, and CTE boundary are documented.
Validation: formatting and clippy passed for both storage feature sets; PostgreSQL unit tests (85) and SQLite unit tests (91) passed. Both full HTTP/storage black-box suites passed, including microsecond boundaries, totals above 32-bit range, quoted filter values, empty matches, 400 buckets, and DST transitions.