Skip to content

feat: open options, query cursors, fact log and log writer (v3) - #4

Merged
adityamukho merged 1 commit into
v3from
feat/etl-surface
Oct 7, 2026
Merged

adityamukho merged 1 commit into
v3from
feat/etl-surface

Conversation

@adityamukho

Copy link
Copy Markdown
Contributor

The C part of project-minigraf/minigraf#462, #465 and #467. It follows the shape in minigraf's docs/superpowers/specs/2026-10-07-binding-etl-surface-design.md (minigraf PR #468).

What's new

  • minigraf_open_with_options(path, options_json, char **error_out). Options are a JSON object, so new options never change the ABI, and unknown keys are API-017. With no handle to hold last_error, an open failure stores its message in *error_out, which the caller frees with minigraf_string_free. minigraf_current_tx_count(db, &out) is added too.
  • Cursor: minigraf_query, minigraf_cursor_vars, minigraf_cursor_next_batch(c, n) (JSON rows, or NULL at the end or on error), minigraf_cursor_last_error, minigraf_cursor_free.
  • Fact log: minigraf_fact_log(db, filter_json), _next_batch (a JSON array of records with typed {"type","value"} values), _last_error, _free.
  • Log writer: minigraf_log_writer_create(path, options_json, &err), _append(record_json), _append_batch(records_json) (a fact-log batch can be passed straight in; a rejected record ends the message with (batch index N)), _advance_tx_count, _tx_count, _finish, _last_error, _free (abandons an unfinished build). Use after finish is API-018.
  • cbindgen.toml sets usize_is_size_t, so batch sizes are size_t. The header is regenerated with cbindgen 0.29.2, matching the header-drift job.
  • The README documents the memory contract and the API.

Branching

Targets the new v3 branch, a copy of main. minigraf is a git dependency on the core v3 commit from PR #468, and serde derive is added for the JSON shapes. CI now also runs on pushes to v3.

Testing

  • cargo test: 10 passed (3 new). They cover cursor batches of 1/7/1000 equal to execute(), API-012, read-only open/two readers/API-014/STG-042/API-017 for unknown options and NULL error_out, record JSON (ref, forever), the tx filter, a round trip with identical records and tx_count, API-018, STG-043, API-015 with batch index, API-017 for a bad UUID, and free leaving no file.
  • New c-smoke CI job: tests/c/etl_smoke.c is compiled with gcc -std=c99 -Wall -Wextra -Werror against include/minigraf.h and libminigraf.a, then run. It passes locally.

🤖 Generated with Claude Code

https://claude.ai/code/session_015GgLEs8YozJjYhwPEYgTUn

Exposes the v3 core's ETL surface in the C API, following minigraf's
docs/superpowers/specs/2026-10-07-binding-etl-surface-design.md:

- minigraf_open_with_options with a JSON options object and an
  error_out for the message (project-minigraf/minigraf#465).
- minigraf_query and MiniGrafCursor: vars, next_batch (JSON rows),
  last_error, free (project-minigraf/minigraf#462).
- minigraf_fact_log and MiniGrafFactLog (JSON records with typed values),
  minigraf_current_tx_count, and MiniGrafLogWriter: create, append,
  append_batch, advance_tx_count, tx_count, finish, last_error, free
  (project-minigraf/minigraf#467).

cbindgen now maps usize to size_t. A new c-smoke CI job compiles
tests/c/etl_smoke.c against the header and the static library with
-Werror and runs it.

Depends on the unreleased v3 core by git revision; switches to the
crates.io release at v3.0.0. CI runs on pushes to v3.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015GgLEs8YozJjYhwPEYgTUn
@adityamukho
adityamukho merged commit ec23626 into v3 Oct 7, 2026
6 checks passed
@adityamukho
adityamukho deleted the feat/etl-surface branch October 7, 2026 06:03
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