Skip to content

[TS7] fix(types): normalize executor result contracts - #10256

Merged
diegosouzapw merged 1 commit into
diegosouzapw:release/v3.8.50from
backryun:fix/ts7-executor-result-contract
Aug 14, 2026
Merged

diegosouzapw merged 1 commit into
diegosouzapw:release/v3.8.50from
backryun:fix/ts7-executor-result-contract

Conversation

@backryun

Copy link
Copy Markdown
Contributor

Summary

  • validate unknown executor outputs before consuming their response envelope
  • normalize the 401 credential-refresh retry through the same executor-result contract
  • declare the internal execution credential and semaphore metadata contract without changing runtime response shapes

TS7 impact

  • TypeScript 6: 28 -> 16 diagnostics (12 removed, 0 added)
  • TypeScript 7.0.2: 28 -> 16 diagnostics (12 removed, 0 added)

Validation

  • node --import tsx/esm --test tests/unit/chatcore-upstream-timeouts.test.ts (5/5)
  • GitHub credential refresh integration case (1/1)
  • node --import tsx/esm --test tests/unit/chatcore-execution-credentials.test.ts (15/15)
  • targeted ESLint
  • npm run check:file-size
  • git diff --check

@diegosouzapw

Copy link
Copy Markdown
Owner

LGTM — type hardening. The normalizeExecutorResult strict guard and ChatCoreExecutorResult metadata type match what runtime already attached/read. instanceof Response is stricter than duck-typing but no executor in-tree returns a non-global-Response. Tests prove malformed output throws. Ready to merge.

@backryun
backryun force-pushed the fix/ts7-executor-result-contract branch from 12d9df3 to dbcf5ba Compare August 13, 2026 22:38
@diegosouzapw
diegosouzapw merged commit 9da4e24 into diegosouzapw:release/v3.8.50 Aug 14, 2026
4 of 5 checks passed
@diegosouzapw

Copy link
Copy Markdown
Owner

Merged into release/v3.8.50 — thank you @backryun! Validated on a combined merge-train (static gates + every affected test + vitest) alongside 9 sibling PRs before landing.

diegosouzapw added a commit that referenced this pull request Aug 14, 2026
#10373)

The `instanceof Response` guard from #10256 broke two ways:

1. `instanceof` is nominal against `globalThis.Response`, but proxyFetch dispatches
   through the npm undici package's fetch, whose Response is a different class — so
   valid upstream responses were rejected as contract violations. Replaced with
   `isResponseLike()` (instanceof fast path + structural brand/member probe); genuinely
   malformed shapes still throw.
2. The thrown error had no `.status`, so it fell through to chatCore's BAD_GATEWAY
   default — an internal defect was treated as a flaky provider, cooling the connection
   down and retrying forever. It now carries status 500 + `executor_contract_violation`,
   registered as request-scoped and terminal (no cooldown, no breaker, no retry).

batch_api.test.ts went from exit 124 (infinite hang, pinning Unit shard 4/4 in every
open PR) to exit 0, 22/22 passing.

Closes #10360
@backryun
backryun deleted the fix/ts7-executor-result-contract branch August 14, 2026 17:42
tkgo11 pushed a commit to tkgo11/OmniRoute that referenced this pull request Sep 23, 2026
diegosouzapw#10373)

The `instanceof Response` guard from diegosouzapw#10256 broke two ways:

1. `instanceof` is nominal against `globalThis.Response`, but proxyFetch dispatches
   through the npm undici package's fetch, whose Response is a different class — so
   valid upstream responses were rejected as contract violations. Replaced with
   `isResponseLike()` (instanceof fast path + structural brand/member probe); genuinely
   malformed shapes still throw.
2. The thrown error had no `.status`, so it fell through to chatCore's BAD_GATEWAY
   default — an internal defect was treated as a flaky provider, cooling the connection
   down and retrying forever. It now carries status 500 + `executor_contract_violation`,
   registered as request-scoped and terminal (no cooldown, no breaker, no retry).

batch_api.test.ts went from exit 124 (infinite hang, pinning Unit shard 4/4 in every
open PR) to exit 0, 22/22 passing.

Closes diegosouzapw#10360
muhamadgalihsaputra pushed a commit to niyatna/NiyatnaRoute that referenced this pull request Sep 27, 2026
muhamadgalihsaputra pushed a commit to niyatna/NiyatnaRoute that referenced this pull request Sep 27, 2026
diegosouzapw#10373)

The `instanceof Response` guard from diegosouzapw#10256 broke two ways:

1. `instanceof` is nominal against `globalThis.Response`, but proxyFetch dispatches
   through the npm undici package's fetch, whose Response is a different class — so
   valid upstream responses were rejected as contract violations. Replaced with
   `isResponseLike()` (instanceof fast path + structural brand/member probe); genuinely
   malformed shapes still throw.
2. The thrown error had no `.status`, so it fell through to chatCore's BAD_GATEWAY
   default — an internal defect was treated as a flaky provider, cooling the connection
   down and retrying forever. It now carries status 500 + `executor_contract_violation`,
   registered as request-scoped and terminal (no cooldown, no breaker, no retry).

batch_api.test.ts went from exit 124 (infinite hang, pinning Unit shard 4/4 in every
open PR) to exit 0, 22/22 passing.

Closes diegosouzapw#10360
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