fix(backend): 冻结 TOOLBOX 注册表为只读 MappingProxyType(CR-H7)
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
from ww_agents import SPECS
|
||||
from ww_skills import TOOLBOX, get_tool
|
||||
|
||||
@@ -105,3 +106,11 @@ def test_get_tool_resolves_known_and_unknown() -> None:
|
||||
assert get_tool("brainstorm") is TOOLBOX["brainstorm"]
|
||||
assert get_tool("worldbuilding") is TOOLBOX["worldbuilding"]
|
||||
assert get_tool("does-not-exist") is None
|
||||
|
||||
|
||||
def test_toolbox_registry_is_read_only() -> None:
|
||||
# CR-H7:注册表是单一真相源,运行时变异(注入/删除)须 fail-fast(冻结为 MappingProxyType)。
|
||||
with pytest.raises(TypeError):
|
||||
TOOLBOX["injected"] = TOOLBOX["brainstorm"] # type: ignore[index]
|
||||
with pytest.raises(TypeError):
|
||||
del TOOLBOX["brainstorm"] # type: ignore[attr-defined]
|
||||
|
||||
Reference in New Issue
Block a user