8000 feat: user predicates and aggregates (minigraf#180) by adityamukho · Pull Request #15 · project-minigraf/minigraf-swift · GitHub
[go: up one dir, main page]

Skip to content

feat: user predicates and aggregates (minigraf#180) - #15

Merged
adityamukho merged 2 commits into
v3from
feat/180-udf-ffi
Oct 25, 2026
Merged

adityamukho merged 2 commits into
v3from
feat/180-udf-ffi

Conversation

@adityamukho
Copy link
Copy Markdown
Contributor

#180 PR 6 (plan steps 17–20, spec §6, §6.1): Swift classes can be registered as predicates and aggregates.

  • Pin 7c8c5540 → 02243f16 (minigraf#757). The old pin already had #181 and #316; #306 needed nothing here.
  • src/lib.rs: the template's UDF FFI (minigraf-binding-template#9), applied unchanged from minigraf-android#16 (the two lib.rs files were identical): MiniGrafUdfError, the three #[uniffi::export(with_foreign)] traits, registerPredicate/registerAggregate over try_register_*, handle locks that only clone the Minigraf. 44 Rust tests (CI's rust-test job runs them).
  • Generated Swift: protocol MiniGrafPredicate/MiniGrafAggregate/MiniGrafAccumulator: AnyObject, Sendable, methods throws. Any Swift error other than MiniGrafUdfError reaches the core as its String(describing:).
  • Tests/swift/main.swift: predicate, aggregate in :find and :over, cursor and prepared query calls, MiniGrafUdfError and a plain Swift error → MiniGrafError.Query [QRY-014], failing step (also in a cursor), non-UUID ref, a predicate querying its own db, INT-040, two threads inside one predicate at once.
  • Consumer contract: testUserFunctions (adult?/product/QRY-014 on a throw).
  • README "User functions" (Sendable guidance included).

The first commit holds only the tests, so CI shows them red before the implementation.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Urda7FD9CYYoxdeGGJa11x

adityamukho and others added 2 commits October 25, 2026 12:33
Red until the shim exports the UDF traits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Urda7FD9CYYoxdeGGJa11x
Pin minigraf v3 to 02243f16 and add the binding template's UDF FFI
(minigraf-binding-template#9): MiniGrafUdfError, the MiniGrafPredicate,
MiniGrafAggregate and MiniGrafAccumulator protocols (AnyObject, Sendable),
and MiniGrafDb.registerPredicate/registerAggregate. A throwing callback
fails the query with QRY-014. README gains a User functions section.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Urda7FD9CYYoxdeGGJa11x
@adityamukho
adityamukho marked this pull request as ready for review October 25, 2026 07:27
@adityamukho
adityamukho merged commit 4f2b296 into v3 Oct 25, 2026
5 checks passed
@adityamukho
adityamukho deleted the feat/180-udf-ffi branch October 25, 2026 07:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
0