fix(ops): harden backend startup and worker recovery

Install modular API, voice and embedding extras and use the supported single-process server entrypoint. Drain worker SIGTERM shutdown within the Compose grace period.

Add isolated HTTPS embedding fixtures, bounded intake execution and reproducible account, publication, restart, lease-recovery and shutdown acceptance. Eight operational scenarios passed with zero real-provider calls.
This commit is contained in:
11linear11
2026-10-09 17:44:04 -04:00
parent a73a496c54
commit 42f5b9e854
9 changed files with 760 additions and 5 deletions
+61
View File
@@ -0,0 +1,61 @@
# Isolated, provider-free operational acceptance; never reads the deployment .env.
services:
db:
image: pgvector/pgvector:pg16
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: fixture
POSTGRES_DB: rag_ops_test
ports: ["127.0.0.1:55459:5432"]
networks: [default, access]
volumes: ["database:/var/lib/postgresql/data"]
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres -d rag_ops_test"]
interval: 2s
timeout: 2s
retries: 30
migrations:
image: rag-phase4-operational:verified
build:
context: ../..
dockerfile: Dockerfile
env_file: ["${ACCEPTANCE_ENV_FILE:?Supply the isolated fixture env file}"]
command: alembic upgrade head
depends_on:
db: {condition: service_healthy}
api:
image: rag-phase4-operational:verified
env_file: ["${ACCEPTANCE_ENV_FILE:?Supply the isolated fixture env file}"]
command: python -m app.server --host 0.0.0.0 --port 8000
ports: ["127.0.0.1:18080:8000"]
networks: [default, access]
volumes:
- originals:/app/data/originals
- extractions:/app/data/extractions
- ${ACCEPTANCE_TLS_DIRECTORY:?Supply fixture TLS directory}/cert.pem:/fixtures/ca.pem:ro
depends_on:
migrations: {condition: service_completed_successfully}
worker:
image: rag-phase4-operational:verified
env_file: ["${ACCEPTANCE_ENV_FILE:?Supply the isolated fixture env file}"]
command: python -m app.worker
volumes:
- originals:/app/data/originals
- extractions:/app/data/extractions
- ${ACCEPTANCE_TLS_DIRECTORY:?Supply fixture TLS directory}/cert.pem:/fixtures/ca.pem:ro
depends_on:
migrations: {condition: service_completed_successfully}
embedding:
image: rag-phase4-operational:verified
command: python /fixtures/phase4_embedding_fixture.py
volumes:
- ./phase4_embedding_fixture.py:/fixtures/phase4_embedding_fixture.py:ro
- ${ACCEPTANCE_TLS_DIRECTORY:?Supply fixture TLS directory}:/fixtures/tls:ro
volumes:
database:
originals:
extractions:
networks:
default:
internal: true
access: {}
+50
View File
@@ -0,0 +1,50 @@
"""Loopback/internal-network fixture, never a production embedding provider."""
import hashlib
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
import json
import ssl
from threading import Event
CALLS = 0
RELEASE = Event()
RELEASE.set()
class Handler(BaseHTTPRequestHandler):
def log_message(self, *_):
pass # Never log inputs or Authorization headers.
def reply(self, data):
body = json.dumps(data).encode()
self.send_response(200)
self.send_header('Content-Type', 'application/json')
self.send_header('Content-Length', str(len(body)))
self.end_headers()
self.wfile.write(body)
def do_GET(self):
if self.path == '/block':
RELEASE.clear()
elif self.path == '/release':
RELEASE.set()
self.reply({'fixture_calls': CALLS, 'real_provider_calls': 0})
def do_POST(self):
global CALLS
length = int(self.headers.get('Content-Length', '0'))
if self.path != '/v1/embeddings' or not 0 < length <= 1024 * 1024:
self.send_error(400)
return
data = json.loads(self.rfile.read(length))
CALLS += 1
RELEASE.wait(30)
self.reply({'model': data['model'], 'data': [dict(index=i, embedding=[float(1 + n) for n in hashlib.sha256(value.encode()).digest()[:3]])
for i, value in enumerate(data['input'])]})
if __name__ == '__main__':
server=ThreadingHTTPServer(('0.0.0.0', 8090), Handler)
context=ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
context.load_cert_chain('/fixtures/tls/cert.pem','/fixtures/tls/key.pem')
server.socket=context.wrap_socket(server.socket,server_side=True)
server.serve_forever()