kcode-audio-session-ingress 0.2.2

Idempotent handoff from completed AudioIngress transcripts into Session History
Documentation
# Audio Session Ingress

`kcode-audio-session-ingress` 0.2.2 coordinates the application-level handoff
from durable completed `kcode-audio-ingress` transcripts into
`kcode-session-history`.

`kcode-audio-ingress` remains the sole owner of original audio, transcription
processing, retries, and completed transcripts. `kcode-session-history` remains
the sole owner of session lifecycle and persistence. This library owns no
persistence and contains no HTTP behavior.

Deterministic transcript-piece planning is delegated to
`kcode-audio-transcript-plan` 0.1.0. That side-effect-free leaf derives the
ordered `TranscriptPlan`, canonical audio piece identities, transcript-only
token estimates, audio metadata, and formatted transcript and confirmed-speaker
text. This coordinator remains responsible for deciding when a plan may be
persisted, correlating it with current recording and History state, and adapting
planning failures to its established error contract.

The cloneable `Coordinator` is scoped to one configured application user. It:

- attributes new submissions to that user and fails closed when AudioIngress's
  global SHA-256 deduplication returns a recording attributed to another user;
- exposes, looks up, retries, confirms, and synchronizes only recordings whose
  `RecordingStatus.user_id` exactly matches the configured user;
- projects recording and transcript-piece state across the two owners;
- exposes AudioIngress's correction packet and applies exact human speaker
  confirmations through its typed API;
- plans completed transcripts into pieces bounded to one quarter of the
  configured effective ingress context window;
- uses deterministic `audio:<recording-id>:<piece-index>` idempotency
  identities;
- submits missing pieces to Session History without duplicating existing work,
  but only after every classifier-aware observation has a human-confirmed full
  name; and
- retries memory ingress only after correlating the current Session History
  record to the exact current configured-user audio piece.

A completed classifier-aware transcript remains in `speaker_review` until its
packet is fully confirmed. Confirmation immediately attempts the idempotent
Session History handoff and includes a compact authoritative chunk-local
speaker mapping with every transcript piece. Legacy recordings without packets
retain their established immediate handoff. A recording with authorized labels
and no represented pieces is `ready_for_ingress`; claimed, failed, and complete
pieces are reported as `ingressing`, `ingress_failed`, and `complete`. An exact
retry of an accepted confirmation is idempotent; a different confirmation is
rejected once any deterministic piece has entered Session History.

New recordings are segmented from the effective context when their ingress
sessions are created. Session History metadata retains the deterministic piece
index and count alongside complete file metadata. Existing canonical
`audio:<recording>:<index>` identities remain authoritative. Synchronization
never remaps or overwrites a complete accepted identity set; it fills a partial
set only when the current plan has the same piece count.

`retry_ingress` first loads the current Session History record, requires a
canonical audio idempotency identity belonging to a completed configured-user
recording, rebuilds the current authoritative plan, and verifies the exact piece
identity, formatted text, and metadata before allowing the retry. Unrelated,
malformed, foreign, stale, or drifted records are rejected without mutation.

The public optional `RetryIngress.state` remains for 0.2 wire compatibility.
When supplied, it must exactly equal the current Session History state or the
coordinator returns a conflict. Caller-supplied state never replaces retained
state: the coordinator always passes the current state to Session History.

The library exposes transport-neutral typed outcomes and error categories. It
does not define a serialized wire format; HTTP and other adapters own their
response DTOs and status-code mapping. Its outcomes retain the fields and retry
inputs needed to preserve Kennedy's pre-extraction HTTP behavior.