Skip to content

refactor(sse): declare the semantic-cache read path's parameters - #8646

Merged
diegosouzapw merged 1 commit into
cheaper-inference:release/v3.8.49from
backryun:chore/ts7-types-semantic-cache
Jul 27, 2026
Merged

diegosouzapw merged 1 commit into
cheaper-inference:release/v3.8.49from
backryun:chore/ts7-types-semantic-cache

Conversation

@backryun

Copy link
Copy Markdown
Contributor

Part of #8484. All five diagnostics in chatCore/semanticCache.ts, one cause — the function's own parameter list.

Declared unknown, then read through

clientRawRequest: unknown;      →  clientRawRequest?.headers
reqLogger: unknown;             →  reqLogger.logConvertedResponse(…)
log: unknown;                   →  log?.debug?.(…)
effectiveServiceTier: unknown;  →  passed where a string is expected
body: Record<string, unknown>;  →  body.temperature / body.top_p

The last one is the least obvious: they go into generateSignature(model, conversation, temperature = 0, topP = 1, …), whose defaults infer number, so unknown from the index signature will not fit.

Fix

Named only the fields this read path actually touches:

body: Record<string, unknown> & { temperature?: number; top_p?: number };
clientRawRequest: { headers?: unknown } | null;
reqLogger: { logConvertedResponse: (response: Record<string, unknown>) => void };
effectiveServiceTier: string | null | undefined;
log: { debug?: (...args: unknown[]) => void } | null;

Everything else on the request body stays unknown behind the index signature — this is not an attempt to type the whole chat body, just to stop the parameters lying about what the function does with them.

No casts added, no call site changed, nothing executable touched.

Verification

208 → 203, zero new errors, on a line-number-agnostic diff of the full tsc error set.

  • npm run typecheck:core — clean
  • eslint, check:file-size — clean
  • 401/401 across the 47 cache suites

No new tests

Parameter declarations matching how the arguments were already being used — no control flow altered, no runtime diff. reqLogger.logConvertedResponse is called unconditionally so it is declared required; log.debug is called with ?. so it stays optional, which is what the existing callers already pass.

All five diagnostics in chatCore/semanticCache.ts come from its own parameter
list: five fields declared `unknown` that the body then reads through.

  clientRawRequest: unknown       -> .headers
  reqLogger: unknown              -> .logConvertedResponse(...)
  log: unknown                    -> .debug?.(...)
  effectiveServiceTier: unknown   -> passed where a string is expected
  body: Record<string, unknown>   -> .temperature / .top_p into generateSignature,
                                     whose defaults (= 0, = 1) infer number

Named only the fields this read path actually touches; the rest of the request
body stays `unknown` behind the index signature. No casts, no call sites
changed, nothing executable touched.

208 -> 203, zero new, on a line-number-agnostic diff of the full tsc error set.

No new tests: parameter declarations matching how the arguments were already
being used, with no control flow altered. 401/401 across the 47 cache suites;
typecheck:core, eslint and check:file-size clean.
@backryun
backryun force-pushed the chore/ts7-types-semantic-cache branch from 33e5ef3 to 4d5c0bb Compare July 26, 2026 20:53
@diegosouzapw

Copy link
Copy Markdown
Collaborator

Validated in local merge-train /tmp/train1d-20260727-090022-suite.log on .113 @ 029cdf4215cf465f0e1716ac9f84a84692b1e881 (full unit suite green on CI-equivalent host)

@diegosouzapw
diegosouzapw merged commit c544c2c into cheaper-inference:release/v3.8.49 Jul 27, 2026
15 checks passed
@backryun
backryun deleted the chore/ts7-types-semantic-cache branch July 27, 2026 14:38
@diegosouzapw diegosouzapw mentioned this pull request Jul 28, 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