mirror of
https://github.com/logos-co/logos-messaging-module.git
synced 2026-08-27 10:41:19 +00:00
* 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>
35 lines
1.9 KiB
C++
35 lines
1.9 KiB
C++
// Stub implementations for logos_events: methods.
|
|
// In the real build, the codegen generates delivery_module_events.cpp with
|
|
// bodies that route through LogosModuleContext::emitEventImpl_. For unit tests,
|
|
// the codegen doesn't run so we provide stubs here.
|
|
//
|
|
// The node-lifecycle events (nodeStarted / nodeStopped) record their last
|
|
// payload in process-global slots (see delivery_module_events_stub.h) so tests
|
|
// can assert that start()/stop() emit them. The message/connection events stay
|
|
// no-ops.
|
|
|
|
#include "delivery_module_plugin.h"
|
|
|
|
#include "delivery_module_events_stub.h"
|
|
|
|
namespace delivery_test_events {
|
|
NodeLifecycleEvent g_lastNodeStarted{};
|
|
NodeLifecycleEvent g_lastNodeStopped{};
|
|
} // namespace delivery_test_events
|
|
|
|
void DeliveryModuleImpl::messageSent(const std::string&, const std::string&, int64_t) {}
|
|
void DeliveryModuleImpl::messageError(const std::string&, const std::string&, const std::string&, int64_t) {}
|
|
void DeliveryModuleImpl::messagePropagated(const std::string&, const std::string&, int64_t) {}
|
|
void DeliveryModuleImpl::messageReceived(const std::string&, const std::string&, const std::vector<uint8_t>&, int64_t) {}
|
|
void DeliveryModuleImpl::connectionStateChanged(const std::string&, int64_t) {}
|
|
void DeliveryModuleImpl::channelMessageReceived(const std::string&, const std::string&, const std::vector<uint8_t>&, int64_t) {}
|
|
void DeliveryModuleImpl::channelMessageSent(const std::string&, const std::string&, int64_t) {}
|
|
void DeliveryModuleImpl::channelMessageError(const std::string&, const std::string&, const std::string&, int64_t) {}
|
|
|
|
void DeliveryModuleImpl::nodeStarted(bool success, const std::string& message, int64_t timestamp) {
|
|
delivery_test_events::g_lastNodeStarted = {success, message, timestamp, true};
|
|
}
|
|
void DeliveryModuleImpl::nodeStopped(bool success, const std::string& message, int64_t timestamp) {
|
|
delivery_test_events::g_lastNodeStopped = {success, message, timestamp, true};
|
|
}
|