feat: implement full-platform STT API (v2.3 consensus plan)

Batch+realtime transcription API: faster-whisper engine w/ EngineOwner
(single GPU owner, OOM downgrade chain, persisted attempted_profiles),
hardware-adaptive device manager (T0-T3 VRAM tiers), Redis/in-proc job
queue w/ leases + crash recovery, postprocess (glossary/rules/LLM w/
egress guard), privacy-first result store (UUID keys, source deleted
after transcribe), retention sweeper, API-key auth (HMAC digests,
scopes, job ownership), WebSocket realtime lane (LocalAgreement),
CLI (detect/transcribe/bench/serve/key), Docker, benchmark runner.

127 mock-based tests pass; ruff clean. Includes verification checklist
and autoplan review notes.
This commit is contained in:
2026-08-12 16:01:21 +09:00
parent b7c30f8b71
commit 7327145d7a
82 changed files with 7351 additions and 0 deletions
+90
View File
@@ -0,0 +1,90 @@
"""Device Manager 단위 테스트 — 정밀도 결정, 능력 등급, override."""
from __future__ import annotations
import pytest
from luke_scribe.devices.manager import DeviceManager
from luke_scribe.devices.vram_probe import GpuInfo, SystemInfo
from luke_scribe.errors import DeviceUnavailable
def _sys(gpus: list[GpuInfo], ram_mb: int = 16384) -> SystemInfo:
return SystemInfo(
cpu_count=8, ram_total_mb=ram_mb, ram_free_mb=ram_mb // 2, disk_free_mb=50000, gpus=gpus
)
def _gpu(name: str, cc: str, total_mb: int, free_mb: int, index: int = 0) -> GpuInfo:
return GpuInfo(
index=index,
name=name,
compute_capability=cc,
vram_total_mb=total_mb,
vram_free_mb=free_mb,
driver_version="550",
runtime_cuda=None,
)
class TestPrecision:
def test_cc_7_plus_12gb_free_float16(self):
m = DeviceManager(_sys([_gpu("T4", "7.5", 15360, 14820)]))
p = m.detect()
assert p.selected_compute_type == "float16"
assert p.selected_device == "cuda:0"
def test_cc_7_plus_low_free_int8_float16(self):
m = DeviceManager(_sys([_gpu("L4", "8.9", 24576, 8000)]))
p = m.detect()
assert p.selected_compute_type == "int8_float16"
def test_pascal_1050_int8(self):
m = DeviceManager(_sys([_gpu("GTX 1050", "6.1", 4096, 3584)]))
p = m.detect()
assert p.selected_compute_type == "int8"
def test_no_gpu_cpu_int8(self):
m = DeviceManager(_sys([]))
p = m.detect()
assert p.selected_device == "cpu"
assert p.selected_compute_type == "int8"
assert p.capability_tier == "T0"
assert any("CPU" in w for w in p.warnings)
class TestCapabilityTier:
def test_t3_both_models(self):
m = DeviceManager(_sys([_gpu("A100", "9.0", 81920, 70000)]))
p = m.detect()
assert p.capability_tier == "T3"
assert p.workers >= 1
def test_t1_small_gpu(self):
m = DeviceManager(_sys([_gpu("RTX 3060", "8.6", 12288, 10000)]))
p = m.detect()
assert p.capability_tier in ("T1", "T2", "T3")
class TestOverrides:
def test_explicit_cuda_missing_fails(self):
m = DeviceManager(_sys([]))
with pytest.raises(DeviceUnavailable):
m.detect(device="cuda:0")
def test_explicit_cuda_ok(self):
m = DeviceManager(_sys([_gpu("T4", "7.5", 15360, 14820)]))
p = m.detect(device="cuda:0", compute_type="float16")
assert p.selected_device == "cuda:0"
assert p.selection_source == "explicit"
assert p.selected_compute_type == "float16"
def test_explicit_cpu(self):
m = DeviceManager(_sys([_gpu("T4", "7.5", 15360, 14820)]))
p = m.detect(device="cpu")
assert p.selected_device == "cpu"
def test_explicit_bad_device(self):
m = DeviceManager(_sys([]))
with pytest.raises(DeviceUnavailable):
m.detect(device="tpu:0")