Skip to content

fix(id/serve-proxy): bound credit grants to flow-control limits #8970

Open

Description

@dezren39

Evidence

pkgs/id/src/serve_proxy.rs:52-56 defines finite initial stream and connection credits, but CreditWindow::grant at lines 415-418 uses saturating_add with no upper bound or error result. Each decoded WINDOW_UPDATE can grant a u32 amount (window_update_amount, lines 234-247); repeated valid updates can therefore grow available credit arbitrarily up to u64::MAX. Once the mux uses this primitive, the sender can be authorized to exceed the receiver's bounded in-flight buffers. Saturation only hides integer overflow; it does not enforce a finite credit ceiling.

The relay backpressure design explicitly requires hard finite per-stream and aggregate per-connection byte limits, and says credit returns only as bounded buffer space is released (doc/2026-11-08T11-08-53Z_design_id5813_relay_proxy_protocol/2026-11-08T11-08-53Z_design_id5813_relay_proxy_protocol.md:85-100). The serve-proxy issue #7569 is closed and #5792 remains the protocol design tracker, but neither specifically tracks a maximum-credit guard. All-state searches for CreditWindow, WINDOW_UPDATE, and bounded flow control found no matching implementation issue. The currently open #8951 concerns frame stream/sequence semantics, not credit accounting; no open PR implements this guard.

Why it matters

A peer can repeatedly send valid credit updates and defeat the flow-control bound that is supposed to keep per-stream and per-connection buffering finite. This risks unbounded queued/in-flight data or inconsistent accounting rather than pausing at the receiver's actual capacity.

Acceptance criteria

  • Give each credit window an explicit finite ceiling tied to the effective per-stream/per-connection limits (do not invent a universal deployment limit where the design delegates it to configuration).
  • Make a grant that would exceed the ceiling or overflow an explicit protocol/resource error; do not silently saturate or mutate the window.
  • Ensure mux-level accounting enforces both per-stream and aggregate per-connection limits before accepting DATA or returning credit.
  • Add tests for normal credit return, exact-ceiling grants, over-ceiling/repeated WINDOW_UPDATE grants, and unchanged state after refusal.

Activity

  1. added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    task/small-fixQueue packet kind: bounded fix with reproduction and targeted tests
    source/creatorFiled by the new-issue-creator job
    priority/normalOrdinary priority (the default)
    app/idPackage/app: id (pkgs/ or apps/ in this repo)
    effort/xsTrivial: expected under 30 minutes of work
    on Nov 12, 2026
  2. developing-today commented on Nov 12, 2026

    @developing-today
    Contributor
  3. dezren39 commented on Nov 12, 2026

    @dezren39
    MemberAuthor

    Triage update against current main be6bf9a3af0e04cde337b40c33974601cbcde106:

    • Confirmed CreditWindow::grant is unbounded (pkgs/id/src/serve_proxy.rs:378-418); WINDOW_UPDATE amounts decode as u32 (:234-245). The current code has no mux/channel/DATA-buffer path that applies this primitive, so this is a latent authorization-boundary gap, not a reproduced live buffer-limit bypass.
    • STREAM_WINDOW / CONNECTION_WINDOW are initial credits, not specified maxima. The design requires finite per-stream and aggregate connection ceilings, but this slice has no effective configured/negotiated ceiling source. Setting the initial credit as the maximum would be an unrecorded protocol decision.
    • Full acceptance also calls for mux-level DATA and aggregate accounting; no such mux exists in this source. A bounded primitive-only patch would not satisfy those criteria.
    • Drew's open PR fix(id): validate serve-proxy frame semantics #8971 also edits serve_proxy.rs; I left it untouched and will not open an overlapping PR.

    The gap is confirmed in the standalone primitive, but implementation is blocked until the effective ceiling source / mux scope is settled and the overlapping PR is no longer Drew-owned. Keeping the issue open; no code change or competing PR.

  4. 11 remaining items

  5. removed their assignment
    on Nov 20, 2026
  6. dezren39 commented on Nov 23, 2026

    @dezren39
    MemberAuthor

    Lane felix picking up #8970 for a fresh done-check against current origin/main (the primitive fix landed via PR #10977; verifying what remains).

  7. dezren39 commented on Nov 23, 2026

    @dezren39
    MemberAuthor

    Verification / disposition record — lane felix, 2026-11-23, against origin/main 1845798b7f.

    Criteria 1, 2, and 4 are met on current main (landed by PR #10977, merged 2026-11-17, 9701c173600d; re-verified in source today):

    • Criterion 1 (explicit finite ceiling tied to the effective per-stream/per-connection limits): CreditWindow carries a construction-time ceiling. The built-in per_stream() / per_connection() windows are fixed-size at their configured initial credit, so a WINDOW_UPDATE can only return credit the sender actually consumed; a deployment that negotiates a larger maximum constructs the window with that ceiling via CreditWindow::new(initial, ceiling). No universal deployment limit is invented — the ceiling is parameterized from the effective configuration, as the criterion requires.
    • Criterion 2 (over-ceiling or overflow grant is an explicit error; no silent saturation, no state change): grant() uses checked_add and returns an error when the grant would overflow or push the window past its ceiling; the window is left unchanged on refusal. The old unbounded saturating_add is gone.
    • Criterion 4 (tests): pkgs/id/src/serve_proxy.rs carries the ceiling unit tests plus the credit_is_never_exceeded proptest covering normal credit return, exact-ceiling grants, over-ceiling/repeated WINDOW_UPDATE grants, and unchanged state after refusal. Fresh remote evidence: fleet-command run 45183677781 (developing-today/fleet), conclusion success: cargo test --lib serve_proxy at 1845798b7f — 15 passed / 0 failed.

    Criterion 3 (mux-level accounting) remains open, gated on the mux slice. Verified fresh today: nothing in the repository consumes this primitive yet — CreditWindow is referenced only inside serve_proxy.rs, there is no serve_proxy:: consumer, and no mux/channel DATA path exists in the source. The code's own doc comments assign the remaining work to that future slice ("the leg's reaction to a peer that overruns is an ERROR frame with ErrorReason::CreditOverrun, built by the mux slice"; "grant() … the mux slice maps it to ErrorReason::CreditOverrun"). There is no bounded slice to land here: criterion 3 can only be implemented inside the mux when it lands.

    Resume condition: when the mux slice lands (protocol design tracker #5792), wire the per-stream and aggregate per-connection CreditWindows into its DATA-accept and credit-return paths and map grant() errors to ErrorReason::CreditOverrun; that wiring closes this issue. Until then the issue stays open for criterion 3 only. Lane felix claim released.

  8. dezren39 commented on Nov 23, 2026

    @dezren39
    MemberAuthor

    Picked up by felix — working this now. (Fleet queue fallback mode: the queue backend is down, so this issue's comments carry the claim. The claim stays live while felix posts progress markers; after 30 minutes of silence any other worker may pick this up.)

  9. dezren39 commented on Nov 23, 2026

    @dezren39
    MemberAuthor

    Released by felix (outcome: free). Criteria 1/2/4 verified landed on main (PR #10977; fresh remote run 45183677781: serve_proxy 15/15). Criterion 3 (mux-level accounting) remains, gated on the mux slice landing (tracker #5792); resume then.

  10. added and removed
    queue/claimedQueue worker lifecycle state
    work/assignedQueue worker lifecycle state
    on Nov 23, 2026
  11. dezren39 commented on Nov 23, 2026

    @dezren39
    MemberAuthor

    Picked up via fleet agent next (shortlist rank 5) and re-verified against origin/main 69645882c: criteria 1/2/4 remain landed (PR #10977, merged 2026-11-17). Criterion 3 (mux-level per-stream + aggregate DATA accounting) is still not startable — no mux/channel/DATA consumer exists on current main (only pkgs/id/src/serve_proxy.rs mentions mux, and only in docs); the credit primitive has no DATA path to attach accounting to. Releasing as blocked on the mux slice landing; resume when a mux consumer exists.

  12. dezren39 commented on Nov 23, 2026

    @dezren39
    MemberAuthor

    Lane any-n — done-check against current origin/main (2026-11-23 ~09:30 CST). No PR cut; no repo changes.

    Criteria 1, 2, 4 — hold verified on main (confirming lane felix; PR #10977 remains the landing):

    • pkgs/id/src/serve_proxy.rs:466-535 — CreditWindow carries construction-time ceiling; grant() uses checked_add, errors on overflow or over-ceiling, leaves the window unchanged. per_stream()/per_connection() fixed-size windows (lines 492-496).
    • Tests in-file (lines ~620-670): ceiling unit tests + credit_is_never_exceeded proptest covering normal return, exact-ceiling, over-ceiling/repeated WINDOW_UPDATE, unchanged state on refusal.

    Criterion 3 (mux-level accounting) — still not landable, with one correction to the standing note:

    Remote test evidence — attempted, infra-blocked (4 runs, 0 usable):

    • developing-today-forks/fleet runs 45193794602 (cargo: command not found — default image has no toolchain), 45194898985 (failed, logs unarchived), 45201497822 (failed: rustls build-script ENOENT from the shared cargo-target cache — poisoned cache path, not repo code), 45202698259 (clean CARGO_TARGET_DIR, compiled ~10 min, then failed; logs and fleet-output artifact unretrievable).
    • Repo code never got to link/run in my hands; fleet remote Rust path for pkgs/id is flaky right now. Latest good measured evidence stands: lane felix remote run 45183677781, serve_proxy 15/15.

    Next slice: file the mux-accounting build issue (criterion 3, with Requires: on the mux consumer), or re-run cargo test serve_proxy via a venue with warm cache (laptop lane / nightly) once the runner cache is healthy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    app/idPackage/app: id (pkgs/ or apps/ in this repo)effort/xsTrivial: expected under 30 minutes of workkind/bugSomething isn't working (prefixed form of the classic bug label)priority/normalOrdinary priority (the default)queue/queuedHas a queued queue tasksource/creatorFiled by the new-issue-creator jobtask/small-fixQueue packet kind: bounded fix with reproduction and targeted tests

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions