Documentation
¶
Overview ¶
Command recordingbackfill migrates call-recording audio files (and their JSON sidecars) that were ingested before v0.21.2 (#164) and therefore still carry a raw phone number in plaintext:
- filenames of the form {rawNumber}_{YYYYMMDDHHMMSS}[-N].{ext}, and/or
- sidecars ({audioPath}.meta.json) with a plaintext "number" field.
Both are rewritten to the current scheme: filenames of the form {numHash}_{YYYYMMDDHHMMSS}[-N].{ext} and sidecars carrying "number_hash" only (see internal/api/ingest_recording.go). Renaming an audio file changes the SourceID that WhisperCollector computes for it ("transcript:"+relPath) — this tool renames the corresponding documents.source_id row in the SAME migration step so that the existing call-transcript document is neither re-transcribed nor orphaned. See internal/recordingbackfill's package doc for the full hazard analysis and crash-safety ordering.
Usage ¶
recordingbackfill [--execute] [--dir <path>]
DRY_RUN is the default: with no flags, the tool only scans and logs the actions it WOULD take (no file or database mutation). Pass --execute to actually perform the migration. This mirrors a hard project rule from a past ops incident: scripts that mutate production data default to dry-run and require an explicit opt-in flag to mutate anything.
--dir overrides the recording root directory; it defaults to $WHISPER_AUDIO_DIR (the same directory WhisperCollector scans).
Idempotent: files already in the new scheme (hash-format filename with a number_hash-only sidecar) are detected and skipped on every run, so running this tool twice — or resuming after an interrupted --execute run — is safe.
Exit codes: 0 success, 1 on a fatal error OR when any file could not be migrated cleanly (skips due to an undetectable phone number, per-file errors, or source_id conflicts — see the logged summary for details).