mirror of
https://github.com/stablyai/orca.git
synced 2026-11-18 11:54:46 +00:00
fix(usage): rebuild corrupt per-source usage cache records instead of failing every scan (#42418)
A null or non-object entry in a per-source usage sidecar made the Codex, Muse and OpenCode scans throw, and since a failed scan never rewrites the sidecar the failure repeated on every refresh. Records missing their sessions/dailyAggregates projections were either reused as zero usage (Muse/OpenCode) or crashed the Codex reuse and incremental-resume paths. - readUsageSourceCache drops entries that are not plain objects. - Muse and OpenCode normalizers drop records lacking projection arrays so the source is reparsed. - Codex requires both projection arrays before reusing or resuming a cached rollout record. Fixes #42413 Co-authored-by: Neil <neil@stably.ai>
This commit is contained in:
@@ -8,11 +8,18 @@ import type {
|
||||
export function normalizeOpenCodeUsagePersistedDatabases(
|
||||
databases: OpenCodeUsagePersistedDatabase[] | undefined
|
||||
): OpenCodeUsagePersistedDatabase[] {
|
||||
return (databases ?? []).map((database) => ({
|
||||
...database,
|
||||
sessions: (database.sessions ?? []).map(normalizeSessionCost),
|
||||
dailyAggregates: (database.dailyAggregates ?? []).map(normalizeDailyAggregateCost)
|
||||
}))
|
||||
// A record missing a projection would be reused as zero usage; drop it so the scanner rereads the database.
|
||||
return (databases ?? []).flatMap((database) =>
|
||||
Array.isArray(database.sessions) && Array.isArray(database.dailyAggregates)
|
||||
? [
|
||||
{
|
||||
...database,
|
||||
sessions: database.sessions.map(normalizeSessionCost),
|
||||
dailyAggregates: database.dailyAggregates.map(normalizeDailyAggregateCost)
|
||||
}
|
||||
]
|
||||
: []
|
||||
)
|
||||
}
|
||||
|
||||
export function normalizeDailyAggregateCost(
|
||||
|
||||
Reference in New Issue
Block a user