72 Commits

Author SHA1 Message Date
Jazz Turner-Baggs
7612b233c9
Add 1:1 Chats using Groups (#139)
* Add Identified Trait for convo

* Add PrivateV2Convo

* Rename to DirectV1

* Rename ConvoTypeOwned variant

* Update DirectV1 to support multiple members

* Apply suggestion from @kaichaosun

Co-authored-by: kaichao <kaichaosuna@gmail.com>

---------

Co-authored-by: kaichao <kaichaosuna@gmail.com>
2026-06-19 12:01:17 -07:00
Jazz Turner-Baggs
c5b264c827
Add Identified Trait for convo (#138)
* Add Identified Trait for convo
2026-06-19 08:43:55 -07:00
Jazz Turner-Baggs
e163980715
Move Ephemeral registry to submodule (#136) 2026-06-17 08:27:39 -07:00
Jazz Turner-Baggs
960d0bc119
DeMLS Integration (#134)
* Add WakeupService

* Move Id to trait

* Add GroupV2

* Add convo cache

* Add TestHarness

* Instrument call paths

* Downgrade Ciphersuite

* Update imports

* cleanups

* Add Wakeups to Client

* fix: protoc dependency for ci

* fix: nix hash

* Remove save_conversation for v2

* PR comments
2026-06-15 13:15:18 -07:00
osmaczko
9d9a691fe3
refactor: remove client-ffi and legacy nim bindings (#133)
closes: #77

The C consumer story lives downstream now: logos-chat-module wraps the
client crate and exposes its own C API. The in-tree client-ffi crate has
no consumers left, and the nim bindings still target the removed
Context-based C API.

- delete crates/client-ffi (including the message-exchange C example)
  and nim-bindings
- drop core/conversations' unused safer-ffi dependency plus the leftover
  C artifact crate-types: staticlib on core/conversations, cdylib on
  double-ratchets (neither crate has extern "C" exports)
- flake.nix: drop the default package (it built libclient_ffi.a plus its
  header); keep the logos-delivery package and the dev shell
- ci.yml: drop the C FFI smoketest steps (valgrind included), the rustup
  install the smoketest no longer needs, and the nix-build job that
  built the removed default package
- ADR 0001: point the FFI-compatibility driver at the downstream C API
  boundary instead of crates/client-ffi
2026-06-15 17:55:58 +02:00
kaichao
78d6b6c47a
chore: fix ci failure steps of nix build (#132)
* chore: fix ci failure steps of nix build

* chore: update comments
2026-06-12 08:52:13 +08:00
kaichao
f41fb40c2f
feat: extend the http registry to store account's installations (#129)
* feat: account to device store

* feat: accout traits and codec

* feat: integrate accounts abstraction

* chore: clean docs and naming

* remove account public key from payload

* chore: fix clippy

* feat: lamport check before update account store

* chore: rebase to core

* chore: register account in new core

* chore: rebase changes and use account pub for index account store

* chore: move chat store outside of libchat

* chore: use account pub for registry
2026-06-11 21:07:11 +08:00
osmaczko
7838d43b30
feat(client): add threaded transport polling (#125)
The client, not the app, now drives the transport; events are delivered
asynchronously, per ADR 0001.

- ChatClient owns Arc<Mutex<Core>> + a worker thread.
- The worker select!s over the inbound and shutdown channels; Drop joins it.
  Outbound runs on the caller's thread.
- A single Transport (DeliveryService + inbound()) owns both directions of the
  boundary, so the client takes one transport rather than a (delivery, inbound)
  pair. InProcessDelivery::new, CDelivery, and chat-cli's transports implement it.
- FFI replaces client_receive with client_push_inbound + client_poll_events.
- chat-cli drains Receiver<Event>; inbound and event channels are both crossbeam.
- Corrects ADR 0001's inbound sequence to push — the worker parks on select!,
  it never polls.
2026-06-11 10:08:07 +02:00
Jazz Turner-Baggs
a610117e81
Update Context to accept External Identity Provider. (#127)
* rename .account_id() to .id()

* Create logos-traits crate

* Remove AccountId references

* external IdentityProvider for Context

* Fix compile errors from merge

* Update logos-traits to shared-traits

* format fixes

* warnings cleanup

* clippy fix

* Remove rebase artifact
2026-06-10 06:59:04 -07:00
osmaczko
0e72fdf483
refactor(core): replace Rc-based Context with a synchronous, Send-able Core (#123)
Make the conversations core Send so the threaded client can own it behind an
Arc<Mutex<Core>>: a background worker polls the transport and handles inbound
payloads while the application thread issues outbound calls (send, create
conversation). Sharing the core across those two threads means moving it into
the spawned worker, which is only legal if it is Send. Access stays serialized
by the client's Mutex (one thread at a time), so the core needs Send but not
Sync and carries no lock of its own. See
docs/adr/0001-client-event-system.md for the background-poller design.

The Rc<RefCell> service-sharing is what made the core !Send. Context is de-Rc'd
and renamed to Core, owning its services outright and driving the inbox and
conversation primitives with plain &mut self.

- Services (identity, delivery, store, registry, MLS context, causal history)
  are bundled into a ServiceContext<S> behind an ExternalServices trait, with
  S = (DS, RS, CS). Constructors live on the (DS, RS, CS) form because S cannot
  be inferred backwards through S::DS.
- Inbox, InboxV2, PrivateV1Convo, and GroupV1Convo become non-generic and
  receive the ServiceContext bundle as a &mut/& parameter; no Rc or
  RefCell-as-shared-state remains, so Core is Send whenever its injected
  services are.
- Dispatch branches on ConversationKind in one place: Core rebuilds the target
  as a Convo<S>/GroupConvo<S> trait object bound to the service bundle, so
  conversations never escape the orchestrator.
- CausalHistoryStore drops its Rc, keeping a plain RefCell.
2026-06-08 21:55:33 +02:00
kaichao
cd7dd6a330
feat: http server based key package registry (#124)
* feat: http server based key package registry

* chore: instructions on running the registration service

* chore: remove duplicate post param

* chore: revert out sourced account id for multi devices support

* feat: signature on account id and key packages

* chore: include http registry in contact registry module

* refactor: use device id for retrieve key package

* chore: use string for device id

* feat: server verification on the register

* chore: doc the smoke test

* chore: fix data folder non exist

* chore: use payload for register and retrieve

* chore: fix clippy
2026-06-04 10:09:29 +08:00
Jazz Turner-Baggs
6f5838af51
Add crate logos-accounts (#103)
Update InboxV2 to use IdentProvider

Create Full featured Provider

Introduce MlsIdentityProvider

Flatten MLSContext

Cleanup warnings until future integration PR

remove duplicate

Update account_id comments
2026-06-02 15:21:21 -07:00
kaichao
4df23aad63
Include sender information on missing messages (#120)
* feat: prefix sender id

* chore: add message struct for sender info

* chore: refactor struct name for frontier

* chore: reuse duplicate test

* chore: fix clippy

* feat: use sender_id in wire

* chore: remove result

* chore: fix nix build

* chore: bump chat_proto version
2026-06-02 21:55:19 +08:00
Jazz Turner-Baggs
2d3ad27d51
Add cron job for ci (#122) 2026-06-01 22:12:12 -07:00
osmaczko
c677cc9334
feat: introduce client event system (#106)
* chore(flake): accept extra system attr; add perl for openssl-sys build

forAllSystems calls the lambda with {system, pkgs}; strict
destructuring requires `..` to ignore the system attribute.

`pkgs.perl` is needed because openssl-sys is pulled vendored via
libsqlite3-sys / rusqlite / chat-sqlite, and its `perl Configure`
step needs FindBin.pm, which Fedora's system perl doesn't ship.

* feat: introduce client event system

- Core processing yields a `PayloadOutcome` enum — `Empty`, `Convo`, or
  `Inbox`. `ConvoOutcome` carries a conversation id and an optional
  decrypted `Content`; `InboxOutcome` adds a `NewConversation`
  (id + `ConversationClass`) for a peer-initiated conversation.
- Client translates `PayloadOutcome` into app-facing `Vec<Event>`
  (`ConversationStarted`, `MessageReceived`) at the boundary, so the
  application loop sees discrete events rather than core types.
- MLS group welcomes produce a `ConversationStarted` event with no
  initial content, fixing the silent-group-join case where the inbox
  layer dropped the observation.
- C FFI exposes an `EventList` opaque type with indexed accessors and
  an `Invalid` sentinel for out-of-bounds / non-applicable reads.
- Symmetric `Inbox` / `InboxV2` handlers: both return
  `Result<InboxOutcome, _>` and own the persistence + ephemeral-key
  cleanup for the conversations they create.
- Updated and simplified `docs/adr/0001-client-event-system.md`.

* chore(flake): bump nixpkgs to nixos-unstable-small

Temporary. The two crates.io UA fixes (NixOS/nixpkgs#512735 for
fetchCargoVendor's python-requests UA, NixOS/nixpkgs#524985 for
importCargoLock's curl UA) haven't propagated to nixos-unstable yet.
Switch to nixos-unstable-small and force logos-delivery to follow so
the smoketest gets the same fix. Revert once nixos-unstable catches up.

Refs:
- https://github.com/rust-lang/crates.io/issues/13482
- https://github.com/rust-lang/crates.io/issues/13783
- https://crates.io/data-access
2026-05-28 23:51:15 +02:00
kaichao
279477cdeb
feat: causal history notify missing messages (#105)
* feat: causal history notify missing messages

* chore: fix test

* chore: fix clippy

* chore: update domain seprator
2026-05-25 11:54:52 +08:00
Jazz Turner-Baggs
fa68714e2f
Add crate logos-accounts (#102) 2026-05-20 14:11:02 -07:00
Jazz Turner-Baggs
65e103ab1d
Remove naming conflict with Signatures (#101) 2026-05-20 13:41:12 -07:00
Jazz Turner-Baggs
b7888c1a70
Dependency cleanup (#100)
* Sort all Cargo.toml deps for less conflicts

* Move relative path deps to workspace

* Standardize workspace imports

* Rename ‘client’ to ‘logos-chat’

* Cleanups
2026-05-20 13:18:25 -07:00
osmaczko
d972741157
chore: add adr for client-event-system (#99) 2026-05-19 21:26:09 +02:00
Jazz Turner-Baggs
3245498438
Add GroupV1 + InboxV2 (#92)
* Add GroupV1

* Clean warnings

* Remove dead test

* Re-use components in integration tests

* Remove deadcode

* undo import fixes

* tidy

* Update Accounts + service_traits

* Remove ClientCtx

* Remove duplicate test_utils

* Wrap constructor in result

* Warning fixups

* Appease clippy

* Update comments

* Update todo

* Clean up warnings

* Avoid panic

* Fix libchat import in chat-cli

* Add InboxV2 comment

* Add comments to GroupV1Convo

* Update doc comments

* reduce visibility

* Doc Integration tests

* Hashlen update

* remove type alias for ProtocolParams

* Remove stray printlines

* Review fixes

* PR review changes

* Add trait comments

* chat_proto import paths

* PR Feedback fixes

* Update CliClient

* Update CLI DeliveryService impls
2026-05-19 11:54:54 -07:00
osmaczko
1e373226ae
chore(chat-cli): switch transport at runtime via --transport flag (#95)
Both file and logos-delivery transports are now compiled into a single
binary and selected at runtime (default: logos-delivery), replacing the
env-var-driven build-time cfg.
2026-05-12 15:33:50 +02:00
Jazz Turner-Baggs
39bf267564
Add Account Struct (#94)
* Add Account Struct

* Quell Warnings

* Update core/conversations/src/account.rs

Co-authored-by: osmaczko <33099791+osmaczko@users.noreply.github.com>

* Add clarity to todo

* Update test account constructor docs

* Add removal todo

* Resolve cargo.lock conflict

* remove warnings

---------

Co-authored-by: osmaczko <33099791+osmaczko@users.noreply.github.com>
2026-04-28 07:47:57 -07:00
Jazz Turner-Baggs
25debdc051
Add Signature + Verifying key types (#93) 2026-04-27 13:35:20 -07:00
osmaczko
eaeffcd21f
feat(chat-cli): wire up logos-delivery transport and switch to client API (#91)
Replace the direct use of `conversations::Context` with `client::ChatClient`,
which is the intended public API for library consumers.

Remove `MessageEnvelope` and the username-keyed session model. The envelope
was never part of the wire protocol — sender identity was only tracked in the
CLI's local state. Chats are now keyed by conversation ID; add `/nickname` as
the user-facing replacement for named sessions.

Add a logos-delivery (Waku) transport alongside the existing file transport.
The active transport is selected at compile time: set `LOGOS_DELIVERY_LIB_DIR`
to link liblogosdelivery, otherwise the file transport is used.

Add logos-delivery as a Nix flake input and expose `.#logos-delivery` so the
library can be built with `nix build` and referenced by `LOGOS_DELIVERY_LIB_DIR`.

CI: rename `c-ffi-smoketest` to `smoketest`; add logos-delivery build step
and a `--smoketest` invocation of chat-cli to verify startup.
2026-04-27 13:22:16 +02:00
Pablo Lopez
df84fc87cf
feat: add flake (#85)
* feat: add flake

* fix: pr feedback

* fix: removing dylib for libchat

not used and it was causing the error with panic abort
2026-04-17 16:27:15 +03:00
kaichao
6c7b3a4252
feat: chat cli demo app (#87)
* chore: remove ffi from double ratchet

* chore: format

* feat: chat cli demo app via file transport

* chore: fix the compile issues

* chore: fix long intro copy to clipboard

* chore: move chat cli to bin folder

* chore: use tmp data folder

* chore: update doc

* chore: use encrypted db with default db pass

* chore: fmt and clippy

* chore: fix clippy and refactor

* chore: utils for helper funcs

* chore: rename sessions to chats
2026-04-17 14:43:04 +08:00
kaichao
94935c28fe
refactor: remove FFI interfaces from double ratchets (#84)
* chore: remove ffi from double ratchet

* chore: update doc

* chore: format
2026-04-16 23:26:19 +08:00
dependabot[bot]
c0e07c765e
Build(deps): bump rand from 0.8.5 to 0.9.3 (#86)
Bumps [rand](https://github.com/rust-random/rand) from 0.8.5 to 0.9.3.
- [Release notes](https://github.com/rust-random/rand/releases)
- [Changelog](https://github.com/rust-random/rand/blob/0.9.3/CHANGELOG.md)
- [Commits](https://github.com/rust-random/rand/compare/0.8.5...0.9.3)

---
updated-dependencies:
- dependency-name: rand
  dependency-version: 0.9.3
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-04-16 07:50:16 -07:00
kaichao
9cc73622ed
Move double ratchet storage operations to PrivateV1 (#82)
* feat: move private store out of context

* feat: move convo store to private v1

* feat: clean context

* chore: params postion

* chore: use git exclue for justfile
2026-04-10 08:33:58 +08:00
osmaczko
d68c0cb275
feat: implement Client crate and C FFI bindings (#73)
Implement a `client` crate that wraps the `libchat` context behind a
simple `ChatClient<D>` API. The delivery strategy is pluggable via a
`DeliveryService` trait, with two implementations provided:

- `InProcessDelivery` — shared `MessageBus` for single-process tests
- `CDelivery` — C function-pointer callback for the FFI layer

Add a `client-ffi` crate that exposes the client as a C API via
`safer-ffi`. A `generate-headers` binary produces the companion C
header.

Include two runnable examples:
- `examples/in-process` — Alice/Bob exchange using in-process delivery
- `examples/c-ffi` — same exchange written entirely in C; smoketested
under valgrind (to catch memory leaks) in CI

iterates: #71
2026-04-08 23:15:48 +02:00
kaichao
8e8b0c0dd7
Use inbox to handle save and load ephemeral key from store (#81)
* feat: move inbox store out from context

* chore: clear boundary between context and inbox to store dependencies
2026-04-08 11:07:23 +08:00
kaichao
c44c52b127
feat: storage implementation and trait abstraction (#79)
* feat: storage for conversations

* fix: db types conversion

* feat: run migrations from sql files

* feat: persist identity

* fix: revert double ratchet storage refactor

* fix: clean

* refactor: use result wrapper for ffi

* refactor: uniform storage error into chat error

* fix: zeroize identity record

* fix: zeroize for secret keys in db operations

* fix: transactional sql migration

* fix: remove destroy_string

* feat: db storage for inbox ephermeral keys

* chore: remove in memory hashmap for ephemeral keys

* feat: persist conversation store

* feat: wire with the double ratchet storage

* feat: remove conversation store

* chore: fix conversation type not used

* feat: mock chat store implementation

* chore: sqlite module

* feat: sqlite crate

* chore: sqlite rename

* chore: more refactor

* extract ratchet store trait

* chore: clear error conversion

* chore: remove customized db conn

* chore: fix clippy

* chore: refactor to use generics and enum

* chore: further clean for review comments
2026-04-03 08:25:26 +08:00
Jazz Turner-Baggs
d905de3592
Remove Legacy FFI from LibChat (#80)
* Remove libchat legacy FFI

* Remove legacy nim bindings

* Remove stray headerfile

* Remove deprecated CI jobs
2026-04-01 12:54:27 -07:00
kaichao
8cddd9ddcf
refactor: use new styling for conversations crate without mod.rs (#72)
* refactor: use new styling for conversations crate without mod.rs

* refactor: remove put crate for identity types
2026-03-27 10:23:33 +08:00
Jazz Turner-Baggs
9a94f9a6d6
Flatten Repos (#70)
* move to “crates” style folder

* Update workspace

* clear crate names

* Rename crate folders based on feedback

* Use workspace dependencies instead of paths

* Move updated files from core
2026-03-24 18:21:00 -07:00
kaichao
daeecbd679
Persist identity (#67)
* feat: storage for conversations

* fix: db types conversion

* feat: run migrations from sql files

* feat: persist identity

* fix: revert double ratchet storage refactor

* fix: clean

* refactor: use result wrapper for ffi

* refactor: uniform storage error into chat error

* fix: zeroize identity record

* fix: zeroize for secret keys in db operations

* fix: transactional sql migration

* fix: remove destroy_string

* refactor: inline identity record name clone
2026-03-25 08:45:22 +08:00
osmaczko
d006f20bce
fix(nim-bindings): add all-endpoints test and fix installation_name ABI (#66)
Add nim-bindings/tests/test_all_endpoints.nim which imports bindings
directly and calls every FFI proc, forcing the linker to include all
symbols. This catches link-time and runtime issues that the pingpong
example missed because unused symbols were optimised out.

Running the new test revealed an ABI mismatch in installation_name:
the Rust function used an explicit out-parameter but ReprCString has
only flat fields, so Nim emits it as a C return value.

CI now runs nimble test next to nimble pingpong.
2026-02-28 21:03:55 +01:00
Jazz Turner-Baggs
1158865bf2
feat: ListConversations (#60)
* Add function to get available conversations_ids

* Update bindings

* linter fix

* remove dynlib reference

* destructor fix
2026-02-28 03:16:10 -08:00
osmaczko
fa79b1c79c
chore(nim-bindings): replace dynlib dlopen with plain importc (#61)
* chore(nim-bindings): replace dynlib dlopen with plain importc

The dynlib pragma hard-coded a library path and resolved it via dlopen() at
runtime, preventing static linking and forcing a specific load-time path.
Using bare {.importc.} lets consumers choose: link liblibchat dynamically
at link time (--passL:-llibchat) or link it statically into their binary.

* Rust -> Nim ABI  (#62)

* Use correct build hook

* force sret like return from rust code for nim compatibility

* Fix target mismatch

* Update usages

* ci: add nim-bindings-test

* fix(nim-bindings): fix ABI mismatch in destroy_* FFI functions and add defer-based cleanup

Nim's C backend silently transforms large struct parameters (>16 bytes) into
pointer parameters when calling importc functions. The destroy_* functions were
declared taking T by value in Rust, but Nim always passed &T — causing Rust to
read garbage from the stack on x86-64 (SIGILL on CI) while accidentally working
on ARM64 macOS due to that ABI coincidentally also using pointers for large structs.

Fix by changing all destroy_* functions to take &mut T and using drop_in_place,
which is the correct idiom for dropping a value through a pointer.

On the Nim side, replace scattered manual destroy calls with defer, which
guarantees cleanup on all exit paths and prevents use-after-destroy bugs.

---------

Co-authored-by: Jazz Turner-Baggs <473256+jazzz@users.noreply.github.com>
2026-02-25 20:09:55 +01:00
Jazz Turner-Baggs
960bb195a1
Update crate name (#59) 2026-02-22 08:24:10 +02:00
Jazz Turner-Baggs
eb941387df
Add Installation name (#58)
* Add Identity name

* Update Context to accept a name

* Change constructor in bindings

* Add name retrieval to bindings

* Update constructor string type

* Remove uneeded files

* rename functions for symmetry
2026-02-19 17:25:42 -08:00
osmaczko
a9ca4ffb7d
chore: expose isNewConvo property (#57) 2026-02-18 20:01:47 +01:00
Jazz Turner-Baggs
95ddce9161
Key types (#56)
* Add generic SymmetricKey container

* Rename SecretKey to SymmetricKey32

* Update SymmetricKey usage

* Add PublicKey

* Update PublicKey uses

* Add PrivateKey

* Replace StaticSecret with PrivateKey

* Fix imports

* Remove InstallKey from constructors

* Final integration

* lint fixes

* Fixups
2026-02-18 09:29:33 -08:00
Jazz Turner-Baggs
3b69f946fd
PrivateV1 Convo Ids (#54)
* Add conversation_ids for privateV1

* Skip handling of unknown payloads

* Tag initial ContentData as new

* Add Integration test

* truncate convo_id to size

* Clippy fixes

* cleanup

* Apply suggestion from @osmaczko

Co-authored-by: osmaczko <33099791+osmaczko@users.noreply.github.com>

* Apply suggestion from @osmaczko

Co-authored-by: osmaczko <33099791+osmaczko@users.noreply.github.com>

* Linter fixes

---------

Co-authored-by: osmaczko <33099791+osmaczko@users.noreply.github.com>
2026-02-11 14:10:21 -08:00
osmaczko
57fe656728
feat: update introduction bundle encoding (#43)
closes: #27
2026-02-11 19:51:22 +01:00
Patryk Osmaczko
cd737ea058 fix: make ci checks pass 2026-02-10 19:45:00 +01:00
Aleksey
c5f9994c9e
feat: add ci checks
* base ci add

* Remove .DS_Store files

* Add .DS_Store to gitignore

* remove master & develop, kept only stable in matrix

Restrict CI workflow to only the main branch for pushes and pull requests.

* Update .github/workflows/ci.yml

Co-authored-by: osmaczko <33099791+osmaczko@users.noreply.github.com>

* Update .github/workflows/ci.yml

Co-authored-by: osmaczko <33099791+osmaczko@users.noreply.github.com>

---------

Co-authored-by: osmaczko <33099791+osmaczko@users.noreply.github.com>
2026-02-10 14:40:01 +01:00
Jazz Turner-Baggs
71f7b8a485
FFI Integration fixes (#48)
* Make conversation store easier to use

* fix: Bug in Inbox id’s

* Clean up warnings

* Add DH decryption for Inbox
2026-02-09 09:55:58 -08:00
Jazz Turner-Baggs
e3e3097947
Safer FFI Migration (#47)
* Use safer_ffi for all functions

* Clean up FFI docs and imports

* Update nim bindings

* Binding Memory Management

* Update tests
2026-02-09 06:37:47 -08:00