Spaces:
Running
Running
| import { describe, expect, it } from 'vitest'; | |
| import { classifyResourceFailure } from './errors'; | |
| describe('resource failure classification', () => { | |
| it('recognizes a full KV cache without treating it as device memory loss', () => { | |
| expect(classifyResourceFailure(new Error('kv_cache_full'))).toBe('context-capacity'); | |
| expect(classifyResourceFailure( | |
| new Error('native completion failed'), | |
| ['stopped due to running out of context capacity'], | |
| )).toBe('context-capacity'); | |
| }); | |
| it('recognizes WebGPU and WASM allocation failures', () => { | |
| expect(classifyResourceFailure(new Error('GPUOutOfMemoryError'))).toBe('memory-pressure'); | |
| expect(classifyResourceFailure( | |
| new Error('Failed to load model'), | |
| ['ggml_webgpu: failed to allocate WebGPU KV buffer'], | |
| )).toBe('memory-pressure'); | |
| expect(classifyResourceFailure(new Error('memory access out of bounds'))).toBe('memory-pressure'); | |
| }); | |
| it('does not relabel unrelated runtime failures as memory pressure', () => { | |
| expect(classifyResourceFailure(new Error('Invalid chat template'))).toBeNull(); | |
| }); | |
| }); | |