diff --git a/docs/config.md b/docs/config.md index 136bf00..3ddb53b 100644 --- a/docs/config.md +++ b/docs/config.md @@ -681,6 +681,21 @@ Audio rules: - 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. +- 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 diff --git a/docs/integrations/whisperx.md b/docs/integrations/whisperx.md index de41b88..26bb626 100644 --- a/docs/integrations/whisperx.md +++ b/docs/integrations/whisperx.md @@ -15,7 +15,10 @@ Narratio sends an HTTP `POST` to the configured transcription URL using - `language`: the configured language string. 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 application attempt creates one bounded multipart framing and streams the audio diff --git a/docs/internal/stage-prepare.md b/docs/internal/stage-prepare.md index 6608626..6357cbb 100644 --- a/docs/internal/stage-prepare.md +++ b/docs/internal/stage-prepare.md @@ -21,7 +21,7 @@ Materialize canonical current-session inputs before processing stages. - `inputs/glossaries/{party,campaign,setting,spells,combined}.yml` - `inputs/players.yml` - `inputs/party.yml` -- `audio/*.flac` +- prepared recordings in `audio/` - optional `inputs/previous/manifest.json` - optional `inputs/previous/artifacts/**` - 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 its four individual input dependencies. - 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 - 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. - writes effective autocorrection rules as a Seriatim envelope, with checksum, 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/semantic_contracts_initial.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` diff --git a/docs/internal/stage-transcribe.md b/docs/internal/stage-transcribe.md index 616a25f..a221add 100644 --- a/docs/internal/stage-transcribe.md +++ b/docs/internal/stage-transcribe.md @@ -6,7 +6,7 @@ Generate raw per-speaker transcripts from prepared audio using WhisperX. ## Inputs -- `audio/*.flac` from `prepare` +- prepared recordings in `audio/` from `prepare` ## Outputs @@ -15,7 +15,9 @@ Generate raw per-speaker transcripts from prepared audio using WhisperX. ## Key Behavior - 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 completion collection before starting HTTP work. - 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 cancellation semantics. -- [Configuration](../config.md#pipeline) owns concurrency and other +- [Configuration](../config.md) owns source selection, concurrency, and other operator-selected values. - Implementation and tests: `internal/stage/transcribe.go`, `internal/stage/transcribe_reconciliation.go`, diff --git a/docs/operations.md b/docs/operations.md index dd5d4a1..54bc70b 100644 --- a/docs/operations.md +++ b/docs/operations.md @@ -260,8 +260,10 @@ narratio run 2026-04-04 --stage transcribe Narratio hashes the current prepared audio, validates recorded transcript JSON, checksum, size, and location, and calls WhisperX only for missing or obsolete -speakers. A changed audio file replaces only its speaker; a changed WhisperX -URL or language makes every current speaker non-reusable. Retry, timeout, and +speakers. Preparation and inspection share read-only [audio selection](config.md#session); +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. Use force only when every current transcript must be replaced, including after diff --git a/docs/roadmap/audio-inputs.md b/docs/roadmap/audio-inputs.md index 74bdd76..02fbdb4 100644 --- a/docs/roadmap/audio-inputs.md +++ b/docs/roadmap/audio-inputs.md @@ -1,6 +1,6 @@ # Multi-Format Audio Inputs and Shared Discovery -Status: Agreed scope; implementation pending +Status: Implemented and verified ## Goal @@ -21,7 +21,7 @@ shared-discovery remediation in The original audit identified inconsistent discovery under the old behavior; the multi-format scope follows the operator's later decision. -## Current Baseline +## Historical Baseline Reviewed against `aa0379294fba8422f7e6469261e4730b1c19bd8e`. @@ -238,7 +238,8 @@ benchmark requirement is introduced. ## Relationship to Other Work 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 [topic 4](audit/discussion.md#4-keep-downloaded-audio-and-its-source-identity-together) diff --git a/docs/roadmap/audit/catalog.md b/docs/roadmap/audit/catalog.md index 58d6a64..2c387e0 100644 --- a/docs/roadmap/audit/catalog.md +++ b/docs/roadmap/audit/catalog.md @@ -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 the whole finding to a roadmap. -Nine entries are closed by the safety and transfer remediation sprint; 34 remain -open. **Planned** identifies an agreed remedy awaiting +Ten entries are closed by the safety, transfer, and audio discovery work; 33 +remain open. **Planned** identifies an agreed remedy awaiting implementation. **Potentially eliminated** requires verification that the offending lifecycle is removed. **Coordinate** identifies shared changes, not a commitment 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), [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) -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 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 -Status: Open +Status: Closed -**Disposition / owner.** Planned — the [audio-inputs roadmap](../audio-inputs.md) -owns shared discovery, regular-file eligibility, broad automatic extension -filtering, and early unresolved speaker-stem collision errors, as agreed in +**Disposition / owner.** Implemented and verified under the +[audio-inputs roadmap](../audio-inputs.md) and [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 -verification remain pending. + +**Closure.** `internal/audio` owns local and S3 selection, prepared names, and +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), [BN-04](11-boundaries.md#bn-04--p3-audio-discovery-is-owned-independently-by-preparation-and-inspection). diff --git a/docs/roadmap/audit/discussion.md b/docs/roadmap/audit/discussion.md index 5d9b629..358ca18 100644 --- a/docs/roadmap/audit/discussion.md +++ b/docs/roadmap/audit/discussion.md @@ -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 -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). @@ -421,8 +421,8 @@ Roadmap owner: [Multi-Format Audio Inputs and Shared Discovery](../audio-inputs. ### Concrete example -The operator selects `first/speaker.flac` and `second/speaker.flac`. Preparation -accepts these distinct recordings and gives the prepared copies distinct names. +At the audit baseline, the operator selects `first/speaker.flac` and +`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 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 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._ ## After Discussion diff --git a/docs/roadmap/implementation.md b/docs/roadmap/implementation.md index 0fc1d8f..6f3ea42 100644 --- a/docs/roadmap/implementation.md +++ b/docs/roadmap/implementation.md @@ -1,6 +1,6 @@ # Multi-Format Audio Inputs Implementation Plan -Status: Ready for implementation +Status: Complete Baseline: `0288111c721ed49f19aade68370f30f92017d581`. @@ -271,6 +271,8 @@ decoder toolchain, or new performance gate is needed. ## 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 and the extension set. Explain automatic versus explicit selection, current S3 prefix behavior, and the operator action for unresolved speaker-stem diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md index c9114d1..c6f08e2 100644 --- a/docs/troubleshooting.md +++ b/docs/troubleshooting.md @@ -974,7 +974,7 @@ Symptom: Likely causes: - incorrect `session.inputs.audio_s3.prefix`; -- no matching `.flac` objects; +- no matching [audio candidates](config.md#session); - storage connectivity or permissions failure. Diagnostics: diff --git a/examples/README.md b/examples/README.md index efe86f6..6f1c417 100644 --- a/examples/README.md +++ b/examples/README.md @@ -90,7 +90,8 @@ those IDs only when the pipeline imports a matching catalog. see [attribution](../docs/oss/attribution.md). - [Sample speaker audio](audio/sample-speaker.flac) is a text placeholder that 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 `OBJECT_STORAGE_KEY_ID`, `OBJECT_STORAGE_KEY`, `AUDITA_LLM_API_KEY`, and diff --git a/internal/app/audio_inspection_consistency_test.go b/internal/app/audio_inspection_consistency_test.go index 37fc28a..a22b6e5 100644 --- a/internal/app/audio_inspection_consistency_test.go +++ b/internal/app/audio_inspection_consistency_test.go @@ -4,6 +4,8 @@ import ( "context" "os" "path/filepath" + "slices" + "sort" "testing" "time" @@ -31,7 +33,7 @@ func TestAudioInspectionAgreesWithPreparation(t *testing.T) { cfg := testConfig(t) root := filepath.Dir(cfg.SessionPath) for _, name := range tc.files { - mustWriteFile(t, filepath.Join(root, name), "audio") + mustWriteFile(t, filepath.Join(root, name), name) } if tc.directory { cfg.Session.Inputs.AudioFiles = nil @@ -59,14 +61,27 @@ func TestAudioInspectionAgreesWithPreparation(t *testing.T) { t.Fatalf("prepare error: %v", err) } 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 { 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) { - t.Fatalf("inspection paths %v, prepared %d", check.Paths, count) + sort.Strings(expected) + 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 { t.Fatalf("inspection error: %v", check.Err) } - if len(fake.Reads) != 0 { - t.Fatal("inspection downloaded audio") + if len(fake.Reads) != 0 || len(fake.Uploads) != 0 || len(fake.Deletes) != 0 { + t.Fatal("inspection performed a remote mutation or download") } entries, err := os.ReadDir(cfg.Pipeline.Workspace.Root) if err != nil || len(entries) != 0 { @@ -109,5 +124,17 @@ func TestRemoteAudioInspectionAgreesWithPreparation(t *testing.T) { if (err != nil) != collision { 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) + } + } } }