Repository navigation
Description
Parent: #8147
Summary
Route native channel messages through tinyeventqueues instead of the in-memory mpsc::channel(100), so a restart or a full channel no longer loses inbound messages.
Problem
Native channels feed ChannelHostCallbacks::deliver_inbound (channels/runtime/startup/callback.rs, ~L67) into a bounded mpsc::channel(100) (channels/runtime/startup/start_channels.rs, ~L164). Anything in flight is lost on restart, and a burst beyond 100 back-pressures or drops. Nothing is triaged.
Solution
deliver_inboundingests into the queues viainbound::routeand returns only after the durable write, so the platform ack / poll cursor advance follows persistence.- Replace the mpsc dispatcher with the module's
Delivercallback; keep it as the direct path when the queues are unavailable. - Same envelope rules as hosted channels (dedupe on platform message id; group chatter as context).
Acceptance criteria
- Restart-safe — regression test: core stopped with pending native messages; after restart they are delivered exactly once as turns.
- Burst-safe — more than 100 messages in a burst are all accounted for (delivered / context / dropped-with-reason), none silently lost.
- Ack after persist — the channel's ack/cursor advances only after
Ingestreturns. - Fallback intact — with the component off, the current path still works.
- Diff coverage ≥ 80% — the implementing PR meets the changed-lines coverage gate (Vitest + cargo-llvm-cov, enforced by
.github/workflows/ci-fast.yml).
Related
Part of #8147. Builds on #8136 (inbound domain, tinyeventqueues v0.1.2) and tinyhumansai/tinyeventqueues#6.
Audit findings (2026-10-20)
- The only production sender into
mpsc::channel(100)(channels/runtime/startup/start_channels.rs:164) isChannelHostCallbacks::deliver_inbound(startup/callback.rs:67-94, viamodule_providers.rs:62). It returnsOk(())once the send succeeds, before anything is persisted. - The receiver is
run_message_dispatch_loop(dispatch/processor.rs:80-105): aJoinSetbounded bymax_in_flight_messages, runningprocessor/turn.rs(732 LOC). ChannelHostCallbacksserves the tinychannels contractai.tinyhumans.tinychannels.ChannelsHost. Its module acks the platform before the host persists (Telegram's offset advances beforetx.send), so ack-after-persist needs the upstream change in [inbound-queues] providers: commit the platform cursor only after the host persists senamakel/tinychannels#84.- Open PR feat(channels): debounce and serialize inbound messages per conversation #8130 adds an in-process
KeyedDebouncerand[inbound_debounce]config on this exact path. The queues already coalesce per conversation (Gate, rate limits and coalescing for inbound events tinyeventqueues#2). Decide before starting: close feat(channels): debounce and serialize inbound messages per conversation #8130 in favour of this issue, or land it and remove it here. - Predecessor: One inbound path: native channel listeners onto the shared runner with durable sessions #7968 (native listeners onto the shared runner), closed.
Agent brief
Depends on: senamakel#514, senamakel/tinychannels#84, senamakel/tinyeventqueues#2 · Blocks: #8152, senamakel#515 · Parallel with: #8148, #8150, #8151
Research first
- The feat(channels): debounce and serialize inbound messages per conversation #8130 decision above. Record it on this issue.
- Which ack policy each native provider needs.
after_ingestis enough once [inbound-queues] providers: commit the platform cursor only after the host persists senamakel/tinychannels#84 commits afterDeliverInboundreturns;after_turnis only for providers that must not mark the message read before the reply.
Files to consider
- Read:
crates/openhuman-core/src/channels/runtime/startup/callback.rs:60-100,startup/start_channels.rs:150-310,dispatch/processor.rs:80-105,dispatch/processor/turn.rs - Change:
startup/callback.rs(ingest viainbound::route, return after the durable write),startup/start_channels.rs(the mpsc becomes the direct path only), thechannel:handler ininbound/deliver/, thevendor/tinychannelsgitlink - Tests:
channels/runtime/startup_tests.rs,dispatch/*_tests.rs
Workflow: implementing-an-epic step.
Subagents: tdd-implementer (Sonnet), merge-conflict-resolver if #8130 lands first, then code-reviewer.
Gates: cargo check --manifest-path Cargo.toml · pnpm rust:clippy · cargo test -p openhuman channels::runtime inbound · pnpm rust:layout · node scripts/modules/pin-status.mjs
Activity
M3gA-Mind commentedon Nov 16, 2026
Re-checked on current main: not done yet.
deliver_inboundstill feeds a bounded in-memorympsc::channel(100), so in-flight messages are still lost on a restart. A keyed debouncer was added on this path (#8130), but it's in memory too. Keeping this open as part of #8147.