Commit Graph
11 Commits
Author SHA1 Message Date
stubbsta 83977a69af replace rln stub header with actual header and update tests 2026-08-27 09:49:38 +02:00
stubbsta 21b935a383 Add RLN module callbacks 2026-08-27 09:47:26 +02:00
Igor Sirotin f719052096 chore: bump logos-delivery and migrate to the nim-ffi 0.3 C ABI (#90) 2026-08-25 16:39:41 +02:00
Igor SirotinandClaude Fable 5 2701c440b4 feat: expose Store queries via storeQuery (#76)
* feat: expose Store queries via storeQuery

A Logos Core module integrating paid Store retrieval (lez-payment-streams)
needs to issue Store queries through delivery_module, but the plugin surface
only covered lifecycle, send, subscribe and node info. liblogosdelivery already
ships waku_store_query in its kernel tier, so forward to it: storeQuery(
jsonQuery, peerAddr, timeoutMs) hands the query JSON through verbatim and
returns the response JSON, waiting past the query's own timeout so the FFI
error (not a callback timeout) is what the caller sees.

The kernel tier is explicitly unstable; the include is scoped to this one
symbol and the method documents that its JSON contract follows it.

Resolves logos-co/logos-delivery-module#30

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* docs: add use-at-your-own-risk warning on storeQuery

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-07-29 16:23:33 +01:00
967ad9222b feat: add Reliable Channels API support (#68)
* chore: bump logos-delivery to master 8ad99f1

Brings in the Reliable Channels FFI API (logosdelivery_channel_create/
_exists/_send/_close) and channel_message_* events. The create_node
config gained the layered {mode, preset, messagingOverrides,
channelsOverrides} shape; legacy flat JSON remains accepted, so the
existing flat configs and applyPortDefaults keep working.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* test: sync liblogosdelivery.h stub with logos-delivery master 8ad99f1

Replace the hand-condensed stub with the real header surface so the
unit-test ABI matches exactly: adds the four Reliable Channels
functions, RET_MISSING_CALLBACK, and the FFICallBack typedef name used
by the real header.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* feat: add Reliable Channels API to delivery module

Expose the new logos-delivery channel FFI surface:
- channelCreate(channelId, contentTopic, senderId) -> channel id
- channelExists(channelId) -> "true"/"false" (verbatim FFI string)
- channelSend(channelId, payload) -> requestId, payload base64-encoded
  into { payload, ephemeral:false } like send()
- channelClose(channelId)

Route the new event types through event_callback as typed events:
channel_message_received (payload base64-decoded), channel_message_sent,
channel_message_error.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* test: mock channel FFI functions and add channel-api unit tests

Mock the four logosdelivery_channel_* functions (invokeOk pattern),
stub the three new channel event bodies, and cover
channelCreate/channelExists/channelSend/channelClose with the same
no-context / mocked-value / call-count assertions as the existing API.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* test: add reliable-channel integration tests

Cover the full channel lifecycle against the real library: exists=false
for unknown ids, create returns the channel id, exists flips true/false
across create/close, close of an unknown channel errors, and
channelSend returns a request id on an open channel and fails on an
unknown one.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* refactor: extract shared decodePayloadField for event payloads

Both message_received and channel_message_received now decode their
payload field through one helper that accepts either wire shape: a JSON
array of numbers (generic Nim seq[byte] serialization) or a base64
string (hand-built events).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* fix: make event_callback exception-safe across the FFI boundary

Address PR review: event_callback is a C callback invoked from the Nim
runtime, so a C++ exception escaping it would unwind into Nim frames
and terminate the process.

- decodePayloadField: validate array elements are integers in 0..255
  instead of a throwing get<int>(); malformed payloads decode to empty.
- Wrap the whole parse + field-extraction + dispatch in one try/catch
  on nlohmann::json::exception — .value()/.get() type mismatches were
  equally able to escape, not just the payload conversion.
- Stub header: note that upstream's onChannelMessage* comment refers to
  internal listener labels, while the delivered eventType strings are
  channel_message_*; the mirrored body stays verbatim with upstream.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* refactor: split the event payload decoder per event type

message_received carries a JSON byte array, channel_message_received a
base64 string. One parser sniffing both shapes let either event silently
accept the other's encoding; each now decodes only its own.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-authored-by: Igor Sirotin <sirotin@status.im>
2026-07-29 14:41:16 +01:00
Igor SirotinandClaude Opus 4.8 9e6d2f6020 feat: expose node metrics via collectOpenMetricsText() for openmetrics (#55)
* feat: expose node metrics via collectOpenMetricsText() for openmetrics

liblogosdelivery already aggregates Prometheus metrics in its global
registry and renders them as exposition text behind the "Metrics"
node-info attribute. Implement the openmetrics module's new
collectOpenMetricsText() convention (logos-co/openmetrics-module#5) by
handing that text back verbatim — the scraper parses it, injects a
module="delivery_module" label, and merges it with other modules.

No in-module parsing/reshaping: the module is a pure passthrough.
Select it with {"name":"delivery_module","format":"text"} in the
openmetrics start config.

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

* test: add real-node integration test for collectOpenMetricsText()

Asserts the live liblogosdelivery "Metrics" node-info path returns
non-empty Prometheus/OpenMetrics exposition text — the document the
openmetrics module's text source consumes.

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

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-23 22:19:50 +01:00
Iuri Matias 76d5fe9626 add doctest (#47)
add doctest

update config

test for kadmelia; remove kadmelia option from doctests; add another hang test

test for kadmelia

remove kadmelia option from doctests; add another hang test

test lib directly

increase timeout

make start call non-blocking and generate an event instead

remove poc test

remove poc test
2026-06-17 10:09:41 -04:00
2abc08df8c update to new api (#40)
* update to new api

update to new api

update to new api

replace with boost

update flake

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: NagyZoltanPeter <113987313+NagyZoltanPeter@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-05-21 13:26:39 -04:00
Igor SirotinandClaude Sonnet 4.6 a588d6494f fix: use QByteArray for payload end to end, removing base64 layer (#28)
send() now accepts QByteArray directly (base64 still applied internally
for the FFI JSON). messageReceived emits payload as QByteArray instead
of a base64-encoded QString, matching logos-delivery behaviour.

Closes #27

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-18 11:55:30 +01:00
Iuri Matias f2498dcaf8 add test for createNode 2026-04-16 14:03:43 -04:00
Iuri Matias 17f7935d96 fix library generation; add tests
fix library generation; add tests

add CI

update

ci fix
2026-04-15 17:12:38 -04:00