Skip to content

fix(relay): enforce scoped budgets consistently at every ingress - #25

Closed
albertovincenzi wants to merge 1 commit into
fix/shed-applicable-binding-budgetfrom
fix/enforce-applicable-scoped-budgets
Closed

fix(relay): enforce scoped budgets consistently at every ingress#25
albertovincenzi wants to merge 1 commit into
fix/shed-applicable-binding-budgetfrom
fix/enforce-applicable-scoped-budgets

Conversation

@albertovincenzi

Copy link
Copy Markdown
Collaborator

Problem

Scoped-budget validation disagreed across the two supported ingress paths. HTTP rejected a missing scope even when whenOp made that budget irrelevant to the item. A producer writing directly to a user-owned ingress queue had the opposite and more dangerous behavior: when an applicable scope was absent, the relay silently skipped that counter and forwarded the item under only the other budgets.

Fix

  • add one pure missing-scope resolver that applies whenOp before requiring a scoped key
  • use it at the HTTP door, so unrelated operations are no longer rejected
  • use it in relay classification, so malformed direct-ingress items enter the existing poison and dead-letter path rather than bypassing a limit
  • classify foreign shared-queue messages first, preserving the rule that one path never validates another path payload
  • add core coverage for applicable versus unrelated operations and relay coverage for direct-ingress poison classification

Dependency

This PR is intentionally based on #10, which first makes shed-mode budget selection match relay selection. The new helper completes that same applicability contract for scope validation.

Review notes for Alice

The relay does not drop a malformed item silently: it uses the existing poison path, which nacks the head with a reason and increments dead-letter telemetry. A missing scope is immutable in the queued payload and cannot become admissible on retry, while forwarding it would violate the declared per-key limit. Please pay particular attention to ordering in classify: foreign ownership is resolved before payload validation.

Verification

  • cargo test -p gate-core
  • cargo test -p gate-server --lib
  • cargo clippy --workspace --all-targets -- -D warnings
  • cargo fmt --all -- --check
  • git diff --check

@alice-viola

Copy link
Copy Markdown
Contributor

Landed on master via #67 (merge commit 944ee9b) as part of the 62-PR integration — this PR's head commit 3a0a443 is an ancestor of master. GitHub could not mark it merged automatically because its base is fix/shed-applicable-binding-budget, not master. Closing as landed.

@alice-viola alice-viola closed this Sep 7, 2026
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.

2 participants