Skip to content

fix(server): return 503 on full Slack queue instead of acking-and-dropping (#356) - #375

Open
gnanirahulnutakki wants to merge 1 commit into
devfrom
fix/356-slack-full-queue-503
Open

fix(server): return 503 on full Slack queue instead of acking-and-dropping (#356)#375
gnanirahulnutakki wants to merge 1 commit into
devfrom
fix/356-slack-full-queue-503

Conversation

@gnanirahulnutakki

Copy link
Copy Markdown
Member

Summary

Fixes #356 — inbound Slack messages were silently dropped when the bounded worker queue was full, yet Slack still received a 200 ack and never retried. Under burst (queue depth > WORKER_QUEUE_CAPACITY = 1024) real messages were lost with a misleading log, and the 2xx told Slack not to redeliver.

Root cause

  • crates/server/src/state.rsAppState::enqueue collapsed mpsc::error::TrySendError::Full and Closed into a single bool (try_send(...).is_ok()), erasing the retryable-vs-terminal distinction.
  • crates/server/src/routes.rsslack_events logged "turn worker is gone; dropping message" and returned StatusCode::OK regardless of why the enqueue failed.

This was asymmetric with the /chat path, which already surfaces a full queue as 503.

Fix

  • enqueue now returns a three-way EnqueueOutcome { Accepted, Full, WorkerGone } instead of a bool.
  • slack_events acks 200 only on Accepted; on both Full and WorkerGone it returns 503 SERVICE_UNAVAILABLE so Slack redelivers rather than treating the message as durably received. This mirrors the existing /chat QueueFull → 503 behavior.
  • The long-poll forwarder (Matrix/Discord/Telegram) is intentionally untouched — those transports have no HTTP redelivery contract and already log-and-drop on Full / break on Closed.

Regression test

state::tests::enqueue_distinguishes_full_queue_from_a_gone_worker fills a capacity-1, undrained queue and asserts:

  • first message → Accepted
  • second (queue saturated) → Full (retryable, not silently accepted, not WorkerGone)
  • after dropping the receiver → WorkerGone

The test exercises the exact distinction the fix introduces; it does not compile against the old bool API.

Verification

All green locally (macOS, toolchain 1.96.1):

  • cargo fmt --check
  • cargo clippy -p ardur-server --all-targets -- -D warnings
  • cargo test -p ardur-server (incl. the new regression test)
  • cargo test -p ardur-e2e-tests

Not merged — left for peer review.

@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 79d4880d-2626-4231-ae9e-4e53e248750c

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/356-slack-full-queue-503

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@gnanirahulnutakki
gnanirahulnutakki force-pushed the fix/356-slack-full-queue-503 branch from 94c7f17 to e553c4d Compare July 23, 2026 18:42
…pping (#356)

Inbound Slack messages were silently dropped when the bounded worker
queue was saturated, yet Slack still received a 200 ack and never
retried — silent data loss under burst.

Root cause: AppState::enqueue collapsed mpsc TrySendError::Full and
Closed into a single bool (try_send(...).is_ok()), and slack_events
returned StatusCode::OK regardless of the drop. This is asymmetric with
/chat, which already surfaces QueueFull as 503.

Fix: enqueue now returns a three-way EnqueueOutcome { Accepted, Full,
WorkerGone }. slack_events acks 200 only on Accepted and returns 503
SERVICE_UNAVAILABLE on Full and WorkerGone, so Slack redelivers instead
of treating the message as received. Mirrors the /chat full-queue path.

Adds a regression test (enqueue_distinguishes_full_queue_from_a_gone_worker)
that fills a capacity-1, undrained queue and asserts Full is reported
distinctly from WorkerGone.

Verification: cargo test -p ardur-server, cargo test -p ardur-e2e-tests,
cargo clippy -p ardur-server --all-targets -D warnings, cargo fmt --check
— all green.

Fixes #356

Checkpoint: architect/sessions/fix-356-slack-full-queue-2026-07-23/journal.md

Signed-off-by: GR <gnanirn@gmail.com>
@gnanirahulnutakki
gnanirahulnutakki force-pushed the fix/356-slack-full-queue-503 branch from e553c4d to eed4761 Compare August 11, 2026 19:06
gnanirahulnutakki added a commit that referenced this pull request Aug 11, 2026
…uinn-proto, resync Cargo.lock (#387)

Three coupled fixes that together restore a mergeable `dev`.

1. cargo-deny (required check) is failing on every open PR and on `dev`
   itself with a single finding:

       error[unmaintained]: bitmaps is unmaintained
         ID: RUSTSEC-2026-0247
         Solution: No safe upgrade is available!

   `bitmaps` is transitive only, via matrix-sdk -> imbl ->
   imbl-sized-chunks. It is an unmaintained notice, not a vulnerability,
   and cargo-deny itself reports that no safe upgrade exists. That is
exactly the class `[advisories].ignore` already documents (bincode via
   syntect, paste via fastembed, proc-macro-error2 via Matrix/Teloxide,
rustls-pemfile via qdrant-client), so it is ignored on the same terms.
   Vulnerability advisories are still upgraded rather than ignored — see
   (2).

2. Patch the two crates behind all five open Dependabot alerts. Both are
   reachable from the workspace and both have released fixes:

     - russh 0.62.2 -> 0.62.5 (direct dep of crates/terminal), closing
       GHSA-m65r-rprj-r5rg (CVE-2026-68930, channel-scoped server
       callbacks reachable without an open channel), GHSA-g9hv-x236-4qp3
       (pre-auth X25519 wrong-length panic), GHSA-cqjc-rmpq-xprq
       (post-auth pty-req panic) and GHSA-5xvq-cp9x-6p6r (pre-auth
       all-zero Curve25519 encode_mpint OOB).
     - quinn-proto 0.11.14 -> 0.11.16 (transitive), closing the one HIGH
       alert, GHSA-4w2j-m93h-cj5j (remote memory exhaustion from
       unbounded out-of-order stream reassembly).

Dependabot did raise these as #385 and #382, but against `main`, where
   they fail DCO; `dev` never received them.

3. Resync Cargo.lock, which had drifted from the manifests: it was
   missing `ardur-delegate-tool` (#332) and `ardur-durability` (#327)
   along with tar/filetime/xattr, and still carried stale entries.
   `.github/workflows/release.yml` builds `--locked`, so a release cut
from `dev` would have failed to resolve. `cargo metadata --locked` now
   succeeds.

Verified locally: `cargo deny check` reports advisories/bans/licenses/
sources all ok; `cargo fmt --check`, `cargo build --workspace` and
`cargo clippy --workspace --all-targets -D warnings` are clean.

---

**Why this lands first:** `cargo-deny` is a required check and is
currently red on *every* open PR (#368, #369, #370, #372, #373, #374,
#375 all show exactly one failing required check, and it is this one).
Nothing can merge into `dev` until the advisory is resolved.

Signed-off-by: GR <gnanirn@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant