feat: update gateway pool and usage flows

This commit is contained in:
fawney19
2026-05-12 21:05:11 +08:00
parent 38012c62ff
commit d1a47c068e
18 changed files with 582 additions and 328 deletions
@@ -24,7 +24,7 @@ function buildCandidate(
}
describe('poolTrace', () => {
it('keeps only pool nodes that actually participated in scheduling audit fallback', () => {
it('keeps pool audit nodes even when they were not attempted', () => {
const attempts = buildPoolAttemptCandidatesFromAudit([], [
{
candidate_index: 0,
@@ -68,11 +68,13 @@ describe('poolTrace', () => {
},
], 'req-1')
expect(attempts).toHaveLength(2)
expect(attempts).toHaveLength(3)
expect(attempts[0].key_id).toBe('key-success')
expect(attempts[0].status).toBe('success')
expect(attempts[1].key_id).toBe('key-skipped')
expect(attempts[1].status).toBe('skipped')
expect(attempts[2].key_id).toBe('key-available')
expect(attempts[2].status).toBe('available')
})
it('preserves real trace attempts even when audit status is non-standard', () => {
@@ -12,11 +12,6 @@ export const TIMELINE_STATUS: CandidateRecord['status'][] = [
'stream_interrupted',
]
const POOL_HIDDEN_STATUS = new Set<CandidateRecord['status']>([
'available',
'unused',
])
const PROVIDER_TYPE_LIKE_NAMES = new Set<string>([
'codex',
'kiro',
@@ -40,9 +35,7 @@ export const makeAttemptKey = (candidateIndex: number, retryIndex: number): stri
}
export const isPoolParticipatedCandidate = (candidate: CandidateRecord): boolean => {
if (POOL_HIDDEN_STATUS.has(candidate.status)) return false
if (candidate.status === 'pending' && !candidate.started_at) return false
return true
return TIMELINE_STATUS.includes(candidate.status)
}
export const isAttemptedCandidate = (