HEL-879 rework: fix the four manager-review edges - (1) dual-port launcher owns the app lifecycle exactly once: uvicorn listeners run with lifespan=off, either listener ending stops the other BEFORE the shared store closes, cancellation cleans up listeners first, and create_app's lifespan gains a fail-closed double-entry guard (the old shape silently re-initialized Store/epoch/life/chat_lock on the second entry); (2) room ownership survives delete failures: end_session keeps the session in a bounded persisted cleanup ledger until the remote delete lands (retry/idempotent, LiveKit 404 = already gone = settled), expiry moves rooms into that ledger instead of silently dropping them (the manager measured zero DELETE attempts on expired ends), graceful shutdown does not hang up live calls, restart compensates only this instance's own recorded rooms bounded by attempts/TTL+grace with abandonment recorded, and the router answers 503 (not 404) while a room is still owned so the browser keeps its owed DELETE; (3) TurnLedger binds each speech handle to its own generation stream explicitly (oldest pending handle gets the stream the SDK starts; a newer speech retires an older generation-less handle) - a handle without a generation can no longer steal the next turn's stream/receipt, the worker discards interrupted/failed bindings fail-closed before consuming; (4) release snapshot v3: verify requires three-way count equality (manifest source = manifest snapshot = restored actual; rows_match is an extra constraint, never an OR bypass), the rollback drill actually restores by source path into a persistent isolated tree and opens the restored DBs there, same-basename DBs get collision-free archive names, duplicate sources are refused; new regression file tests/test_voice_rework_hel879.py 14/14 reproducing every edge first, full pytest 338/338
Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
co-authored by
multica-agent
parent
7f0a739213
commit
78a5cfd8d7
@@ -302,13 +302,23 @@ async def test_receipt_sender_confirms_once_and_reports_server_refusal():
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def live_server(api):
|
||||
def live_server(api, tmp_path):
|
||||
app, provider, _ = api
|
||||
# HEL-879: an app's lifespan has exactly one owner — the api fixture's
|
||||
# TestClient still holds its lifespan, so the live server gets its OWN app
|
||||
# instance on the same file-backed database (companion row included) and
|
||||
# the same provider; the old fixture entered one app's lifespan twice
|
||||
# concurrently, the exact defect the app now refuses loudly.
|
||||
router = build_router(providers={t: provider for t in (Tier.HIGH, Tier.STANDARD, Tier.LOW)},
|
||||
budget=engineering_budget())
|
||||
served = create_app(db_path=tmp_path / "adapter.db", router=router,
|
||||
life_config=LifeConfig(enabled=True, poll_seconds=3600),
|
||||
semantic_mode="stub")
|
||||
probe = socket.socket()
|
||||
probe.bind(("127.0.0.1", 0))
|
||||
port = probe.getsockname()[1]
|
||||
probe.close() # free the port for uvicorn to bind
|
||||
config = uvicorn.Config(app, host="127.0.0.1", port=port, log_level="error")
|
||||
config = uvicorn.Config(served, host="127.0.0.1", port=port, log_level="error")
|
||||
server = uvicorn.Server(config)
|
||||
thread = threading.Thread(target=server.run, daemon=True)
|
||||
thread.start()
|
||||
@@ -318,7 +328,7 @@ def live_server(api):
|
||||
break
|
||||
except Exception:
|
||||
time.sleep(0.1)
|
||||
yield f"http://127.0.0.1:{port}", app, provider
|
||||
yield f"http://127.0.0.1:{port}", served, provider
|
||||
server.should_exit = True
|
||||
thread.join(timeout=5)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user