docs(voice): freeze OpenAI Realtime Phase 0 contracts
Align voice specifications and the MVP plan with OpenAI Realtime. Document audio admission, bounded playback, cancellation ownership, turn correlation, cleanup barriers and calibration prerequisites. Preserve historical checkpoints and record unrun acceptance gates.
This commit is contained in:
@@ -0,0 +1,582 @@
|
||||
# Realtime MVP Phase 0 contract checkpoint
|
||||
|
||||
2026-10-08. Contract/configuration preparation repaired as documented in the final checkpoint below; runtime and quality
|
||||
acceptance remain pending. This scoped amendment selects OpenAI Realtime for
|
||||
voice in the current six English specifications. The historical Persian report,
|
||||
extraction/embedding providers, HTTP DTOs, canonical search outputs and applied
|
||||
migrations are preserved. The [Realtime MVP plan](../plans/realtime-agent-mvp-plan.md)
|
||||
governs the new backend phase sequence; its 3-5 focused days is a conditional
|
||||
estimate, superseding the earlier four-day integration sequence.
|
||||
|
||||
The frozen frontend audio/events are in
|
||||
[API Section 7.1](../specifications/RAG-Phase1-API-Catalog.md).
|
||||
Both directions use raw mono signed PCM16LE at 24 kHz.
|
||||
Existing session_ready/transcript/sources/turn_interrupted/error shapes remain;
|
||||
user_speech_started, audio_started and audio_ended are server events, playback_progress is
|
||||
a validated client control. Provider objects and correlation mappings stay private.
|
||||
No production UI, public text chat, new retrieval or voice runtime is implemented.
|
||||
|
||||
## Backend-only configuration prerequisites
|
||||
|
||||
The following names define the configuration handoff. Only key/model/proxy
|
||||
are currently read by the isolated proof; the other settings must be wired by
|
||||
Phases 1/2. Blank prerequisites must fail closed, not enable a capability.
|
||||
|
||||
| Setting | Initial value or requirement |
|
||||
| --- | --- |
|
||||
| OPENAI_API_KEY | Server secret with funded Realtime model access; do not share the prototype API_KEY fallback with production voice |
|
||||
| OPENAI_REALTIME_MODEL | gpt-realtime-mini, the observed proof configuration; no silent substitution |
|
||||
| OPENAI_REALTIME_VOICE | shimmer, the proof default; fixed by backend, no browser selector/update_voice |
|
||||
| OPENAI_PROXY | Optional operator-controlled proxy; proof falls back to HTTPS_PROXY/HTTP_PROXY; never caller supplied or logged with credentials |
|
||||
| LIVE_TRUSTED_ORIGIN | Exact browser origin including scheme/host/port, e.g. http://localhost:3000 behind a same-origin development proxy; HTTPS in deployment; reject missing/untrusted Origin, no wildcard |
|
||||
| LIVE_CONNECT_TIMEOUT_SECONDS | 15, proof connection timeout |
|
||||
| LIVE_SETUP_TIMEOUT_SECONDS | 30, provider-confirmed setup required before session_ready |
|
||||
| LIVE_TOOL_TIMEOUT_SECONDS | 75 maximum including queue time, earlier trusted monotonic deadline wins; shared four-running/eight-waiting SearchToolRunner |
|
||||
| LIVE_IDLE_TIMEOUT_SECONDS | Explicit finite positive deployment choice required; not yet approved |
|
||||
| LIVE_SESSION_TTL_SECONDS | 600 proposed engineering default; cleanup bounded by expiry |
|
||||
| LIVE_SHUTDOWN_TIMEOUT_SECONDS | Explicit finite positive cleanup deadline required; not yet approved |
|
||||
| LIVE_MAX_QUEUED_AUDIO_SECONDS | 2 per application transport/browser buffer; 96000 bytes / 100 messages, separate from generated backlog |
|
||||
| LIVE_MAX_OUTPUT_BACKLOG_BYTES | 1440000 aggregate G+T+R (30 s); 512 packed slabs, API 7.1.5 |
|
||||
| LIVE_OUTPUT_CREDIT_WINDOW_BYTES | 72000 (1500 ms) across delivery reservations and sent-unconfirmed audio |
|
||||
| LIVE_PLAYBACK_STALL_TIMEOUT_SECONDS | 5 per eligible open/sealed ref with a reportable unplayed millisecond; finalizing/interrupted/retired refs excluded, fresh timer identity per eligibility interval/renewal, API 7.1.5 |
|
||||
| Output memory caps | Raw/scratch/copy/metadata payload budget 2060288 bytes per session; object overhead/global admission require validation, API 7.1.5 |
|
||||
| LIVE_MAX_BINARY_MESSAGE_BYTES | 9600, even nonempty PCM (200 ms) |
|
||||
| LIVE_MAX_CLIENT_CONTROL_BYTES / LIVE_MAX_SERVER_EVENT_BYTES | 4096 / 65536 UTF-8 bytes |
|
||||
| LIVE_FINAL_PROGRESS_WINDOW_MS | 1000 from interruption detection, engineering default |
|
||||
| LIVE_TRUNCATION_ACK_TIMEOUT_SECONDS | 5 after dispatch, engineering default; fail context synchronization on timeout |
|
||||
| LIVE_SEND_TIMEOUT_SECONDS | 5 per send, engineering default |
|
||||
| Other transport caps | Input 10 s since commit; control queues 64 / 262144 bytes; provider message 262144 bytes; 64 unretired / 256 total refs, API 7.1.3 |
|
||||
| SEARCH_CALIBRATION_REPORT | Operator-controlled path to a new measured report; initially absent, never the pending phase2-status.json |
|
||||
| Auth session TTL | Eight hours proposed; identity integration remains Phase 2 |
|
||||
|
||||
Durations must be finite and positive; no automatic provider retries or
|
||||
caller overrides. Secrets/proxy/report paths are not frontend capabilities.
|
||||
Snapshot nonsecret execution settings when durable lifecycle is implemented.
|
||||
|
||||
Official documentation checked on 2026-10-08:
|
||||
[gpt-realtime-mini model](https://developers.openai.com/api/docs/models/gpt-realtime-mini)
|
||||
lists the configured model and function calling;
|
||||
[Realtime client configuration](https://developers.openai.com/api/reference/resources/realtime/client-events)
|
||||
lists shimmer and 24 kHz PCM input/output and forbids changing voice after audio
|
||||
has been emitted. [Conversation guidance](https://developers.openai.com/api/docs/guides/realtime-conversations)
|
||||
describes session configuration and WebSocket interruption/truncation.
|
||||
Documentation support does not verify this account, Persian quality or runtime.
|
||||
|
||||
### Provider configuration lifecycle and replacement decision
|
||||
|
||||
Read the official sources on 2026-10-08; this is documentation verification,
|
||||
not account/model access, Persian quality or live truncation acceptance.
|
||||
|
||||
| Selected configuration from the proof | Official lifecycle | Required action |
|
||||
| --- | --- | --- |
|
||||
| gpt-realtime-mini | Deprecated 2026-07-20; API retirement 2027-01-20 | Preserve this alias initially; backend fails explicitly on unavailable access, never substitutes a model |
|
||||
| shimmer | Listed Realtime built-in voice; no separate retirement date found in the consulted sources | Preserve fixed voice; no browser override or in-session switch |
|
||||
| Input transcription whisper-1, language fa | Deprecated 2026-08-26; API retirement 2027-02-26 | Preserve the proof's actual Persian transcription setup initially; no automatic transcription-model replacement |
|
||||
| Input/output audio/pcm, rate 24000 | Official Realtime input/output configuration supports 24 kHz PCM | Keep frozen application PCM16LE; configuration acknowledgement is still required |
|
||||
|
||||
Sources: [model](https://developers.openai.com/api/docs/models/gpt-realtime-mini),
|
||||
[client configuration/truncation](https://developers.openai.com/api/reference/resources/realtime/client-events),
|
||||
[WebSocket interruption](https://developers.openai.com/api/docs/guides/realtime-conversations),
|
||||
and [official deprecations](https://developers.openai.com/api/docs/deprecations).
|
||||
Successful truncation has a provider acknowledgement; a send alone is not
|
||||
confirmation. API Section 7.1.2 adds application ordering/timeout policy rather
|
||||
than assuming provider response cancellation fixes unheard context.
|
||||
The proof also sets output speed 0.98; this repair changes none of its settings.
|
||||
|
||||
AI/backend owner must make and record a separate replacement decision before
|
||||
the respective retirement dates, with explicit account/budget approval and
|
||||
Persian/tool/truncation regression validation. Official recommendations currently
|
||||
include gpt-realtime-2.1-mini for Realtime and gpt-live-transcribe or gpt-transcribe
|
||||
for transcription; these are candidates, not selected profiles. Do not change
|
||||
extraction/embedding profiles, migrate automatically, or treat a listed model
|
||||
as proof of funded account access. Recheck lifecycle guidance at deployment.
|
||||
|
||||
|
||||
## Search/calibration gate and exact next commands
|
||||
|
||||
Keep the current configured ollama / bge-m3 / 1024 / preprocessing v1 profile
|
||||
and endpoint unchanged. A read-only compatibility probe using the existing
|
||||
check_compatibility could not connect (OperationalError, secret-bearing raw
|
||||
diagnostic suppressed), so the persisted vector dimension/identity and eligible
|
||||
bindings are unverified. TEST_DATABASE_URL is absent. No approved bindings,
|
||||
persisted enabled actor, measured successful report or real-call opt-in were
|
||||
provided for this task.
|
||||
|
||||
[Current calibration status](../calibration/phase2-status.json) is pending with
|
||||
null cutoff and zero recorded provider calls. The existing runner
|
||||
app.calibrate_search uses the canonical candidate service for six answerable
|
||||
and four unsupported questions and authorizes at most ten query embeddings.
|
||||
It verifies original hash, ready/active/undeleted scoped document bindings,
|
||||
embedding profile and stable selection/authorization. Reuse its report loader,
|
||||
app.modules.knowledge.calibration.load_cutoff(report), then inject the returned
|
||||
CalibratedCutoff into SearchService. Profile and retrieval policy must match.
|
||||
Missing cutoff remains CALIBRATION_REQUIRED with empty sources; a diagnostic
|
||||
candidate inspection or test-only cutoff cannot replace measurements.
|
||||
|
||||
Run these provider-free commands now/from the repository root:
|
||||
|
||||
~~~powershell
|
||||
.venv/Scripts/python -m app.calibrate_search --help
|
||||
.venv/Scripts/python -m app.ingest --help
|
||||
.venv/Scripts/python -m app.knowledge --help
|
||||
.venv/Scripts/python -m pytest tests/unit/test_scoped_search.py tests/unit/test_search_phase2.py tests/unit/test_search_phase2_repairs.py tests/unit/test_search_phase2_remaining.py tests/unit/test_search_phase3.py tests/unit/test_search_phase3_shutdown.py -q --tb=short -p no:cacheprovider
|
||||
git diff --check
|
||||
~~~
|
||||
|
||||
### Read-only operator preflight
|
||||
|
||||
Run from the repository root with the existing virtual environment. The first
|
||||
example uses only frozen local bytes; it writes nothing and opens no database or
|
||||
provider. PowerShell's literal here-string avoids native -c quoting problems.
|
||||
|
||||
~~~powershell
|
||||
@'
|
||||
import hashlib
|
||||
import json
|
||||
from pathlib import Path
|
||||
from app.modules.knowledge.calibration import validate_cases
|
||||
|
||||
p = Path("docs/calibration/phase2-cases.json")
|
||||
annotations = json.loads(p.read_text(encoding="utf-8"))
|
||||
validate_cases(annotations["cases"])
|
||||
original = p.parent / annotations["original_file"]
|
||||
digest = hashlib.sha256(original.read_bytes()).hexdigest()
|
||||
if digest != annotations["original_sha256"]:
|
||||
raise SystemExit("ORIGINAL_HASH_MISMATCH")
|
||||
print(json.dumps({"original_sha256": digest, "annotations_sha256":
|
||||
hashlib.sha256(p.read_bytes()).hexdigest()}))
|
||||
'@ | .venv/Scripts/python -
|
||||
~~~
|
||||
|
||||
The exact bindings file is a JSON object, not a document list or report:
|
||||
|
||||
~~~json
|
||||
{
|
||||
"<original_sha256 printed above: 64 lowercase hex characters>": "<actual ready selected document UUID>"
|
||||
}
|
||||
~~~
|
||||
|
||||
Both angle-bracket strings are placeholders and must be replaced. For the
|
||||
unchanged current original, the verified key is
|
||||
7d1e384210faa9430f715a3f30736c8ad7c782f701843a68bab969845934835f.
|
||||
The value must come from real intake/status, not an illustrative UUID. Keep
|
||||
bindings outside frozen annotations and retain operator approval separately.
|
||||
No example below fabricates or writes a binding.
|
||||
|
||||
After publication/selection, set these approved preflight inputs (replace each
|
||||
placeholder; they are identity/path inputs, not credentials):
|
||||
|
||||
~~~powershell
|
||||
$env:PREFLIGHT_ADMIN_ID = '<existing enabled admin UUID>'
|
||||
$env:PREFLIGHT_USER_ID = '<existing enabled calibration-user UUID in the same organization>'
|
||||
$env:PREFLIGHT_BINDINGS = '<absolute path to approved bindings.json>'
|
||||
~~~
|
||||
|
||||
This executable read-only compatibility/eligibility example uses the existing
|
||||
check_compatibility API. It requires the current worker revision, checks the
|
||||
persisted vector dimension/full profile and document profiles, checks enabled
|
||||
admin/user roles and same organization, then checks the bound original is ready,
|
||||
active, undeleted, unpurged and profile-compatible. An initial profile-only
|
||||
result followed by PREFLIGHT_FAILED is not full preflight acceptance. SET
|
||||
TRANSACTION READ ONLY prevents mutations; timeouts bound queries and connection.
|
||||
The example never uses authority's locking path in a read-only transaction.
|
||||
|
||||
~~~powershell
|
||||
@'
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
from dataclasses import asdict
|
||||
from pathlib import Path
|
||||
from uuid import UUID
|
||||
|
||||
from sqlalchemy import create_engine, text
|
||||
from app.infrastructure.database import check_compatibility
|
||||
from app.modules.documents.settings import IngestionSettings
|
||||
from app.modules.knowledge.service import actor
|
||||
|
||||
engine = None
|
||||
try:
|
||||
cases_path = Path("docs/calibration/phase2-cases.json")
|
||||
annotations = json.loads(cases_path.read_text(encoding="utf-8"))
|
||||
original = cases_path.parent / annotations["original_file"]
|
||||
digest = hashlib.sha256(original.read_bytes()).hexdigest()
|
||||
if digest != annotations["original_sha256"]:
|
||||
raise ValueError("Original hash mismatch")
|
||||
settings = IngestionSettings()
|
||||
engine = create_engine(
|
||||
settings.database_url.get_secret_value(),
|
||||
connect_args={"connect_timeout": 3},
|
||||
pool_pre_ping=False,
|
||||
)
|
||||
with engine.connect() as conn:
|
||||
with conn.begin():
|
||||
conn.execute(text("SET TRANSACTION READ ONLY"))
|
||||
conn.execute(text("SET LOCAL statement_timeout = '5s'"))
|
||||
conn.execute(text("SET LOCAL lock_timeout = '2s'"))
|
||||
check_compatibility(conn, settings.embedding_profile, require_worker=True)
|
||||
print("persisted_profile: compatible (including worker revision)")
|
||||
# Set only to existing operator-approved identities and bindings.
|
||||
admin_id = UUID(os.environ["PREFLIGHT_ADMIN_ID"])
|
||||
user_id = UUID(os.environ["PREFLIGHT_USER_ID"])
|
||||
bindings = json.loads(
|
||||
Path(os.environ["PREFLIGHT_BINDINGS"]).read_text(encoding="utf-8")
|
||||
)
|
||||
document_id = UUID(bindings[digest])
|
||||
admin = actor(conn, admin_id, administrator=True)
|
||||
user = actor(conn, user_id)
|
||||
if admin["organization_id"] != user["organization_id"]:
|
||||
raise ValueError("Actors differ in scope")
|
||||
snapshot = conn.execute(text("""
|
||||
SELECT knowledge_revision, access_epoch
|
||||
FROM organization_settings WHERE organization_id=:org
|
||||
"""), {"org": user["organization_id"]}).mappings().one()
|
||||
row = conn.execute(text("""
|
||||
SELECT id FROM documents
|
||||
WHERE id=:id AND organization_id=:org AND file_sha256=:digest
|
||||
AND status='ready' AND is_active
|
||||
AND deleted_at IS NULL AND content_purged_at IS NULL
|
||||
AND processing_profile->'embedding'=CAST(:profile AS jsonb)
|
||||
"""), {
|
||||
"id": document_id, "org": user["organization_id"], "digest": digest,
|
||||
"profile": json.dumps(asdict(settings.embedding_profile)),
|
||||
}).one_or_none()
|
||||
if row is None:
|
||||
raise ValueError("Bound original not ready/selected/eligible")
|
||||
print(json.dumps({
|
||||
"preflight": "eligible_snapshot",
|
||||
"knowledge_revision": snapshot["knowledge_revision"],
|
||||
"access_epoch": snapshot["access_epoch"],
|
||||
}))
|
||||
print("Preflight only; no embeddings, calibration or voice calls made.")
|
||||
except Exception as exc:
|
||||
# Do not print exception text, URL, SQL parameters, settings or credentials.
|
||||
print("PREFLIGHT_FAILED: " + type(exc).__name__ +
|
||||
"; check approved identities/bindings, original hash and configured database/profile.")
|
||||
raise SystemExit(1)
|
||||
finally:
|
||||
if engine is not None:
|
||||
engine.dispose()
|
||||
'@ | .venv/Scripts/python -
|
||||
~~~
|
||||
|
||||
The persisted profile is a column metadata/comment check, not a query to an
|
||||
invented embedding_profiles table. Configured profile identity alone is
|
||||
insufficient. The preflight is a short-lived eligible snapshot, not a durable
|
||||
approval or account-access proof: the calibration CLI revalidates binding,
|
||||
actor, selection revision/epoch and final authorization. Freeze the entire
|
||||
selected corpus for the run; all selected originals must be approved, not just
|
||||
the fixture. Rerun this read-only preflight after selection/review changes.
|
||||
|
||||
### Verified CLI sequence and separate authorizations
|
||||
|
||||
After an operator restores the configured database, verifies its pinned profile
|
||||
using check_compatibility, approves the calibration original and supplies enabled
|
||||
admin/user UUIDs, use the existing intake/publication/selection workflow. Set
|
||||
these PowerShell variables to actual approved values: $administratorId, $userId,
|
||||
$uploadKey (new UUID), $documentId (intake result), $knowledgeRevision (selection
|
||||
get result), $bindingsPath and $reportPath (new path in an existing directory).
|
||||
Preserve the complete selected corpus on selection replacement.
|
||||
|
||||
**Ingestion opt-in:** independently approve the original and worker embedding
|
||||
budget before these commands. worker --once can claim any eligible job in its database; it is not document-targeted and an exit code of zero does not prove this original was processed. Use an
|
||||
approved queue/database and inspect it first. Neither intake nor worker has an
|
||||
--allow-provider-calls flag; starting the worker is its explicit operator opt-in.
|
||||
|
||||
~~~powershell
|
||||
.venv/Scripts/python -m app.ingest import data/calibration/phase2-source.md --administrator-id $administratorId --idempotency-key $uploadKey
|
||||
.venv/Scripts/python -m app.worker --once
|
||||
.venv/Scripts/python -m app.ingest status $documentId --administrator-id $administratorId
|
||||
.venv/Scripts/python -m app.knowledge selection get --administrator-id $administratorId
|
||||
.venv/Scripts/python -m app.knowledge selection replace --administrator-id $administratorId --expected-revision $knowledgeRevision --document-id $documentId
|
||||
~~~
|
||||
|
||||
If other documents are selected, repeat --document-id for each retained approved
|
||||
UUID; do not remove them inadvertently. Ready publication alone is inactive.
|
||||
Record the frozen original_sha256 from phase2-cases.json to the actual selected
|
||||
document UUID in the external bindings JSON. Never fabricate IDs or set states
|
||||
with SQL. Required review decisions remain independent.
|
||||
|
||||
**Calibration opt-in:** separately approve up to ten compatible query embeddings,
|
||||
freeze actor/selection/profile, and only then run:
|
||||
|
||||
~~~powershell
|
||||
.venv/Scripts/python -m app.calibrate_search --user-id $userId --bindings $bindingsPath --output $reportPath --allow-provider-calls
|
||||
~~~
|
||||
|
||||
Set SEARCH_CALIBRATION_REPORT to this successful measured report only after
|
||||
review. Null-cutoff technical_error/measured_failure reports do not unlock search.
|
||||
No voice smoke command exists for the actual runtime yet; Phase 1 must add it.
|
||||
Do not start scripts/live_voice_server.py as grounded-search acceptance:
|
||||
its tool result is hardcoded. Voice smoke requires a third independent opt-in,
|
||||
approved actor/corpus/budget and a ten-minute cap. Ingestion/calibration approval
|
||||
never authorizes Realtime calls.
|
||||
|
||||
## Initial preparation evidence (historical; not rerun by this repair)
|
||||
|
||||
Initial Git status was clean. Read the instructions, current contracts, proof,
|
||||
canonical service, calibration runner/loader, actual LangChain adapter and
|
||||
current calibration records. Read-only configuration inspection observed the
|
||||
model above and a configured Realtime key (value never printed), no proxy and
|
||||
the embedding profile above. Key presence is not access validation.
|
||||
The read-only persisted-profile probe failed to connect; no database mutations
|
||||
or providers were invoked. Exact targeted check outcomes are recorded below
|
||||
after execution. PostgreSQL acceptance, real ingestion, calibration, held-out
|
||||
quality and Realtime/browser smoke are not run. No runtime readiness is claimed.
|
||||
|
||||
Executed targeted provider-free regression command above: **162 passed**, zero skips, 5.49 seconds. CLI help for calibration/intake/selection and tracked git diff --check passed. The first configuration inspection command failed due to Windows quoting; its corrected read-only command passed. No provider or PostgreSQL acceptance was run. A concurrently created untracked scripts/mock_stream_server.py was observed during final inspection and preserved untouched.
|
||||
|
||||
Final preservation checks: proof and all three applied migration files match HEAD byte-for-byte; frozen calibration original hash, changed-document local links, UTF-8 and new-report whitespace passed.
|
||||
|
||||
## Earlier five-findings repair checkpoint (2026-10-08; historical)
|
||||
|
||||
This repair supersedes the earlier incomplete lifecycle/bounds preparation,
|
||||
not the historical test evidence. All five findings are corrected in
|
||||
documentation; runtime enforcement and acceptance remain unimplemented.
|
||||
|
||||
| Finding | Correction / current location |
|
||||
| --- | --- |
|
||||
| 1. Interruption/progress ordering | API 7.1.1-7.1.2: open/sealed/finalizing/retired refs, stop/flush, 1000 ms final window, equal duplicate tombstones, zero missing progress, 5 s acknowledged cleanup barrier before continuation, late-output suppression |
|
||||
| 2. Progress coordinates | API 7.1.1: one ref per provider item/audio content part, no splitting; exact sent bytes, sample alignment, integer floor conversion; new audio_ended delimiter distinguishes generation from playback completion |
|
||||
| 3. Transport bounds | API 7.1.3: byte/count/message/fragment admission, pre-ready rejection, queues and send deadlines, deterministic error/close policy; values explicitly engineering defaults |
|
||||
| 4. Configuration lifecycle | Provider configuration lifecycle table above and plan Section 4: actual whisper-1/fa and model retirement dates, fixed shimmer, future replacement decision |
|
||||
| 5. Reproducible preflight | Read-only operator preflight above: frozen hash, exact bindings object, check_compatibility, enabled actor/scope/ready-selection checks and verified CLI sequence |
|
||||
|
||||
API 7.1.4 contains all six requested contract walkthroughs. Existing event
|
||||
shapes are preserved; audio_ended is the minimal additional delimiter for the
|
||||
last segment, not playback acknowledgement. All mappings/provider IDs remain
|
||||
private; HTTP DTOs and canonical search results are unchanged.
|
||||
|
||||
Unresolved product/deployment decisions: approve engineering frame/queue/ref
|
||||
limits, final-report/cleanup/send windows, capacity/latency targets, idle and
|
||||
shutdown deadlines, auth/session TTL, trusted Origin/hosting, account/funding
|
||||
and replacement profiles before retirement. The defaults define initial
|
||||
integration behavior without recording product approval. Provider multi-part
|
||||
cleanup/cancellation acknowledgement must be proved; unsupported layouts or
|
||||
failed synchronization terminate rather than continuing unsafe context.
|
||||
|
||||
External prerequisites remain verified database/persisted profile, approved
|
||||
originals and ready bindings, enabled same-scope actors, stable full selection,
|
||||
required human reviews, a valid measured calibration report, separate funded
|
||||
ingestion/calibration/voice opt-ins, and later frontend/runtime availability.
|
||||
Missing prerequisites block only their dependent acceptance; absent calibration
|
||||
still returns CALIBRATION_REQUIRED. No cutoff, model access or factual-quality
|
||||
result is invented.
|
||||
|
||||
Current repair validation is documentation-only. Historical 162-test results
|
||||
above were not rerun and do not establish this contract's runtime behavior.
|
||||
No database connection/preflight acceptance, PostgreSQL suite, ingestion,
|
||||
calibration, embeddings, voice or other real-provider call is executed by this
|
||||
repair. The persisted-profile failure above belongs to initial preparation.
|
||||
|
||||
### Earlier executed repair checks and results
|
||||
|
||||
Executed from the repository root, without provider calls:
|
||||
|
||||
~~~text
|
||||
git status --short
|
||||
git diff --stat
|
||||
git diff -- <affected current documentation>
|
||||
git diff --check
|
||||
.venv/Scripts/python -m app.calibrate_search --help
|
||||
.venv/Scripts/python -m app.worker --help
|
||||
.venv/Scripts/python -m app.ingest import --help
|
||||
.venv/Scripts/python -m app.ingest status --help
|
||||
.venv/Scripts/python -m app.knowledge selection get --help
|
||||
.venv/Scripts/python -m app.knowledge selection replace --help
|
||||
~~~
|
||||
|
||||
All six CLI help commands exited 0 and matched the documented positional
|
||||
arguments/flags. Tracked whitespace check exited 0; Git's expected LF/CRLF
|
||||
conversion warnings are not whitespace failures. The local original-hash
|
||||
here-string under Read-only operator preflight was executed verbatim and exited
|
||||
0: original SHA-256
|
||||
7d1e384210faa9430f715a3f30736c8ad7c782f701843a68bab969845934835f,
|
||||
annotation SHA-256
|
||||
b6bd922a0f17a1425d2cf06a3ed801fe0e2a892ec7c069e1e540288b9b2cad8f.
|
||||
|
||||
Read-only inline validation used strict UTF-8 decoding, relative-link existence
|
||||
checks, new-report trailing-whitespace checks, Python ast.parse on both
|
||||
here-string bodies, SHA-256 comparisons against the 177-file repair-start
|
||||
snapshot, and git show HEAD:<path> byte comparisons for the proof and all
|
||||
three applied migrations: passed. PowerShell parsed all six report command
|
||||
blocks with scriptblock.Create without executing their dependent commands:
|
||||
passed. Manual contract consistency review covered all six API walkthroughs,
|
||||
integer/sample/sent-versus-generated accounting, normal and interrupted
|
||||
retirement, final-window/ack barriers, bounds/error/close mapping and
|
||||
plan/report/current-spec alignment.
|
||||
|
||||
Exactly eight documentation files changed in this repair; 168 other baseline
|
||||
files matched their repair-start bytes. A concurrent external edit to
|
||||
scripts/mock_stream_server.py initially triggered the preservation check;
|
||||
it was reported separately and left untouched. No command in this repair
|
||||
writes that file. scripts/live_voice_server.py and all three migrations also
|
||||
match HEAD byte-for-byte. Frozen calibration originals, annotations and
|
||||
status records match the repair-start snapshot.
|
||||
|
||||
Not run: database-dependent read-only preflight (syntax validated only),
|
||||
PostgreSQL acceptance, ingestion/worker processing, calibration/query embeddings,
|
||||
held-out quality, voice/provider smoke, runtime/browser validation and pytest.
|
||||
Historical test/probe results remain explicitly historical. Phase 0 is a
|
||||
documentation checkpoint; no runtime/quality/database readiness is certified.
|
||||
|
||||
## Remaining-four-findings repair checkpoint (2026-10-08)
|
||||
|
||||
This checkpoint supersedes the previous preparation where generation bursts,
|
||||
cancellation races, delayed user transcripts and overlapping turns were
|
||||
underspecified. It is documentation only; no Phase 1-4 runtime is implemented.
|
||||
API Section 7.1 is authoritative. Public event shapes are unchanged by this
|
||||
repair; provider identifiers and release/cancellation tokens remain private.
|
||||
|
||||
| Finding | Correction / authoritative location |
|
||||
| --- | --- |
|
||||
| 1. Bounded output delivery | API 7.1.3/7.1.5: separate G generated reservoir, T transport reservation and R sent-unconfirmed credit ledger; 30 s aggregate backlog, 1500 ms paced window, byte/count/scratch/metadata caps, 5 s no-progress deadline and terminal overload |
|
||||
| 2. Cancellation ownership | API 7.1.2: both VAD flags false, backend-only response-ID-targeted cancellation; coalesced intent, terminal-state race handling, narrow no-active-response exception that never substitutes for cleanup |
|
||||
| 3. Delayed transcripts | API 7.1.6: authorized user-input ASR retains original turn even when delayed; assistant late output cannot restore interrupted work; normal completion is distinguished from actual interruption |
|
||||
| 4. Response release / overlap | API 7.1.6: correlated stop/committed input, current generation token, valid authority/epoch and all cleanup barriers; one consumed initial-create/continuation intent, supersession by genuine new speech and callback-safe gate reevaluation |
|
||||
|
||||
API 7.1.4 now has twelve concrete walkthroughs: the six earlier scenarios plus
|
||||
all six requested burst/stall/race/transcript/commitment/third-turn scenarios.
|
||||
The plan's Phase 1/2 prompts, current implementation guide, architecture audio
|
||||
summary, scenarios and progress records point to the same requirements.
|
||||
Pacing does not equate provider generation completion with application delivery
|
||||
or browser playback. A normally finished exchange is not automatically marked
|
||||
interrupted when new speech begins.
|
||||
|
||||
### Official behavior and unverified assumptions
|
||||
|
||||
Official OpenAI documentation read on 2026-10-08:
|
||||
[client events](https://developers.openai.com/api/reference/resources/realtime/client-events)
|
||||
specifies VAD create_response/interrupt_response, response-ID-targeted
|
||||
cancellation and a session-unaffected error when no response is active;
|
||||
[Realtime reference](https://developers.openai.com/api/reference/python/resources/realtime)
|
||||
describes input transcription as asynchronous to response events and audio
|
||||
generation faster than real time;
|
||||
[conversation guide](https://developers.openai.com/api/docs/guides/realtime-conversations)
|
||||
describes manual response creation with VAD retained, function-result
|
||||
continuation and application-managed WebSocket playback/truncation.
|
||||
|
||||
These sources establish provider capabilities, not the proof's compliance.
|
||||
The selected engineering policy is backend cancellation ownership, both VAD
|
||||
flags false, a 30-second aggregate backlog and 1500 ms delivery window, rather
|
||||
than provider auto-cancellation or unlimited storage. Exact structured
|
||||
no-active-response error classification, speech-start/commit identity ordering,
|
||||
response-intent acknowledgement correlation, multi-item context cleanup,
|
||||
and bounds under real Persian audio require later authorized provider/runtime
|
||||
acceptance. The consulted reference does not publish a stable no-active error
|
||||
code: none is invented, nor is arbitrary error text treated as benign.
|
||||
|
||||
Unresolved engineering/product decisions: approve the backlog/window/count,
|
||||
memory/session admission and stall/cleanup latency budgets; measure allocator
|
||||
overhead, real delta distribution and progress cadence; validate the selected
|
||||
model/account/Origin/network and provider correlations; retain separate model
|
||||
replacement decisions and retirement dates. Defaults define finite initial
|
||||
integration behavior, not product approval or an unlimited-duration guarantee.
|
||||
|
||||
External prerequisites remain a compatible persisted database/profile,
|
||||
approved frozen original/document bindings and enabled same-scope actor,
|
||||
stable approved selection/human reviews, successful measured calibration, and
|
||||
separate ingestion/calibration/voice authorization. CALIBRATION_REQUIRED remains
|
||||
until a valid measured report exists. Missing prerequisites block their
|
||||
dependent acceptance only.
|
||||
|
||||
### Executed / not run for this repair
|
||||
|
||||
Executed checks for this four-findings repair:
|
||||
|
||||
- Read AGENTS.md, the reference map, applicable skill/current contracts,
|
||||
plan/report and actual Git status/diff; no nested instructions were found.
|
||||
- Consulted the official OpenAI references linked above; no provider calls.
|
||||
- `git diff --check` passed (exit 0); existing line-ending notices are
|
||||
informational. Manual contract review checked counters, rounding, pacing,
|
||||
cancellation races, all twelve walkthroughs and current implementation prompts.
|
||||
- Read-only Python inline validation passed: strict UTF-8 and local Markdown
|
||||
link targets in all eight affected documents; report whitespace; two embedded
|
||||
Python examples parsed with `ast.parse` without execution.
|
||||
- PowerShell `[scriptblock]::Create` parsed all six fenced PowerShell examples;
|
||||
their commands were not executed. CLI help was not rerun in this repair.
|
||||
- SHA-256 comparison against the repair-start snapshot: exactly eight
|
||||
documentation files changed, all 169 other baseline files unchanged, no
|
||||
concurrent external changes. Proof, existing mock-server changes and all
|
||||
three applied migrations retain their repair-start bytes; proof/migrations
|
||||
also match HEAD byte-for-byte.
|
||||
- Frozen calibration originals/annotations/status records retain their
|
||||
repair-start hashes. The phase2 original matches the recorded
|
||||
`original_sha256` in `docs/calibration/phase2-cases.json`.
|
||||
|
||||
The inline Python validator used only pathlib/hashlib/json/re/ast and read-only
|
||||
`git show HEAD:<path>`; it opened no database and executed no embedded example.
|
||||
The PowerShell parser read the report and compiled each fenced example only. Earlier 162-test, CLI/preflight and database-probe results
|
||||
remain historical; this repair does not rerun or adopt them as runtime evidence.
|
||||
No database connection/workflow, providers, embeddings, ingestion, calibration,
|
||||
voice, PostgreSQL acceptance, runtime tests or pytest are executed.
|
||||
|
||||
## Playback-stall / cleanup timeout repair (2026-10-08)
|
||||
|
||||
Documentation-only correction; API Section 7.1 remains authoritative. This
|
||||
checkpoint supersedes the earlier unconditional playback-stall wording, not
|
||||
historical check results. Public event shapes and all configured limits remain
|
||||
unchanged; no runtime, transport redesign or provider replacement is implemented.
|
||||
|
||||
- API 7.1.1/7.1.2: only open/sealed refs may be stall-eligible. Interruption
|
||||
atomically moves affected refs to finalizing and invalidates stall identities
|
||||
before browser stop/flush controls. Finalizing includes normal-tail cleanup
|
||||
without relabeling completed output interrupted. Final progress, cancellation
|
||||
confirmation and cleanup acknowledgements retain their independent deadlines.
|
||||
- API 7.1.5: an eligible ref has a successfully sent, reportable unplayed whole
|
||||
millisecond. Each eligibility interval/progress renewal gets a fresh monotonic
|
||||
deadline and private identity. Queued callbacks recheck current state, identity,
|
||||
session usability and expiry under the serialized state decision. Finalization
|
||||
wins make callbacks no-ops; a genuine active stall that wins remains terminal.
|
||||
- Retirement releases only remaining delivery credit once, after acknowledged
|
||||
cleanup when required (or terminal teardown). Frozen generated/sent/played
|
||||
counters survive as bounded evidence; released capacity is not heard audio.
|
||||
Credit release never bypasses current-input/authorization/all-cleanup gates.
|
||||
- API 7.1.4 adds four walkthroughs (sixteen total): final progress 0.2 s, terminal
|
||||
confirmation 4.8 s, cleanup dispatched 4.8 s/acknowledged 9.6 s; a queued stall
|
||||
callback racing finalization; fresh post-cleanup output timing; and genuine
|
||||
active-playback failure at five seconds. The 9.6 s acknowledgement is timely
|
||||
against cleanup's 9.8 s deadline without a stopped-playback timeout at 5 s.
|
||||
|
||||
Plan Phase 1/2 prompts/defaults and implementation guide Section 9 align;
|
||||
architecture/scenario/TODO walkthrough counts and this configuration summary
|
||||
also align. Timer ownership is an engineering contract, not measured provider
|
||||
or browser behavior. Existing capacity/latency approvals, allocator/global
|
||||
admission validation, provider correlation/account/model/Origin access,
|
||||
compatible persisted profile, approved bindings/selection/human reviews and
|
||||
separate ingestion/calibration/voice authorizations remain external gates.
|
||||
CALIBRATION_REQUIRED remains until a valid measured report exists. Missing
|
||||
prerequisites block dependent acceptance only; no runtime, quality or
|
||||
PostgreSQL acceptance is claimed.
|
||||
|
||||
### Checks for this timeout-only repair
|
||||
|
||||
- Executed `git status --short`, `git diff --stat`, affected-file
|
||||
`git diff -- <paths>`, instruction discovery and targeted UTF-8 reads.
|
||||
- Executed `git diff --check`: exit 0; only informational LF/CRLF notices.
|
||||
- Executed `.venv/Scripts/python -c` with a read-only inline validator
|
||||
(pathlib/hashlib/json/re/ast/subprocess; only `git show HEAD:<path>`
|
||||
subprocess reads). Strict UTF-8, local link targets, report whitespace,
|
||||
two Python AST parses, 39 JSON fenced-example parses and the sixteen-row
|
||||
walkthrough count passed; embedded examples were not executed.
|
||||
- Executed PowerShell syntax-only parsing: read the report with
|
||||
`Get-Content -LiteralPath ... -Raw -Encoding UTF8`, extract its
|
||||
`~~~powershell` fences with `[regex]::Matches`, and compile each using
|
||||
`[scriptblock]::Create`: all six parsed, no example commands executed.
|
||||
- Read-only SHA-256 baseline comparison passed: eight affected documents
|
||||
changed; all 169 other baseline files unchanged; no external changes.
|
||||
Proof/mock scripts and three applied migrations match repair-start bytes;
|
||||
proof and migrations also match `git show HEAD:<path>` byte-for-byte.
|
||||
Frozen originals/annotations/status hashes are unchanged and the phase2
|
||||
original matches the recorded original_sha256. The first preservation
|
||||
checker attempt stopped on a Windows-path key mismatch; normalizing
|
||||
separators in the checker fixed it, and the full validation then passed.
|
||||
- Manual contract consistency review covered eligibility/state transitions,
|
||||
timer renewal identity, queued callback races, independent 1/5/5-second
|
||||
barriers, once-only retirement credits, retained evidence, new-output
|
||||
timing and all four walkthroughs against the unchanged response-release gate.
|
||||
|
||||
No database connection/workflow, provider call, ingestion, calibration, voice,
|
||||
CLI help/workflow, runtime test or pytest was run. Earlier acceptance/check
|
||||
results remain historical; these documentation checks establish none of
|
||||
runtime enforcement, model quality or PostgreSQL acceptance.
|
||||
Reference in New Issue
Block a user