HEL-879 rework materials: hatchling cache correction with the offline mem0ai wheel actually built from the fixed source (sha256 698284b6..., zero downloads/installs, no 3.10 mixing, recorded in release-artifacts.json), hel895 release doc §0 now separates the historical HEL-895/896 candidate from the current hel-879-assembly candidate and §4/§5 carry the v3 snapshot semantics, budget §6.2.4 amended - a sealed library is never reopened by raising total_requests (contradiction removed), runbook §3.3/3.5/3.6/4.4/4.5 corrected (bounded cleanup ledger replaces the unproven rooms-die-naturally claim; assistant_interim kind; real-but-default-off proactive seam; single-owner dual launcher), one comment-only correction in web/src/voice/session.ts removing the unproven server-auto-cleanup claim (no logic/style change; CSS and JS bundle hashes byte-stable), CG-011 + her incremental subtitles now have a real minimal backend seam (voice/seam.py + worker/llm_chat_api wiring, proactive default off) with the precise frontend interface and acceptance list in docs/rework/hel879/voice-seam-interfaces.md, real-SDK check extended to 10 items (worker callback path on real SpeechHandle/SpeechCreatedEvent; interim seam through real LLMStream) and re-run on .12 ALL PASS, handoff-HEL-879.json appended with the rework scope; regression at this head: pytest 341/341, ruff clean except 1 pre-existing error identical at 7f0a739, web typecheck 0 errors / lint 0 errors 1 pre-existing warning / vitest 88/88 / build passes (CSS index-BpZaybfD.css unchanged), voice chain 8/8, budget split 10/10, release offline R1-R7, http pagination 7/7, real-service browser 9/9 with zero non-loopback outbound, pinned-SDK 16/16+12/12+6/6+7/7+12/12, requirements checks 4/4 (origin/main and c121c42, each with/without handoff)

Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
zonggong
2026-10-27 04:27:04 +08:00
co-authored by multica-agent
parent 78a5cfd8d7
commit 7c73d392b9
21 changed files with 567 additions and 94 deletions
+61 -6
View File
@@ -16,6 +16,7 @@ Zero network beyond 127.0.0.1; fake LiveKit/TTS transports throughout.
from __future__ import annotations
import asyncio
import contextlib
import json
import socket
import ssl
@@ -40,9 +41,12 @@ from cybergril.think.router import build_router # noqa: E402
from cybergril.think.scenes import Tier # noqa: E402
from cybergril.voice import livekit_wire # noqa: E402
from cybergril.voice.receipt import TurnLedger # noqa: E402
from cybergril.voice.seam import ( # noqa: E402
AssistantInterimPublisher,
pick_proactive,
)
from cybergril.voice.session import VoiceConfig, VoiceSessionService # noqa: E402
# ---------------------------------------------------------------- TurnLedger
def _stream(turn_id: str) -> SimpleNamespace:
@@ -103,7 +107,9 @@ def _proto_field1(data: bytes) -> str:
"""Decode varint-prefixed field 1 (room) from a livekit proto body."""
if not data or (data[0] >> 3) != 1 or (data[0] & 7) != 2:
return ""
length, index, shift, value = 0, 1, 0, 0
length = 0
index = 1
shift = 0
while True:
byte = data[index]
length |= (byte & 0x7F) << shift
@@ -253,7 +259,7 @@ async def test_cleanup_is_bounded_then_recorded_abandoned(tmp_path):
try:
session = await service.open_session(epoch=1)
now[0] += service.config.session_ttl_seconds + 1
with pytest.raises(Exception):
with pytest.raises(livekit_wire.RoomDeleteError):
await service.end_session(session.session_id)
for _ in range(200):
debt = service.cleanup_debt(session.session_id)
@@ -381,6 +387,57 @@ def test_router_delete_failure_is_503_and_keeps_room_owned():
assert again.status_code == 404
# ------------------------------------------------- CG-011 seam (HEL-879)
def test_assistant_interim_publisher_accumulates_and_resets():
published: list[dict] = []
publisher = AssistantInterimPublisher(published.append)
assert publisher.feed("") is None
assert publisher.feed("她在") is not None
publisher.feed("打字中")
assert published[-1] == {"kind": "assistant_interim", "role": "assistant",
"text": "她在打字中"}
publisher.reset()
publisher.feed("新的一轮")
assert published[-1]["text"] == "新的一轮", "no inheritance across turns"
def test_proactive_selection_is_archived_newest_bounded():
messages = [
{"id": 1, "role": "user", "status": "sent", "proactive": False, "text": "hi"},
{"id": 2, "role": "companion", "status": "sent", "proactive": True, "text": "旧主动"},
{"id": 3, "role": "companion", "status": "sent", "proactive": True, "text": "新主动"},
{"id": 4, "role": "companion", "status": "queued", "proactive": True, "text": "未落库"},
{"id": 5, "role": "companion", "status": "sent", "proactive": True, "text": " "},
{"id": 6, "role": "companion", "status": "sent", "proactive": False, "text": "普通回复"},
]
picked = pick_proactive(messages, already_spoken=set(), limit=1)
assert [m["id"] for m in picked] == [3], "newest eligible proactive row only"
again = pick_proactive(messages, already_spoken={3}, limit=1)
assert [m["id"] for m in again] == [2]
assert pick_proactive(messages, already_spoken={2, 3}, limit=1) == []
@pytest.mark.asyncio
async def test_pending_proactive_reads_unified_messages_page():
from cybergril.voice.chat_api_client import ChatApiClient
def handler(request: httpx.Request) -> httpx.Response:
assert request.url.path == "/api/messages"
assert request.url.params["limit"] == "20"
return httpx.Response(200, json={"messages": [
{"id": 9, "role": "companion", "status": "sent",
"proactive": True, "text": "落库的主动留言"}], "epoch": 1})
client = ChatApiClient("http://api.test", transport=httpx.MockTransport(handler))
try:
rows = await client.recent_messages()
picked = pick_proactive(rows, already_spoken=set(), limit=1)
assert picked[0]["id"] == 9
finally:
await client.aclose()
# ---------------------------------------------------- dual-listener lifecycle
def _free_port() -> int:
@@ -461,10 +518,8 @@ async def test_dual_listeners_share_one_lifecycle_and_close_in_order(
assert len(set(store_inits)) == 1, "the app must be initialized exactly once"
finally:
serve_task.cancel()
try:
with contextlib.suppress(asyncio.CancelledError):
await serve_task
except asyncio.CancelledError:
pass
await client.aclose()
# Exit boundary: both listeners fully shut down BEFORE the store closes,