Skip to content

Defer speaker tagging until Tome finalizes the transcript body - #2

Open
nicw wants to merge 2 commits into
dloomis:mainfrom
nicw:pr/finalization-guards
Open

Defer speaker tagging until Tome finalizes the transcript body#2
nicw wants to merge 2 commits into
dloomis:mainfrom
nicw:pr/finalization-guards

Conversation

@nicw

@nicw nicw commented Jul 30, 2026

Copy link
Copy Markdown

Tome live-writes transcript bodies with a placeholder call-leg label (Them; You is a permanent mic-leg label) and only rewrites them to diarized "Speaker N" names when its finalizer runs, minutes after capture ends. Anything that reads speaker labels off the body in that window caches results the finalizer can never retroactively fix — auto-tagging cached "Them"-keyed proposals, and an Apply from the tag modal could permanently corrupt body, attendees, and pipeline state.

This PR adds one shared finalization signal and gates every consumer on it:

  • New hasLiveLegLabels() in utils/transcript.ts — a single definition of "Tome isn't done yet".
  • AutoSpeakerTagger defers a live-bodied transcript without marking it attempted, so the metadataCache "changed" event from Tome's rewrite re-queues it the moment the labels are real. (isEligible becomes async; the slot-wait countdown badge is cleared when an in-wait head goes ineligible so it can't leak.)
  • Manual "Tag speakers" (command + card pill) now notices "Transcript is still finalizing — try Tag speakers again in a minute." instead of running word replacements, spawning the LLM, or opening the tag modal on placeholder labels.
  • writeSpeakerProposals refuses to cache any proposal keyed on the literal "Them" — belt-and-braces coverage of every proposal write path, including the manual modal.
  • waitAndLink waits (bounded, 120 s) for the body to clear the placeholder before enriching and setting pipeline_state: titled; on timeout it bails without removing the persistence entry, so next-load reconcile retries. This is defense-in-depth for the crash/unknown-status/reconcile/legacy paths — the per-guid happy path may already be safe depending on when the service reports complete.

Tests: 11 (transcript helper, tagger deferral, proposal refusal), plus an npm test script (jiti is already in devDependencies; no new deps).

Notes for review:

  • The "Them" literal is Tome-specific and the tagger/manual gates have no timeout — if a recorder legitimately kept "Them" as a final label, tagging would defer forever. Happy to hoist it to a named constant or add an escape hatch if you'd prefer.
  • Sibling PR Auto-link reliability: punctuation-blind name matching and an event-driven transcript wait #3 touches the same waitAndLink region; whichever lands second I'll rebase. Once both land, its findReady probe could additionally gate on hasLiveLegLabels — small follow-up.

Tested on this branch against v0.8.7: npm run build, npm run lint, npm test (11/11).

🤖 Generated with Claude Code

nicw and others added 2 commits July 29, 2026 21:19
Tome live-writes the transcript to the vault from session start using a
placeholder speaker label ("Them", alongside the permanent "You") and only
rewrites it to diarized "Speaker N" labels when its finalizer runs, 1-3
minutes after the note is linked. pipeline_state can read "titled" before
that rewrite, so speaker tagging could run against the placeholder body:
auto-tagging cached proposals keyed on "Them" (which the finalizer never
retroactively fixes), and a manual Tag speakers during the window offered a
Them/You modal whose Apply would corrupt body + attendees + pipeline_state.

Add hasLiveLegLabels to the shared transcript utils and gate every consumer
on it: AutoSpeakerTagger.isEligible defers a still-live body without marking
it attempted (Tome's rewrite fires a metadataCache "changed" event that
re-arms the file), the pump re-checks eligibility before the LLM slot gate
so the slot-to-run span stays await-free, doTagSpeakers refuses early with a
Notice on the manual path, and writeSpeakerProposals refuses any mapping
keyed on the literal "Them" as a last line of defense.

Adds node:test coverage for the helper and both refusal paths, plus a test
script to run it.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The link tail could enrich a transcript and set pipeline_state "titled"
while the body still carried Tome's live-call-leg placeholder ("Them") —
titling a body Tome was about to rewrite. The content-keyed guards in
AutoSpeakerTagger and writeSpeakerProposals already make an early title
harmless to speaker tagging, but this tail also runs on paths where nothing
else waits (service crash, unknown session status, next-load reconcile, the
legacy heuristics rung), so wait here too as defense-in-depth.

After the transcript file is found and the superseded-session check passes,
poll its body once per second (up to 2 minutes, covering Tome's usual
finalize window) until the placeholder clears. On timeout, surface a
"still finalizing" status and return without removing the in-flight
bookkeeping entry, so the next-load reconcile re-runs the tail once the
body has settled.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant