Speed up rectification scoring without changing results.
Cache work that depends only on the candidate minute, drop unread response fields, and reject windows above 241 candidates before any chart is built. Eleven canonical scenario hashes match 77057a819. Sealed and reported-offset replays match the 2026-10-08 records (changed_trial_count 8 and 581) and are stored as scoring_perf_2026_10_13.
Co-Authored-By: Grok (agent loop)
This commit is contained in:
co-authored by
Grok (agent loop)
parent
74384be024
commit
8e0503f9c0
@@ -330,17 +330,27 @@ async function readEngineJsonTimed(
|
||||
const elapsedMs = Date.now() - started;
|
||||
const data = await response.json().catch(() => null);
|
||||
if (!response.ok) {
|
||||
const kind: EngineCallFailureKind = response.status === 429 ? "busy" : "http_error";
|
||||
const errorText = data && typeof data === "object"
|
||||
? String((data as Record<string, unknown>).error ?? (data as Record<string, unknown>).message ?? "")
|
||||
: "";
|
||||
const errorCode = data && typeof data === "object"
|
||||
? String((data as Record<string, unknown>).error_code ?? "")
|
||||
: "";
|
||||
const tooManyCandidates = response.status === 400
|
||||
&& (errorCode === "too_many_candidates" || errorText.includes("too_many_candidates"));
|
||||
const kind: EngineCallFailureKind = response.status === 429
|
||||
? "busy"
|
||||
: tooManyCandidates
|
||||
? "bad_payload"
|
||||
: "http_error";
|
||||
logEngineCallFailure({
|
||||
path,
|
||||
kind,
|
||||
elapsedMs,
|
||||
httpStatus: response.status,
|
||||
});
|
||||
const message = data && typeof data === "object"
|
||||
? String((data as Record<string, unknown>).error ?? (data as Record<string, unknown>).message ?? `Jyotish API ${response.status}`)
|
||||
: `Jyotish API ${response.status}`;
|
||||
throw new RectificationEngineError(persistenceCodeForKind(kind), message, {
|
||||
const message = errorText || `Jyotish API ${response.status}`;
|
||||
throw new RectificationEngineError(tooManyCandidates ? "too_many_candidates" : persistenceCodeForKind(kind), message, {
|
||||
kind,
|
||||
httpStatus: response.status,
|
||||
retryAfterSeconds: retryAfterFromHeaders(response.headers) ?? undefined,
|
||||
|
||||
Reference in New Issue
Block a user