Skip to content

feat: prepared queries with JSON bindings (minigraf#181) - #11

Merged
adityamukho merged 2 commits into
v3from
feat/181-prepared-ffi
Oct 24, 2026
Merged

adityamukho merged 2 commits into
v3from
feat/181-prepared-ffi

Conversation

@adityamukho

Copy link
Copy Markdown
Contributor

PR 4 (C) of project-minigraf/minigraf#181 (spec §4.2, §5, §6, §7.3; plan step 16).

  • minigraf_prepare, minigraf_prepared_execute, minigraf_prepared_query, minigraf_prepared_last_error, minigraf_prepared_free; include/minigraf.h regenerated with cbindgen 0.29.2. Core pin and Cargo.lock at 5f2ba46e (minigraf#738).
  • Bindings: a JSON object (NULL means {}) of slot name to true/false, a number (an integer with no fraction or exponent, so 2 vs 2.0 is preserved), a string, null, or a typed {type, value} form: the fact-record value types, plus entity, txCount (full u64), timestamp and anyValidTime. Anything else is API-017.
  • Lifetime (spec §6): MiniGrafDb keeps a weak list of its prepared queries, and its Drop (minigraf_close) empties them before the database drops, so the path reopens. A prepared query used after that fails with API-018 and must still be freed.
  • Tests: 5 new Rust unit tests (16 in all): repeated runs checked per row, every plain and typed form, the cursor, API-005/006/007/017/018/022/023/024, reopen after close. tests/c/etl_smoke.c and consumer-test/contract.c both run a prepared query, and both pass locally. README: the memory contract, API table and bindings format.

Codex: 2 findings (txCount above i64::MAX, missing API-005–007 tests), both fixed.

Found while checking spec §6: an unfreed cursor or fact log already blocks reopening after minigraf_close. Filed as #10, not fixed here.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Urda7FD9CYYoxdeGGJa11x

adityamukho and others added 2 commits October 24, 2026 15:08
Core pin 5f2ba46e (minigraf#738). minigraf_prepare,
minigraf_prepared_execute/_query/_last_error/_free. Bindings are a JSON
object of slot name to a plain JSON value or a {type, value} form;
anything else is API-017. minigraf_close empties every prepared query,
so the path reopens; a prepared query used after it fails with API-018.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Urda7FD9CYYoxdeGGJa11x
@adityamukho
adityamukho merged commit a97e4ba into v3 Oct 24, 2026
15 checks passed
@adityamukho
adityamukho deleted the feat/181-prepared-ffi branch October 24, 2026 10:46
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