Revert "fix(memory): bound OOM-prone accumulators (#10179)" (#10255)

Co-authored-by: Orca <help@stably.ai>
This commit is contained in:
Neil
2026-07-23 18:35:31 -07:00
committed by GitHub
co-authored by Orca
parent 6eb70d8370
commit aab112933e
1577 changed files with 15167 additions and 91655 deletions
@@ -2,10 +2,7 @@ import { describe, expect, it, vi } from 'vitest'
import {
CODEX_APP_SERVER_CAPABILITY_RETRY_INTERVAL_MS,
CodexAppServerCapabilityCache,
getCodexAppServerHostKey,
MAX_CODEX_APP_SERVER_CAPABILITY_HOSTS,
MAX_CODEX_APP_SERVER_HOST_KEY_CODE_UNITS,
type CodexAppServerHostKey
getCodexAppServerHostKey
} from './codex-app-server-capability-cache'
const unsupportedError = new Error('unsupported')
@@ -117,48 +114,4 @@ describe('CodexAppServerCapabilityCache', () => {
expect(getCodexAppServerHostKey({ kind: 'wsl', distro: 'Ubuntu' })).toBe('wsl:Ubuntu')
expect(getCodexAppServerHostKey({ kind: 'wsl', distro: 'Debian' })).toBe('wsl:Debian')
})
it('retains exactly the host limit and LRU-evicts on the next host', () => {
const cache = new CodexAppServerCapabilityCache()
const hostKeys = Array.from(
{ length: MAX_CODEX_APP_SERVER_CAPABILITY_HOSTS },
(_, index): CodexAppServerHostKey => `wsl:distro-${index}`
)
hostKeys.forEach((hostKey) => cache.rememberUnsupported(hostKey, 0))
expect(cache.shouldTry(hostKeys[0], 1)).toBe(false)
cache.rememberUnsupported('wsl:overflow', 0)
expect(cache.shouldTry(hostKeys[0], 1)).toBe(false)
expect(cache.shouldTry(hostKeys[1], 1)).toBe(true)
expect(cache.shouldTry('wsl:overflow', 1)).toBe(false)
})
it('bounds oversized generated and direct host keys', () => {
const exactDistro = 'x'.repeat(MAX_CODEX_APP_SERVER_HOST_KEY_CODE_UNITS - 'wsl:'.length)
const oversizedDistro = `${exactDistro}x`
expect(getCodexAppServerHostKey({ kind: 'wsl', distro: exactDistro })).toBe(
`wsl:${exactDistro}`
)
const firstDigest = getCodexAppServerHostKey({ kind: 'wsl', distro: oversizedDistro })
expect(firstDigest).toMatch(/^wsl:sha256:[a-f0-9]{64}$/)
expect(getCodexAppServerHostKey({ kind: 'wsl', distro: oversizedDistro })).toBe(firstDigest)
const directOversized = `wsl:${oversizedDistro}` as CodexAppServerHostKey
const cache = new CodexAppServerCapabilityCache()
cache.rememberUnsupported(directOversized, 0)
expect(cache.shouldTry(directOversized, 1)).toBe(false)
})
it('clear forgets supported and unsupported host state', () => {
const cache = new CodexAppServerCapabilityCache()
cache.rememberSupported('native')
cache.rememberUnsupported('wsl:Ubuntu', 0)
cache.clear()
expect(cache.isKnownSupported('native')).toBe(false)
expect(cache.shouldTry('wsl:Ubuntu', 1)).toBe(true)
})
})