Repository navigation
feat(query): :order-by, :offset and top-k Sort (#306 PR 2) - #755
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TcpoiFyFeQQQELL872LfQF
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TcpoiFyFeQQQELL872LfQF
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TcpoiFyFeQQQELL872LfQF
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TcpoiFyFeQQQELL872LfQF
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TcpoiFyFeQQQELL872LfQF
… follows k (#306) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TcpoiFyFeQQQELL872LfQF
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TcpoiFyFeQQQELL872LfQF
…tnesses (#306) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TcpoiFyFeQQQELL872LfQF
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TcpoiFyFeQQQELL872LfQF
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TcpoiFyFeQQQELL872LfQF
…#306) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TcpoiFyFeQQQELL872LfQF
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TcpoiFyFeQQQELL872LfQF
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TcpoiFyFeQQQELL872LfQF
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TcpoiFyFeQQQELL872LfQF
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
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.
Part of #306 (PR 2 of 2:
:order-by,:offset, top-kSort). Specdocs/superpowers/specs/2026-10-24-limit-order-by-design.md; plan steps 10–17 detailed indocs/superpowers/plans/2026-10-24-306-limit-order-by.md(first commit).What
:order-by [k :desc …]names:findelements (variables, aggregates, windows as written in:find, matched asFindSpec ==),:ascdefault;:offset N/$slot. New codesPRS-116(:offsetwithout:order-by),PRS-117(entry not a:findelement),PRS-118(malformed:order-by);PRS-115now covers:offset.INT-012/INT-013as for the other options.:offset $oslots (resolve_count_slot).Step::Sort { cols, order, keep }afterAggregate/Window, thenLimit { offset, limit }. The full order is the keys, then every other:findcolumn ascending, byvalue_order(aggregate::row_order).Sortholds the:findvalues, metered (QRY-012); under:limitit keeps a heap of the bestoffset + limitrows;:limit 0pulls nothing. It drops the DICT lookups after each input batch, since kept they grow with the input (found by a test: top-k over committed data hitQRY-012fromIdSpace). Withoutkeep, it heap-sorts with the same sift code instead ofsort_unstable_by(saves ~5 KiB of binary).order_by_section,offset_section, corpus (4 valid, 3 syntax, 4 semantic); verifier 37 tokens, 16 templates,SEMANTICwitnesses forPRS-116–118.KNOWN_DRIFTempty at bound 3 (local) and bound 4 (bench).Tests (bench machine)
test-hooks: 1,844 / 15 (+25).tests/limit_order_test.rs: 14 ordered shapes (plain, join,not,or, grouped/ungrouped aggregates and the zero row, window, rule queries,:as-of,:any-valid-time, expression), in memory and on committed + pending facts, with every limit/offset combination, throughexecute, cursor, prepared and prepared cursor, reorder on/off: each equals the test's own full sort of the unlimited answer, sliced. Pages, every value class, write transactions, slot errors,QRY-012for a full sort vs. top-k under the same limit. Two mutations (direction flipped, tie-break flipped) fail it.limit_and_top_k_over_10m_facts, one fixture)::limit 100.72 ms, +132 KiB RSS;:order-by [?v :desc] :limit 10returns the ten largest in 28.5 s (bench profile) under a 1 MiB limit, +0 KiB RSS.Envelope (
--profile envelope, one NUMA node), p50 / peak RSSattribute_scanlimittop_ktop_kcosts a scan (skipping that is #641) and holds ten rows.Docs: CHANGELOG, ERROR_REFERENCE, README, ROADMAP, CLAUDE.md, TEST_COVERAGE, BENCHMARKS. Docs site: project-minigraf/minigraf-docs PR (merge after this). Codex review: no findings.
🤖 Generated with Claude Code
https://claude.ai/code/session_01TcpoiFyFeQQQELL872LfQF