openhuman icon indicating copy to clipboard operation
openhuman copied to clipboard

Event can be triaged twice when every queue ingest times out

Open senamakel opened this issue 1 month ago • 1 comments

Parent: tinyhumansai/openhuman#8147

Summary

When every attempt to ingest an event into the queues times out, the event can be triaged twice: once by the caller's direct path and once by the queues if the ingest actually landed. Record the dedupe key on the direct path so the queued copy is recognized and skipped.

Steps to reproduce

  1. Make Ingest slow enough that inbound::route times out on every attempt, while the write still completes in the module.
  2. Send one Composio trigger or webhook.
  3. route returns Direct (crates/openhuman-core/src/inbound/route.rs), the caller triages it directly, and the module later delivers the stored copy too.

Expected

One triage / at most one turn for the event.

Actual

Two triages; the second is logged but not prevented.

Solution

On the ambiguous-timeout fallback, record the event's dedupe key (source:event_id) as completed (tombstone) before or alongside running the direct path, and have Deliver skip an envelope whose key is already completed.

Acceptance criteria

  • [ ] Regression test — fails today: a timed-out-but-landed ingest produces two apply_decision calls; passes with the fix: exactly one.
  • [ ] No new loss — an ingest that genuinely failed is still handled by the direct path.
  • [ ] 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)

  • Where it happens: crates/openhuman-core/src/inbound/route.rs:122-130 returns Offered::Direct after three ambiguous attempts (deadlines 60 s, 10 s and 10 s at L54-58, with 500 ms pauses at L61). It warns "the queues may also deliver it".
  • Why the host can't catch the copy: the only host-side guard is an in-memory ring of 1,024 Accepted turn ids (inbound/deliver.rs:60, 285-295). A direct-path triage never enters it, so the queued copy is not recognized.

Agent brief

Depends on: none · Blocks: none · Parallel with: senamakel/openhuman#514, tinyhumansai/openhuman#8155

Research first

  • Where to record the key so that it survives a restart: the queue's ingress tombstone (via a module member, which would be an upstream change) or a host document collection keyed source:event_id.

Files to consider

  • Read: crates/openhuman-core/src/inbound/route.rs:40-163, inbound/deliver.rs:54-123,280-300
  • Change: inbound/route.rs, inbound/deliver.rs
  • Tests: inbound/route_tests.rs, inbound/deliver_tests.rs

Workflow: implementing-an-epic step.

Subagents: systematic-debugger to reproduce the double triage, then tdd-implementer (Sonnet), then code-reviewer.

Gates: cargo check --manifest-path Cargo.toml · pnpm rust:clippy · cargo test -p openhuman inbound::route inbound::deliver

senamakel avatar Oct 20 '26 12:10 senamakel

Picking this up: draft fix in #8667. The ambiguous-timeout fallback now claims the event (source:event_id) for the direct path and records it in a host collection, inbound.direct, so Deliver skips the queued copy, after a restart too. If the queues deliver first while the offer is still retrying, the direct path is skipped instead.

CodeGhost21 avatar Nov 11 '26 12:11 CodeGhost21