Document and verify multi-format audio discovery

This commit is contained in:
2026-12-02 03:25:20 +00:00
parent 9e2fc7313e
commit 0ec57fe2f4
12 changed files with 96 additions and 37 deletions

View File

@@ -681,6 +681,21 @@ Audio rules:
- configure local mode (`audio_dir` or `audio_files`) or S3 mode (`audio_s3.prefix`), not both. - configure local mode (`audio_dir` or `audio_files`) or S3 mode (`audio_s3.prefix`), not both.
- `audio_s3` requires `pipeline.storage.backend: s3` and a configured S3 bucket. - `audio_s3` requires `pipeline.storage.backend: s3` and a configured S3 bucket.
- Explicit `audio_files` take precedence over `audio_dir`. Paths are resolved relative
to the session document and must identify regular files. Explicit files and
manifest-registered audio may have any suffix or none.
- Local directory scans are non-recursive. S3 selection scans the configured
prefix relative to the session's S3 prefix. Both use the same case-insensitive
candidate suffixes: `.aac`, `.aif`, `.aifc`, `.aiff`, `.alac`, `.amr`,
`.ape`, `.au`, `.caf`, `.flac`, `.m4a`, `.m4b`, `.mka`, `.mp2`, `.mp3`,
`.mp4`, `.oga`, `.ogg`, `.opus`, `.snd`, `.wav`, `.wave`, `.weba`, `.webm`,
`.wma`, and `.wv`. Other entries are ignored by automatic discovery.
- Distinct local paths with the same full basename receive distinct prepared
names. Speaker IDs use the prepared filename without its final extension. If
two resulting IDs match, choose one encoding or rename the recordings. S3
objects with the same full basename are rejected.
- Selection does not verify encoding. The transcription backend determines
whether it can decode the selected bytes.
### Storage backend selection ### Storage backend selection

View File

@@ -15,7 +15,10 @@ Narratio sends an HTTP `POST` to the configured transcription URL using
- `language`: the configured language string. - `language`: the configured language string.
The server must return a `2xx` response whose body is valid JSON. Narratio does The server must return a `2xx` response whose body is valid JSON. Narratio does
not currently require a more specific response schema at this boundary. not currently require a more specific response schema at this boundary. The
backend determines codec and container support; a malformed or unsupported
recording remains a transcription failure. Narratio does not transcode or probe
the selected audio. See [audio selection](../config.md#session).
The transcription URL must be an absolute `http` or `https` URL. Each The transcription URL must be an absolute `http` or `https` URL. Each
application attempt creates one bounded multipart framing and streams the audio application attempt creates one bounded multipart framing and streams the audio

View File

@@ -21,7 +21,7 @@ Materialize canonical current-session inputs before processing stages.
- `inputs/glossaries/{party,campaign,setting,spells,combined}.yml` - `inputs/glossaries/{party,campaign,setting,spells,combined}.yml`
- `inputs/players.yml` - `inputs/players.yml`
- `inputs/party.yml` - `inputs/party.yml`
- `audio/*.flac` - prepared recordings in `audio/`
- optional `inputs/previous/manifest.json` - optional `inputs/previous/manifest.json`
- optional `inputs/previous/artifacts/**` - optional `inputs/previous/artifacts/**`
- deterministic `manifest.inputs` entries (checksums + provenance) - deterministic `manifest.inputs` entries (checksums + provenance)
@@ -34,9 +34,11 @@ Materialize canonical current-session inputs before processing stages.
envelope with checksums, sizes, and provenance. The combined record declares envelope with checksums, sizes, and provenance. The combined record declares
its four individual input dependencies. its four individual input dependencies.
- enforces local audio vs S3 audio mutual exclusivity. - enforces local audio vs S3 audio mutual exclusivity.
- rejects duplicate explicit local audio sources after resolution. - uses `internal/audio` for read-only source discovery shared with inspection;
rejects duplicate explicit local audio sources after resolution.
- gives distinct local source paths with the same basename deterministic unique - gives distinct local source paths with the same basename deterministic unique
prepared filenames so neither source is overwritten. prepared filenames so neither source is overwritten; unresolved speaker-ID
collisions fail before audio materialization.
- downloads S3 audio into a temporary sibling before verifying and installing the prepared copy; its recorded identity comes from the same response as the bytes. - downloads S3 audio into a temporary sibling before verifying and installing the prepared copy; its recorded identity comes from the same response as the bytes.
- writes effective autocorrection rules as a Seriatim envelope, with checksum, - writes effective autocorrection rules as a Seriatim envelope, with checksum,
size, and source provenance, including an empty list when no rules apply. size, and source provenance, including an empty list when no rules apply.
@@ -96,5 +98,5 @@ reusable; changed or unavailable evidence causes a normal prepare rerun.
`internal/stage/prepare_resume_test.go`, `internal/stage/prepare_resume_test.go`,
`internal/stage/semantic_contracts_initial.go`, `internal/stage/semantic_contracts_initial.go`,
`internal/stage/semantic_contracts_initial_test.go`, `internal/stage/semantic_contracts_initial_test.go`,
`internal/audio/s3_audio_test.go`, `internal/audio/discovery_test.go`, `internal/audio/s3_audio_test.go`,
`internal/previouscache/*_test.go` `internal/previouscache/*_test.go`

View File

@@ -6,7 +6,7 @@ Generate raw per-speaker transcripts from prepared audio using WhisperX.
## Inputs ## Inputs
- `audio/*.flac` from `prepare` - prepared recordings in `audio/` from `prepare`
## Outputs ## Outputs
@@ -15,7 +15,9 @@ Generate raw per-speaker transcripts from prepared audio using WhisperX.
## Key Behavior ## Key Behavior
- discovers prepared audio from manifest inputs or the canonical audio - discovers prepared audio from manifest inputs or the canonical audio
directory and derives each speaker identity from its `.flac` filename. directory. Manifest-selected files are authoritative; fallback scans use the
shared candidate filter. Speaker IDs remove the final filename extension;
duplicate IDs are rejected before dispatch.
- hashes the current audio and reconciles it with the versioned per-speaker - hashes the current audio and reconciles it with the versioned per-speaker
completion collection before starting HTTP work. completion collection before starting HTTP work.
- reuses only records whose audio identity, observable WhisperX semantics, - reuses only records whose audio identity, observable WhisperX semantics,
@@ -83,7 +85,7 @@ reuse it normally.
- [WhisperX](../integrations/whisperx.md) owns HTTP, retry, timeout, and - [WhisperX](../integrations/whisperx.md) owns HTTP, retry, timeout, and
cancellation semantics. cancellation semantics.
- [Configuration](../config.md#pipeline) owns concurrency and other - [Configuration](../config.md) owns source selection, concurrency, and other
operator-selected values. operator-selected values.
- Implementation and tests: `internal/stage/transcribe.go`, - Implementation and tests: `internal/stage/transcribe.go`,
`internal/stage/transcribe_reconciliation.go`, `internal/stage/transcribe_reconciliation.go`,

View File

@@ -260,8 +260,10 @@ narratio run 2026-04-04 --stage transcribe
Narratio hashes the current prepared audio, validates recorded transcript JSON, Narratio hashes the current prepared audio, validates recorded transcript JSON,
checksum, size, and location, and calls WhisperX only for missing or obsolete checksum, size, and location, and calls WhisperX only for missing or obsolete
speakers. A changed audio file replaces only its speaker; a changed WhisperX speakers. Preparation and inspection share read-only [audio selection](config.md#session);
URL or language makes every current speaker non-reusable. Retry, timeout, and prepared recordings retain their bytes and filename suffixes. A changed audio
file replaces only its speaker; a changed WhisperX URL or language makes every
current speaker non-reusable. Retry, timeout, and
concurrency tuning do not invalidate completed speakers. concurrency tuning do not invalidate completed speakers.
Use force only when every current transcript must be replaced, including after Use force only when every current transcript must be replaced, including after

View File

@@ -1,6 +1,6 @@
# Multi-Format Audio Inputs and Shared Discovery # Multi-Format Audio Inputs and Shared Discovery
Status: Agreed scope; implementation pending Status: Implemented and verified
## Goal ## Goal
@@ -21,7 +21,7 @@ shared-discovery remediation in
The original audit identified inconsistent discovery under the old behavior; The original audit identified inconsistent discovery under the old behavior;
the multi-format scope follows the operator's later decision. the multi-format scope follows the operator's later decision.
## Current Baseline ## Historical Baseline
Reviewed against `aa0379294fba8422f7e6469261e4730b1c19bd8e`. Reviewed against `aa0379294fba8422f7e6469261e4730b1c19bd8e`.
@@ -238,7 +238,8 @@ benchmark requirement is introduced.
## Relationship to Other Work ## Relationship to Other Work
This roadmap owns the multi-format extension and shared discovery work associated This roadmap owns the multi-format extension and shared discovery work associated
with CAT-12. Original audit findings remain open until implementation is verified. with CAT-12. CAT-12 is closed after implementation and verification; the
historical audit reports remain unchanged.
The agreed source-identity and transfer-size changes in The agreed source-identity and transfer-size changes in
[topic 4](audit/discussion.md#4-keep-downloaded-audio-and-its-source-identity-together) [topic 4](audit/discussion.md#4-keep-downloaded-audio-and-its-source-identity-together)

View File

@@ -41,8 +41,8 @@ their scope. Unless assigned otherwise, a finding remains independent audit
remediation. Shared code does not make a refactoring a prerequisite or assign remediation. Shared code does not make a refactoring a prerequisite or assign
the whole finding to a roadmap. the whole finding to a roadmap.
Nine entries are closed by the safety and transfer remediation sprint; 34 remain Ten entries are closed by the safety, transfer, and audio discovery work; 33
open. **Planned** identifies an agreed remedy awaiting remain open. **Planned** identifies an agreed remedy awaiting
implementation. **Potentially eliminated** requires verification that the offending implementation. **Potentially eliminated** requires verification that the offending
lifecycle is removed. **Coordinate** identifies shared changes, not a commitment lifecycle is removed. **Coordinate** identifies shared changes, not a commitment
that the roadmap implements the entire finding. Findings close only after their that the roadmap implements the entire finding. Findings close only after their
@@ -58,7 +58,7 @@ Decisions on [audio generation/size handling](discussion.md#4-keep-downloaded-au
[subprocess completion](discussion.md#5-finish-subprocess-shutdown-before-releasing-its-files), [subprocess completion](discussion.md#5-finish-subprocess-shutdown-before-releasing-its-files),
[publication source lifetimes](discussion.md#6-open-publication-sources-as-they-are-needed), [publication source lifetimes](discussion.md#6-open-publication-sources-as-they-are-needed),
and [audio selection and naming](discussion.md#7-give-preparation-and-inspection-the-same-audio-selection-rules) and [audio selection and naming](discussion.md#7-give-preparation-and-inspection-the-same-audio-selection-rules)
are agreed; audio selection remains pending in its separate roadmap. Topic 1 are agreed and implemented. Topic 1
records cancellation-aware workspace lock waiting, now implemented. Remote checkpoint timing and records cancellation-aware workspace lock waiting, now implemented. Remote checkpoint timing and
failure handling are deferred, not decisions blocking publication import. failure handling are deferred, not decisions blocking publication import.
@@ -369,15 +369,19 @@ S3 is unnecessary.
### CAT-12 — P2: Share audio discovery and accept valid same-basename recordings in inspection ### CAT-12 — P2: Share audio discovery and accept valid same-basename recordings in inspection
Status: Open Status: Closed
**Disposition / owner.** Planned — the [audio-inputs roadmap](../audio-inputs.md) **Disposition / owner.** Implemented and verified under the
owns shared discovery, regular-file eligibility, broad automatic extension [audio-inputs roadmap](../audio-inputs.md) and
filtering, and early unresolved speaker-stem collision errors, as agreed in
[discussion topic 7](discussion.md#7-give-preparation-and-inspection-the-same-audio-selection-rules). [discussion topic 7](discussion.md#7-give-preparation-and-inspection-the-same-audio-selection-rules).
Coordinate with the [restore roadmap's preparation changes](../session-restore.md#adapt-preparation-and-operator-reporting)
without making either feature a prerequisite for the other. Implementation and **Closure.** `internal/audio` owns local and S3 selection, prepared names, and
verification remain pending. speaker-ID collision checks. Preparation, reuse, and inspection consume these
selections; transcription accepts manifest-selected files and uses the shared
filter for fallback. Audio discovery and real preparation/inspection tests cover
same-basename and mixed-format selection; transcription retry and WhisperX HTTP
and replay tests cover durable reuse and byte-preserving transport. Full tests,
race tests, vet, and build pass on Go 1.27.4.
Original findings: [CX-01](03-complexity.md#cx-01--p2-audio-discovery-is-duplicated-and-inspection-rejects-valid-inputs), Original findings: [CX-01](03-complexity.md#cx-01--p2-audio-discovery-is-duplicated-and-inspection-rejects-valid-inputs),
[BN-04](11-boundaries.md#bn-04--p3-audio-discovery-is-owned-independently-by-preparation-and-inspection). [BN-04](11-boundaries.md#bn-04--p3-audio-discovery-is-owned-independently-by-preparation-and-inspection).

View File

@@ -413,7 +413,7 @@ the current publication must remain unchanged on failure. CAT-09 is closed._
## 7. Give preparation and inspection the same audio selection rules ## 7. Give preparation and inspection the same audio selection rules
Status: Decisions agreed; implementation pending Status: Implemented and verified
Finding: [CAT-12](catalog.md#cat-12--p2-share-audio-discovery-and-accept-valid-same-basename-recordings-in-inspection). Finding: [CAT-12](catalog.md#cat-12--p2-share-audio-discovery-and-accept-valid-same-basename-recordings-in-inspection).
@@ -421,8 +421,8 @@ Roadmap owner: [Multi-Format Audio Inputs and Shared Discovery](../audio-inputs.
### Concrete example ### Concrete example
The operator selects `first/speaker.flac` and `second/speaker.flac`. Preparation At the audit baseline, the operator selects `first/speaker.flac` and
accepts these distinct recordings and gives the prepared copies distinct names. `second/speaker.flac`. Preparation accepts these distinct recordings and gives the prepared copies distinct names.
Inspection rejects them because their basenames match. A status command can Inspection rejects them because their basenames match. A status command can
therefore report unavailable audio for a session preparation can process. therefore report unavailable audio for a session preparation can process.
@@ -468,7 +468,7 @@ Operator response:
_Approved: regular-file selection, shared broad audio-extension filtering for _Approved: regular-file selection, shared broad audio-extension filtering for
automatic discovery, extension-agnostic explicit inputs, and early rejection of automatic discovery, extension-agnostic explicit inputs, and early rejection of
unresolved speaker-stem collisions. CAT-12 remains open pending implementation unresolved speaker-stem collisions. CAT-12 is closed after implementation
and verification._ and verification._
## After Discussion ## After Discussion

View File

@@ -1,6 +1,6 @@
# Multi-Format Audio Inputs Implementation Plan # Multi-Format Audio Inputs Implementation Plan
Status: Ready for implementation Status: Complete
Baseline: `0288111c721ed49f19aade68370f30f92017d581`. Baseline: `0288111c721ed49f19aade68370f30f92017d581`.
@@ -271,6 +271,8 @@ decoder toolchain, or new performance gate is needed.
## Stage 7: Align documentation and verify the final sprint state ## Stage 7: Align documentation and verify the final sprint state
**Complete.** Documentation and CAT-12 are updated; Go 1.27.4 tests, race tests, vet, build, and diff checks pass.
1. Update `docs/config.md` as the canonical owner of source-selection semantics 1. Update `docs/config.md` as the canonical owner of source-selection semantics
and the extension set. Explain automatic versus explicit selection, current and the extension set. Explain automatic versus explicit selection, current
S3 prefix behavior, and the operator action for unresolved speaker-stem S3 prefix behavior, and the operator action for unresolved speaker-stem

View File

@@ -974,7 +974,7 @@ Symptom:
Likely causes: Likely causes:
- incorrect `session.inputs.audio_s3.prefix`; - incorrect `session.inputs.audio_s3.prefix`;
- no matching `.flac` objects; - no matching [audio candidates](config.md#session);
- storage connectivity or permissions failure. - storage connectivity or permissions failure.
Diagnostics: Diagnostics:

View File

@@ -90,7 +90,8 @@ those IDs only when the pipeline imports a matching catalog.
see [attribution](../docs/oss/attribution.md). see [attribution](../docs/oss/attribution.md).
- [Sample speaker audio](audio/sample-speaker.flac) is a text placeholder that - [Sample speaker audio](audio/sample-speaker.flac) is a text placeholder that
reserves the expected filename and directory shape. Replace it with a real reserves the expected filename and directory shape. Replace it with a real
FLAC file before running transcription. supported recording before running transcription; keep the configured filename
or update the session file to match.
The examples contain environment-variable names but no credential values. Set The examples contain environment-variable names but no credential values. Set
`OBJECT_STORAGE_KEY_ID`, `OBJECT_STORAGE_KEY`, `AUDITA_LLM_API_KEY`, and `OBJECT_STORAGE_KEY_ID`, `OBJECT_STORAGE_KEY`, `AUDITA_LLM_API_KEY`, and

View File

@@ -4,6 +4,8 @@ import (
"context" "context"
"os" "os"
"path/filepath" "path/filepath"
"slices"
"sort"
"testing" "testing"
"time" "time"
@@ -31,7 +33,7 @@ func TestAudioInspectionAgreesWithPreparation(t *testing.T) {
cfg := testConfig(t) cfg := testConfig(t)
root := filepath.Dir(cfg.SessionPath) root := filepath.Dir(cfg.SessionPath)
for _, name := range tc.files { for _, name := range tc.files {
mustWriteFile(t, filepath.Join(root, name), "audio") mustWriteFile(t, filepath.Join(root, name), name)
} }
if tc.directory { if tc.directory {
cfg.Session.Inputs.AudioFiles = nil cfg.Session.Inputs.AudioFiles = nil
@@ -59,14 +61,27 @@ func TestAudioInspectionAgreesWithPreparation(t *testing.T) {
t.Fatalf("prepare error: %v", err) t.Fatalf("prepare error: %v", err)
} }
if !tc.reject { if !tc.reject {
count := 0 var expected, actual []string
for _, source := range check.Paths {
b, err := os.ReadFile(source)
if err != nil {
t.Fatal(err)
}
expected = append(expected, string(b))
}
for _, input := range m.Inputs { for _, input := range m.Inputs {
if input.Kind == "audio" { if input.Kind == "audio" {
count++ b, err := os.ReadFile(input.Path)
if err != nil {
t.Fatal(err)
}
actual = append(actual, string(b))
} }
} }
if count != len(check.Paths) { sort.Strings(expected)
t.Fatalf("inspection paths %v, prepared %d", check.Paths, count) sort.Strings(actual)
if !slices.Equal(expected, actual) {
t.Fatalf("inspection content %v, prepared %v", expected, actual)
} }
} }
}) })
@@ -91,8 +106,8 @@ func TestRemoteAudioInspectionAgreesWithPreparation(t *testing.T) {
if (check.Err != nil) != collision { if (check.Err != nil) != collision {
t.Fatalf("inspection error: %v", check.Err) t.Fatalf("inspection error: %v", check.Err)
} }
if len(fake.Reads) != 0 { if len(fake.Reads) != 0 || len(fake.Uploads) != 0 || len(fake.Deletes) != 0 {
t.Fatal("inspection downloaded audio") t.Fatal("inspection performed a remote mutation or download")
} }
entries, err := os.ReadDir(cfg.Pipeline.Workspace.Root) entries, err := os.ReadDir(cfg.Pipeline.Workspace.Root)
if err != nil || len(entries) != 0 { if err != nil || len(entries) != 0 {
@@ -109,5 +124,17 @@ func TestRemoteAudioInspectionAgreesWithPreparation(t *testing.T) {
if (err != nil) != collision { if (err != nil) != collision {
t.Fatalf("prepare error: %v", err) t.Fatalf("prepare error: %v", err)
} }
if !collision {
var keys []string
for _, input := range m.Inputs {
if input.Kind == "audio" {
keys = append(keys, input.S3Key)
}
}
sort.Strings(keys)
if !slices.Equal(check.Keys, keys) {
t.Fatalf("inspection keys %v, prepared keys %v", check.Keys, keys)
}
}
} }
} }