真 bug 合集:向量库探活误报 + edit 降级漏查能力位 + 群聊沉默窗口不撤销 + pytest 配置节名错 #93
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
1.
storage.py向量库探活把 property 当函数调用 →/diagnose恒误报src/nonebot_plugin_arise/storage.py:1763:_qdrant是@property(storage.py:690),返回AsyncQdrantClient,加括号即TypeError: 'AsyncQdrantClient' object is not callable。决定性证据:全文件
self._qdrant共 11 处,10 处是self._qdrant.upsert(...)式属性访问,唯独 1763 行多了括号(955/1009/1585/1596/1600/1622/1632/1892/1917/1934全部无括号)。后果:
/diagnose走_probe("向量库", ...),而_probe宽捕Exception只回类名 → 真实部署上向量库永远报down,理由是TypeError,一个纯误报且理由具误导性。为什么没被发现:唯一相关测试
tests/test_admin_commands.py:625用的是自定义假 storage,PersistentStorage.ping_vector_store从未被执行过。PersistentStorage.ping_vector_store的测试(否则同类手误还会再来一次)。2.
_handle_edit的降级路径不查capabilities.self_recallruntime_loop.py::_handle_edit:if self._capabilities.edit:走原生 edit;else 分支直接await self._egress.recall(chat_id, entry.message_id),全程不查capabilities.self_recall。而同文件
_handle_self_recall有这个 fail-closed 检查——issue #20 修过一模一样的 bug,这次从edit那扇门原样漏出来。CapabilitySet全字段默认False,edit=False & self_recall=False就是缺省组合,而edit工具对模型恒可见。违反 ADR-0004「core 拥降级策略」+ ADR-0012「无
self_recall→ post-send 撤回不可用」。capabilities.self_recall检查,为假即 fail-closed 不产生任何平台调用。tests/fake_egress.py:49的recall()是唯一一个不检查能力位就记账的方法(其余七个都raise NotImplementedError),所以就算有人写了这条组合的用例也不会红。3. 沉默窗口在群聊里不撤销 → 恰好在抢话
_silence_window.interrupt()全仓唯一调用点在__init__.py:263,位于_handle_reactive_message内,而该 handler 注册在reactive_matcher = on_message(rule=to_me())。后果:群聊里第三方正常发言(没 @ 机器人)不撤销待发消息——恰恰是这个机制要治的「抢话」。私聊因
to_me()恒真而碰巧正确,这也是它一直没被发现的原因。CONTEXT.md「沉默窗口」条与
silence_window.py:3模块文档都断言「窗口内任何人发言即撤销(补位而非抢话)」,与接线不符。@event_postprocessor,只调_silence_window.interrupt(chat_id)。纯撤销、不产生任何 LLM 调用,所以不构成「新增消息接收面/成本面」的架构决定(那是gating.py:28记录过的既有顾虑,本改动不触及)。仓里已有两个@event_postprocessor先例(_handle_environment_signal/_handle_presence_events)。4.
[tool.pytest]节名错,整节配置静默失效pyproject.toml:93是[tool.pytest],而 pytest 只读[tool.pytest.ini_options]。全仓无ini_options、无pytest.ini/setup.cfg/tox.ini(已核实)。于是以下全部未生效:
--import-mode=prepend、--strict-markers、--tb=short、-ra、-s、-v、pythonpath = ["src"]、asyncio_mode = "auto"、asyncio_default_fixture_loop_scope = "session"。注意实际影响没有听起来大,别当成"测试都白跑了":
pythonpath冗余(包是 editable 安装);asyncio_mode/loop_scope被tests/conftest.py的pytest_collection_modifyitems钩子独立补偿(用is_async_test给异步测试补pytest.mark.asyncio(loop_scope="session")),且 69 个测试文件本身带显式 marker——测试是真在跑,1436 绿不是假的。真实损失是
--strict-markers(打错的 marker 被静默忽略)和几条纯观感项。改成
[tool.pytest.ini_options]。改完跑一次全量确认没有因
--strict-markers生效而暴露出既有的错拼 marker;有就一并修。5.
ports.py:172错误文案查漏顺带发现的文案问题(低价值,搭车修)。实施时读一下当前文本再决定怎么改。
Not in scope
__init__.py拆分、StoragePort抽出等在结构批)。send失败兜底(另一张票,改动面中等)。