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

Skip to content

feat: user predicates and aggregates (#180) - #16

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

PR 3 of minigraf#180 (plan steps 17–20, spec §6/§6.1): UDF registration in the Python binding.

  • Shim (src/lib.rs): copied from minigraf-binding-template#9 (1faf4117) — MiniGrafUdfError (+ From<UnexpectedUniFFICallbackError>), the three #[uniffi::export(with_foreign)] traits, MiniGrafDb.register_predicate / register_aggregate over try_register_*, and handle locks that only clone the Minigraf; with the template's Rust tests.
  • Pin: core v3 7c8c5540 → 02243f16 (#757 merge). The old pin already had #181 and #316; #306 needs no binding change.
  • Package: exports Predicate, Aggregate, Accumulator, UdfError (and the MiniGraf* names).
  • pytest (tests/test_udf.py): predicate; aggregate in :find and :over; UdfError and any other exception → MiniGrafError.Query QRY-014 (exact message checked); bad Ref from finish; UDFs through cursors and prepared queries, incl. a failure in a cursor; a predicate querying the same db; INT-040; two threads sharing one predicate; two queries inside one predicate at once (barrier — fails if the GIL or a binding lock were held across the core).
  • Consumer contract: an adult? predicate, a product aggregate and QRY-014 on a raise.
  • CI: the test job now runs cargo test, so the copied Rust tests run.
  • README: "User functions" — example, failures, lifecycle, threading/GIL, re-entry.

Tests were red before the shim change (import error), green after: 58 pytest, 44 Rust tests, clippy -D warnings and fmt clean. Codex review findings (three test gaps) are addressed in the second commit.

Part of project-minigraf/minigraf#180.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Urda7FD9CYYoxdeGGJa11x

adityamukho and others added 2 commits October 25, 2026 11:10
Copies minigraf-binding-template#9: MiniGrafUdfError, the three
with_foreign traits, MiniGrafDb.register_predicate/register_aggregate
over the core's try_register_*, and handle locks that only clone the
database, with the template's Rust tests. Pins core v3 at 02243f16.

The package exports Predicate, Aggregate, Accumulator and UdfError.
pytest covers a predicate, an aggregate in :find and :over, UdfError
and any other exception as QRY-014, a bad Ref from finish, a predicate
querying the same database, INT-040, and two threads sharing one
predicate. The consumer contract gains a predicate and an aggregate,
CI runs cargo test, and the README gains "User functions".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Urda7FD9CYYoxdeGGJa11x
…ate at once, exact foreign-exception message (#180)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Urda7FD9CYYoxdeGGJa11x
@adityamukho
adityamukho merged commit ade0eea into v3 Oct 25, 2026
13 checks passed
@adityamukho
adityamukho deleted the feat/180-udf-ffi branch October 25, 2026 05:52
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