Skip to content

fix(routing): evict affinity after terminal stream EOF - #9184

Merged
diegosouzapw merged 1 commit into
diegosouzapw:release/v3.8.50from
Zartharas:fix/8928-stream-early-eof-affinity
Aug 6, 2026
Merged

diegosouzapw merged 1 commit into
diegosouzapw:release/v3.8.50from
Zartharas:fix/8928-stream-early-eof-affinity

Conversation

@Zartharas

Copy link
Copy Markdown
Contributor

Summary

  • evict a matching session-affinity pin when a non-Antigravity stream ends with terminal STREAM_EARLY_EOF
  • preserve the existing single same-connection retry before eviction
  • use the connection-guarded affinity helper so a pin that moved to another connection is not deleted
  • add focused regression coverage for retry ordering, error classification, and guarded eviction

Related Issues

Validation

Choose the change type and focused loop from the
Contribution Golden Path. The full unit suite,
Vitest, the 60% coverage gate, and the production build run in CI on this PR:

  • Change type: routing / resilience
  • Focused test: node --import tsx/esm --test tests/unit/stream-early-eof-affinity-8928.test.ts
    • 3 passed
    • 0 failed
  • npm run lint — delegated to PR CI; the focused checkout did not install the full dependency tree
  • Reconciled with release/v3.8.50 at fc35dc248f46354e80fdcdaa551e6598abcf5124
  • Production-code changes include a new automated test
  • SonarQube PR analysis is green or remaining issues are documented below — pending CI

Additional check:

  • git diff --check

Tests Added Or Updated

  • tests/unit/stream-early-eof-affinity-8928.test.ts
    • verifies eviction occurs only after the bounded retry is unavailable or exhausted
    • verifies both STREAM_EARLY_EOF and stream_early_eof are recognized
    • verifies the connection-matched helper is used
    • verifies the branch does not perform an unguarded affinity deletion

Coverage Notes

The focused test covers the terminal early-EOF branch, including retry ordering and the guarded session-affinity eviction call.

The underlying helper already has database-level tests confirming that it removes only a pin matching the failed connection and preserves a pin pointing at another connection.

Reviewer Notes

The change does not mark the connection unavailable and does not alter the existing bounded retry behavior.

It only removes the persisted affinity pin after the request is about to return the terminal early-EOF response. The current request still receives the original 502, while the next client retry is no longer forced back to the failed connection.

@Zartharas
Zartharas marked this pull request as ready for review August 2, 2026 02:35
@Zartharas
Zartharas requested a review from diegosouzapw as a code owner August 2, 2026 02:35
@diegosouzapw
diegosouzapw merged commit def958b into diegosouzapw:release/v3.8.50 Aug 6, 2026
3 checks passed
diegosouzapw added a commit that referenced this pull request Aug 6, 2026
…as in CI

The base kept moving during the reconcile cycle: #9184 grew
src/sse/handlers/chat.ts 1857->1877 and #9005 grew
open-sse/executors/default.ts 1027->1042. Re-measured on the merged
tree; gate back to 0 violations.
diegosouzapw added a commit that referenced this pull request Aug 6, 2026
…9554)

* fix(quality): reconcile inherited file-size drift on the release tip

13 files sit above their frozen LOC on the clean tip 8180b49
(measured by the gate itself). The PR-mode base-relative check (#8522)
correctly lets innocent PRs pass, but per-PR rebaselines were lost
across successive conflict resolutions of this hot file during the
08-05/06 merge batch — so the absolute mode (nightly, local runs) is
permanently red and stops distinguishing real growth from inherited
drift.

Frozen values updated to the measured tip, each annotated with the
merged PR that grew the file (#9024 #9324 #9329 #9193 #9332 #9228
#9236 #9314 #9260 #8934 #9196 #9163); executors default.ts and kiro.ts
(above the 1000 cap with no frozen entry) join the frozen set.

* fix(quality): prune orphaned ESLint suppressions and clear the 5 unsuppressed errors

The 'No new ESLint warnings' job reds the whole queue with exit 2:
'There are suppressions left that do not occur anymore' — the 08-05
merge batch removed code whose violations were frozen in
eslint-suppressions.json, leaving orphaned entries (673->670 files,
4338->4333 violations after eslint --prune-suppressions).

The full-tree run also surfaced 5 real unsuppressed errors merged with
the batch, fixed here instead of suppressed (new violations must be
fixed, per policy): 4x no-explicit-any in
tests/unit/catalog-order-contract.test.ts ((conn as any).id -> typed
cast) and 1x react/no-unescaped-entities in the agent-bridge
SetupWizard (#9095).

Also restores the _comment policy header the successive hot-file
conflict resolutions had dropped (TS7 debt freeze provenance + prune
policy).

* fix(quality): absorb the two file-size growths merged while this PR was in CI

The base kept moving during the reconcile cycle: #9184 grew
src/sse/handlers/chat.ts 1857->1877 and #9005 grew
open-sse/executors/default.ts 1027->1042. Re-measured on the merged
tree; gate back to 0 violations.

* fix(tests): move the orphaned RTL ratchet test to a collected path as node:test

#8828 added tests/unit/scripts/check-rtl-ratchet.test.ts — a path no
runner collects (the node:test globs enumerate an explicit subdir list
without scripts/, and vitest.config.ts never included it), so the file
NEVER ran and the test-discovery orphan gate reds the queue. Moved to
tests/unit/ (collected by node:test) and converted from vitest
describe/it/expect to node:test+assert to match the runner and the
sibling check-*.test.ts files. 5/5 green under the real runner.

---------

Co-authored-by: diegosouzapw <diegosouzapw@users.noreply.github.com>
@Zartharas
Zartharas deleted the fix/8928-stream-early-eof-affinity branch September 24, 2026 13:26
muhamadgalihsaputra pushed a commit to niyatna/NiyatnaRoute that referenced this pull request Sep 27, 2026
…9184)

Validated in local merge-train T4 (HouMinXi+Zartharas+Andrian+artickc)
muhamadgalihsaputra pushed a commit to niyatna/NiyatnaRoute that referenced this pull request Sep 27, 2026
…iegosouzapw#9554)

* fix(quality): reconcile inherited file-size drift on the release tip

13 files sit above their frozen LOC on the clean tip 30be158
(measured by the gate itself). The PR-mode base-relative check (diegosouzapw#8522)
correctly lets innocent PRs pass, but per-PR rebaselines were lost
across successive conflict resolutions of this hot file during the
08-05/06 merge batch — so the absolute mode (nightly, local runs) is
permanently red and stops distinguishing real growth from inherited
drift.

Frozen values updated to the measured tip, each annotated with the
merged PR that grew the file (diegosouzapw#9024 diegosouzapw#9324 diegosouzapw#9329 diegosouzapw#9193 diegosouzapw#9332 diegosouzapw#9228
diegosouzapw#9236 diegosouzapw#9314 diegosouzapw#9260 diegosouzapw#8934 diegosouzapw#9196 diegosouzapw#9163); executors default.ts and kiro.ts
(above the 1000 cap with no frozen entry) join the frozen set.

* fix(quality): prune orphaned ESLint suppressions and clear the 5 unsuppressed errors

The 'No new ESLint warnings' job reds the whole queue with exit 2:
'There are suppressions left that do not occur anymore' — the 08-05
merge batch removed code whose violations were frozen in
eslint-suppressions.json, leaving orphaned entries (673->670 files,
4338->4333 violations after eslint --prune-suppressions).

The full-tree run also surfaced 5 real unsuppressed errors merged with
the batch, fixed here instead of suppressed (new violations must be
fixed, per policy): 4x no-explicit-any in
tests/unit/catalog-order-contract.test.ts ((conn as any).id -> typed
cast) and 1x react/no-unescaped-entities in the agent-bridge
SetupWizard (diegosouzapw#9095).

Also restores the _comment policy header the successive hot-file
conflict resolutions had dropped (TS7 debt freeze provenance + prune
policy).

* fix(quality): absorb the two file-size growths merged while this PR was in CI

The base kept moving during the reconcile cycle: diegosouzapw#9184 grew
src/sse/handlers/chat.ts 1857->1877 and diegosouzapw#9005 grew
open-sse/executors/default.ts 1027->1042. Re-measured on the merged
tree; gate back to 0 violations.

* fix(tests): move the orphaned RTL ratchet test to a collected path as node:test

diegosouzapw#8828 added tests/unit/scripts/check-rtl-ratchet.test.ts — a path no
runner collects (the node:test globs enumerate an explicit subdir list
without scripts/, and vitest.config.ts never included it), so the file
NEVER ran and the test-discovery orphan gate reds the queue. Moved to
tests/unit/ (collected by node:test) and converted from vitest
describe/it/expect to node:test+assert to match the runner and the
sibling check-*.test.ts files. 5/5 green under the real runner.

---------

Co-authored-by: diegosouzapw <diegosouzapw@users.noreply.github.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.

fix: STREAM_EARLY_EOF does not evict session affinity, pinning retries to failed account

2 participants