fix(openai): prompt engineering and transcript model
This commit is contained in:
@@ -0,0 +1,106 @@
|
||||
# OpenAI Persian delivery Phase 2 ? 2026-10-11
|
||||
|
||||
Implementation: fixed OpenAI delivery revision `iranian-persian-professional-v1`
|
||||
composed after the unchanged shared POLICY. Gemini uses exactly POLICY as before.
|
||||
OpenAI reservations freeze `style_revision` and `effective_instructions_digest`
|
||||
(SHA-256 of exact UTF-8 effective instructions) alongside Phase 1 audio settings.
|
||||
Missing or changed fields make an old reservation unusable before provider opening;
|
||||
replay retains its identity and stored snapshot. Use a fresh reservation after a
|
||||
prompt, revision, or voice change. No public event/DTO or migration changes.
|
||||
|
||||
Style asks for respectful conversational Iranian Persian, clear technical terms,
|
||||
short complete sentences, moderate pacing and clause pauses. It distinguishes
|
||||
insufficient evidence from technical failure, preserves facts and negation, and
|
||||
remains subordinate to fresh retrieval and untrusted-source rules. No behavioral
|
||||
examples were added: reviewer-approved examples and attribution are unavailable.
|
||||
This is prompt configuration, not measured speech quality or model compliance.
|
||||
|
||||
## Fixed comparison protocol and listener rubric
|
||||
|
||||
Use `docs/evaluation/openai-persian-delivery-comparison.json` as the locked run
|
||||
manifest. Model is `gpt-realtime-mini`; ASR is Phase 1 default whisper-1/fa,
|
||||
VAD .5/300/500 ms, no noise reduction, runtime-owned responses/interruptions.
|
||||
Compare marin first, then cedar, with shimmer as control. All three use the same
|
||||
exact effective instructions and approved input set. This is a voice-only
|
||||
experiment; ASR/model comparisons belong to other phases. Do not silently
|
||||
substitute unavailable models or inputs. Capture the full execution profile,
|
||||
prompt digest, input hashes, run/session IDs, and environment for every run.
|
||||
|
||||
Before any calls, a human freezes approved recordings/dialogue inputs, binds
|
||||
any document questions to authorized ready selected originals and reviewed
|
||||
critical facts, and records an input-set identifier and digest. Include greetings,
|
||||
ambiguity, no_evidence, error, technical terms, numbers, dates, conditions,
|
||||
exclusions, negation, and fresh-retrieval follow-ups. Do not invent expected facts.
|
||||
Every voice uses new sessions with identical inputs/order and reset context;
|
||||
record session readiness acknowledgment and exact profile. Keep recordings only
|
||||
as approved evaluation assets, never production recording/history.
|
||||
|
||||
An operator keeps a separate voice-to-clip mapping, strips voice names from
|
||||
listener filenames and metadata, randomizes presentation order independently for
|
||||
at least three native Iranian Persian listeners, and collects independent scores
|
||||
before revealing mappings. Score naturalness, pronunciation, and conversational
|
||||
professionalism separately: 1 unusable; 2 frequent distracting problems; 3
|
||||
understandable with noticeable problems; 4 natural with minor issues; 5 consistently
|
||||
natural and professional. Record pacing and clarification/failure accuracy comments.
|
||||
Require each dimension mean >=4/5 for the selected voice, with all three listeners
|
||||
covering the same clips. Report sample/listener counts, missing ratings and means
|
||||
per voice; missing scores are not zero and cannot establish passage. A separate
|
||||
human fact review must find no changed critical values, conditions, or negation.
|
||||
Report p50/p95 latency and observed usage/cost availability separately.
|
||||
|
||||
## Compatibility and interruption gate
|
||||
|
||||
The classifier is unchanged: only gpt-realtime-mini/shimmer with structured
|
||||
invalid_request_error/response_cancel_not_active and absent/null param is verified.
|
||||
Marin/cedar are unverified. Never accept them by substring or inferred similarity.
|
||||
An explicit bounded probe authorization must specify pairs, connection/response
|
||||
limits, timeouts and spend budget before any compatibility provider calls.
|
||||
Capture sanitized structured type/code/param and cancellation event correlation,
|
||||
terminal status ordering and matching item/content/played-position truncation ack.
|
||||
Never log raw audio, transcripts, credentials or document/provider payloads.
|
||||
Only matching actual candidate evidence authorizes a classifier extension.
|
||||
|
||||
Then exercise the main application runtime: interruption during generation and
|
||||
retrieval, completed generation with undrained playback, terminal-before-error
|
||||
and terminal-after-error races, rapid repeated speech starts, final played-position
|
||||
updates (including zero), duplicate/late acknowledgments, missing terminal/incorrect
|
||||
truncation failures, stop/disconnect, replay/profile rejection and stale selection/
|
||||
access barriers. Require correlated cancellation, independent terminal confirmation,
|
||||
frozen played position and exact truncation acknowledgment before next response.
|
||||
Synthetic fixtures establish regression behavior only, not real compatibility.
|
||||
|
||||
## Acceptance report
|
||||
|
||||
Implementation status: implemented except pending human-reviewed examples.
|
||||
Acceptance status: not_run; Phase 2 remains open. Listener scores for all voices:
|
||||
not_run. Candidate cancellation probes/runtime interruption evidence: not_run.
|
||||
New provider connections/calls: 0; paid evaluation budget consumed: 0.
|
||||
Historical shimmer evidence remains limited to the context-sync repair report;
|
||||
it does not prove Persian delivery or every active interruption scenario.
|
||||
Missing prerequisites: approved examples, frozen human inputs, three native
|
||||
listeners, explicit bounded provider authorization, and actual application/browser
|
||||
interruption evidence. No selected voice promotion, deployment or defaults change.
|
||||
|
||||
Prompt structure follows [official voice prompting guidance](https://developers.openai.com/api/docs/guides/voice-prompting).
|
||||
Use [Realtime voice guidance](https://developers.openai.com/api/docs/guides/realtime-conversations)
|
||||
when checking candidate availability; documentation is not empirical compatibility.
|
||||
|
||||
## Executed regression evidence
|
||||
|
||||
- `.venv/Scripts/python -m pytest tests/unit/test_openai_persian_style.py tests/unit/test_openai_speech_configuration.py tests/unit/test_live_context_sync.py tests/unit/test_realtime_phase1.py tests/unit/test_realtime_repairs.py tests/unit/test_realtime_remaining.py tests/unit/test_gemini_live.py -q -p no:cacheprovider --tb=short`: final 338 passed in 50.27 s. Initial 337 passed/1 failed was a new test's incorrect Gemini setup-shape assumption, corrected to inspect emitted instructions.
|
||||
- `.venv/Scripts/python -m pytest tests/integration/test_openai_speech_profile.py -m postgres --require-postgres -q -p no:cacheprovider --tb=short`: 10 passed in 107.86 s, zero skips. Isolated task-created pgvector container `rag-persian-phase2-20261011-test`, loopback 55441, dedicated `rag_persian_phase2_test`; existing immutable migrations applied by fixtures. Container and anonymous storage removed afterward. No full PostgreSQL suite claim.
|
||||
- `.venv/Scripts/python -m pytest -m "not postgres" -q -p no:cacheprovider --tb=short`: stopped before completion while the existing environment-isolation driver ran a captured second full suite. No pass claim.
|
||||
- `.venv/Scripts/python -m pytest -m "not postgres" -k "not test_ordinary_suite_ignores_ambient_ingestion_configuration" -q -p no:cacheprovider --tb=short`: 1880 passed, 3 Windows symlink skips, 426 deselected (PostgreSQL plus the duplicate-suite driver), 1 failed, 25 deprecation warnings, 189.36 s. Unchanged `test_real_large_escaped_json_keeps_concurrent_loop_active[4499]` measured 187.67 ms against its 100 ms heartbeat bound.
|
||||
- `.venv/Scripts/python -m pytest tests/unit/test_json_processing.py -q -p no:cacheprovider --tb=short`: 8 passed, 1 failed in 11.53 s. The 4499 case passed; the 10000 case measured 234.46 ms against 100 ms. Timing instability remains unresolved; no limits or ingestion code were changed and no definitive cause is claimed.
|
||||
- Static checks: shared POLICY equals HEAD byte-for-byte as a Python string; Gemini adapter diff is empty; cancellation classifier AST equals HEAD; manifest matches effective configuration; new/extended Python files parse; `git diff --check` passed.
|
||||
|
||||
Affected Phase 2 sources: `app/modules/voice/openai_style.py`,
|
||||
`app/infrastructure/realtime.py`, `app/modules/voice/configuration.py`,
|
||||
`tests/unit/test_openai_persian_style.py`, and the existing working-tree
|
||||
`tests/integration/test_openai_speech_profile.py`. Documentation: this handoff,
|
||||
comparison JSON/rating CSV, API catalog and reference map. Existing Phase 1
|
||||
configuration/transcript/runtime edits were preserved; no Phase 3/4 work added.
|
||||
|
||||
These results establish deterministic adapter/runtime coverage and targeted
|
||||
persistence behavior, not listener scores, actual model grounding compliance,
|
||||
marin/cedar cancellation compatibility, or release readiness.
|
||||
@@ -0,0 +1,224 @@
|
||||
# OpenAI Persian speech Phase 1 implementation and frontend handoff
|
||||
|
||||
Date: 2026-10-11. Scope: Phase 1 of [the quality plan](../plans/openai-realtime-persian-quality-plan.md).
|
||||
Implementation and acceptance are tracked separately in the [baseline report](../evaluation/openai-persian-speech-baseline.json).
|
||||
No Phase 2 style/voice or Phase 3 conversation/retrieval change is included.
|
||||
|
||||
## Configuration and frozen admission
|
||||
|
||||
The main `python -m app.server` path uses VoiceSettings, the selected provider
|
||||
factory and RealtimeAdapter. Gemini's profile, setup and instructions remain
|
||||
unchanged. The standalone live_voice_server.py spike is untouched.
|
||||
No public DTO, normalized event, database schema or migration changes.
|
||||
|
||||
OpenAI reservations now include `execution_profile.audio_input`: exact requested
|
||||
PCM format, transcription model/language mode/prompt/keywords, server VAD
|
||||
threshold/prefix/silence settings and noise reduction. The same validated settings
|
||||
produce the adapter session.update. Both VAD ownership flags remain false.
|
||||
Readiness requires matching provider acknowledgment, including all configured
|
||||
audio fields; conflicting language modes or an automatic idle timeout fail closed.
|
||||
Configuration copies are revalidated before the factory opens a connection.
|
||||
|
||||
The baseline remains whisper-1/fa, no prompt/keywords, VAD threshold 0.5,
|
||||
prefix padding 300 ms and silence duration 500 ms, no noise reduction.
|
||||
The VAD values previously omitted from the wire are now explicit documented
|
||||
defaults. Noise off is explicit null. These are requested settings; the
|
||||
deployment's historical acknowledgment/default noise value was not observed.
|
||||
No baseline speech accuracy or release acceptance is inferred from defaults.
|
||||
|
||||
| Setting | Default | Validation |
|
||||
| --- | --- | --- |
|
||||
| OPENAI_REALTIME_ASR_MODEL | whisper-1 | whisper-1 or gpt-transcribe; no silent substitution |
|
||||
| OPENAI_REALTIME_ASR_LANGUAGE | fa | fa/en/null; must be null for gpt-transcribe |
|
||||
| OPENAI_REALTIME_ASR_LANGUAGES | [] | Unique fa/en list; gpt-transcribe only |
|
||||
| OPENAI_REALTIME_ASR_PROMPT | empty | At most 1024 characters |
|
||||
| OPENAI_REALTIME_ASR_KEYWORDS | [] | At most 64 unique, nonblank terms, 100 characters each; no angle brackets or line breaks; gpt-transcribe only |
|
||||
| OPENAI_REALTIME_VAD_THRESHOLD | 0.5 | Finite 0..1 |
|
||||
| OPENAI_REALTIME_VAD_PREFIX_PADDING_MS | 300 | Integer 0..2000 |
|
||||
| OPENAI_REALTIME_VAD_SILENCE_DURATION_MS | 500 | Integer 100..2000 |
|
||||
| OPENAI_REALTIME_NOISE_REDUCTION | null | null, near_field or far_field |
|
||||
|
||||
The integer ranges and text/list caps are local engineering limits, not provider
|
||||
performance guarantees. These fields are server configuration; no client selectors.
|
||||
Environment `null` parses as Python None only for the new optional ASR language/noise fields. JSON arrays are required for list settings.
|
||||
|
||||
Explicit ASR candidate, without changing any defaults:
|
||||
|
||||
```dotenv
|
||||
OPENAI_REALTIME_ASR_MODEL=gpt-transcribe
|
||||
OPENAI_REALTIME_ASR_LANGUAGE=null
|
||||
OPENAI_REALTIME_ASR_LANGUAGES=["fa","en"]
|
||||
OPENAI_REALTIME_ASR_PROMPT="Iranian Persian technical support with English terminology."
|
||||
OPENAI_REALTIME_ASR_KEYWORDS=["PCM16LE","API"]
|
||||
OPENAI_REALTIME_VAD_THRESHOLD=0.5
|
||||
OPENAI_REALTIME_VAD_PREFIX_PADDING_MS=300
|
||||
OPENAI_REALTIME_VAD_SILENCE_DURATION_MS=500
|
||||
OPENAI_REALTIME_NOISE_REDUCTION=null
|
||||
```
|
||||
|
||||
Operators must maintain literal vocabulary and a short context description.
|
||||
Never insert expected answers, retrieved document text or display transcripts.
|
||||
The transcription stream is display guidance; the conversation model consumes
|
||||
audio independently. The runtime never turns display transcripts into input.
|
||||
|
||||
Official schema verified on 2026-10-11:
|
||||
[Realtime transcription](https://developers.openai.com/api/docs/guides/realtime-transcription)
|
||||
supports gpt-transcribe after committed turns over WebSocket.
|
||||
[Client-event schema](https://developers.openai.com/api/reference/resources/realtime/client-events)
|
||||
supports gpt-transcribe, plural languages, keywords, server VAD and near/far-field
|
||||
noise reduction. Do not send singular and plural language fields together.
|
||||
This verifies documented schema support, not account availability or real quality.
|
||||
No transcription delay, semantic VAD or separate transcription service was added.
|
||||
The [deprecation notice](https://developers.openai.com/api/docs/deprecations) still
|
||||
lists gpt-realtime-mini retirement on January 20, 2027 and whisper-1 on February
|
||||
26, 2027. Defaults were retained for a controlled baseline; no replacement was
|
||||
promoted or assumed available.
|
||||
|
||||
Replay still returns the original session/request identity after configuration
|
||||
changes. Stream admission compares the frozen snapshot before opening the
|
||||
provider. OpenAI reservations missing audio_input or differing from today's
|
||||
effective profile are unusable; no snapshot is repaired or rewritten. Reconcile
|
||||
and close the old reservation, then create a fresh reservation/request ID.
|
||||
The existing active-session busy rule and ownership checks still apply.
|
||||
|
||||
## Speech assets and scoring
|
||||
|
||||
The [manifest](../evaluation/openai-persian-speech-manifest.json) contains 30
|
||||
planning slots: ten each quiet/office/moderate noise, split 20 development and
|
||||
ten held-out, with three planned speaker slots and coverage requirements.
|
||||
Every recording, speaker identity, consent, duration and device field is empty.
|
||||
Speaker slots are assignments to collect, not claims of actual participants.
|
||||
|
||||
A native human must fill the [annotation template](../evaluation/openai-persian-speech-annotations.json)
|
||||
from approved real recordings, including reference text, reviewer identity,
|
||||
critical number/date/identifier/negation literals, pause and utterance boundaries.
|
||||
Critical facts have objects `{fact_id, kind, literal}`. Approve labels before
|
||||
comparison; do not derive them from provider transcripts. Keep held-out samples
|
||||
out of tuning and prompt/vocabulary construction.
|
||||
|
||||
Copy the [observation template](../evaluation/openai-persian-speech-observations.template.json)
|
||||
to a separate measured report. Record the exact full execution profile and its
|
||||
SHA256 using sorted-key, compact, UTF-8 JSON. Each observation repeats that digest
|
||||
and supplies its session reference, final transcript, human critical-fact results,
|
||||
completion delay (speech end to final transcript), response latency (speech end
|
||||
to first output audio), segmentation/truncation counts, usage/cost availability
|
||||
and classified failure notes. Critical results map fact_id to a human boolean;
|
||||
provide critical_reviewed_by. Never fabricate absent observations or zero latency.
|
||||
Use relative recording paths from the manifest directory and hashes of originals.
|
||||
|
||||
```powershell
|
||||
.venv/Scripts/python -m app.score_speech --manifest docs/evaluation/openai-persian-speech-manifest.json --annotations docs/evaluation/openai-persian-speech-annotations.json --observations path/to/measured-observations.json --split held_out
|
||||
```
|
||||
|
||||
The scorer is offline and makes no provider calls. It emits JSON to stdout;
|
||||
exit 0 means its ASR gate passed, 1 means failed/blocked, 2 means invalid evidence.
|
||||
It normalizes NFC, Arabic/Persian ya/kaf, decimal digit forms, punctuation and
|
||||
whitespace/ZWNJ. It preserves numeric/identifier separators, signs, percentages,
|
||||
repeated words and negation. It reports edit counts and condition-weighted WER,
|
||||
empty/truncated transcripts, segmentation errors and p50/p95 completion/response
|
||||
latency. Critical facts use separate human judgments, not substring heuristics.
|
||||
Incomplete references/recordings/review/cohort prerequisites cannot pass.
|
||||
A scorer pass never closes frontend or real-speech product acceptance.
|
||||
|
||||
No real-provider work is authorized by this handoff. Before each batch record
|
||||
explicit authorized models, maximum sessions, total audio duration, tool calls,
|
||||
embedding calls and currency/spend ceiling, then track actual consumption.
|
||||
First compare baseline ASR versus candidate with identical recordings,
|
||||
conversation model, voice, instructions, VAD and noise. Freeze the chosen short
|
||||
prompt/vocabulary before held-out evaluation. Next compare 500 versus 800 ms
|
||||
silence with threshold/prefix and selected ASR fixed. Finally compare noise
|
||||
off/near_field for confirmed headsets or off/far_field for confirmed laptop
|
||||
microphones. Use fresh sessions and the same utterance order/context each time:
|
||||
gpt-transcribe uses earlier transcribed turns as context.
|
||||
|
||||
Report WER <=10% quiet, <=15% office, <=25% moderate noise; zero designated
|
||||
quiet/office critical errors; segmentation, empty/truncated transcripts,
|
||||
completion delay, response latency, exact full profiles/digests and unavailable
|
||||
usage/cost. Investigate >20% comparable p95 latency regression before promotion.
|
||||
Classify capture, assembly, ASR, segmentation and direct audio understanding
|
||||
independently; improved ASR does not establish improved model understanding.
|
||||
|
||||
## Actual frontend handoff and acceptance checklist
|
||||
|
||||
The repository contains developer examples, not the separately maintained
|
||||
production frontend. No actual browser/hardware acceptance or frontend repair is
|
||||
claimed. The receiving developer must record frontend build/commit, backend
|
||||
build/commit, browser/version, OS, capture device and all observed results.
|
||||
|
||||
Use the runnable [VoiceTranscripts helper](../../examples/voice-transcripts.js)
|
||||
with existing VoiceClient onEvent callbacks:
|
||||
|
||||
```javascript
|
||||
import {VoiceTranscripts} from './voice-transcripts.js';
|
||||
import {VoiceClient} from './voice-client.js';
|
||||
const display = new VoiceTranscripts();
|
||||
const client = new VoiceClient(event => {
|
||||
const row = display.apply(event);
|
||||
if (row) renderTranscript(row.turn_ref, row.role, row.text, row.status);
|
||||
// Handle other existing events as before.
|
||||
});
|
||||
// At the start of each fresh session: display.reset().
|
||||
```
|
||||
|
||||
The callback retains the unchanged application events. Partial text appends by
|
||||
turn_ref AND role; a completed full text replaces that row. Never append finals
|
||||
or assign late finals to the latest active turn. Identical words in distinct
|
||||
deltas are real content. Provider identity replay is handled by the backend; the
|
||||
public transcript has no replay ID, so clients must not deduplicate by text.
|
||||
Interruption retains assistant text marked interrupted; delayed user finals
|
||||
remain displayable on their original turn. An absent transcript stays unavailable.
|
||||
The helper is bounded to 512 rows/65536 characters per row and resets between
|
||||
sessions. Adapt capacity to the actual renderer without retaining production
|
||||
recordings or durable full voice history.
|
||||
|
||||
All items below are **not_run** until the receiving frontend records evidence:
|
||||
|
||||
- [ ] Capture PCM16LE, mono, 24000 Hz; verify bytes with an approved test fixture,
|
||||
device native rate and actual resampling. Reject mismatches before capture.
|
||||
- [ ] Verify positive/negative sample endian/sign, clipping and gain with actual
|
||||
devices. Record browser echoCancellation/noiseSuppression/autoGainControl.
|
||||
- [ ] Verify frame sizes <=9600 bytes, queue <=96000 bytes/100 messages, capture
|
||||
frame loss/gaps and sustained sending, including at least 30 seconds silence.
|
||||
- [ ] Verify output PCM format, sample-based playback progress per audio_ref,
|
||||
queued versus heard audio, flush final progress and cleanup during stop.
|
||||
- [ ] Verify repeated words, distinct equal partial deltas, full-final replacement,
|
||||
T1 completion after T2 partial, role separation and unavailable transcripts.
|
||||
- [ ] Verify interrupted assistant text stays interrupted; late user completion
|
||||
updates only its original turn; revoked/closed sessions deliver no text.
|
||||
- [ ] Verify response audio starts without waiting for ASR completion.
|
||||
- [ ] For each device, collect designated natural-pause cases (including pauses
|
||||
around numbers, negation, self-corrections and English terms) at 500/800 ms;
|
||||
mark actual split/merge errors against human utterance boundaries.
|
||||
- [ ] Exercise interruption during generation/retrieval and after generation with
|
||||
queued playback; accurate heard-position truncation, terminal confirmation,
|
||||
no stale output and one durable close remain required.
|
||||
- [ ] Exercise fresh reservation, configuration change/replay, legacy rejection,
|
||||
stop/disconnect/reconciliation, selection/access revocation and provider error.
|
||||
- [ ] Record held-out condition WER/critical gates and capture/assembly failures
|
||||
separately, with exact frozen profiles and latency comparisons.
|
||||
- [ ] Record receiving developer and human reviewer signoff. Only then mark
|
||||
frontend acceptance passed; Phase 1 remains open while any gate is unrun.
|
||||
|
||||
## Verification record
|
||||
|
||||
Exact executed checks and limitations are maintained in the baseline report.
|
||||
Unit/mock/scorer fixtures are synthetic regression inputs, not quality evidence.
|
||||
Applied revisions, retrieval/calibration policy, cancellation classifier,
|
||||
commit fencing, response-release barriers and heard-position truncation remain.
|
||||
The only runtime tightening rejects malformed transcription event types or
|
||||
post-completion user deltas; display text is never a response-release condition.
|
||||
|
||||
Final affected validation: 361 provider-free voice/configuration/scorer/frontend
|
||||
regressions passed; 82 isolated PostgreSQL profile/replay/authorization/terminal
|
||||
and revocation cases passed with zero skips. The broader database run reported a
|
||||
failure and was interrupted after sustained lack of progress; its full acceptance
|
||||
is unverified. Broad ordinary-suite attempts also failed existing deadline and
|
||||
responsiveness assertions. No assertion was weakened and no unrelated product
|
||||
repair was made. Exact attempts and final results are in the baseline report.
|
||||
The task-owned database container and anonymous storage were removed.
|
||||
|
||||
Final full provider-free attempt: 1874 passed, three existing Windows symlink
|
||||
skips, one existing GeminiVision extraction 100-ms deadline failure. Both
|
||||
parameter variants passed afterward in isolation (2 passed); no cause is
|
||||
established and the full run is not represented as green. These checks do not
|
||||
establish real microphone, ASR, hardware, frontend or deployment acceptance.
|
||||
@@ -0,0 +1,143 @@
|
||||
# Persian understanding Phase 3 ? implementation and gated acceptance
|
||||
|
||||
2026-10-11. Scope: Phase 3 only of the [quality plan](../plans/openai-realtime-persian-quality-plan.md).
|
||||
Implementation and empirical acceptance are separate. No provider calls, promotion,
|
||||
new agent, retrieval engine, GPT-Live adapter, migrations or dependencies.
|
||||
|
||||
## Optional reasoning
|
||||
|
||||
`OPENAI_REALTIME_REASONING_EFFORT=null` preserves omission on the provider wire.
|
||||
Only `low` and `medium` are accepted for the exact `gpt-realtime-2.1` and
|
||||
`gpt-realtime-2.1-mini` identifiers. Other explicit combinations fail before
|
||||
provider opening, including settings copies that bypass initial validation.
|
||||
Settings, factory and adapter use the existing paths. OpenAI execution profiles
|
||||
freeze `reasoning` as null or an effort object. Enabled reasoning requires matching
|
||||
provider acknowledgment before readiness; unrequested non-null reasoning fails.
|
||||
Model/effort changes or missing enabled snapshots reject stream admission before
|
||||
opening. Replay preserves identity, request hash and the original snapshot.
|
||||
Use fresh reservations after changes. Gemini profiles and instructions are unchanged.
|
||||
|
||||
The [official Realtime session schema](https://developers.openai.com/api/reference/resources/realtime/client-events)
|
||||
defines session reasoning effort. The [2.1 model](https://developers.openai.com/api/docs/models/gpt-realtime-2.1)
|
||||
and [2.1 mini model](https://developers.openai.com/api/docs/models/gpt-realtime-2.1-mini)
|
||||
are reasoning-capable Realtime candidates. The project restricts effort to its
|
||||
planned low/medium comparison; documentation does not establish account access
|
||||
or empirical cancellation compatibility. No classifier extension is authorized
|
||||
without exact structured candidate evidence; the existing baseline restriction stays.
|
||||
|
||||
## Track A preflight
|
||||
|
||||
[Comparison report](../evaluation/openai-persian-understanding-comparison.json)
|
||||
records exact secret-safe local profiles. Local deployment observation is unverified.
|
||||
Local settings: OpenAI gpt-realtime-mini/shimmer; gpt-transcribe languages fa,en;
|
||||
server VAD threshold 0.5, prefix 300 ms, silence 500 ms, both automatic flags false;
|
||||
noise reduction null; style iranian-persian-professional-v1 and recorded digest.
|
||||
Transport testing is true; no calibration report is configured.
|
||||
All four Phase 4 originals and the Phase 2 calibration original match recorded
|
||||
SHA-256 hashes. Hash identity does not approve originals. The four approvals are
|
||||
pending, document bindings null, factual DOCX inclusion unapproved, four unseen
|
||||
annotations empty. Phase 2 status has cutoff null and a historical configured
|
||||
embedding profile; the report separately records current local embedding identity.
|
||||
No approved actor/binding set exists to verify actual persisted document eligibility,
|
||||
selection, access epoch or embedding compatibility. Those checks remain blocked;
|
||||
no deployment corpus or access is changed. CALIBRATION_REQUIRED remains closed.
|
||||
|
||||
Reuse existing commands only after approvals, identity/bindings and budget exist:
|
||||
|
||||
```powershell
|
||||
.venv/Scripts/python -m app.calibrate_search --user-id <authorized-actor> --bindings <approved-bindings.json> --output <new-measured-report.json> --allow-provider-calls
|
||||
.venv/Scripts/python -m tests.evaluate_search --cases <approved-independent-cases.json> --bindings <approved-bindings.json> --calibration <measured-report.json> --user-id <authorized-actor> --output <new-report.jsonl> --allow-provider-calls --provider-call-budget 26
|
||||
```
|
||||
|
||||
Calibration retains its ten-call cap. Retrieval acceptance retains its 1?26 call
|
||||
budget, original bindings, human review, exact selected corpus, frozen embedding
|
||||
and retrieval policy, final authorization and independent question checks.
|
||||
The CLIs' help was executed without provider calls. Neither calibration nor
|
||||
retrieval evaluation was run. Do not treat draft/status files as measured reports.
|
||||
|
||||
## Track B comparison protocol
|
||||
|
||||
The report contains exact prospective low/medium profiles for both candidates,
|
||||
with all other local settings fixed. These are preparation, not selected ASR/voice
|
||||
or passing profiles. Freeze the human-selected ASR/voice, effective instructions,
|
||||
26 approved dialogue scenarios (20 answerable including every critical case,
|
||||
six unsupported), corpus/bindings, selection and embedding/calibration profile
|
||||
before each comparison. Keep scenarios independent from retrieval labels.
|
||||
No scenarios, labels, speech, listener scores or human approvals were fabricated.
|
||||
|
||||
Each live batch requires explicit authorized models, maximum sessions, audio
|
||||
seconds, tool calls, embedding calls and spend ceiling; credentials are insufficient.
|
||||
Run low first for both models. Only a measured failed understanding gate permits
|
||||
separately identified medium evaluation. Use the same approved recordings and
|
||||
corresponding text inputs diagnostically through existing operator/runtime paths.
|
||||
No automatic evaluation runner or new orchestration was introduced.
|
||||
|
||||
Use the [observation template](../evaluation/openai-persian-understanding-observation.template.json)
|
||||
for each case: independently classify audio interpretation, ASR display, tool query,
|
||||
retrieval and answer failures. Compare human spoken intent, displayed transcript,
|
||||
actual query, returned document/chunk evidence and spoken answer. A transcript
|
||||
error alone is not proof of direct audio misunderstanding. Text success with audio
|
||||
failure supports an audio-stage diagnosis; matching failures require inspecting
|
||||
query/evidence/answer stages. Retain multiple categories when justified.
|
||||
|
||||
Check fresh retrieval before each document follow-up/correction/critical claim,
|
||||
clarification for ambiguous references, exact numbers/dates/conditions/exclusions/
|
||||
negation, all six unsupported responses and technical-error explanations.
|
||||
Exercise selection removal, access revocation, late evidence suppression and fresh
|
||||
sessions. Existing provider-free regressions establish runtime barriers, not model
|
||||
instruction adherence. For each candidate model/voice pair, collect exact structured
|
||||
cancel type/code/param with intent correlation, terminal ordering and matching
|
||||
played-position item/content truncation acknowledgments. Exercise interruption
|
||||
while generating, retrieving and draining completed playback, rapid follow-ups,
|
||||
stop/disconnect and stale-context invalidation. Never widen error matching by text.
|
||||
|
||||
Select only complete passing profiles: independent retrieval gate; >=18/20 answers,
|
||||
all critical, 6/6 unsupported; no invented/stale/unauthorized claims; speech/delivery
|
||||
and lifecycle compatibility gates. Rank understanding, critical speech accuracy,
|
||||
then delivery; latency/cost break equivalent quality. Report p50/p95 on comparable
|
||||
samples; investigate p95 increase >20%. Report observed token/audio usage and
|
||||
known cost or explicit unavailable status. No passing profile exists here; selection
|
||||
is null, live quality/latency/usage/cost unavailable, calls/spend zero.
|
||||
|
||||
## Regression evidence
|
||||
|
||||
Checks and classified failures are recorded in the comparison JSON and appended
|
||||
below after completion. No unrelated evaluation defect is silently repaired.
|
||||
|
||||
- Focused ASR/style/reasoning command: `.venv/Scripts/python -m pytest tests/unit/test_openai_reasoning.py tests/unit/test_openai_speech_configuration.py tests/unit/test_openai_persian_style.py -q -p no:cacheprovider --tb=short`: **51 passed**.
|
||||
- Affected final regression command: `.venv/Scripts/python -m pytest tests/unit/test_openai_reasoning.py tests/unit/test_realtime_phase1.py tests/unit/test_realtime_repairs.py tests/unit/test_realtime_remaining.py tests/unit/test_live_context_sync.py tests/unit/test_search_phase4_gate.py tests/unit/test_search_phase4_repairs.py -q -p no:cacheprovider --tb=short`: **351 passed**, 39.30 s.
|
||||
- Full provider-free command: `.venv/Scripts/python -m pytest -m "not postgres" -q -p no:cacheprovider --tb=short`: **1 failed, 1892 passed, 3 existing Windows symlink skips, 429 deselected**, 326.47 s. Existing `test_real_large_escaped_json_keeps_concurrent_loop_active[4499]` measured 132.03 ms against 100 ms. No related production or test limit was changed.
|
||||
- Focused failure investigation: `.venv/Scripts/python -m pytest tests/unit/test_json_processing.py -q -p no:cacheprovider --tb=short`: **9 passed**, 11.13 s. Full-suite failure remains reported; no definitive cause or all-green regression claim.
|
||||
- Final persisted profile command: `.venv/Scripts/python -m pytest tests/integration/test_openai_speech_profile.py -m postgres --require-postgres -q -p no:cacheprovider --tb=short`: **18 passed**, zero skips, 126.16 s. Includes four acknowledgment cases added after broad suite collection. Fresh task-created loopback database `rag_persian_phase3_test` in container `rag-persian-phase3-20261011-test`, port 55442, PostgreSQL 16.15 / pgvector 0.8.7. Only disposable schemas, no deployment DB writes.
|
||||
- Existing label validators: calibration case structure passed; independent draft retrieval manifest failed closed with `Frozen 20 answerable / 6 unsupported with four unseen cases required` before database/provider setup.
|
||||
- Python AST, report JSON, tracked whitespace, unchanged shared POLICY/Gemini adapter and applied migration byte comparisons passed.
|
||||
|
||||
Phase 3 affected files: configuration.py, voice_provider.py, realtime.py,
|
||||
.env.example, new test_openai_reasoning.py, extended test_openai_speech_profile.py,
|
||||
API catalog, this guide, comparison JSON and observation template, reference map
|
||||
and Phase 3 checkpoint in the plan. Pre-existing speech/style/runtime/transcript
|
||||
and evaluation edits were preserved. No public API/normalized event fields changed.
|
||||
|
||||
- Required broad database command: `.venv/Scripts/python -m pytest -m postgres --require-postgres -q -p no:cacheprovider --tb=short` with process-local isolated TEST_DATABASE_URL: **429 passed, zero skips, 1896 deselected**, 1647.70 s. The final targeted 18-test profile run additionally covered acknowledgment tests added after this collection; counts overlap and must not be summed. No real providers.
|
||||
|
||||
Implementation status: implemented. Acceptance status: blocked. The unrelated
|
||||
provider-free full-suite failure remains unresolved; real calibrated retrieval,
|
||||
26-case dialogue quality, native speech scores and exact candidate interruption
|
||||
compatibility remain not_run. Quality/latency/usage/cost cannot be inferred from
|
||||
these regressions. Phase 3 is not closed and no complete profile is promoted.
|
||||
|
||||
Cleanup confirmed zero disposable test schemas and zero public tables. The task-created container and its anonymous volume were removed; pre-existing containers were preserved.
|
||||
|
||||
|
||||
## Operational calibration checkpoint — 2026-10-11
|
||||
|
||||
After the implementation checkpoint above, the user approved the ten-case sample
|
||||
and authorized execution. [The activation handoff](search-calibration-activation-2026-10-11.md)
|
||||
records actual intake, selection, measured 6/6 complete support and zero unsupported
|
||||
false positives across four cases, ten local embedding queries, and activation of
|
||||
the measured report in the main API with transport-testing bypass disabled.
|
||||
The calibration prerequisite is now satisfied in this environment. Independent
|
||||
26-case acceptance, real OpenAI voice quality and candidate interruption evidence
|
||||
remain pending; this operational result does not close Phase 3 or promote a fully
|
||||
validated speech profile. Earlier zero-provider-call statements describe the
|
||||
implementation checkpoint, not this subsequent calibration workflow.
|
||||
@@ -0,0 +1,87 @@
|
||||
# Measured search calibration activation — 2026-10-11
|
||||
|
||||
The approved ten-case calibration was executed against the PostgreSQL database used by the running `app.server` API. The successful report is now mounted read-only and selected by the API. Transport-testing bypass is disabled. This is a measured retrieval configuration for frontend testing, not completion of the independent Persian voice quality gates.
|
||||
|
||||
## Approval and input identity
|
||||
|
||||
The user explicitly approved the sample original and its ten frozen labels in this conversation, then authorized execution of the workflow.
|
||||
|
||||
- Original: `data/calibration/phase2-source.md`
|
||||
- Original SHA-256: `7d1e384210faa9430f715a3f30736c8ad7c782f701843a68bab969845934835f`
|
||||
- Frozen annotations: [phase2-cases.json](../calibration/phase2-cases.json), six answerable and four unsupported cases.
|
||||
- Actual document: `aa4f291c-8808-497f-975f-ce0f7f6f838a`
|
||||
- Organization: `37439088-523c-4403-899f-47e3f809123c`
|
||||
- Enabled administrator: `aec70b67-db27-4696-b2b9-49435a99a3b1`
|
||||
- [Actual bindings](../calibration/approved-bindings.json)
|
||||
- [Scoped operator approval](../calibration/operator-approval-2026-10-11.json)
|
||||
|
||||
The original and labels were preserved. Intake used `app.ingest import` with request ID `872d6761-e74b-4492-9e54-f3a1d5d9f066`, not direct database publication. The existing worker completed its first attempt and atomically published six chunks. Extracted block text was checked against the approved original; this deterministic check does not invent a human review. Markdown used readable-text extraction without vision inference.
|
||||
|
||||
Selection was changed through `app.knowledge selection replace`, fenced at revision 8. The resulting knowledge revision is 9 and access epoch remains 3. All three previously active documents remain selected; the approved calibration document was added. The queue contained no pending unrelated jobs before import.
|
||||
|
||||
## Actual measurement
|
||||
|
||||
[Measured report](../calibration/measured-search-2026-10-11.json):
|
||||
|
||||
| Item | Observed result |
|
||||
| --- | --- |
|
||||
| Status | `calibrated` |
|
||||
| Complete support | 6/6 answerable cases |
|
||||
| Unsupported false positives | 0/4 unsupported cases |
|
||||
| Calibration query embedding calls | 10, within the authorized budget of 10 |
|
||||
| Embedding profile | Ollama / bge-m3 / 1024 dimensions / preprocessing v1 |
|
||||
| Canonical embedding endpoint | `http://localhost:11434/v1` |
|
||||
| Selected cosine distance | `0.33686461167069426` |
|
||||
| Calibration ID | `baec206d-3e5c-477c-9290-fd84f706fa28` |
|
||||
| Final authorization check | Confirmed |
|
||||
| OpenAI voice calls by this workflow | 0 |
|
||||
| Billing and token usage | Not reported by the calibration harness |
|
||||
|
||||
The adapter translates the local embedding endpoint to `host.docker.internal` for container transport while preserving canonical profile identity. Ingestion embedding work is separate from the ten counted calibration query calls.
|
||||
|
||||
The cutoff was selected by the existing calibration algorithm from measured candidate distances. No manually chosen threshold, edited label, fabricated recording, or unsupported successful result was substituted.
|
||||
|
||||
Execution used the existing API image and service configuration:
|
||||
|
||||
```powershell
|
||||
$taskRepo = (Get-Location).Path
|
||||
docker compose run --rm --no-deps --volume "${taskRepo}/docs/calibration:/app/docs/calibration" --volume "${taskRepo}/data/calibration:/app/data/calibration:ro" api python -m app.calibrate_search --user-id aec70b67-db27-4696-b2b9-49435a99a3b1 --bindings /app/docs/calibration/approved-bindings.json --output /app/docs/calibration/measured-search-2026-10-11.json --allow-provider-calls
|
||||
```
|
||||
|
||||
The report path is immutable for this run: rerunning requires a new output filename. The measured report can contain retrieved text from selected documents; retain it as an environment-specific evaluation artifact and review its contents before sharing.
|
||||
|
||||
## Activated runtime
|
||||
|
||||
Only the API service received the new read-only Compose mount:
|
||||
|
||||
```yaml
|
||||
- ./docs/calibration:/app/docs/calibration:ro
|
||||
```
|
||||
|
||||
The ignored local `.env` now selects:
|
||||
|
||||
```dotenv
|
||||
SEARCH_CALIBRATION_REPORT=/app/docs/calibration/measured-search-2026-10-11.json
|
||||
VOICE_TRANSPORT_TESTING=false
|
||||
```
|
||||
|
||||
The API was recreated with `docker compose up -d --no-deps api`. Its candidate voice settings remain OpenAI `gpt-realtime-2.1`, reasoning `low`, voice `shimmer`, and user ASR `gpt-transcribe`. Gemini, applied database migrations, model cancellation classification, and existing runtime code were not edited by this operational calibration workflow.
|
||||
|
||||
## Verification
|
||||
|
||||
- All ten measured case results passed: A1–A6 returned complete evidence; U1–U4 returned `no_evidence`.
|
||||
- Report annotation hash, successful status, final authorization, call budget, and embedding-profile equality passed.
|
||||
- Container-side execution of the existing configuration handler with the actual administrator ID returned `voice=true`, `captions=true`, `calibration_status=calibrated`, and `voice_transport_testing=false`. This was a trusted read-only handler check, not a browser login or an authenticated HTTP acceptance test.
|
||||
- The existing voice capability loader accepted the mounted report and produced the expected calibration ID, distance, profile, and retrieval policy without opening a voice-provider connection.
|
||||
- HTTP `GET http://localhost:8080/health/ready`: 200, ready.
|
||||
- HTTP CORS preflight for `http://localhost:4200` to `/api/v1/configuration`: 200 with the matching allowed origin.
|
||||
- `git diff --check`: passed before the documentation checkpoint; rerun after final documentation.
|
||||
- Broad regression suites were not rerun for this configuration/data-only workflow. Previously reported suite limitations remain.
|
||||
|
||||
## Frontend test and remaining acceptance
|
||||
|
||||
Connect the frontend to `http://localhost:8080` and create a fresh voice session. Existing session reservations keep their frozen profiles and are not upgraded by this restart.
|
||||
|
||||
For a direct calibration smoke check, ask about the sample pump pressure and temperature condition, or the application discount and permit exclusion. An unsupported question such as the land price should yield a lack-of-evidence answer rather than an invented value. Then test actual uploaded documents and record displayed user transcript, tool query, returned evidence, spoken answer, pauses, and interruptions separately.
|
||||
|
||||
The independent 26-case corpus still lacks complete approvals, bindings, and human labels. No independent retrieval gate, real OpenAI dialogue evaluation, listening score, or candidate interruption compatibility was run here. The sample's 10/10 result does not prove accuracy on every uploaded document and does not establish ASR or Persian delivery quality. Phase 3 quality acceptance remains open.
|
||||
Reference in New Issue
Block a user