correlator: LLM tier reads the scene's transcript, not the whole call (server-26#102)

The last leg of the #80/#95 scene-context leak. llm_correlator._call_block
read call_doc's whole-call transcript for every scene, so on a multi-scene
call every scene's cheap-tier and tiebreaker decision was made against text
that also contained the other scenes.

- intelligence.py: each processed[] scene now carries its own "transcript" —
  transcript_corrected, else this scene's segments joined, else (single scene)
  the whole transcript.
- _build_context / preview_correlation / correlate_call: take a `transcript`
  param; _build_context resolves ctx["scene_transcript"] from it, falling
  back to the call doc (sweep, single-scene, tests) — the fallback is kept
  here, unlike embedding/severity, because a scene always has real text.
- upload.py: both scene loops pass scene["transcript"].
- llm_correlator._call_block: reads ctx["scene_transcript"] (call-doc
  fallback retained for test-built ctx).
- recorrelation_sweep: passes the call doc's text explicitly.
- +1 regression test. Full c2-core suite green (296 passed, sandboxed venv).

NOT for merge until the running correlation measurement window closes and its
dump is analysed — deploying a correlator change mid-window would mix old and
new behaviour in the sample.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Logan Cusano
2026-09-07 00:06:37 -04:00
co-authored by Claude Sonnet 5
parent b430cf32f2
commit ef1e3d7f9d
6 changed files with 75 additions and 7 deletions
+15 -1
View File
@@ -172,7 +172,7 @@ async def extract_scenes(
Each scene dict contains:
tags, incident_type, location, location_coords, resolved,
severity, vehicles, units, transcript_corrected,
severity, vehicles, units, transcript, transcript_corrected,
segment_indices, embedding
Side-effect: updates calls/{call_id} in Firestore with merged tags,
@@ -337,6 +337,19 @@ async def extract_scenes(
)
embedding = await asyncio.to_thread(_sync_embed, scene_text)
# This scene's own words, unprefixed — corrected text if we have it,
# else the raw segments this scene owns, else (single-scene) the whole
# transcript. The correlator's LLM tier reads this per scene instead of
# the call doc's whole-call transcript (server-26#102).
if transcript_corrected:
scene_transcript = transcript_corrected
elif segments and segment_indices:
scene_transcript = " ".join(
segments[i]["text"] for i in segment_indices if i < len(segments)
)
else:
scene_transcript = transcript
processed.append({
"tags": tags,
"incident_type": incident_type,
@@ -348,6 +361,7 @@ async def extract_scenes(
"severity": severity,
"resolved": resolved,
"reassignment": reassignment,
"transcript": scene_transcript,
"transcript_corrected": transcript_corrected,
"segment_indices": segment_indices,
"embedding": embedding,