Skip to content

feat(query): sort terminal pipeline rows by time (#2006) - #2187

Merged
Sinity merged 1 commit into
masterfrom
feature/feat/query-pipeline-sort-2006
Jun 19, 2026
Merged

Sinity merged 1 commit into
masterfrom
feature/feat/query-pipeline-sort-2006

Conversation

@Sinity

@Sinity Sinity commented Jun 19, 2026

Copy link
Copy Markdown
Owner

Summary

Adds a typed sort by time pipeline stage for terminal query-unit rows. SQL-backed terminal units (messages, actions, blocks, and assertions) now carry the parsed sort stage into archive row execution so users can request ascending or descending time order directly in the DSL.

Problem

#2006 defines the query DSL as the product selection language, including pipeline stages. Terminal row queries already existed, but their ordering was fixed per row source; the parser accepted pipeline stage syntax without a storage-backed row-ordering path for this useful base case.

Solution

  • Extended pipeline parsing/formatting for sort by time [asc|desc].
  • Threaded the parsed sort stage through terminal row execution into archive storage readers.
  • Added bounded SQL order fragments for message/action/block/assertion rows, with runtime-transform units rejecting sort stages until they have a durable lowerer.
  • Updated query docs and the SQL interpolation audit metadata for the new closed ORDER BY fragments.

Verification

  • nix develop --command devtools test tests/unit/storage/test_no_string_interpolated_sql.py tests/unit/cli/test_query_expression.py -k 'pipeline or string_interpolated_sql' → 12 passed.
  • nix develop --command devtools test tests/unit/cli/test_help_snapshots.py::test_root_help_snapshot tests/unit/storage/test_no_string_interpolated_sql.py tests/unit/cli/test_query_expression.py -k 'root_help_snapshot or pipeline or string_interpolated_sql' → 13 passed after rebasing onto current master.
  • nix develop --command devtools verify --quick → exit_code 0.
  • nix develop --command devtools verify before rebase → 6060 passed, 1 stale root-help snapshot failure caused by master moving underneath the branch; the focused root-help snapshot passed after rebase.

Problem: #2006 pipeline queries can now scope and window terminal rows, but persisted terminal row queries still had no in-language ordering stage. Saved query strings needed a concrete sort primitive before more advanced pipeline stages can build on them.

What changed: add a typed `sort by time [asc|desc]` terminal pipeline stage, expose it in explain payloads, lower it into SQLite ORDER BY clauses for message/action/block/assertion rows, and reject runtime-transform units until they have a streaming sort lowerer.

Verification: devtools test tests/unit/cli/test_query_expression.py -k pipeline; devtools verify --quick.

Ref #2006
@coderabbitai

coderabbitai Bot commented Jun 19, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@Sinity, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 24 minutes and 3 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 7a4e186b-93bb-4b72-a398-1ba091c981f4

📥 Commits

Reviewing files that changed from the base of the PR and between 6b20350 and ace9f42.

📒 Files selected for processing (6)
  • docs/search.md
  • polylogue/archive/query/expression.py
  • polylogue/archive/query/unit_results.py
  • polylogue/storage/sqlite/archive_tiers/archive.py
  • tests/unit/cli/test_query_expression.py
  • tests/unit/storage/test_no_string_interpolated_sql.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/feat/query-pipeline-sort-2006

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

github-actions Bot pushed a commit that referenced this pull request Jun 19, 2026
@Sinity
Sinity merged commit 4aee6b6 into master Jun 19, 2026
14 checks passed
@Sinity
Sinity deleted the feature/feat/query-pipeline-sort-2006 branch June 19, 2026 18:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant