kcode-k1-full-audio 0.2.1

Durable orchestration of full audio into classified overlapping K1 fragments
Documentation
# Full audio

`K1FullAudio` synchronously converts a complete media value to Ogg Opus, fragments it, submits every fragment for classification, and stores one private manifest Object.

## Public API

```rust
pub type FullAudioId = kcode_k1_objects::TxId;

pub struct K1FullAudio { /* private fields */ }

#[derive(Clone, Debug, Eq, PartialEq)]
pub enum FullAudioState {
    Processing,
    AwaitingLabels,
    NeedsAttention,
    Complete,
}

#[derive(Clone, Debug, PartialEq)]
pub struct FullAudioFragmentStatus {
    pub fragment_id: FragmentId,
    pub start_sample_48k: u64,
    pub end_sample_48k: u64,
    pub status: FragmentStatus,
}

#[derive(Clone, Debug, PartialEq)]
pub struct FullAudioStatus {
    pub state: FullAudioState,
    pub fragments: Vec<FullAudioFragmentStatus>,
    pub final_transcript: Option<String>,
}

impl K1FullAudio {
    pub fn open(
        ffmpeg_path: impl AsRef<Path>,
        objects: Arc<K1Objects>,
        classification: Arc<AudioClassification>,
    ) -> Result<Self, String>;

    pub fn submit(&self, audio: &[u8]) -> Result<FullAudioId, String>;

    pub fn status(&self, id: FullAudioId) -> Result<FullAudioStatus, String>;
}
```

The crate exports no public constants or free functions. `FullAudioId` is the manifest Object transaction ID. `K1FullAudio` is the facade, and its fields are private. The displayed derives are the consumer-relevant implemented traits.

### `K1FullAudio::open`

Requires an absolute trusted FFmpeg path and does not probe the filesystem. The supplied Objects and classification facades retain all persistence and transaction authority.

Performance: Not yet benchmarked; it copies and validates the path without filesystem I/O.

### `K1FullAudio::submit`

Accepts the converter's nonempty self-contained media domain, converts its first audio stream exactly through the converter, deterministically fragments the normalized Ogg Opus stream in source order, and validates all fragment metadata before classification. It submits every complete fragment sequentially and strictly, then saves one immutable private `k1-full-audio-manifest-v1` Object with empty filename and description. It returns that Object transaction ID without polling, and equal submissions remain independent.

Every half-open 48 kHz fragment interval has positive duration of at most 7,200,000 samples. Starts and ends strictly increase from zero, adjacent intervals overlap, the fragmenter produces a 720,000-sample overlap, manifest admission accepts any positive overlap, and fragment IDs are unique.

A later submission failure can leave earlier fragment Objects and work, but no manifest is saved unless every fragment submission and manifest encoding succeeds. The API provides no rollback or cancellation, and starts no background work.

Performance: Not yet benchmarked; work and allocation scale with input, converted audio, fragment, and manifest sizes, with sequential fragment submissions followed by a manifest save.

### `K1FullAudio::status`

Requires a present Object with the exact private type and empty metadata, strictly decodes and validates its immutable manifest, queries one present classification status per fragment, and preserves manifest order. Unknown IDs, malformed or mismatched Objects, invalid geometry, duplicate references, missing fragment statuses, and inconsistent classification values are errors.

`NeedsAttention` takes precedence when any fragment is `Failed` or `Discarded`; otherwise `Processing` applies when any fragment is `Queued` or `Running`. `Complete` requires every fragment to be `Confirmed` with a final transcript. A set containing only valid `Completed` and `Confirmed` fragments is otherwise `AwaitingLabels`. A confirmed fragment without a transcript, or any other state with one, is inconsistent.

`final_transcript` is present only for `Complete`. Deterministic stitching compares adjacent speech case-insensitively and without punctuation, ignores conforming quality and speaker prefixes for seam matching, removes only confident duplicate prefixes, preserves source text and attribution, and retains uncertain seams separated by a newline. Status is read-only; the API provides no update, deletion, or partial-result stream.

Performance: Not yet benchmarked; work and allocation scale with manifest, fragment-status, and transcript sizes, with a manifest load and a sequential status lookup for each fragment.