67 Commits

Author SHA1 Message Date
Ivan FB
b156b84ff3
docs(changelog): drop premature 0.2.0; fold into Unreleased at 0.1.4
The branch carried a dated `[0.2.0] - 2026-06-04` release section and
`version = "0.2.0"` while the active release line is still 0.1.x, which
misrepresents unshipped work as a released version. Treat 0.1.4 as the latest
release and move everything above it back under `[Unreleased]`, merging the
0.2.0 bullets into the existing Added/Changed/Fixed groups. Set the package
version to 0.1.4 and realign the example `requires` (>= 0.2.0 -> >= 0.1.4) so
they stay satisfiable.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-12 17:34:40 +02:00
Ivan FB
79e5dc64c6
fix(pool): deinit context resources in full teardown
destroyFFIContext stopped/joined the worker threads and marked the slot for
rebuild, but no longer deinited the context — so the six ThreadSignalPtr fds
were orphaned every full teardown (the exact leak this path exists to prevent),
and the still-initialised Lock + event registry/queue locks were left live.

createFFIContext's rebuild path (initialized == false) reruns
initContextResources, which calls initLock / initEventRegistry / initEventQueue
and installs fresh signals over the stale handles — re-initialising a live lock
is UB. Restore the deinitContextResources() call (as the pre-recycle code did)
before marking the slot uninitialised so the rebuild starts from clean state.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-12 17:30:08 +02:00
Ivan FB
6bc626946e
fix(codegen): emit 3-arg async destroy ABI in C++/Rust bindings
The recycle/async-destroy work changed the Nim `ffiDtor` export from
`int destroy(ctx)` to `int destroy(ctx, callback, userData)`, but the C++
and Rust generators still emitted the 1-arg signature. Foreign callers
therefore passed only `ctx`; inside Nim, `callback`/`userData` held
uninitialised register garbage. `requestRecycle` stored the garbage
callback and the recycle handler later invoked it — a jump through a wild
pointer that segfaulted in every C++ E2E / ASan / TSan job (the crash
surfaced at teardown, after each test's assertions had already passed).

Generate the 3-arg ABI and have the destructor/Drop block on the recycle
callback via the existing sync-call helper, so the pool slot is fully
drained and parked before the handle goes away — otherwise rapid
create/destroy churn (StressShortLivedPerThreadContext, ThreadedHammer)
could outrun the recycle and exhaust the pool.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-12 16:12:33 +02:00
Ivan FB
fe6749d3af
ci(test): pass -d:ffiAllowSignalHandler when compiling unit tests
The noSignalHandler compile-time guard rejects any build of the ffi
modules that doesn't set -d:noSignalHandler (embedded) or
-d:ffiAllowSignalHandler (standalone). test.yml compiled the unit tests
with a raw `nim c` missing the flag, so every per-test job failed at the
guard. The nimble test tasks already pass it; mirror that here.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-12 14:55:38 +02:00
Ivan FB
0e176bd5eb
fix(ffi): set up foreign-thread GC in entry procs; recycle/event cleanup
- Call initializeLibrary() (setupForeignThreadGc) in the `.ffi.` request
  wrapper and in add/remove_event_listener so a foreign (Go) caller thread
  has an initialised Nim heap before any allocation ($reqTypeName /
  $eventName / registry ops). Without it such a thread segfaults in the
  allocator under GC pressure — the production unwrap SIGSEGV.
- recycleContext resets the event registry/queue + stuck flag on park so a
  reused pool slot starts clean.
- ffiDtor doc/cleanup for the async recycle ABI.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-12 11:28:48 +02:00
Ivan FB
e0d1ba38d1
feat(build): enforce -d:noSignalHandler at compile time
A nim-ffi library is loaded into a foreign host (Go/Rust/...) that must
own OS signal handling; if the Nim runtime installs its own handlers it
clobbers the host's (e.g. Go's SIGSEGV -> sigpanic recovery, stack
growth, goroutine preemption), turning recoverable faults into hard
process crashes. The flag can only be set on the consumer's final build
command, so a dependency cannot inject it -- but it CAN refuse to
compile without it. Add a compile-time guard so any consumer that omits
-d:noSignalHandler fails the build with an actionable message instead of
crashing at runtime (the cause of a real status-go regression).
Standalone Nim binaries (nim-ffi's own tests) build with
-d:ffiAllowSignalHandler.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-11 15:34:53 +02:00
Ivan FB
0170d7c469
update changelog and ffi.nimble for v0.1.5 2026-06-11 15:34:36 +02:00
Ivan FB
24cf796fcd
fix(pool): recycle contexts to stop per-cycle fd leak (#74) 2026-06-11 15:33:18 +02:00
Ivan FB
c2ea4f3f98
add changelog for 0.1.4 2026-06-11 15:26:27 +02:00
Ivan FB
64b628599f
create v0.1.4 2026-06-11 15:23:51 +02:00
Gabriel Cruz
16dc1b3573
chore(ci): add nph linting (#77) 2026-06-10 16:30:30 -03:00
Gabriel Cruz
9b3cde7674
feat: move user event code to a dedicated event thread (#69) 2026-06-09 11:35:04 -03:00
Gabriel Cruz
54c41a3e62
refactor(ffi): event thread scaffolding + FFIContext lifecycle split (#71) 2026-06-08 11:46:16 -03:00
Ivan FB
721f244312
docs: finalize 0.2.0 changelog and correct 0.1.4 date
CBOR is the headline 0.2.0 feature, not 0.1.4: at v0.1.4 serial.nim was
still JSON/string-based, so the prior CBOR attribution was wrong. Also
complete the 0.2.0 scope (events, registry, codegen) ahead of tagging.

Date 0.1.4 by its last functional change (#14, 2026-05-13) rather than
the later changelog/version-bump commits, so the version reflects when
its code actually settled.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-04 09:17:56 +02:00
Ivan FB
11aae0c7b8
add changelog for 0.1.4 (#73) 2026-06-03 23:43:52 +02:00
Ivan FB
f96a5b158a
Remove wildcard event listener; keep per-event dispatch (#70) 2026-06-02 22:22:35 +02:00
Ivan FB
e0bd74232b
Rust event examples (#53)
* rust examples: sync main.rs + tokio main.rs demoing the listener API

Adds two bundled examples to the generated Rust crate:

- examples/main.rs: sync flow using std::sync::mpsc to bridge a typed
  on_echo_fired listener into main + a wildcard add_event_listener
  that uses decode_event_payload::<EchoEvent>(envelope) for the
  matching event id.
- examples/tokio_main.rs: same shape via #[tokio::main] +
  tokio::sync::mpsc.

Bumps generateCargoToml to ship `[dev-dependencies]` with tokio's
`rt-multi-thread` + `macros` features so the bundled examples can use
#[tokio::main] without polluting the library's runtime profile.

Run with `cargo run --example main` (set DYLD_LIBRARY_PATH=<repo> on
macOS until build.rs emits an rpath).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* simplify examples

---------

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-01 13:34:56 -03:00
Ivan FB
c43563f82f
rust codegen: per-event typed add_on_<x>_listener + wildcard add_event_listener (#52) 2026-05-29 20:40:28 +02:00
Gabriel Cruz
7ccf34591d
chore: avoid throwing exceptions in C++ bindings (#46) 2026-05-29 12:35:49 -03:00
Ivan FB
e394166c46
Cpp typed event listeners (#51) 2026-05-28 22:40:33 +02:00
Ivan FB
3f19411684
Event listener abi (#50) 2026-05-28 16:00:28 +02:00
Ivan FB
496a341466
Event registry wiring (#49) 2026-05-27 22:26:39 +02:00
Ivan FB
94ee6603ff
add auto-assign pr author (#54) 2026-05-27 14:35:11 -03:00
Ivan FB
e99220a3e4
fix use-after-free concern (#47)
Co-authored-by: Gabriel Cruz <8129788+gmelodie@users.noreply.github.com>
2026-05-26 23:46:27 +02:00
Gabriel Cruz
e43c1e03e8
tests: cover gaps in CBOR type coverage (#41) 2026-05-26 17:10:42 -03:00
Ivan FB
216316826c
add FFIEventRegistry: multi-listener data structure for FFI events (#45) 2026-05-26 21:42:01 +02:00
Gabriel Cruz
436c0d760b
test(cpp-e2e): add multi-context, cross-library, pipeline, stress tests (#30) (#42) 2026-05-26 09:18:12 -03:00
Ivan FB
6a7e4616fd
Adjust events to cbor (#39) 2026-05-25 15:51:56 +02:00
Gabriel Cruz
31d0ebfa51
chore(ci): extend cpp-e2e to OS matrix (#38) 2026-05-22 11:43:37 -03:00
Ivan FB
c7cf46bdea
avoid move ctor and assing operator in cpp generated code (#36) 2026-05-21 16:38:13 +02:00
Ivan FB
5e6e58e7d1
Increase version to v0.2.0 (#37) 2026-05-21 16:33:38 +02:00
Gabriel Cruz
ee472f05ad
chore(ci): fsanitize tests (#34) 2026-05-20 14:14:42 -03:00
Ivan FB
584e818ac9
Add basic cpp e2e tests (#27) 2026-05-19 12:43:34 +02:00
Ivan FB
e12745e85c
Add cddl generator (#24) 2026-05-18 20:00:57 +02:00
Ivan FB
ac303a707e
Start using CBOR (#23)
Co-authored-by: NagyZoltanPeter <113987313+NagyZoltanPeter@users.noreply.github.com>
Co-authored-by: Gabriel Cruz <8129788+gmelodie@users.noreply.github.com>
2026-05-16 01:08:42 +02:00
Gabriel Cruz
159c9287d8
chore(ci): run tests in parallel (#26) 2026-05-15 00:11:09 +02:00
Ivan FB
e48c9f9edf
remove ffiType macro because it is duplicated by ffi macro (#22) 2026-05-13 14:48:54 +02:00
Ivan FB
6d31fa30bd
use fixed array of ctx to avoid consuming all fds (#14) 2026-05-13 00:02:23 +02:00
Gabriel Cruz
81c62c263e
fix: context buffer overflow (#21) 2026-05-11 19:21:40 -03:00
Ivan FB
a52c4facd9
Simplified FFI authoring with auto-generated C++ and Rust bindings (#15) 2026-05-11 23:28:17 +02:00
Gabriel Cruz
e99eb60fd1
chore: run tests with refc (#20)
* chore: run tests with refc

* chore: split ci jobs

* chore: fix tests
2026-05-09 10:47:37 -03:00
Gabriel Cruz
37d19c0687
chore: remove CatchableError (#19) 2026-05-08 14:14:16 -03:00
Ivan FB
e3eca63236
first ci version (#12) 2026-04-29 23:48:36 +02:00
Ivan FB
df2277e726
Fix memleaks (#11)
* protect against mem leak in case of failures sending requests to ffi thread
* better cleanup if failures in createFFIContext
* avoid dangling cstring in handleRes under ARC/ORC
* better resource cleanup in destroyFFIContext
* invoke onNotResponding if failure in destroyFFIContext
* correct seq copy in alloc
* make sure the lock is init before cleanUpResources
* better possible exception handling in processReq
* guard allocSharedSeq if given seq is empty
* enhance error handling in ffi_context
* add new tests and some corrections
2026-04-27 21:22:45 +02:00
Pablo Lopez
bb8a3e7e22
fix: add install_name for mac (#8)
not to hardcode the paths
2026-02-20 17:37:13 +02:00
Igor Sirotin
c2c03f1f0f
chore: update license files to comply with Logos licensing requirements 2026-02-05 15:12:18 +00:00
Ivan Folgueira Bande
06111de155
properly importing and exporting chronicles v0.1.3 2026-01-23 17:55:43 +01:00
Ivan Folgueira Bande
d3fe7b4389
properly exposing chronicles and tables when importing ffi v0.1.2 2026-01-23 17:34:01 +01:00
Ivan Folgueira Bande
bb8ed28ab0
add require chronicles taskpools and import std tables v0.1.1 2026-01-23 15:01:08 +01:00
Ivan FB
9fff004b19
add explicit timeout when sending watchdog requests (#7) 2026-01-16 15:48:35 +01:00