self_recall/edit平台撤回窗口+per-chat速率预算 #120
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/115-recall-window-and-rate-budget"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #115
Summary
ADR-0012 §6 的两根安全支柱之一——速率预算(主兜底)——此前从未落地,另一根
(平台撤回窗口)依赖的 Sent Log 时间字段也从未补上。本片补齐两者,顺带吸收
send_message的quote_message_id跨 chat 引用校验缺口。sent_at时间字段:SentLogEntry/SentLogModel/StoragePort.record()协议及内存/持久化两个实现均适配;None显式fail-closed(视同已超窗口),不随包分发迁移(可空列)。
_within_platform_recall_window纯函数 +platform_recall_window_seconds独立构造参数(因被_handle_self_recall/_handle_edit两个方法读取,按既有RuntimeLoopConfig归类规则不进config);
self_recall/edit在能力位分叉之前拒绝超窗口句柄,零平台调用。action_rate_budget.py,形状仿gating.SilenceBudgetState令牌桶先例但不复用;self_recall/edit合计消费同一个 per-chat 桶,降级 recall+resend 路径的
egress.recall同样受限;内存 + 持久化两个存储实现 + 新表。
_run_tool_loop新增known_message_ids参数,只有run()真实来信时非空,事件驱动路径一律降级为不带引用的普通发送。
Review
两轴 review(sonnet,Standards + Spec 轴并行,随后对抗式复核)抓到 4 条
standards 轴发现,全部确认成立并已修复:
_handle_edit降级路径的 self_recall 能力检查/MAX_SENDS_PER_TURN检查排在预算消费之后,导致注定打不到平台的失败请求白白吃掉预算、饿死同
chat 后续真正合法的 self_recall/edit——已复现、修复、补两条回归测试,并
用变异测试验证修复确实被新测试捕获。
test_handle_ownership.py文档字符串过期(声称SentLogEntry仍无 time 字段)——已订正。
PersistentStorage的速率预算读写此前只测过内存假实现——补了DB round-trip 测试(
test_action_rate_budget_storage.py)。补了纯函数边界单测(
test_platform_recall_window.py)。Spec 轴零发现——AC 四条逐项核对无遗漏。
Test plan
uv run pytest:1631 passeduv run ruff check .:cleandocs分支本地提交(不推送)