8000 feat(query): collect-set (#316 PR 3) by adityamukho · Pull Request #747 · project-minigraf/minigraf · GitHub
[go: up one dir, main page]

Skip to content

feat(query): collect-set (#316 PR 3) - #747

Merged
adityamukho merged 4 commits into
v3from
feat/316-collect-set
Oct 24, 2026
Merged

adityamukho merged 4 commits into
v3from
feat/316-collect-set

Conversation

@adityamukho
Copy link
Copy Markdown
Collaborator

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-join bodies and or-join branches; 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 new WhereClause); the reason is in the plan.
  • engine/collect.rs: CollectSet operator — a one-entity probe of the pattern's Scan per row (as IndexNestedLoopJoin), keyword entities via keyword_eid, non-entities give #{}; the set being built is charged to the query's Meter (QRY-012).
  • Grammar: collect_set in expr_clause, refused as a unary head; docs/GRAMMAR.md regenerated; corpus fixtures.

Error codes (#306 holds PRS-115–118, #180 holds QRY-014): PRS-122 no binding, PRS-123 operand not ?var + attribute keyword (bind slots included), QRY-015 a collected value is a set. collect-set nested in an expression is PRS-067; the name is refused by register_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 without test-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

adityamukho and others added 4 commits October 24, 2026 18:31
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
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TcpoiFyFeQQQELL872LfQF
@codecov
codecov Bot commented Oct 24, 2026
Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.95706% with 18 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/query/datalog/parser.rs 76.92% 11 Missing and 1 partial ⚠️
src/query/engine/collect.rs 97.40% 1 Missing and 1 partial ⚠️
src/query/engine/plan.rs 91.66% 2 Missing ⚠️
src/query/datalog/executor.rs 0.00% 1 Missing ⚠️
src/query/engine/filter.rs 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@adityamukho
adityamukho merged commit 545b379 into v3 Oct 24, 2026
19 checks passed
@adityamukho
adityamukho deleted the feat/316-collect-set branch October 24, 2026 16:18
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

0