feat(voice): implement local S2S retained history and provider selection

Add pinned CPU engine dependencies, retained interrupted-response history, provider admission, offline evaluation and isolated browser tooling.

Record Phase 2 acceptance and Phase 3/4 preparation, bounded paid-test accounting and interruption incident findings. Human interruption acceptance, paired OpenAI evaluation and rollback remain pending.
This commit is contained in:
11linear11
2026-10-16 17:09:27 -04:00
parent 8d348f0ba1
commit a94b8cd3ea
111 changed files with 14764 additions and 58 deletions
@@ -0,0 +1,142 @@
# Phase 2 offline assets and Linux lifecycle follow-up — 2026-10-16
Current verdict (2026-10-16): **Phase 2 accepted for isolated development-only
normal Persian browser voice**. [Final evidence](phase-02-accepted-20261016.md)
and [machine-readable results](phase-02-accepted-20261016.json):
125 local + 258 preservation + 63 PostgreSQL tests passed; actual browser response
fully played and closed normally. Conservative cost exposure $0.420504399, below
the same $1 cap; final invoice details remain unresolved with full reserves held.
Paid engine stopped normally. No buffer/speed change or operational promotion.
Phase 3/4 remain not_started. Earlier checkpoints below are historical and are
superseded where they describe open Phase 2 gates.
Current incident follow-up: [first browser-turn initialization stall repaired](phase-02-browser-first-turn-repair-20261016.md).
User session failed after transcription. Native snapshots identified first-reply
Lingua model preload; same cache now warms before listener readiness. Three full
proxy/API/native continuous-input fixture sessions and98 focused tests pass.
Fixed image a51167d1952a; no buffer/speed/timeout change. Repair handoff carries all
prior attempts; cumulative reservation ceiling $0.995118333 of the same$1. Human
browser greeting passed: 7.296s fully played, closed/user_requested, no persisted error.
Current reserved exposure is $0.925118333; final billing and applicable DB gates
remain. Earlier ready checkpoints below are historical.
Current browser handoff (2026-10-16): [isolated browser is ready](phase-02-browser-ready-20261016.md).
Angular/API/login and actual proxied WebSocket session_ready/normal close passed;
no inference in connection check. Three real startup probes passed. Human microphone/
reply/transcript acceptance remains open. Same $1 authorization; reconciled prior
exposure $0.689118333, cumulative ceiling $0.901118333, startup reserve $0.748118333.
Private login file and 30-minute engine watchdog documented. No tuning/operational change.
Latest actual run (2026-10-16): [real native Persian round trip passed](phase-02-real-native-20261016.md).
Six actual requests succeeded, 2.528s reply audio, successful terminal/normal
release and clean shutdown. Cumulative reservation is $0.998 of the same $1;
final billing remains unresolved, so no further paid request. User accepted native output; browser/microphone remains open; earlier memory blocker below is historical.
No operational switch or audio tuning change.
Latest preparation (2026-10-16): [bounded real native session](phase-02-native-paid-preparation-20261016.md).
Single-sample pronunciation accepted by the user. Cumulative reservation ceiling
is $0.998 including the retained $0.56; no new paid request. Real launch awaits
>5GiB host headroom. Budget/runner checks and actual native fixture pass; browser
and real session acceptance remain open. Audio tuning and operations unchanged.
Latest real-stage checkpoint: [Persian component tests under $1 authorization](phase-02-real-components-20261016.md).
PCM TTS, STT and LLM succeeded; generated audio awaits listening and final TTS
billing remains unverified. Earlier no-paid-call statements below are historical.
Newest: [actual native sessions, signals, cleanup repair and OOM recovery](phase-02-native-session-20261016.md).
Normal native audio/close, signals and fixture-provider failure now pass; target
cold start and real component/browser listening remain unaccepted.
Later checkpoints: [resources acquired and validated](phase-02-linux-assets-20261016.md),
then [Queue repair and actual constructor success](phase-02-queue-repair-20261016.md).
Missing-resource and constructor blockers below are historical; full native
session/audio/POSIX and real-provider acceptance remain open.
Phase 2 remains **in_progress**. Four real POSIX signal checks passed against the
built image's actual lifecycle and HTTP component gateway. Full asset-backed
engine construction is still blocked by missing local NLTK tagger and Silero
source/JIT resources. No runtime source, image, provider configuration, audio
speed/buffer setting or operational service changed. No download or paid request.
Machine-readable observations and source/script fingerprints are in
[the JSON report](phase-02-offline-preflight-20261016.json).
## Existing local resources
Standard Linux `nltk_data` and Torch Hub roots were absent. Project/cache searches
located a real `punkt_tab` cache under
`/home/moz/Projects/venv/olm/lib/python3.13/site-packages/llama_index/core/_static/nltk_cache`.
The four required English tokenizer files match the SHA-256 values in the earlier
201-file [Windows resource manifest](phase-02-local-assets.json). Copies were
staged under ignored `.local-s2s-build/assets-linux/nltk`; originals were preserved.
These English resources retain the upstream tokenizer behavior; this check does
not assess Persian sentence splitting or speech quality.
In the immutable image, NLTK **3.10.3** loaded those files and split the two-sentence
English check correctly with downloading blocked. The complete `configure_nltk`
call then rejected the missing POS tagger with
`LOCAL_ENGINE_ASSET_VALIDATION_FAILED` (expected exit 1). No full asset manifest
was created because the bundle is incomplete.
Still needed:
- Three `averaged_perceptron_tagger_eng` JSON files listed in
`services/local_s2s/assets.py`.
- A complete local Silero hub source bundle, including `hubconf.py` and
`src/silero_vad/data/silero_vad.jit` with its source dependencies.
The cached faster-whisper `silero_vad_v6.onnx` is a different artifact and was not
substituted. Historical Windows paths are not mounted on this Linux machine.
Transfer the old resources or separately authorize their acquisition before full
engine testing. Fingerprint the complete supplied bundle and validate it inside
Linux before initializing handlers.
## Actual Linux signal subset
[Runnable check](image-lifecycle-smoke.py) uses the image's unmodified `run_owned`
and `ComponentServer`, real loopback HTTP, and real `os.kill` delivery to a fresh
owned child process per case. The runtime object and upstream HTTP transport are
fixtures; no speech pipeline or real provider is constructed. This is stronger
than manually invoking installed signal handlers, but does **not** close the
full-engine POSIX gate or prove container PID-1/native-worker cleanup.
| OS signal | Fixture runtime stop | Result | Signal to child exit |
| --- | --- | --- | --- |
| SIGINT | succeeds | passed | 0.1140 s |
| SIGINT | raises | passed | 0.1144 s |
| SIGTERM | succeeds | passed | 0.1143 s |
| SIGTERM | raises | passed | 0.1141 s |
Each check observed one accepted in-flight fixture request, one cancellation and
one release; zero pending requests and zero transport close errors; a closed
listening socket, joined gateway thread and restored signal handlers. Numeric
final cleanup counters were emitted even when runtime stop raised. That controlled
error made `run_owned` return 1 as required; the checking child itself exited 0.
Run from the repository root with the existing image (no image build or package
installation required):
```sh
docker run --rm --network none --read-only --cap-drop ALL \
--security-opt no-new-privileges --memory 512m --pids-limit 128 \
--tmpfs /tmp:rw,noexec,nosuid,size=32m -e PYTHONPATH=/app \
-v "$PWD/docs/evaluation/local-s2s/image-lifecycle-smoke.py:/checks/image-lifecycle-smoke.py:ro" \
--entrypoint python \
sha256:5c80c77c54da4641318e69cdb8fff092391cd746e491fa8029280c2999ce27d1 \
/checks/image-lifecycle-smoke.py
```
Initial harness launch omitted `PYTHONPATH=/app` and failed to import `services`
from the externally mounted script; the corrected command above passed all four
cases. No image or application change was needed. All owned check containers were
removed. The pre-existing unrelated `fastapi_db` restart loop was left untouched.
No broad regression rerun was needed for this evaluation-only change; the earlier
423 passing checks remain historical evidence, not a new execution claim.
## Remaining gate and next action
Provision the missing real resources, generate/review a complete fingerprint
manifest, validate NLTK POS and Silero JIT in the immutable image, then construct
the complete engine with controlled provider I/O and test native sessions/audio
and POSIX shutdown. Actual provider requests and a Persian browser/listening run
remain separate bounded-authorized steps. No Phase 2 acceptance is claimed here.