HEL-879 verify endpoint grants and correct final window evidence
Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
@@ -51,9 +51,9 @@ LiveKit 7880(客户端经 8363 WSS 桥)→ FunASR 流式识别 → 统一 `P
|
||||
| 项 | 结果 | 证据 |
|
||||
| --- | --- | --- |
|
||||
| 连续 ≥3 轮(同档案、同对话源、音色一致) | ✅ 通话2:haimianbaobao/nezha/rain 三轮全部 `turn_end`;跨通话记忆延续可见(通话2 回复接住通话1 话题) | `call1b.subtitles.jsonl`、`chat_message` 全表 |
|
||||
| 完整播放 receipt | ✅ 4 条 `sharing_attempt` 全部 `ack_at` 落值、state=judged;被截断轮无回执(fail-closed,msg7=cancelled) | `receipts_table`、`/api/chat/received 200` |
|
||||
| 完整播放 receipt | ✅ 总管收尾独立复核:最终库及一致性快照均为 **8 条** `sharing_attempt`,全部 `ack_at` 落值、state=judged;取消用户轮 msg7/msg23 对应回执均为0。原交付4条是较早阶段数字,不能代表最终库 | 只读SQL与快照恢复核对;`/api/chat/received 200` |
|
||||
| 开口打断 | ✅(发生真实性)通话1 三次真实 `turn_cancel(interrupted)`,用户开口截断在播回复、旧轮 user 行标 cancelled;**精确 ~1s 停声计时未取得**(量测设计缺陷+后两轮回复过短无以复测,见 §5) | `call1.subtitles.jsonl` seq68/87/92 |
|
||||
| 挂断立即停麦无残音 | ✅ DELETE 200 → 房间真实删除(ListRooms 空)、删除后仅 2 帧在途(20ms)、本地 track 停发 | `call1b.json hangup` |
|
||||
| 软件客户端挂断清理 | ✅ DELETE 200 → 房间真实删除(ListRooms 空)、删除后仅 2 帧在途(约20ms)、软件客户端 track 停发;**不代表用户设备麦克风指示灯或扬声器残音已验** | `call1b.json hangup` |
|
||||
| 断线(不挂断)+ TTL 到期后台删房 | ✅ 掉线不删 → 会话过期自动转债删除;15:52/15:56/15:57 三笔全部结清,账本空、房间空 | 轮询记录(窗口观察) |
|
||||
| API 重启清理 | ✅ 重启 epoch 4→5、档案/历史完整、voice 配置在;重启遗留会话按 TTL 由补偿清理全部结清 | 同上 |
|
||||
| 文字/语音互斥 | ✅(机制)文字轮被后到语音轮取消(msg23=cancelled)——同一把 chat 锁双向互斥成立;**「文字打断语音」方向未单独取证**(触发时机竞态,见 §5) | `call3.json`、消息表 |
|
||||
@@ -77,6 +77,10 @@ LiveKit 7880(客户端经 8363 WSS 桥)→ FunASR 流式识别 → 统一 `P
|
||||
|
||||
- **精确 1 秒级打断停声计时**:本轮三次真实打断均已发生并留痕,但帧级停声
|
||||
时间戳未随证据落盘(下一轮客户端应在每帧记录到达时间并按 speech 归属切分)。
|
||||
`call1.json` 已有发布音频到取消3.26秒、到最后agent帧5.3秒、cancel后204帧的
|
||||
原始粗计时,不能隐去这些慢值。该计时未区分触发录音的语音起点、旧speech与
|
||||
后续speech,不能据此量出旧声准确停止时间,**更不能判定达到约1秒**;下轮须
|
||||
定向测量后再作结论。
|
||||
- **「文字打断语音」方向**:本轮竞态取证到反向(语音取消文字);机制同一把锁,
|
||||
下轮把文字触发改为「assistant_interim 出现后」即可定向取证。
|
||||
- **真实设备浏览器路径**(D3 用户动作):证书「高级→继续」两处(8361/8363)、
|
||||
@@ -98,3 +102,23 @@ LiveKit 7880(客户端经 8363 WSS 桥)→ FunASR 流式识别 → 统一 `P
|
||||
- 回滚:全部为本轮新建独立进程/目录,删除 `/opt/cybergril-hel879`、
|
||||
`/opt/voice-agent-cybergril`、`/opt/cybergril-voice-certs` 即完全退场;Git 侧
|
||||
为本分支正常追加提交,PR#11 与既有实例未动。
|
||||
|
||||
## 7. 总管独立收尾复核补充
|
||||
|
||||
只读核对14次请求/42717 tokens及sealed=1,封账值与真实用量相等;清理账sessions=0、
|
||||
debts=0,8360/8361/8363/8082/9880无监听。没有重新打开原账或恢复本轮服务。
|
||||
证据包完整SHA256为`b23af43b39ed77263c7b3f285796e77e8b1278acbf547b4619adad600ed5c394`。
|
||||
|
||||
一致性快照已由总管在本地隔离目录按原工具实际恢复,SHA256与三方行数相等,
|
||||
恢复库同为sealed=1、14/42717用量和8条已确认回执。归档永不因上述“回滚”说明
|
||||
自动删除;保留测试资料与证据,销毁须另有明确授权。
|
||||
|
||||
原MANIFEST的code_commit记录8dc84f8(运行时修复尚未提交),不是最终修复提交。
|
||||
独立复核部署中的livekit_wire.py SHA256为
|
||||
`ffc477cd96d48c510905ce9fb887ba5b00edd6941ee59cf1b960f51f18500941`,
|
||||
与3766531收录源码逐字节一致;本说明补足溯源,不篡改原归档。
|
||||
|
||||
本轮只完成R5部分验证,不能称全部R5验收通过。实际6次建房必须连同3个空会话如实
|
||||
保留,不把“3次实际通话”写成“只建房3次”。窗口已收尾且3次实际通话用完,未用
|
||||
模型/token/TTS额度不自动授权新窗口;后续将精确打断计时、文字打断语音和用户设备
|
||||
浏览器路径作为必补项,与自定义音色交回后的统一验证安排集中处理,不擅自重开账。
|
||||
|
||||
@@ -143,11 +143,46 @@ assert mine_claims["iss"] == sdk_claims["iss"] and mine_claims["sub"] == sdk_cla
|
||||
assert set(mine_claims) == set(sdk_claims), (sorted(mine_claims), sorted(sdk_claims))
|
||||
ok.append("mint_token claims byte-parity with livekit.api.AccessToken (video/iss/sub/keys)")
|
||||
|
||||
# 6. server token decodes as the SDK Service._auth_header shape
|
||||
server_tok = wire.mint_server_token("devkey", "s3cret", ttl_seconds=60, now=1700000000.0)
|
||||
sc = pyjwt.decode(server_tok, "s3cret", algorithms=["HS256"], options={"verify_exp": False})
|
||||
assert sc["iss"] == "devkey" and sc["sub"] == "" and "video" not in sc
|
||||
ok.append("mint_server_token matches SDK no-grant auth header claims")
|
||||
# 6. Exercise BOTH real wire helpers: endpoint-specific grants must match the SDK,
|
||||
# and Twirp JSON must round-trip (a generic grantless token was insufficient on
|
||||
# the actual server; HEL-879's first real window exposed that missing coverage).
|
||||
async def server_endpoint_parity():
|
||||
seen = []
|
||||
def handler(request):
|
||||
assert request.headers["content-type"] == "application/json"
|
||||
body = json.loads(request.content)
|
||||
mine = pyjwt.decode(request.headers["authorization"].removeprefix("Bearer "),
|
||||
"s3cret", algorithms=["HS256"], options={"verify_exp": False})
|
||||
if request.url.path.endswith("CreateDispatch"):
|
||||
assert body == {"agentName": "offline-agent", "room": "offline-room", "metadata": "offline"}
|
||||
grants = api.VideoGrants(room_admin=True, room="offline-room")
|
||||
response = httpx.Response(200, json={"id": "AD_offline", "room": "offline-room"})
|
||||
else:
|
||||
assert request.url.path.endswith("DeleteRoom") and body == {"room": "offline-room"}
|
||||
grants = api.VideoGrants(room_create=True)
|
||||
response = httpx.Response(200, content=b"")
|
||||
sdk = pyjwt.decode(api.AccessToken("devkey", "s3cret").with_grants(grants).to_jwt(),
|
||||
"s3cret", algorithms=["HS256"], options={"verify_exp": False})
|
||||
# The SDK includes its default media permissions even for a service
|
||||
# token. They do not authorize these endpoints; compare the required
|
||||
# service grants without adding unused media privileges to our token.
|
||||
media_defaults = {"canPublish", "canSubscribe", "canPublishData"}
|
||||
assert all(sdk["video"][k] is True for k in media_defaults)
|
||||
required = {k: v for k, v in sdk["video"].items() if k not in media_defaults}
|
||||
assert mine["video"] == required, (mine["video"], required)
|
||||
assert mine["iss"] == sdk["iss"] and mine["sub"] == sdk["sub"]
|
||||
seen.append(request.url.path.rsplit("/", 1)[-1])
|
||||
return response
|
||||
async with httpx.AsyncClient(transport=httpx.MockTransport(handler)) as client:
|
||||
dispatch = await wire.create_dispatch(client, internal_url="http://offline.test",
|
||||
api_key="devkey", api_secret="s3cret", agent_name="offline-agent",
|
||||
room="offline-room", metadata="offline")
|
||||
assert dispatch.dispatch_id == "AD_offline"
|
||||
assert await wire.delete_room(client, internal_url="http://offline.test",
|
||||
api_key="devkey", api_secret="s3cret", room="offline-room")
|
||||
assert seen == ["CreateDispatch", "DeleteRoom"]
|
||||
asyncio.run(server_endpoint_parity())
|
||||
ok.append("actual CreateDispatch/DeleteRoom helpers: Twirp JSON and required SDK endpoint authorization grants match")
|
||||
|
||||
# 7. SpeechHandle/worker API surface used by worker.py exists on the real SDK
|
||||
from livekit.agents.voice.speech_handle import SpeechHandle
|
||||
|
||||
@@ -12,6 +12,7 @@ from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
import contextlib
|
||||
import json
|
||||
import socket
|
||||
import sys
|
||||
import tempfile
|
||||
@@ -48,11 +49,18 @@ class FakeLiveKit:
|
||||
if self.fail:
|
||||
return httpx.Response(500)
|
||||
if request.url.path.endswith("CreateDispatch"):
|
||||
agent, room = _dispatch_fields(request.content)
|
||||
body = json.loads(request.content)
|
||||
agent, room = body["agentName"], body["room"]
|
||||
assert request.headers["content-type"] == "application/json"
|
||||
claims, _ = livekit_wire.decode_token(request.headers["authorization"].removeprefix("Bearer "))
|
||||
assert claims["video"] == {"roomAdmin": True, "room": room}
|
||||
self.dispatches.append({"agent_name": agent, "room": room})
|
||||
return httpx.Response(200, json={"id": f"AD_{len(self.dispatches)}", "room": room})
|
||||
if request.url.path.endswith("DeleteRoom"):
|
||||
self.deleted.append(_dispatch_fields(request.content)[0])
|
||||
assert request.headers["content-type"] == "application/json"
|
||||
claims, _ = livekit_wire.decode_token(request.headers["authorization"].removeprefix("Bearer "))
|
||||
assert claims["video"] == {"roomCreate": True}
|
||||
self.deleted.append(json.loads(request.content)["room"])
|
||||
return httpx.Response(200)
|
||||
return httpx.Response(404)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user