Skip to content

impl(042): increment 4 part 1, the callback host server and the seam queue - #403

Merged
bartekus merged 1 commit into
mainfrom
impl/042-callback-server
Oct 30, 2026
Merged

bartekus merged 1 commit into
mainfrom
impl/042-callback-server

Conversation

@bartekus

Copy link
Copy Markdown
Contributor

Spec 042 3.10 to 3.12, part 1: the host-side server of the two callback protocols and the bounded seam queue, in rustev-remote-http.

  • src/callback_server.rs: hosts any ContextSource behind POST /rustev/remote-context/1/{describe,fetch,cancel,invalidations} and any EvidenceSink behind POST /rustev/remote-sink/1/{describe,deliver}. Attempt ids run once per idempotency window (attempt_id_conflict for other content), another describe digest is describe_mismatch, cancel answers follow the declared support, poll invalidations keep a bounded log (baseline poll, gaps visible), deliveries are accepted once then duplicate or conflict, rejected deliveries are not remembered. Every table is bounded.
  • src/seam_queue.rs: the 3.12 queue (in-flight limit and capacity 1 to 65,536, immediate remote_seam_queue_full refusal, deadline-bounded wait, depth/refusal/late counters).
  • tests/callback_server.rs over loopback, plus unit tests of the queue.
  • No existing module changes (spec 059 stays rebasable); archive-policy.json lists the two files (packaged size 315.8 KiB of the 320 KiB bound).

Part 2 adds the clients of both protocols on top of the queue.

Local: cargo test -p rustev-remote-http --test callback_server --lib (48 pass) and cargo clippy -p rustev-remote-http --all-targets -D warnings clean.

@github-actions

Copy link
Copy Markdown

AI review (no-findings)

I reviewed all six changed paths carefully, tracing the authentication path, idempotency logic, cancellation semantics, deduplication, the seam-queue invariants, and the test coverage.

callback_server.rs

  • Bearer check (constant_time_eq) leaks length in the short-circuit on a.len() == b.len(), but the expected length is derived from a server-held secret so no novel attack surface beyond what constant-time-without-length already admits; the implementation is the standard pattern.
  • Idempotency key is correct: budget_ms zeroed before hashing; all other fields (including traceparent) are included, which is intentional per the "every member but the budget" comment.
  • Fetch task spawning while holding the fetches mutex is safe: tokio::spawn is non-blocking and the spawned task acquires the lock only after the spawning scope releases it.
  • Rejected-delivery removal happens inside the lock; a concurrent waiter already holds a watch::Receiver clone, so tx.send(Some(Rejected)) reaches it even after the Delivery struct is evicted from the map.
  • unwrap_or_default() in run_fetch degrades gracefully to an empty body (client gets a parse error rather than a structured response) if internal serialization fails—an edge case but not a security issue.
  • Comment "Dropping the hosted fetch's future stops it here" in the cancel function is technically inaccurate: the drop happens in the spawned run_fetch task's select!, not in cancel itself. The semantics are correct (the cancel signal causes the future to be dropped in the spawned context), but the comment describes the wrong location.
  • TLS enforcement (tls.is_none() && !addr.ip().is_loopback()) correctly rejects 0.0.0.0 bindings without TLS.

seam_queue.rs

  • depth = total - slots.available_permits() can never underflow: available_permits is bounded by the initial semaphore value and no code calls add_permits.
  • Slot::start correctly releases the queued-slot permit on deadline via self being dropped, reducing depth without leaking.
  • The _ arm in Slot::start catches AcquireError (semaphore closed) as QueueDeadline; since the SeamQueue holds the Arc<Semaphore>, the semaphore is never closed while a Slot exists—this is unreachable in practice.

tests/callback_server.rs

  • The assertion contains("describe_mismatch") on the raw response body is consistent with ContextCode(RemoteCode::IdentityMismatch) serialising to the wire string "describe_mismatch" per the protocol spec (3.10.4); failure_of round-trips through the typed deserialiser, confirming the mapping.
  • The cancel_answers_follow_the_declared_support test correctly uses hang: true to ensure the cancel arrives while the fetch is in-flight.

Spec and archive-policy

  • The spec increment description (Increment 4 part 1, 2026-10-29) accurately narrates the implementation; the "No existing module of the crate changes" claim is borne out by the diff (only pub mod declarations added to lib.rs).
  • archive-policy.json adds both new source files in alphabetical order within the rustev-remote-http section.

No concrete defects found.

{"head": "6a428f8c1fd0ba6addde8f570b067557b1e29398", "verdict": "no-findings", "findings": []}

Subject: ca81e1e...6a428f8, diff digest 1e61ca522a9ae725b59de23ed344e21481e97a614cce8560cc1d9dc4a5e34d06, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus added this pull request to the merge queue Oct 30, 2026
Merged via the queue into main with commit 8cd9c0c Oct 30, 2026
30 checks passed
@bartekus
bartekus deleted the impl/042-callback-server branch October 30, 2026 03:32
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