Repository navigation
feat(query): collect-set (#316 PR 3) - #747
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TcpoiFyFeQQQELL872LfQF
[(collect-set ?e :attr) ?s] binds the set of the values of [?e :attr ?v]
under the query's view, #{} when there are none. Parsed as an expression
clause (Expr::CollectSet, clause level only), planned as a CollectSet
operator over a one-entity probe of the pattern's scan, metered (QRY-012).
New codes: PRS-122 (no binding), PRS-123 (bad operand), QRY-015 (a set
value collected).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TcpoiFyFeQQQELL872LfQF
8000
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.
PR 3 of 3 for #316 (spec
docs/superpowers/specs/2026-10-24-set-values-design.md§7; plan steps 17–20, detailed in this PR).[(collect-set ?e :user/scope) ?scopes]binds, per row, the set of the values of[?e :user/scope ?v]under the query's:as-of/:valid-at, with retractions applied as for that pattern;#{}(row kept) when there are none. Works in:where, rule bodies,not-joinbodies andor-joinbranches; an already-bound output keeps rows where the sets are equal (#596). Reads stored facts only.Implementation
Expr::CollectSet { entity, attribute }, parsed only as the whole expression of a binding clause, so the safety check (INT-018), optimizer ordering, magic sets, stratification and prepared slots treat it as an expression clause unchanged. This deviates from the plan outline (a newWhereClause); the reason is in the plan.engine/collect.rs:CollectSetoperator — a one-entity probe of the pattern'sScanper row (asIndexNestedLoopJoin), keyword entities viakeyword_eid, non-entities give#{}; the set being built is charged to the query'sMeter(QRY-012).collect_setinexpr_clause, refused as a unary head;docs/GRAMMAR.mdregenerated; corpus fixtures.Error codes (#306 holds PRS-115–118, #180 holds QRY-014):
PRS-122no binding,PRS-123operand not?var+ attribute keyword (bind slots included),QRY-015a collected value is a set.collect-setnested in an expression isPRS-067; the name is refused byregister_predicate.Tests:
tests/collect_set_test.rs(16), a parser unit test, 7 queries in the plan-independence matrix (frozen answers appended). Full suite with and withouttest-hooks, clippy (--all-features, both wasm targets) pass. Codex review: no findings.Part of #316; close by hand after merge.
🤖 Generated with Claude Code
https://claude.ai/code/session_01TcpoiFyFeQQQELL872LfQF