Files
rag-technical-docs-assistant/docs/guides/realtime-agent-phase4-acceptance.md
T
11linear11 b06eaf59f4 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.
2026-10-09 17:44:13 -04:00

511 lines
37 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 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.