docs(acceptance): record Phase 4 evidence and remaining gates

Publish reproducible per-scenario operational and bounded intake results, correlation identifiers, timing observations, provider-call counts and startup/recovery guidance.

Record retrieval, human-review, calibration, actual frontend and HTTPS/WSS prerequisites separately. Preserve historical evidence and explicitly keep Phase 4 incomplete.
This commit is contained in:
11linear11
2026-10-09 17:44:13 -04:00
parent 42f5b9e854
commit b06eaf59f4
5 changed files with 911 additions and 13 deletions
+11 -1
View File
@@ -1,3 +1,5 @@
For the current modular document/voice backend, use the [Phase 4 startup and recovery guide](docs/guides/phase4-backend-operations.md) and [acceptance evidence](docs/guides/realtime-agent-phase4-acceptance.md). Install `.[api,voice,embedding]`, apply online migrations, and run one `python -m app.server` process with a separate `python -m app.worker`. Service readiness does not certify calibrated retrieval or usable grounded voice. The paragraphs and prototype walkthrough below preserve older checkpoints.
Phase 6 adds [integration validation and operator handoff](docs/guides/ingestion-operator-handoff.md), redacted worker heartbeat/stage diagnostics and an opt-in real-provider smoke command. The existing chat retriever still uses Chroma/FastEmbed and does not search uploaded PostgreSQL chunks. Scoped pgvector search and authorized knowledge selection are the next milestone; published documents remain inactive.
Current target: the English [LangChain Live document MVP](docs/specifications/RAG-AI-Phase1-Delivery-Plan.md), with new browser uploads and direct Persian speech-to-speech. Ingestion Phases 1-4 plus the [Phase 5 worker, publication and retry](docs/guides/worker-orchestration.md) are implemented. Durable review decisions/resume and factual FAQ inclusion are implemented behind trusted backend services. Scoped uploaded-document retrieval, HTTP identity/upload/review transport, Live and UI remain planned. See [documentation and implementation order](docs/README.md) and [recorded setup/validation](docs/guides/ingestion-foundation-setup.md). The four sample files are acceptance examples, not the accepted corpus. The startup/API details below describe the legacy prototype.
@@ -220,7 +222,7 @@ CHROMA_PERSIST_DIR="./data/vector_db"
Start the application with Uvicorn:
```bash
uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload
python -m app.server --host 0.0.0.0 --port 8000
```
- **Interactive Swagger Documentation**: [http://localhost:8000/docs](http://localhost:8000/docs)
@@ -321,3 +323,11 @@ Contributions are welcome! To contribute:
## 📄 License
This project is open-source and licensed under the [MIT License](LICENSE).
Live uses the bounded single-process entrypoint above; run ingestion separately with
`python -m app.worker`. See the [voice integration guide](docs/guides/frontend-voice-integration-example.md)
for backend provider settings, transport limits, recovery and acceptance prerequisites.
Document/knowledge endpoints and backend-only `INGEST_OCR_REVIEW_REQUIRED`
(default true) are documented in the [Phase 3 frontend handoff](docs/guides/realtime-agent-phase3-handoff.md).
API and worker must share immutable original/extraction storage. New job profiles
freeze the OCR gate; existing/legacy jobs and factual review remain unchanged.
+205 -11
View File
@@ -1,15 +1,18 @@
# Phase 1 agent reference map
Current voice decision (2026-10-09): **Gemini Live is temporarily the sole voice
provider because an OpenAI Realtime voice key is unavailable.** The validated
backend Gemini model/voice configuration is shared by reservation, stream and
operator smoke. No OpenAI voice key is required. Extraction/embedding providers,
frozen profiles, measured calibration and canonical search are unchanged.
The provider-independent browser audio/events, direct document/chunk identities
and durable owner/replay/revocation rules remain authoritative. Historical
OpenAI checkpoints below remain historical. Gemini interruption closes safely
where native sample-level context truncation cannot be verified; seamless
barge-in is not certified. See [Phase 2 repair report](guides/realtime-agent-phase2-repair.md).
Current voice configuration (2026-10-09): **VOICE_PROVIDER=gemini|openai selects
one backend adapter. Gemini remains the temporary default because an OpenAI
Realtime voice key is unavailable.** Reservation, authenticated stream and
operator smoke share the selected model/voice/profile. Only the selected voice
key is required; there is no fallback or frontend provider selector. Legacy
PROVIDER and existing GEMINI_* settings remain supported; conflicting provider
aliases fail configuration. Dedicated OPENAI_REALTIME_* settings do not change
embedding credentials. Browser PCM16LE remains mono 24 kHz in both directions.
Pinned reservations cannot switch providers on connection or replay. Gemini
interruption requiring unverified context truncation closes safely; OpenAI keeps
its existing native cancellation/truncation contract. Canonical search, original
documents, frozen profiles and owner/replay/revocation rules remain unchanged.
See [Phase 2 repair report](guides/realtime-agent-phase2-repair.md).
Use this index to select the governing contract and inspect the real implementation before changing, testing, or reviewing behavior. Paths are relative to this file. Current voice contract amended 2026-10-08 by Realtime Phase 0; English revision 1.3 remains the broader scope baseline. Historical component evidence below is preserved; the English revision 1.3 documentation checkpoint reran no application/provider/database tests; current repair acceptance is recorded at the end. Use the latest applicable recorded acceptance, not earlier unavailable-database reports. Dated component records below describe their historical checkpoint; absence-of-worker statements there are superseded by the current Phase 5/6 inventory and repair evidence.
@@ -71,7 +74,7 @@ Ingestion foundation now exists: [manifest](../pyproject.toml), [settings/types/
| `git status --short` | Executed for working-tree inspection |
| `git diff --check` | Executed for tracked whitespace validation; untracked new files need separate inspection |
| `rg --files --hidden -g '!.git/**'` | Executed for file discovery |
| `uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload` | README example and entry point verified statically; runtime not verified |
| `python -m app.server --host 0.0.0.0 --port 8000` | Supported single-process entrypoint; selected legacy parser verified by real loopback boundary/fragment/compression/queue tests |
| `python -m app.services.agent.exec` | README example and CLI entry point verified statically; provider smoke harness, not automated regression tests; not run |
Prototype runtime prerequisites remain unverified: configured credentials, approved corpus, writable vector storage, and provider/model access. Importing the application creates settings/retrieval singletons and can load embeddings/index documents. Do not use imports as a supposedly network-free smoke test. README installation now uses pyproject.toml extras. Foundation imports are independent of those prototype prerequisites. Verified foundation commands are listed below; current worker commands and acceptance are in the Phase 5 section at the end of this map.
@@ -1871,3 +1874,194 @@ Regression sources add `tests/unit/test_phase2_remaining.py` and executable
acceptance uses a local transport bridge; Node executes the delivered client and
worklet. Exact results and unrun real-provider/browser prerequisites are in the
repair record. No selected-model multi-turn or frontend readiness claim is made.
## Phase 2 provider selection and transport repair (2026-10-09)
Current locations: [selected provider factory](../app/infrastructure/voice_provider.py),
[voice settings](../app/modules/voice/configuration.py),
[authority classification](../app/modules/voice/authority.py),
[supported single-process server](../app/server.py),
[pre-payload WebSocket parser](../app/infrastructure/voice_websocket.py).
API and operator smoke share construction; unchanged Gemini/OpenAI adapters keep
their separate native capabilities. Browser PCM remains 24 kHz; reservations pin
provider/model/voice/profile and cannot switch on replay/connection. Legacy
PROVIDER/GEMINI_* remain supported; conflicting provider aliases fail. Dedicated
OPENAI_REALTIME_* keys do not change embedding configuration.
See the [current repair checkpoint](guides/realtime-agent-phase2-repair.md#provider-selection-and-transport-repair-2026-10-09)
for finding/fix/test mapping, exact checks and preservation evidence, and the
[frontend guide](guides/frontend-voice-integration-example.md) for configuration,
startup, retained creation attempts, dual playback bounds and the 10-second
uncommitted idle-input limitation. Real loopback tests execute the explicitly
selected installed parser; generic Uvicorn defaults are not supported admission.
Exactly one API process owns media guards; ingestion runs separately. Fake tests
are not real provider/Persian speech/browser hardware or frontend readiness proof.
Verified final commands: `.venv/bin/python -m pytest -m "not postgres" -q -p no:cacheprovider --tb=short`
— **1679 passed**, two existing Windows path skips; `.venv/bin/python -m pytest -m postgres --require-postgres -q -p no:cacheprovider --tb=short`
— **372 passed**, zero skips, using only the isolated task-created test database.
Affected PostgreSQL cases: **61 passed**. Missing TEST_DATABASE_URL produced the
required prerequisite failure. Executable JS, syntax/compile, diff and baseline
preservation checks passed. See the report for exact durations, failed/interrupted
runs, isolated-database settings and remaining external prerequisites.
## Current Phase 3 HTTP and OCR policy inventory (2026-10-09)
D01-D04/D06 preview/D07, K01/K02 and read-only F01 are now implemented in
[document routes](../app/api/v1/documents.py) and
[knowledge/configuration routes](../app/api/v1/knowledge.py). These use existing
intake/review/worker/selection services, with bounded streaming
[multipart admission](../app/api/v1/uploads.py) and safe scoped
[polling queries](../app/infrastructure/document_queries.py). This supersedes
prior pending-HTTP statements above. The standalone frontend developer handoff is
[Phase 3 integration](guides/realtime-agent-phase3-handoff.md), with executable
DocumentClient and a same-origin Vite proxy example. Existing VoiceClient/worklet,
Gemini/OpenAI selection, canonical search and migrations 0001–0005 are preserved.
`INGEST_OCR_REVIEW_REQUIRED=true` is a deployment default frozen in new job
profiles; false admits only automatically validated OCR. Legacy profiles retain
mandatory review without rewriting their digests. Non-OCR and factual approval
remain separate. Mixed automatic/inspected PDFs report partially_reviewed;
only actually inspected locators receive human annotations. Publication remains
ready and inactive until K02. F01 reports configured safe policy/capabilities,
while document polling reports the frozen policy and actual retained review state.
The two remaining Phase 2 findings are repaired: cancellation propagates out of
receive-capacity waits, and the parser preserves its native UTF-8 rejection for
durable LIVE_PROTOCOL_ERROR classification even when Uvicorn would report 1006.
See the [Phase 2 checkpoint](guides/realtime-agent-phase2-repair.md) and
[Phase 3 validation record](guides/realtime-agent-phase3-handoff.md) for exact
checks, actual failures/corrections and remaining real-provider/browser prerequisites.
Final Phase 3 checks: **1724 provider-free passed**, two existing Windows path
skips; **162 affected PostgreSQL passed**, zero skips; **323 affected unit passed**;
**22 final HTTP acceptance cases passed** and **2 explicit two-provider redaction
cases passed**. Prior broader PostgreSQL checkpoint: **393 passed**, zero skips;
see the handoff for its timing relative to the final mixed-PDF refinement.
Missing TEST_DATABASE_URL produced the required failure. Compose, Node execution/
syntax, AST/TOML, diff and preservation checks passed. **200 task-start files remain
byte-identical**, 26 intended existing files changed, 11 added, none removed.
The isolated task-owned test container was removed after zero-schema/table checks.
## Four verified Phase 3 findings repair (2026-10-09)
The ingestion regression source `tests/unit/test_phase3_repairs.py` is restored
byte-for-byte from `9be4719` (55 cases). HTTP admission/filename/proxy regressions
now live in `tests/unit/test_phase3_http_repairs.py`. K02 uses the existing bounded
blocking pool; D07's DTO-derived finite body budget is 60,151,072 bytes with
pre-extension capacity checks. D04 nonempty bodies remain 422 VALIDATION_ERROR.
See the [current handoff repair record](guides/realtime-agent-phase3-handoff.md)
for exact finding-to-test mappings, executed results and open validation failures.
Earlier Phase 3 counts above are historical and do not establish restored coverage.
## Phase 3 JSON responsiveness and acceptance follow-up (2026-10-09)
Large D07/K02 JSON handling now uses two admitted requests, 64 KiB cooperative
spooling and local child-process UTF-8/JSON/DTO validation in
`app/infrastructure/json_processing.py`, with bounded result frames and owned
cancellation/cleanup. D07 also bounds retained normalized DTOs to two review
transactions. Existing finite byte budgets and safe error/correlation mappings
remain. `app/modules/knowledge/langchain_tool.py::prepare_search_tools` runs
through the existing blocking pool during API startup, before readiness, to move
observed cold framework loading outside first-tool waits; document-only optional
framework behavior remains supported. No dependency or external service added.
New regressions: `tests/unit/test_json_processing.py` (actual large escaped JSON
responsiveness and lifetime/admission checks),
`tests/unit/test_phase3_acceptance_repairs.py` (startup order/off-loop preparation
and optional framework). Existing correlation, HTTP, all 55 restored ingestion
and isolated PostgreSQL acceptance sources remain intact. See the
[current handoff record](guides/realtime-agent-phase3-handoff.md) for measured
GIL comparisons, diagnostic stacks/wait locations, exact completed commands and
remaining unresolved historical parser-stall cause. Real providers, Persian
speech, browser hardware and production deployment remain unverified.
Final follow-up acceptance: **92 focused unit passed**, **1753 provider-free
passed** (two existing Windows-path skips; 397 PostgreSQL cases deselected),
**25 affected isolated PostgreSQL passed**, zero acceptance skips. Missing
TEST_DATABASE_URL failed as required. Actual 26.8/59.5 MB escaped JSON heartbeat
maximum gaps: **14.03/11.64 ms**, versus **215.07/336.19 ms** in a thread.
Seven scoped baseline files changed, **231 stayed byte-identical**, three added.
The historical parser-stall cause remains explicitly unresolved; no real-provider,
Persian speech or browser hardware claim is made. Exact commands/results,
intermediate failures and database cleanup are in the handoff.
## Realtime MVP Phase 4 acceptance checkpoint (2026-10-09)
The [Phase 4 acceptance report](guides/realtime-agent-phase4-acceptance.md)
records current baseline verification, per-scenario outcomes, JSON heartbeat
observations, guarded provider-free health correlation IDs, isolated database
checks, spending prerequisites and startup/recovery commands. This is the
Realtime MVP phase, separate from the older scoped-search Phase 4 report.
Current checks: **92 focused passed**, **1753 provider-free passed** (two existing
Windows-path skips), **397 isolated PostgreSQL passed**, zero acceptance skips.
Actual large-JSON maximum heartbeat gaps were **13.06/16.21 ms**. Health made
zero provider calls; missing TEST_DATABASE_URL failed explicitly. Disposable
database cleanup/removal and dependency/Compose/whitespace checks passed.
The developer confirms the actual frontend is still in development. Funded
Gemini and OpenAI acceptance, independent held-out retrieval quality, real UI/
hardware and HTTPS/WSS deployment remain `not_run` with exact prerequisites.
The configured calibration remains pending with null cutoff. No completion,
provider quality or operational readiness claim follows from technical tests.
Existing provider adapters/selection, frozen OCR/factual policies, shared
retrieval, protected inputs and applied migrations were retained.
## Phase 4 executed operational follow-up (2026-10-09)
The latest [acceptance report](guides/realtime-agent-phase4-acceptance.md) and
[startup/recovery guide](guides/phase4-backend-operations.md) supersede the
technical-only operational checkpoint above. Actual built Docker API/worker,
accounts and HTTP, publication/selection, provider-free health, persistent service
recreation, interrupted-worker lease recovery, synthetic review/retry and graceful
shutdown passed **eight scenarios** with zero real-provider calls. Correlations,
timing definitions and observations are in
[operational evidence](calibration/realtime-phase4-operations.json).
Final suites: **1755 provider-free passed** (two existing Windows-path skips),
**397 isolated PostgreSQL passed**, zero database acceptance skips. Missing database
configuration failed explicitly. Task containers/networks were removed; unrelated
containers and named acceptance volumes were preserved.
The user's bounded permission for four originals/APIs resulted in **one** real
OpenRouter vision HTTP attempt; all native Gemini/OpenAI voice, calibration,
evaluation and paid embedding call counts remained zero. Actual bindings and
failures are in [bounded intake evidence](calibration/realtime-phase4-bounded-intake.json).
The original DOCX failed ambiguous factual association; the infographic failed
extraction quality; both PDFs remain queued without paid extraction. No human
approval or unseen label was manufactured. Real embedding request limits and
container endpoint reachability, approved calibration/review/labels and finalized
retrieval gate remain non-UI prerequisites. Gemini Live preflight returned 503
CALIBRATION_REQUIRED; OpenAI additionally lacks its dedicated key. Actual frontend
and hardware, provider quality, and public HTTPS/WSS remain separately not_run.
Phase 4 is incomplete. Docker dependency/startup configuration and demonstrated
worker SIGTERM cleanup were repaired; protected inputs and frozen contracts remain.
## Ingestion and voice transport admission amendment (2026-10-09)
The [scoped repair report](guides/ingestion-voice-admission-repair.md) supersedes
prior claims that initial FAQ preambles or recognition diagnostics must terminate
intake, and documents the explicit `VOICE_TRANSPORT_TESTING` policy (default false).
Initial unheaded source introductions accompany all approved FAQ pairs; detached
post-pair prose still fails. Gemini/OpenRouter incomplete recognition and warnings
retain legible candidates and require exact human extraction review even with a
frozen false OCR policy. Fatal native format/provenance/readability remains enforced.
Independent factual approval, same-job retry and explicit selection remain intact.
Explicit transport testing admits owned voice reservations/streams without measured
cutoff and exposes frozen calibration_status in create/recovery/poll and F01.
Shared search still admits no uncalibrated evidence: CALIBRATION_REQUIRED remains its
canonical result. Provider selection/adapters, authorization before provider opening,
replay identities, epochs and stream profile matching remain. No migrations or
external dependencies added. Actual provider quality/UI/hardware/public HTTPS/WSS
remain separately unverified. Full commands, outcomes, intermediate obsolete contract
assertions and protected-input checks are recorded in the scoped report.
Executed scoped repair checks: **124 focused unit passed**, **1767 full provider-free
passed** (two existing Windows-path skips), **7 new PostgreSQL repair scenarios
passed**. Initial full database run: 401 passed and two superseded warning-only
assertion failures; strengthened corrupt-text cases passed. Final database recheck:
**402 passed**, zero skips, with only the two unchanged large-review cases already
passed in the initial full run deselected. All 404 current database scenarios have
passing executed evidence across these runs. Protected inputs/migrations and the
restored 55-case source remained byte-identical. Exact timings, reproduction,
intermediate failures, JUnit path and cleanup are in the scoped repair report.
@@ -0,0 +1,86 @@
{
"run_id": "d92ed043-b4f9-4211-95a5-5c99198cfd1b",
"provider_http_attempt_budget": 1,
"provider_http_attempts": 1,
"voice_provider": "gemini",
"vision_provider": "openrouter",
"real_voice_sessions": 0,
"usage": "unavailable",
"billing": "unavailable",
"documents": [
{
"original": "docx",
"original_sha256": "6ce416719802136d16c82e153bf0671af5bb87b441cc5fed144ebd253d647f23",
"document_id": "e1425aec-14c3-40d4-9438-b136e9459553",
"job_id": "08657dad-f1f0-41a2-b859-7ffacf49a2d0",
"request_id": "88b37dcd-b0e8-4503-9eb9-c7598a736feb",
"status": "failed",
"review_required": false,
"review_state": "not_required",
"job_error": {
"code": "EXTRACTION_QUALITY_FAILED",
"message": "Ingestion could not complete; use the error code and review state.",
"retryable": false
},
"searchable": false,
"elapsed_seconds": 1.9884367549966555
},
{
"original": "infographic",
"original_sha256": "cd177e935f25200c53af958a6c7b4540b820d49043e62fa1d383e6a76954f935",
"document_id": "c9a0d811-c342-47bf-bfe5-d9d76021a2ee",
"job_id": "e27b6945-a1f9-430c-be77-68899ce0eed6",
"request_id": "96026e3c-8da6-44a3-977c-5eeb67178409",
"status": "failed",
"review_required": false,
"review_state": "not_evaluated",
"job_error": {
"code": "EXTRACTION_QUALITY_FAILED",
"message": "Ingestion could not complete; use the error code and review state.",
"retryable": false
},
"searchable": false,
"elapsed_seconds": 18.996491828002036
},
{
"original": "letter",
"original_sha256": "f5732a2eff7fec3e7827c5f25c9a9d50897363935101e46f631404c03ce6ef99",
"document_id": "73c016f1-45bb-4c6b-872a-deb86a8138fc",
"job_id": "dcb167d7-ad46-4660-b108-2eb2f2c42726",
"request_id": "c84c69eb-ac28-4aac-aad1-a68e5ac80aaf",
"status": "queued",
"review_required": false,
"review_state": "not_evaluated",
"job_error": null,
"searchable": false,
"elapsed_seconds": 0.3404236310016131
},
{
"original": "regulation",
"original_sha256": "42f7cbc0ad4a187f7d8a89b0ace484e936ab25c96820fe6ac18b25533e987096",
"document_id": "9579a3a5-98ac-4190-ad9c-705287b3b92a",
"job_id": "cbd9ea91-14fb-4c73-b500-821d81b72293",
"request_id": "378dadb5-1d83-4f05-a872-d3e9338b8d71",
"status": "queued",
"review_required": false,
"review_state": "not_evaluated",
"job_error": null,
"searchable": false,
"elapsed_seconds": 0.3018569989944808
}
],
"observations": [
{
"scenario": "selected_gemini_http_voice_preflight",
"status": "blocked",
"request_id": "a605c27c-b9a1-4c25-bfd6-022853af0dd1",
"conversation_id": "6ced1dee-ad4b-4fe2-ae84-b2b797f0f61b",
"error_code": "CALIBRATION_REQUIRED",
"voice_provider_calls": 0,
"reason": "No finalized measured calibration; no human-approved selected corpus."
}
],
"actor_id": "daa03748-7d3c-426f-9b25-c6c82c0571c8",
"status": "completed_bounded_intake_quality_blocked",
"api_exit_code": -15
}
@@ -0,0 +1,98 @@
{
"run_id": "8a470295-0ccc-42a7-85d3-a3f1bb98372c",
"category": "isolated_deployment_fixture",
"real_provider_calls": 0,
"scenarios": [
{
"scenario": "real_lifespan_readiness_and_provider_free_health",
"status": "passed",
"elapsed_seconds": 2.7411439619900193,
"request_ids": [
"9dd17fda-95e3-45a9-8cdc-a6268e9020bd",
"1ed86221-2edb-4cee-b783-4f71461c91e5"
],
"fixture_calls": 0,
"application_process_counts": {
"api": 1,
"worker": 1
}
},
{
"scenario": "supported_account_provisioning_and_login",
"status": "passed",
"elapsed_seconds": 17.433966975993826,
"actor_id": "e85e7d43-331f-42dc-bbcf-0f46fffc400f",
"organization_id": "6dc6c195-87f0-46ab-b46e-275717cba0f5",
"request_id": "8bcc84df-b9ce-4b4c-84f2-e4306c16fd85"
},
{
"scenario": "upload_replay_worker_atomic_publication_and_explicit_selection",
"status": "passed",
"elapsed_seconds": 3.768920069996966,
"document_id": "2005c5a1-0e37-41e1-8b25-96395c1a0ad6",
"job_id": "993e0e39-4b1c-4080-a440-b991449407e6",
"original_sha256": "3349dcec66a32947c9f724686c9e87c83a27b4cc2a2aa7c0ad1beb51201db375",
"request_ids": [
"8e38f468-22f0-41bd-9751-27a854f24537",
"fb88e9ca-125d-4fc4-85de-0ff48cb75100"
],
"fixture_calls": 1
},
{
"scenario": "repeated_health_does_not_embed",
"status": "passed",
"elapsed_seconds": 1.6057777310052188,
"fixture_calls_before": 1,
"fixture_calls_after": 1
},
{
"scenario": "service_recreation_persists_originals_accounts_selection_and_reconciles_live",
"status": "passed",
"elapsed_seconds": 58.87800858999253,
"conversation_id": "2a129117-ab5e-4268-b7bf-bf0aaca4e6b3",
"session_id": "6e05019e-8289-455f-99e9-a2c863bbd87c",
"terminal_status": "failed",
"document_id": "2005c5a1-0e37-41e1-8b25-96395c1a0ad6",
"retained_extraction_blocks": 1,
"database_container_recreated": true
},
{
"scenario": "killed_worker_lease_reclaim_and_duplicate_free_publication",
"status": "passed",
"elapsed_seconds": 32.29467027100327,
"document_id": "af8752ae-7d60-4843-96d6-be2f91d4db7f",
"job_id": "e205df31-423c-4c36-8a1d-451a41e713b5",
"attempts": 2,
"claim_changed": true,
"chunks": 1
},
{
"scenario": "synthetic_factual_review_and_same_job_retry",
"status": "passed",
"elapsed_seconds": 3.318508076990838,
"document_id": "a318a27e-a473-4f32-8be8-fe1f10abc61c",
"job_id": "a51bf8d4-d338-4d06-b430-22866b1c028e",
"evidence_sha256": "880e7f76f27bd110f6d15d3dd49b0c2f5bc7b68cd858d6acbd2508fdf2e6c7e6",
"request_ids": [
"304bbbf6-6b4e-4df4-923d-7304fdcdc6ab",
"ae806cba-a926-43cd-a148-341a39d574a1"
],
"approval_category": "synthetic_fixture_only"
},
{
"scenario": "logout_and_graceful_service_shutdown",
"status": "passed",
"elapsed_seconds": 2.4197775310021825,
"request_id": "6d19ce9b-8c14-468c-896f-3927256bae65",
"exit_codes": {
"api": 0,
"worker": 0
}
}
],
"shutdown_exit_codes": {
"api": 0,
"worker": 0
},
"status": "passed"
}
@@ -0,0 +1,510 @@
# Realtime MVP Phase 4 acceptance — 2026-10-09
Status: **incomplete; external acceptance prerequisites remain open**. The
operational follow-up below supersedes the initial technical-only checkpoint's
authorization/actor/binding observations. This is
the Realtime MVP Phase 4 checkpoint, distinct from ingestion/search phases with
the same number. No production frontend was created. Technical tests below use
fake providers and disposable data; they cannot certify Persian speech,
grounding, microphone/playback hardware or the developer's UI.
## Baseline and evidence
Baseline HEAD: `9be47191d6c7c01689e3a684078b55b481717638`, plus the pre-existing
uncommitted Phase 2/3 implementation and repairs; this HEAD alone cannot reproduce
the working snapshot. Preserve/review that complete working tree when handing off.
Start from the [latest Phase 3 repair record](realtime-agent-phase3-handoff.md),
including its JSON responsiveness follow-up, not the earlier superseded counts.
The existing bounded JSON child-process implementation, two-request admission,
64 KiB cooperative spooling, deadline and owned cleanup were retained.
`tests/unit/test_phase3_repairs.py` matches `9be4719` byte-for-byte: SHA-256
`a3531d71de9cdd48755754d55ae8238b2ee4412ac92a43dd01396d4c8976edfd`.
All 55 restored ingestion cases remain present. No reproduced product blocker
has justified a runtime change at this checkpoint. The historical parser
connected-state/shutdown stall remains unexplained; later green checks do not
establish its cause or a fix.
## External prerequisites and authorization
The developer confirmed that available configuration is in `.env` and the
frontend is still being developed. `.env` was inspected for presence and safe
status only; no secrets are included here. A Gemini key is configured; account
funding and model access were not tested. No dedicated OpenAI Realtime key is
configured. Backend selection and both adapters remain intact; Gemini remains
the temporary default. No fallback or provider switch was performed.
The configured calibration file exists but reports `status: pending`,
`cutoff: null`, zero calls and no final authorization confirmation. The existing
[retrieval status](../calibration/phase4-status.json) and
[draft labels](../calibration/phase4-cases.draft.json) remain unchanged:
16 populated draft answerable labels, four unseen slots pending and six draft
unsupported labels. Drafts do not constitute independent frozen approved labels.
| Required input | Observed status / exact blocker |
| --- | --- |
| Developer UI checkout / URL / Origin | Not supplied; developer says UI is under development. No matching checkout found under `/home/moz/Projects/raymand`; broader frontend candidates did not establish this project's UI. |
| Approved corpus and hash-to-document bindings | No approved bindings package supplied or configured in `.env`. Sample originals are not approval. |
| Enabled persisted acceptance actor | No acceptance actor ID supplied or configured; disposable test actors do not qualify. |
| Human extraction and factual decisions | No approved decision package supplied; never synthesized. |
| Independent frozen evaluation labels | Four unseen annotations absent; populated annotations remain draft. |
| Measured finalized calibration | Configured report is pending with null cutoff; retrieval stays fail-closed. |
| Ingestion opt-in and budget | Not supplied. Worker was not started against an operational corpus. |
| Calibration opt-in and budget | Not supplied; existing command caps at ten query embedding calls. |
| Evaluation opt-in and budget | Not supplied; existing command permits up to 26 calls. |
| Voice opt-in and budget | Not supplied for either provider; existing smoke permits at most 600 seconds and ten tool calls. A key's presence is not spending authorization. |
| Browser hardware | No developer UI/hardware acceptance session available. |
| HTTPS/WSS deployment | No deployment URL, certificate or proxy environment supplied. |
## Scenario outcomes
For every external `not_run` row: correlation IDs, timings and terminal outcome
are **null**, actual external provider calls are **0**, and usage/billing are
unavailable. Null observations are not passes. Technical fake-provider counts
are not billable provider calls.
Existing pytest scenarios validate generated identity/correlation relationships
but do not archive their ephemeral IDs in console output; those individual IDs
were not collected in this run. The health request IDs below are actual captured
values. No provider conversation or turn ID exists for the unexecuted voice runs.
| Scenario | Outcome | Evidence / blocking reason |
| --- | --- | --- |
| Large D07 JSON, concurrent loop heartbeat | passed | 26,784,224 bytes: 994.92 ms processing, 96 ticks, 13.06 ms maximum gap; 59,504,172 bytes: 5,617.58 ms, 546 ticks, 16.21 ms maximum gap. Actual escaped JSON/DTO processing; both below the existing 100 ms regression threshold. |
| JSON admission, malformed bodies, timeout/cancellation and child/spool cleanup | passed | Focused 92-case suite includes real-child creation cancellation, disk lifetime ownership and normalized DTO retention. |
| Restored ingestion, HTTP repairs, Gemini fake transport and cold-start preparation | passed | Same focused suite; all 55 restored ingestion tests, ten Gemini adapter tests, startup preparation off-loop before readiness. |
| Full provider-free regression | passed | 1,753 passed, two existing Windows-path skips, 397 PostgreSQL cases deselected; 176.37 s. 25 existing WebSocket deprecation warnings. |
| Isolated PostgreSQL acceptance | passed | 397 passed, zero skips, 1,755 deselected, four existing WebSocket deprecation warnings; 666.32 s. Includes both real-parser cases and all 25 Phase 3 HTTP cases. Disposable PostgreSQL 16.15 / pgvector 0.8.7. |
| Missing database prerequisite | passed | Expected exit 1: both parameter cases fail with `TEST_DATABASE_URL is required for PostgreSQL acceptance`; 1.57 s, no skips. |
| Provider-free health behavior | passed | ASGI requests with permitted Host: liveness 200 in both states, readiness 503/200. Provider adapter/search entrypoints guarded to raise; zero calls. This does not exercise operational startup or deployment. |
| Developer UI login/upload/poll/review/retry/selection/voice/recovery | not_run | UI still in development; actual checkout/URL and acceptance account/corpus unavailable. Helpers and mocked requests are excluded as UI acceptance. |
| Retrieval A01–A20 and U01–U06 | not_run | Missing approved bindings/reviews, four unseen annotations, frozen labels, measured cutoff and evaluation opt-in/budget. Per-case existing status remains not_run. |
| Gemini funded selected-model quality and Persian voice | not_run | Key configured, but funding/access unverified; actor, approved corpus/reviews, calibration and voice opt-in/budget absent. |
| OpenAI funded selected-model quality and Persian voice | not_run | OpenAI Realtime key absent, plus the independent actor/corpus/calibration/authorization prerequisites. No switch to Gemini used to claim OpenAI acceptance. |
| Persian factual question | not_run | Real selected-provider session, approved evidence/question and UI/hardware unavailable. |
| Follow-up question | not_run | Approved multi-turn question sequence, real session and UI/hardware unavailable. |
| Topic change | not_run | Approved multi-document sequence, real session and UI/hardware unavailable. |
| Ambiguous reference | not_run | Independent approved ambiguity labels and funded voice authorization absent. |
| Insufficient support | not_run | Approved unsupported labels/corpus, calibration and funded voice authorization absent. |
| Conflicting evidence | not_run | Approved conflict scenario/corpus and funded voice authorization absent. |
| Prompt-like source content | not_run | Approved adversarial-source scenario/corpus and funded voice authorization absent. |
| Interruption during search | not_run | Real selected provider, UI microphone and eligible calibrated search unavailable. |
| Interruption during playback | not_run | Real selected provider and UI microphone/playback hardware unavailable. |
| Provider loss | not_run | Authorized real provider session and actual UI unavailable. |
| Logout during voice | not_run | Actual UI, enabled acceptance account and authorized real voice session unavailable. |
| Access epoch revocation | not_run | Actual UI, approved actor/authorization mutation scenario and real session unavailable. |
| API restart during voice | not_run | Actual UI and authorized operational voice environment unavailable. Technical reconciliation tests are separate. |
| HTTPS/WSS deployment acceptance | not_run | Deployment endpoint, TLS/proxy setup and external browser session unavailable. |
Retrieval gate: **not_run**, not passed or failed: require at least 18/20
answerable cases, every critical case and all 6/6 unsupported cases. No threshold,
label, frozen profile, original or publication policy was changed.
## Reproduction and timing
Run from repository root with the existing Linux `.venv/bin/python`. Initial
restricted-sandbox focused/full runs were interrupted (exit 130) after setup
errors/stalls; they are not counted as acceptance. Existing validation needs
local sockets, and JSON tests spawn processes. Completed reruns use approved
local socket/process access, without real-provider calls.
```sh
.venv/bin/python -m pytest tests/unit/test_json_processing.py tests/unit/test_phase3_acceptance_repairs.py tests/unit/test_phase3_http_repairs.py tests/unit/test_phase3_repairs.py tests/unit/test_gemini_live.py -q -s -p no:cacheprovider --tb=short
# 92 passed in 16.32s
.venv/bin/python -m pytest -m 'not postgres' -q -p no:cacheprovider --tb=short
# 1753 passed, 2 skipped, 397 deselected, 25 warnings in 176.37s
docker run --rm -d --name rag-phase4-acceptance-test --tmpfs /var/lib/postgresql/data -e POSTGRES_PASSWORD=fixture -e POSTGRES_DB=rag_acceptance_test -p 127.0.0.1:55449:5432 pgvector/pgvector:pg16
TEST_DATABASE_URL=postgresql+psycopg://postgres:fixture@127.0.0.1:55449/rag_acceptance_test .venv/bin/python -m tests.postgres_prerequisites
# passed: PostgreSQL 16.15, vector 0.8.7; actual CREATE/DROP database privileges
TEST_DATABASE_URL=postgresql+psycopg://postgres:fixture@127.0.0.1:55449/rag_acceptance_test .venv/bin/python -m pytest -m postgres --require-postgres -q -p no:cacheprovider --tb=short
# 397 passed, zero skips, 1755 deselected, 4 warnings in 666.32s
env -u TEST_DATABASE_URL .venv/bin/python -m pytest tests/integration/test_realtime_phase3_http.py::test_large_eligible_review_persists_and_replays -m postgres --require-postgres -q -p no:cacheprovider --tb=short
# Expected exit 1: two missing TEST_DATABASE_URL setup errors in 1.57s
UV_CACHE_DIR=/tmp/phase4-uv-cache uv pip check --python .venv/bin/python
# 62 packages checked; all compatible. python -m pip check unavailable: pip is not installed.
docker compose config --quiet
git diff --check
# Passed; Compose configuration, local links and new-report whitespace also passed.
```
After completed PostgreSQL acceptance, SQL inspection found zero application test
schemas (excluding the intended `test_vector` extension namespace), zero public
tables and zero additional test databases. `docker stop rag-phase4-acceptance-test`
removed the `--rm` container and its tmpfs database. Existing containers and
operational databases were not modified.
Fixes/regressions: no runtime defect reproduced in the completed checks, so no
implementation or test expectations changed. The isolated parser cases passed;
the older intermittent stall's cause remains unresolved. The full database suite
took 666.32 s under this checkpoint's concurrent load; that aggregate duration
does not measure HTTP/voice request latency. No paid calls were made.
Preservation: SHA-256 comparison over 236 pre-existing repository files found
235 unchanged; only the reference map changed to link this new report. Both
voice adapters/selection, applied migrations, frozen profiles, originals,
shared retrieval and all unrelated working-tree changes remained byte-identical.
The new acceptance report is the sole added file for this checkpoint.
The earlier sandbox missing-database probe instead failed socket-based settings
validation (two setup errors, 0.65 s); only the approved rerun above establishes
the missing-database guard. Initial health requests with unconfigured
`localhost:5173` correctly returned 403; a restricted permitted-Host probe stalled
and was interrupted. The completed guarded ASGI probe used the actual configured
permitted Host. Its observed correlation IDs were:
| Request | State | HTTP | X-Request-ID |
| --- | --- | --- | --- |
| `/health/live` | not ready | 200 | `296ce87a-16dc-44a1-9c96-146ac0638e2c` |
| `/health/ready` | not ready | 503 | `e6c7fe1a-2d85-4bc9-aa44-265af3ef7089` |
| `/health/live` | ready | 200 | `eb9e8faa-3037-43a4-9e64-a73f7021674b` |
| `/health/ready` | ready | 200 | `3561feff-d92c-4e3e-bbb1-055710659a7c` |
Reproduce the health-only probe without starting ingestion or a provider:
```sh
.venv/bin/python - <<'PY'
import asyncio
from unittest.mock import patch
import httpx
import app.main as main
async def probe():
with patch('app.infrastructure.voice_provider.create_adapter', side_effect=AssertionError('provider call')), patch('app.api.v1.dependencies.get_search_service', side_effect=AssertionError('search call')):
async with httpx.AsyncClient(transport=httpx.ASGITransport(app=main.app), base_url='http://' + main.config.trusted_hosts[0]) as client:
for state in (False, True):
main.app.state.ready = state
for route in ('/health/live', '/health/ready'):
response = await asyncio.wait_for(client.get(route), 10)
assert response.status_code == (503 if route.endswith('ready') and not state else 200)
print(route, state, response.status_code, response.headers['x-request-id'])
asyncio.run(probe())
PY
```
JSON processing time is monotonic elapsed time from actual receive/spool/decode/
loads/DTO validation through transfer. Heartbeat gap is the largest interval
between concurrent 10 ms scheduler ticks. These observations include concurrent
test load and are neither voice latency nor a production SLA.
For later executed UI/provider acceptance, record an opaque scenario/run ID,
`X-Request-ID`, conversation/live session IDs, `turn_ref`, provider response ID,
tool `call_id`, and evidence `document_id`/`chunk_id` when present. Use monotonic
timestamps within one process; do not subtract browser/backend wall clocks.
Record user-turn completion, tool dispatch start, canonical search end/result
delivery, first output audio arrival, first sample actually played and terminal
outcome as distinct events. Derive tool duration, turn-to-first-audio and
turn-to-terminal from their named boundaries. Browser playback timing requires
actual playback progress, not bytes emitted by the backend. Missing events stay
null with reasons. Diagnostic text smoke is not a speech/playback acceptance run.
Classify observed failures as transcription, retrieval, tool dispatch, grounding,
playback or lifecycle; include expected/actual behavior, fix and affected rerun.
Never log document bodies, audio, cookies or credentials.
## Startup and recovery
Use the existing [Phase 3 handoff](realtime-agent-phase3-handoff.md),
[frontend connection handoff](frontend-backend-connection-handoff.md),
[foundation setup](ingestion-foundation-setup.md) and
[worker instructions](worker-orchestration.md). Supply `INGEST_DATABASE_URL`,
the compatible frozen embedding profile, exact trusted Host/
Origin, credentials for the explicitly selected provider and durable original/
extraction paths before operational startup. Current `.env` alone is not the
complete deployment package.
Authentication requires no configurable session signing secret: login generates
an opaque random cookie token, stores its SHA-256 hash in PostgreSQL, and derives
CSRF with HMAC keyed by that session token. This corrects the unsupported session
secret prerequisite in the earlier handoff.
1. Back up operational PostgreSQL and original/extraction storage. Use the
existing Compose database and `migrations` service or `alembic upgrade head`.
Applied revisions 0001–0005 are immutable; do not downgrade/rebuild them.
2. On a new empty installation provision the trusted administrator with
`python -m app.bootstrap --organization-name <name> --username <name>
--assistant-name <name> --instruction <instruction>`; passwords are prompted,
never command arguments. Bootstrap refuses existing organizations.
3. Start exactly one API process: `python -m app.server --host 0.0.0.0 --port
8080`. Check `/health/live` and `/health/ready` using an allowed Host.
Readiness follows startup reconciliation, not provider quality certification.
4. Start the separate `python -m app.worker` only after ingestion opt-in and
budget approval. Existing Compose uses one API, separate worker, shared durable
original/extraction directories and PostgreSQL volume. Do not blindly run
`docker compose up` while ingestion authorization is missing.
5. Complete actual required extraction and independent factual reviews; retry
the same eligible document/job explicitly with retained idempotency keys.
Preserve default-true per-job OCR policy and mandatory legacy review. Ready
publication remains inactive until explicit K02 document selection.
6. Obtain independently annotated unseen cases and approved hash bindings; run
`python -m app.calibrate_search --user-id <actor> --bindings <approved.json>
--output <new-report.json> --allow-provider-calls` only with separate
ten-call calibration approval. Retain the full finalized report.
7. Reuse `python -m tests.evaluate_search --cases <frozen-cases.json> --bindings
<approved.json> --calibration <full-report.json> --user-id <actor> --output
<new-results.json> --allow-provider-calls --provider-call-budget 26` only with
evaluation approval. The current draft manifest is not eligible input.
8. Separately authorize the explicitly selected voice provider. Existing
diagnostic command: `VOICE_PROVIDER=gemini python -m app.voice_smoke
--user-id <actor> --query <approved-question> --allow-provider-calls --seconds
90 --max-tool-calls 4`. Use `VOICE_PROVIDER=openai` only for an independently
authorized OpenAI run with its key. These are command templates, not executed
calls or authorization. Record embedding and native voice usage separately;
unavailable usage/billing stays unavailable. Then execute the developer UI
scenario set, including Persian speech and real hardware.
On API restart, startup reconciliation must finish before admission. Reauthenticate
and create a fresh voice session; do not reuse stale session paths or silently
reconnect/switch provider. Preserve ambiguous creation/review/retry attempt keys
and resolve through replay/polling. Worker recovery uses durable claims/leases;
do not manually reset jobs or publish partial chunks. Inspect safe error codes
and correlation IDs before an eligible same-job retry. Logout/revocation closes
voice resources; retain backend ownership and shared retrieval.
For deployment, configure exact HTTPS Origin/Host, Secure cookies, WSS upgrade
proxy and timeout behavior, and persistent storage. Execute external-browser
TLS/WSS, microphone/playback, disconnect and recovery acceptance separately.
Local or ASGI health results do not satisfy that gate.
## Operational follow-up: approved originals and bounded calls
The developer subsequently authorized the four existing originals and a few small
API tests, expressly avoiding repeated credit consumption. The agent imposed a
three-paid-call total ceiling, allocated **one HTTP attempt to ingestion vision**
and made no additional paid call after extraction failed. This is not authorization
for the full ten-query calibration / 26-query evaluation / ten-minute voice run.
Stage accounting: ingestion vision **1 attempt**, embedding **0**, calibration
**0**, evaluation **0**, Gemini Live **0**, OpenAI Realtime **0**. Usage and
billing remain unavailable. No automatic or manual paid retry was performed.
Approved-input evidence is retained in
[bounded intake results](../calibration/realtime-phase4-bounded-intake.json).
The enabled administrator and all four immutable document/job bindings were
created through supported bootstrap and actual authenticated HTTP, not requested
from the developer or invented. They belong to a disposable isolated acceptance
database; none is a ready selected operational corpus or a human approval.
| Scenario | Actual result | Correlation / timing / classification |
| --- | --- | --- |
| Approved DOCX upload and one worker attempt | failed closed | Document `e1425aec-14c3-40d4-9438-b136e9459553`, job `08657dad-f1f0-41a2-b859-7ffacf49a2d0`, request `88b37dcd-b0e8-4503-9eb9-c7598a736feb`; 1.9884 s; chunk/review association, zero provider calls. |
| Approved infographic upload and one worker attempt | failed closed | Document `c9a0d811-c342-47bf-bfe5-d9d76021a2ee`, job `e27b6945-a1f9-430c-be77-68899ce0eed6`, request `96026e3c-8da6-44a3-977c-5eeb67178409`; 18.9965 s; extraction quality, one OpenRouter vision HTTP attempt using its configured Gemini vision model. This is not Gemini Live acceptance. |
| Approved letter PDF upload | passed intake; processing not_run | Document `73c016f1-45bb-4c6b-872a-deb86a8138fc`, job `dcb167d7-ad46-4660-b108-2eb2f2c42726`, request `c84c69eb-ac28-4aac-aad1-a68e5ac80aaf`; 0.3404 s; queued, zero calls. No automatic multi-page paid work. |
| Approved regulation PDF upload | passed intake; processing not_run | Document `9579a3a5-98ac-4190-ad9c-705287b3b92a`, job `cbd9ea91-14fb-4c73-b500-821d81b72293`, request `378dadb5-1d83-4f05-a872-d3e9338b8d71`; 0.3019 s; queued, zero calls. |
| Gemini selected-provider HTTP voice reservation | blocked | Request `a605c27c-b9a1-4c25-bfd6-022853af0dd1`, conversation `6ced1dee-ad4b-4fe2-ae84-b2b797f0f61b`; HTTP 503 `CALIBRATION_REQUIRED`, zero native voice calls; no live session/turn/audio IDs exist. |
| OpenAI Realtime acceptance | not_run | Separate OpenAI key absent; no finalized calibration or approved selected corpus. No switch/fallback. |
The intake elapsed times cover upload, one worker attempt where specified and
detail polling, measured with monotonic clocks; they are not pure upload latency,
retrieval timing, voice timing or an SLA. The operator harness places a shared
one-attempt guard at the actual HTTP opener, including failed attempts. DOCX and
image were processed once; PDF jobs were only uploaded. The API completed actual
lifespan shutdown. Its subprocess exit -15 is Uvicorn's deliberate signal re-raise
after `Application shutdown complete.`, not failed cleanup.
Offline measured diagnosis of the original DOCX produced 201 blocks (one
paragraph, 100 questions, 100 answers) and 100 factual groups. `prepare_chunks`
correctly requires independent factual approval. Retaining the review then rejects
`Ambiguous governing context for factual FAQ`: an unheaded preamble has no trusted
pair association. This remains an original-association release blocker, not a
credentials/UI issue. No text was deleted/reordered, heading invented, grouping
rule weakened or human decision fabricated. Resolving the authorial scope needs
explicit independent annotation or a separately justified faithful support change.
The image's actual durable failure was `EXTRACTION_QUALITY_FAILED` at `extract`;
no reviewable candidate was retained. The first run did not capture the provider's
low-level validation reason, and it is not inferred from that generic code. No
response text was logged and no second paid request was made to obtain it.
The real embedding profile remains `ollama / bge-m3 / 1024 / v1`. A read-only
local `/api/tags` probe confirmed `bge-m3:latest` exists. Nevertheless, constructing
the existing configured adapter fails before networking with
`Explicit embedding input and batch limits required`: `INGEST_EMBEDDING_LIMITS`
is absent. Exact compatible limits/counter policy must be established, not
estimated or written into already frozen job profiles. The configured calibration
report remains pending/null. The distinct calibration original
`data/calibration/phase2-source.md` was not covered by the four-original approval.
Four unseen independently annotated cases, approved frozen labels and genuine
human review decisions are still missing. The real retrieval gate is **blocked**
and unexecuted: 18/20 answerable, every critical and 6/6 unsupported remains intact.
### Reproduced operational repair and runnable verification
An actual idle `python -m app.worker` on the isolated migrated database exited
**-15** on SIGTERM without reaching its engine-disposal path. The worker now stops
new claims, wakes idle polling, completes an already owned job through unchanged
lease/heartbeat/fencing code, restores its signal handler and disposes the engine.
Actual rerun exited **0**. Two new regressions cover idle and active-job drain;
the existing worker tests plus these regressions passed **16 cases in 3.28 s**.
Production Compose gives worker drain 90 seconds, with lease recovery required
after any later forced kill. No applied migration or provider/retrieval code changed.
The image now installs the declared API/voice/embedding extras (the new multipart
transport directly needs `python_multipart`) and defaults to `app.server` for the
selected bounded parser. It preserves both backend provider adapters. Operational
fixture infrastructure lives under `tests/`, supplies no real keys, isolates the
worker/embedding service on an internal network and exposes only API/DB loopback
ports via a separate access network. The initial internal-only network did not
publish reachable ports; observed connection refused was corrected in the fixture
topology, not in production authorization or transport.
See the [backend operations guide](phase4-backend-operations.md) and executable
[operational harness](../../tests/phase4_operations.py) for service recreation,
startup reconciliation, fixture review/retry, blocked-worker kill/lease reclaim,
provider-free health and graceful shutdown. Fixture decisions are synthetic
transport tests, explicitly excluded from human/corpus approval evidence.
Exact approved-input command (already executed, one real HTTP attempt):
```sh
.venv/bin/python -m tests.phase4_bounded_intake --database-url postgresql+psycopg://postgres:fixture@127.0.0.1:55459/rag_paid_test --storage /tmp/rag-phase4-approved-intake --output /tmp/phase4-approved-intake.json --allow-provider-calls
```
This command needs a fresh isolated database/storage/report and preserves hashes
and the configured real embedding profile. Do not repeat a paid run merely to
recreate report IDs. It is not calibration/evaluation or a workaround for the
voice preflight. Reuse the existing `app.calibrate_search`, `tests.evaluate_search`
and `app.voice_smoke` commands only after their actual prerequisites and separate
stage budgets are satisfied.
Follow-up full provider-free command:
```sh
.venv/bin/python -m pytest -m 'not postgres' -q -p no:cacheprovider --tb=short
# 1755 passed, 2 existing Windows-path skips, 397 deselected, 25 warnings in 161.99s
UV_CACHE_DIR=/tmp/phase4-ops-uv-cache uv pip check --python .venv/bin/python
# 62 packages compatible
env -u TEST_DATABASE_URL .venv/bin/python -m pytest tests/integration/test_realtime_phase3_http.py::test_large_eligible_review_persists_and_replays -m postgres --require-postgres -q -p no:cacheprovider --tb=short
# Expected exit 1: two missing TEST_DATABASE_URL errors in 0.60s, zero skips
```
The first full PostgreSQL run on the persistent fixture database was interrupted:
16 passed, 1,757 deselected, two warnings in 139.64 s; observed wait classification
included `IO / DataFileImmediateSync`. It is not full-suite acceptance. The final
run uses a separate disposable tmpfs database; persistent service-recreation
acceptance continues to use the named PostgreSQL/original/extraction volumes.
Local backend container verdict and final PostgreSQL evidence are recorded at
the completion of this follow-up below. Real retrieval/selected-provider quality
remain blocked by the non-UI prerequisites above. Actual developer UI/hardware
acceptance remains pending. HTTPS/WSS deployment separately requires an authorized
endpoint, certificate, reverse proxy and external browser environment; none was
supplied. Full Phase 4 is not complete.
### Final executed container acceptance and verdict
**Local backend startup: verified in the isolated real deployment.** Eight
scenarios passed through built containers; detailed IDs and exact observations
are in [operational evidence](../calibration/realtime-phase4-operations.json),
run `8a470295-0ccc-42a7-85d3-a3f1bb98372c`. No readiness flag was manually
toggled. Exactly one API and one worker application process were counted.
| Executed scenario | Outcome | Monotonic scenario elapsed |
| --- | --- | --- |
| Real lifespan readiness, process counts and provider-free health | passed | 2.7411 s; actual health request IDs `9dd17fda-95e3-45a9-8cdc-a6268e9020bd`, `1ed86221-2edb-4cee-b783-4f71461c91e5`; zero fixture/real calls at readiness. |
| Supported bootstrap/provision and authenticated HTTP | passed | 17.4340 s; enabled fixture admin `e85e7d43-331f-42dc-bbcf-0f46fffc400f`; user account also provisioned. |
| Upload/replay, separate worker publication and explicit K02 | passed | 3.7689 s; document `2005c5a1-0e37-41e1-8b25-96395c1a0ad6`, job `993e0e39-4b1c-4080-a440-b991449407e6`; one fixture embedding call, zero real calls. |
| Repeated live/ready health after publication | passed | 1.6058 s; fixture-call counter remained 1 before/after six health requests. |
| PostgreSQL/API/worker recreation, retained storage and live reconciliation | passed | 58.8780 s; original hash, stored extraction validation, account/session and selection persisted; abandoned live session `6e05019e-8289-455f-99e9-a2c863bbd87c` was failed before ready observation. |
| Kill worker during an observed blocked embedding HTTP request; lease reclaim | passed | 32.2947 s; job `e205df31-423c-4c36-8a1d-451a41e713b5` completed on attempt 2 with exactly one chunk, no duplicate/partial publication. The recorded final claim change includes its clearing on publication; stale-token fencing is additionally verified by the full PostgreSQL suite. |
| Synthetic factual review/decision and same-job retry | passed | 3.3185 s; job `a51bf8d4-d338-4d06-b430-22866b1c028e` preserved; publication stayed inactive. Decision is explicitly fixture-only, not human evidence for an original. |
| HTTP logout and actual graceful API/worker shutdown | passed | 2.4198 s; subsequent `/me` was 401; both container exit codes were 0 and API shutdown-complete log was observed. |
Final image: `rag-phase4-operational:verified`, ID
`sha256:0390c6c5a4a279f22e86bbc3bf06ca9cfe1a958656dc3b0ca4f1c229db2a2763`.
Actual image API import and `python -m pip check` passed. Worker source SHA-256
inside the image matched the workspace:
`ece3346675d626d7cc7edb37ae4bc6ee5b7381ce13adafc3f26550dfb35004c9`.
The first build took a source snapshot before the worker repair; its different
worker hash was observed and a cached rebuild included the repair before any
final acceptance. No result from that older image is substituted for this run.
The first operational harness run passed startup/accounts but timed out awaiting
publication: the adapter rejected the fixture's non-loopback HTTP endpoint before
any request, as required. A direct fixture-adapter reproduction returned
`Invalid hosted embedding endpoint or timeout`. The fixture was corrected to
HTTPS with a test CA, normal certificate/hostname verification and a fresh task
database/profile; no production TLS check was weakened. The final eight-case run
above then passed. Fixture TLS is not public HTTPS/WSS deployment acceptance.
Exact final commands from repository root:
```sh
docker build -t rag-phase4-operational:verified .
# Initial corrected build followed by a cached source-current rebuild; both completed.
.venv/bin/python -m tests.phase4_operations --prepare --env-file /tmp/rag-phase4-secure-ops.env
export ACCEPTANCE_ENV_FILE=/tmp/rag-phase4-secure-ops.env
export ACCEPTANCE_TLS_DIRECTORY=/tmp/rag-phase4-secure-ops-tls
docker compose -p rag-phase4-ops -f tests/support/phase4-compose.yml up -d db embedding migrations api worker
.venv/bin/python -m tests.phase4_operations --verify --env-file /tmp/rag-phase4-secure-ops.env --output /tmp/phase4-operations-final.json
# passed, eight scenarios, zero real-provider calls
docker run --rm rag-phase4-operational:verified python -m pip check
# No broken requirements found.
docker run --rm -d --name rag-phase4-regression-test --tmpfs /var/lib/postgresql/data -e POSTGRES_PASSWORD=fixture -e POSTGRES_DB=rag_regression_test -p 127.0.0.1:55469:5432 pgvector/pgvector:pg16
TEST_DATABASE_URL=postgresql+psycopg://postgres:fixture@127.0.0.1:55469/rag_regression_test .venv/bin/python -m tests.postgres_prerequisites
# passed, PostgreSQL 16.15 / vector 0.8.7
TEST_DATABASE_URL=postgresql+psycopg://postgres:fixture@127.0.0.1:55469/rag_regression_test .venv/bin/python -m pytest -m postgres --require-postgres -q -p no:cacheprovider --tb=short
# 397 passed, zero skips, 1757 deselected, four warnings in 660.37 s
docker stop rag-phase4-regression-test
docker compose -p rag-phase4-ops -f tests/support/phase4-compose.yml down
```
Before removing the tmpfs regression container, inspection confirmed zero
application test schemas, zero public tables and zero additional test databases.
Final Compose `down` removes only task-owned containers/networks, preserving its
named database/original/extraction volumes, including the separate approved-input
database. These contain disposable acceptance actors/documents, not an operational
corpus. The image and protected fixture environment/CA files remain available for
recreation. Fixture certificate lifetime is two days; prepare fresh test artifacts
for later runs, never reuse that CA as a production credential. The initial baseline
prototype-extra build was interrupted and is not claimed as completed acceptance.
An actual container-only inventory GET also confirmed the current host-local
Ollama endpoint is unavailable as container loopback. The model is available on
host loopback; this is an additional deployment-topology prerequisite if using
the real frozen endpoint inside containers. Choose a topology that preserves its
identity, or obtain an explicit compatible profile/migration decision; do not
change existing profiles/comments to disguise the mismatch.
The backend can be started with the verified isolated commands above (or the
configured host procedure in the [operations guide](phase4-backend-operations.md)).
It supports operational HTTP and worker workflows. The supplied real `.env` alone
is not a usable grounded voice assistant: it lacks a direct-run database URL and
compatible embedding request limits, has pending calibration, and no ready
human-approved explicitly selected corpus has passed the retrieval gate.
Final verdict:
- **Local backend startup:** verified, actual built services/lifespan/accounts/HTTP,
persistent storage recreation and recovery; both services shut down gracefully.
- **Real retrieval acceptance:** blocked, not passed. Exact model request limits,
original association/extraction failures, genuine review decisions, approved
distinct calibration inputs/bindings, four unseen labels and finalized measured
calibration remain prerequisites. Full quality-run budgets are not supplied by
the limited small-call permission.
- **Selected-provider acceptance:** Gemini Live blocked by calibrated-corpus
preflight; actual HTTP 503 evidence, zero native voice calls. OpenAI separately
not_run, missing dedicated key plus shared quality prerequisites. Ingestion
vision's one OpenRouter attempt is separately reported and is not voice proof.
- **Actual UI/hardware acceptance:** pending, developer UI under development;
real Persian ASR/playback/interruption and UI recovery require that UI/audio.
- **HTTPS/WSS deployment:** external prerequisite, no authorized public endpoint,
certificate or proxy/browser deployment environment supplied. Internal fixture
HTTPS is technical transport evidence only.
Full Phase 4 remains incomplete; missing non-UI prerequisites are not relabeled
as UI dependencies. No original, migration, frozen profile, shared retrieval,
provider selection/adapter, review threshold or evaluation label was rewritten.
Final preservation check against the 237-file task-start SHA-256 snapshot:
230 files stayed byte-identical; seven intended files changed (README, Dockerfile,
Compose, worker, reference map, Phase 3 handoff and this report). Eight task files
were added: the operations guide, two evidence JSON files, two execution harnesses,
Compose/embedding fixtures and worker shutdown regression tests. All original
inputs and applied migration files stayed byte-identical. `git diff --check`
passed. After cleanup, Docker listed only the pre-existing `spiderfoot` and
`fastapi_db` containers; acceptance volumes were retained intentionally.
### Subsequent scoped ingestion/admission repair
The [ingestion and voice admission repair](ingestion-voice-admission-repair.md)
supersedes the original DOCX preamble terminal behavior and adds explicit
`VOICE_TRANSPORT_TESTING=true` connectivity admission with uncalibrated metadata.
Vision recognition warnings/incomplete recognition now preserve legible candidates
for genuine human review. Historical paid results and IDs above remain unchanged;
no paid rerun or fabricated decision/calibration occurred. Shared retrieval quality
still requires finalized measured calibration. The scoped report contains current
deterministic repair coverage; these changes do not complete Phase 4.