V4.2 Updated what ai_raw_response data is being captured. The changes were more extensive than I expected.

This commit is contained in:
Jim Lancaster
2026-08-14 07:21:15 -05:00
parent 28811d79ce
commit 6bd4cbb0a7
29 changed files with 2091 additions and 130 deletions
+44
View File
@@ -11,6 +11,8 @@ from transcription.db.models import Job
from transcription.db.models import JobSourceStatus
from transcription.db.models import JobStatus
from transcription.db.models import Source
from transcription.providers.evidence import TransportEvidence
from transcription.services.sources import SourceService
# --- Unit Tests for Model @property Definitions ---
@@ -223,6 +225,48 @@ class TestSourcesPageRendering:
assert "finish_reason" in response.text
assert "response-123" in response.text
@pytest.mark.asyncio
async def test_source_detail_separates_v42_evidence_layers(self, app_client, seed_job):
app, client = app_client
job_id = await seed_job(filename="evidence-source.png")
async with session_scope(session_factory=app.state.runtime.session_factory) as session:
job = await session.get(Job, job_id)
assert job is not None
source = (
await session.exec(select(Source).where(Source.document_id == job.document_id))
).first()
assert source is not None
source_id = source.id
service = SourceService(session_factory=app.state.runtime.session_factory)
await service.update_job_source_transcription(
job_id=job_id,
source_id=source_id,
text="V4.2 transcription",
raw_api_response={"id": "sdk-snapshot"},
ai_metadata={"finish_reason": "stop"},
provider="openrouter",
model="vendor/model",
transport_evidence=TransportEvidence(
response_received=True,
status_code=200,
body=b'{"id":"transport-response"}',
safe_headers={"content-type": "application/json"},
content_type="application/json",
),
)
response = client.get(f"/ui/sources/{source_id}")
assert response.status_code == 200
assert "Export Evidence" in response.text
assert "Request Manifest" in response.text
assert "Transport Response" in response.text
assert "OpenRouter SDK Response Snapshot" in response.text
assert "Normalized Metadata" in response.text
assert "Software Context" in response.text
assert "Derived Artifacts" in response.text
@pytest.mark.asyncio
async def test_source_delete_page_blocks_when_source_is_job_linked(
self, app_client, seed_job