claude-sonnet-5 review Phase 3 (by gpt-5.3-codex)
Quality Gate / gate (push) Failing after 11s

This commit is contained in:
Jim Lancaster
2026-08-20 15:36:17 -05:00
parent 796216087c
commit 450d33d507
14 changed files with 205 additions and 126 deletions
+71
View File
@@ -10,9 +10,11 @@ from transcription.db.models import Document
from transcription.db.models import Job
from transcription.db.models import JobSource
from transcription.db.models import Source
from transcription.errors import ErrorCategory
from transcription.services.people import store_person_portrait
from transcription.services.sources import source_mime_type
from transcription.services.store import SourceStorageError
from transcription.services.store import StoredSourceFile
from transcription.services.store import create_document_job
from transcription.services.store import create_job_for_document
from transcription.services.store import store_source_file
@@ -152,3 +154,72 @@ async def test_source_storage_rejects_unsupported_format(tmp_path):
with pytest.raises(SourceStorageError):
await store_source_file(filename="page.txt", file_bytes=b"text", settings=settings)
@pytest.mark.asyncio
async def test_create_document_job_db_failure_maps_to_internal_category(tmp_path, monkeypatch):
settings = Settings(openrouter_api_key="test-key", upload_dir=tmp_path)
stored_path = tmp_path / "documents" / "stored-file.pdf"
stored_path.parent.mkdir(parents=True, exist_ok=True)
stored_path.write_bytes(b"payload")
async def _fake_store_source_file(**_kwargs) -> StoredSourceFile:
return StoredSourceFile(
path=stored_path,
file_hash="f" * 64,
file_size_bytes=7,
)
async def _boom_create_records(**_kwargs):
raise RuntimeError("database unavailable")
monkeypatch.setattr("transcription.services.store.store_source_file", _fake_store_source_file)
monkeypatch.setattr("transcription.services.store._create_document_job_records", _boom_create_records)
with pytest.raises(SourceStorageError) as exc_info:
await create_document_job(
filename="single-page.pdf",
file_bytes=b"payload",
settings=settings,
)
assert exc_info.value.category == ErrorCategory.INFRA_PERSISTENT
assert exc_info.value.retriable is False
assert not stored_path.exists()
@pytest.mark.asyncio
async def test_create_job_for_document_db_failure_maps_to_internal_category(async_session, tmp_path, monkeypatch):
document = Document(id=uuid4(), name="db-failure-doc")
async_session.add(document)
await async_session.commit()
settings = Settings(openrouter_api_key="test-key", upload_dir=tmp_path)
stored_path = tmp_path / "documents" / str(document.id) / "stored-file.pdf"
stored_path.parent.mkdir(parents=True, exist_ok=True)
stored_path.write_bytes(b"payload")
async def _fake_store_source_file(**_kwargs) -> StoredSourceFile:
return StoredSourceFile(
path=stored_path,
file_hash="f" * 64,
file_size_bytes=7,
)
async def _boom_create_records(**_kwargs):
raise RuntimeError("database unavailable")
monkeypatch.setattr("transcription.services.store.store_source_file", _fake_store_source_file)
monkeypatch.setattr("transcription.services.store._create_job_for_document_records", _boom_create_records)
with pytest.raises(SourceStorageError) as exc_info:
await create_job_for_document(
document_id=document.id,
source_files=[("single-page.pdf", b"payload")],
session=async_session,
settings=settings,
)
assert exc_info.value.category == ErrorCategory.INFRA_PERSISTENT
assert exc_info.value.retriable is False
assert not stored_path.exists()
@@ -107,6 +107,8 @@ class TestWorkflowReliability:
error_detail = next(attempt.error_detail for attempt in attempts if attempt.error_detail is not None)
assert "timed out" in error_detail.lower()
assert "20.0s" in error_detail
assert attempts[0].error_category == "external_timeout_error"
assert "retry the job" in error_detail.lower()
@pytest.mark.asyncio
async def test_timeout_duration_excludes_pre_call_setup(self, default_session_factory, monkeypatch):