You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Two declared types are narrower than the values they describe — found by the first typecheck of worker code
6d44ac7 (#599) put worker sources and tests under tsc for the first time. Two production type defects surfaced and were deliberately left for their own ticket.
workers/api/src/lib/usage.ts:319 — the declared totals shape lacks cacheReadTokens and cacheWriteTokens, which aggregateUsage computes and returns.
The console already works around it: store/console/src/pages/Usage.tsx:35 declares its own parallel shape with those fields optional. So the data crosses the wire, the UI reads it, and the type says it does not exist — which means the compiler cannot help anyone who touches either side.
This is the same drop-on-the-way-out shape #547 fixed for daily. Second instance, same file.
2. JsonSchema.properties[].type is a scalar where the format uses an array
workers/api/src/lib/connectors/types.ts:111 declares type as string. JSON Schema draft-07 permits string[], and behaviourToolSchemauses the array form. So a legal schema this codebase itself produces does not satisfy the type meant to describe it.
Why they belong together
Both are the same defect: a declared type narrower than the value it describes, surviving because nothing compiled the code that would have caught it. Both were invisible for the same reason and became visible on the same day, which is the argument for one guard rather than two fixes.
It is also the type-system instance of the pattern this batch has been removing everywhere else — a stored or declared fact that the runtime contradicts (#587runtime.status, #588RunHealth, #592attempts, #596waiting_until). Here the contradiction is between a type and its own producer.
Acceptance criteria
UsageSummary["totals"] carries every field aggregateUsage returns, and Usage.tsx consumes that type instead of a parallel declaration. The parallel shape is the tell — remove it, do not sync it.
JsonSchema.properties[].type accepts string | string[], and behaviourToolSchema typechecks against it without a cast.
Inferred: that other response types share the parallel-declaration habit. AC4 exists to measure it — it was not measured, and if the answer is "just these two", say so and close that arm rather than manufacturing work.
Two declared types are narrower than the values they describe — found by the first typecheck of worker code
6d44ac7(#599) put worker sources and tests undertscfor the first time. Two production type defects surfaced and were deliberately left for their own ticket.1.
UsageSummary["totals"]omits fieldsaggregateUsagereturnsworkers/api/src/lib/usage.ts:319— the declaredtotalsshape lackscacheReadTokensandcacheWriteTokens, whichaggregateUsagecomputes and returns.The console already works around it:
store/console/src/pages/Usage.tsx:35declares its own parallel shape with those fields optional. So the data crosses the wire, the UI reads it, and the type says it does not exist — which means the compiler cannot help anyone who touches either side.This is the same drop-on-the-way-out shape #547 fixed for
daily. Second instance, same file.2.
JsonSchema.properties[].typeis a scalar where the format uses an arrayworkers/api/src/lib/connectors/types.ts:111declarestypeasstring. JSON Schema draft-07 permitsstring[], andbehaviourToolSchemauses the array form. So a legal schema this codebase itself produces does not satisfy the type meant to describe it.Why they belong together
Both are the same defect: a declared type narrower than the value it describes, surviving because nothing compiled the code that would have caught it. Both were invisible for the same reason and became visible on the same day, which is the argument for one guard rather than two fixes.
It is also the type-system instance of the pattern this batch has been removing everywhere else — a stored or declared fact that the runtime contradicts (#587
runtime.status, #588RunHealth, #592attempts, #596waiting_until). Here the contradiction is between a type and its own producer.Acceptance criteria
UsageSummary["totals"]carries every fieldaggregateUsagereturns, andUsage.tsxconsumes that type instead of a parallel declaration. The parallel shape is the tell — remove it, do not sync it.JsonSchema.properties[].typeacceptsstring | string[], andbehaviourToolSchematypechecks against it without a cast.aggregateUsage— a compile-time assertion is now genuinely enforced after Three tsconfigs exclude test files and CI typechecks none of them, so a type-level guard in any worker test is inert #599, so this is the first issue that can rely on one.Verified vs inferred
file:linecitations; that the console declares a parallel shape atUsage.tsx:35; thatbehaviourToolSchemauses the array form; that The Usage chart shows 4.2M tokens for the day the 250M ceiling was tripped — the daily series drops the cache columns, which are 98.2% of what the ceiling counts #547 fixed the same shape fordaily.