Instrumentation only: TRACE log lines for the tone-mismatch + progress investigation — reprocess (rid, requested tone, prior tone/status), summarize-start (rid, job, tone the worker actually read), progress (every distinct pct the provider emits), store_summary (rid, tone saved). rid minted per click joins all lines; zero behavior change.

This commit is contained in:
avi 2026-09-18 10:49:28 -05:00
commit 768b75915a
2 changed files with 51 additions and 0 deletions

View file

@ -7,6 +7,7 @@ return 404 (no existence leaks). Storage keys are never exposed.
from __future__ import annotations
import contextlib
import logging
import uuid
from datetime import datetime
@ -42,6 +43,7 @@ from shonar.db.models import (
from shonar.services import uploads as up
router = APIRouter(tags=["uploads", "recordings"])
logger = logging.getLogger("shonar.recordings")
async def _recording_out(session, rec: Recording) -> RecordingOut: # noqa: ANN001
@ -400,6 +402,8 @@ async def reprocess_recording(
JobStatus.running,
):
raise HTTPException(409, "That stage is already running.")
prior_tone = existing.tone if existing is not None else None
prior_status = existing.status.value if existing is not None else "new"
if existing is None:
session.add(ProcessingJob(recording_id=rec.id, job_type=job_type,
tone=tone))
@ -414,6 +418,15 @@ async def reprocess_recording(
# Tone rides the job row (the queue carries only ids): a plain
# re-summarize must clear a previous tone, not inherit it.
existing.tone = tone
# TRACE (logging only): one line per click. rid joins this line to the
# worker's start/done lines; prior_tone/prior_status expose rapid double
# clicks overwriting a queued tone before pickup.
logger.info(
"TRACE reprocess rid=%s rec=%s job=%s tone=%r prior_tone=%r "
"prior_status=%s",
proc.trace_request(rec.id, job_type, tone),
rec.id, job_type, tone, prior_tone, prior_status,
)
if job_type is JT.transcribe:
if model is not None:
# A re-transcribe may switch models; the saved per-recording