Ivan FB e3b49d18a2
feat: adapt libsds to nim-ffi 0.2 CBOR ABI
Rebuild the C wrapper on nim-ffi 0.2's high-level macros (declareLibrary +
{.ffiCtor.}/{.ffi.}/{.ffiEvent.}), which marshal parameters and results as
CBOR and expose snake_case sds_* entry points. Replaces the previous
hand-written positional/JSON ABI.

- request/response objects are {.ffi.} types (CBOR); the unwrap response is
  a proper nested object (message, channelId, missingDeps) instead of
  hand-built JSON, and retrievalHint travels as raw bytes (no base64).
- events become {.ffiEvent.} procs (message_ready, message_sent,
  missing_dependencies, periodic_sync, repair_ready), delivered to the host
  via sds_add_event_listener.
- the retrieval-hint provider stays hand-written (a C function pointer has
  no CBOR form); its pointers travel as uint64 through the request channel,
  and the provided buffer is freed with libc free to match the host's
  malloc (Go's C.CBytes).
- pin nim-ffi at the fix/foreign-host-concurrency-v0.2 branch (recycle pool
  + foreign-thread GC fixes) and add the cbor_serialization dependency.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-19 23:50:13 +02:00
..