Skip to content

fix(provider): drop chunk frames processed while disconnected - #1646

Merged
Gajesh2007 merged 1 commit into
masterfrom
codex/overnight-provider-emission
Oct 28, 2026
Merged

Gajesh2007 merged 1 commit into
masterfrom
codex/overnight-provider-emission

Conversation

@jonathan308

@jonathan308 jonathan308 commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator

When ChunkBatcher processes a small response frame between the old session's unbind and a replacement bind, it can retain that frame until a later flush sends it through the replacement connection. Reject frames at the queue's admission point whenever no sink is bound, matching the existing disconnected-flush drop behavior.

The check runs on the existing serial queue. Bound-session batching, the 1,400-byte flush threshold, frame order, terminal barriers and stale-connection teardown behavior are unchanged. This fixes the demonstrated unbound interval; it is not a request/session-generation fence. An old request's frame processed after a replacement has already bound still passes the check.

Before

flowchart TD
    A["Old sink holds the serial queue"] --> B["Queue: unbind old → enqueue frame → bind new"]
    B --> C["Release old sink; unbind clears pending"]
    C --> D["enqueue: append while sink is nil"]
    D --> E["bind replacement before deferred flush"]
    E --> F["flushPendingOnQueue sends old frame to replacement"]
    classDef queue fill:#dbeafe,stroke:#2563eb,color:#172554
    classDef defect fill:#fee2e2,stroke:#dc2626,color:#450a0a
    class A,B,C,E queue
    class D,F defect
Loading

After

flowchart TD
    A["enqueue closure executes on serial queue"] --> B{"Session sink bound?"}
    B -- No --> C["Drop frame before pending append"]
    B -- Yes --> D["Existing append and threshold/deferred flush"]
    C --> E["Replacement bind receives only later admitted frames"]
    D --> F["Existing sink and terminal ordering"]
    classDef queue fill:#dbeafe,stroke:#2563eb,color:#172554
    classDef safe fill:#dcfce7,stroke:#16a34a,color:#052e16
    class A,B,D queue
    class C,E,F safe
Loading

Evidence and validation

  • Deterministic regression uses the actual ChunkBatcher, real NWConnection identity objects and a semaphore-controlled sink. The baseline delivers stale frames for sizes 0, 1, 64 and 1,399 bytes; 1,400/4,096-byte controls already drop them. The fixed source passes all cases. The reproduction controls the real queue without sleeps or private queue access.
  • Five new tests cover the reconnect schedule, unbound flush, stale teardown, 1/200-frame ordering, and four concurrent producers with 40 frames each. The actual-source component suite passes Thread Sanitizer.
  • Built the complete provider test products with the locked dependencies: swift build --build-tests --package-path provider-swift --build-system native --scratch-path <isolated-scratch> --jobs 4. Staged source-matched resources using scripts/stage-test-metallib.sh <isolated-scratch>/arm64-apple-macosx/debug.
  • The rebuilt full-package selection passed 26 tests, zero skips, with isolated daemon/model/verified-weight state and the repository test watchdog. Selector: ChunkBatcherLifecycleTests|ChunkSenderTests|CoordinatorIntegrationTests|cancellationRegistryCancelsAndRemovesToken|CancelledSettlementLifecycleTests, using swift test --skip-build --disable-automatic-resolution --no-parallel with the same package/scratch/build-system arguments. This includes real loopback WebSocket delivery/reconnect, NaCl encryption/cancellation, terminal ordering and control-path fallback.
  • make docs-impact-check BASE=8effff7f7067fec70b2e3b58de0a4ba47ea3986c, make docs-check, make changelog-check, make changelog-preview, and git diff --check pass.
  • Independent correctness/refactor review retained the minimal guard and clarified its scope in the canonical inference documentation.

Local validation used Apple Swift 6.4 on arm64 macOS, provider base 8effff7f, MLX host/kernel source 31f550af, and metallib SHA-256 6ccc62966bb452b767fbd7261175b06c7653259a25f657524f1c1ef71f556d45. No full-model GPU inference, production latency or throughput claim is made. This PR remains in draft for review.

CI status

At commit bc67c1a2, Provider Unit Tests, Provider SDK Tests, Provider Prompt Parity, the aggregate Provider Tests gate, Release Integrity, Commit Signatures, Docs Lint and Docs Impact all pass. No code-review findings are present in the checked GitHub snapshot.

Outstanding external statuses: Darkbloom sandbox integrity reports successful execution but no verified execution receipt; the two Vercel projects d-inference and d-inference-console-ui-dev report failures. These checks have not been disabled or bypassed. This is a draft with validated source behavior and passing provider CI, not a claim that every repository gate is green.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

@vercel

vercel Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
d-inference Error Error Oct 28, 2026 6:33am UTC
d-inference-console-ui-dev Error Error Oct 28, 2026 6:33am UTC
d-inference-landing Ready Ready Preview Oct 28, 2026 6:33am UTC
darkbloom-status Ready Ready Preview Oct 28, 2026 6:33am UTC
eigen-homepages-darkbloom Ready Ready Preview Oct 28, 2026 6:33am UTC

Request Review

@github-actions

github-actions Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Threat model review — advisory

Reviewed head bc67c1a20dc5 against base 8effff7f7067.

Review not completed for this head. Previous findings are superseded, not confirmed resolved.
Service returned HTTP 409; no automatic paid retry

Reviewers: anthropic/claude-sonnet-5.5: first pass completed

Models: budgeted Sonnet / selective Opus / selective Sol 6.1. Findings require human validation; this review never requests changes or blocks merging.

Human review required: CI did not complete the security review. A maintainer must review the saved findings and remaining scope. A green advisory job is not security clearance; do not manually rerun the paid scan.

Failure diagnostics: STATE_WRITE_FAILED

Coverage: 28/28 source units; cross-file integration complete. 2 selected depth batch(es) pending. All threat definitions indexed; relevant full definitions selected. Unchanged callers are not scanned.

Cost this run: $0.0000 reported, $0.0000 reserved with unknown cost; 0 paid request(s), 0 reused batch(es), 0 provider cache-hit tokens.

Saved findings and earlier report · Historical findings are not confirmed resolved.

Bedrock: 10 request(s), 471841 uncached + 0 cache-read + 0 cache-write input / 7409 output tokens; 0 request(s) with unknown usage. OpenRouter backup used 0 time(s). Dollar amounts above cover OpenRouter only; AWS billing is reconciled separately.
Workload allowance: 12 native request(s), including one shared response repair; 500 emergency ceiling. Selected depth and integration rounds are admitted as their scope becomes known.

@Gajesh2007
Gajesh2007 merged commit fc2cd13 into master Oct 28, 2026
28 of 31 checks passed
jonathan308 added a commit that referenced this pull request Oct 28, 2026
Freshness refresh: master gained #1637, #1639, #1640, #1646 and #1655. The merge has no conflicts and leaves the SDK pin unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jonathan308 added a commit that referenced this pull request Oct 28, 2026
Freshness refresh: master gained #1637, #1639, #1640, #1646 and #1655. The merge has no conflicts and leaves the SDK pin unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jonathan308 added a commit that referenced this pull request Oct 28, 2026
Freshness refresh: master gained #1637, #1639, #1640, #1646 and #1655. The merge has no conflicts and leaves the SDK pin unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jonathan308 added a commit that referenced this pull request Oct 28, 2026
Freshness refresh: master gained #1637, #1639, #1640, #1646 and #1655. The merge has no conflicts and leaves the SDK pin unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jonathan308 added a commit that referenced this pull request Oct 28, 2026
Freshness refresh: master gained #1637, #1639, #1640, #1646 and #1655. The merge has no conflicts and leaves the SDK pin unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jonathan308 added a commit that referenced this pull request Oct 28, 2026
Freshness refresh: master gained #1637, #1639, #1640, #1646 and #1655. The merge has no conflicts and leaves the SDK pin unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jonathan308 added a commit that referenced this pull request Oct 28, 2026
Freshness refresh: master gained #1637, #1639, #1640, #1646 and #1655. The merge has no conflicts and leaves the SDK pin unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jonathan308 added a commit that referenced this pull request Oct 29, 2026
Brings in the SSD cache changes merged since this branch's base (#1642,
#1647, #1648, #1649, #1651) plus #1639, #1640 and #1646. The only conflict
was the docs/reference/ssd-kv-cache.md table: keep this PR's victim
selection row and master's updated maintenance sweep row.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch had an error being deployed

2 failed and 3 active deployments
Preview – d-inference-landing — bc67c1a2 Deployed Oct 28, 2026 by vercel[bot]
Preview – eigen-homepages-darkbloom — bc67c1a2 Deployed Oct 28, 2026 by vercel[bot]
Preview – d-inference — bc67c1a2 Deployed Oct 28, 2026 by vercel[bot]
Preview – darkbloom-status — bc67c1a2 Deployed Oct 28, 2026 by vercel[bot]
Preview – d-inference-console-ui-dev — bc67c1a2 Deployed Oct 28, 2026 by vercel[bot]
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