mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-09 03:30:48 +08:00
将 workspace 缓存失效机制切换到 revision token,并补齐回归验证。
通过 revision 驱动 prompt/prebuild 缓存重建,避免请求路径上的目录签名扫描成本,同时新增缓存失效与路径约定相关测试,确保行为稳定。 Made-with: Cursor
This commit is contained in:
parent
768f175c3e
commit
87ff00aa06
4 changed files with 169 additions and 19 deletions
|
|
@ -127,3 +127,63 @@ def test_executor_static_prompt_cache_invalidates_on_settings_change(monkeypatch
|
|||
skill_binding_role="generalist",
|
||||
)
|
||||
assert calls["n"] == 2
|
||||
|
||||
|
||||
def test_executor_static_prompt_cache_invalidates_on_workspace_revision_change(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
from oclaw.runtime import system_prompt as sp
|
||||
|
||||
class DummyStore:
|
||||
def get_setting(self, key: str) -> str:
|
||||
_ = key
|
||||
return ""
|
||||
|
||||
class DummyReg:
|
||||
pass
|
||||
|
||||
calls = {"n": 0}
|
||||
token = {"v": 1}
|
||||
|
||||
def _skills_block(**kwargs) -> str:
|
||||
_ = kwargs
|
||||
calls["n"] += 1
|
||||
return "skills-block"
|
||||
|
||||
monkeypatch.setattr(sp, "expert_workspace_signature_token", lambda: ("revision", token["v"]))
|
||||
monkeypatch.setattr(sp, "build_project_context_block", lambda **kwargs: "")
|
||||
monkeypatch.setattr(sp, "build_skills_catalog_block", _skills_block)
|
||||
monkeypatch.setattr(
|
||||
sp,
|
||||
"render_runtime_prompt",
|
||||
lambda prompt_id, variables, strict: f"{prompt_id}\n{variables.get('skills_catalog') or ''}",
|
||||
)
|
||||
|
||||
store = DummyStore()
|
||||
reg = DummyReg()
|
||||
_ = sp.get_executor_prompt_static(
|
||||
store=store,
|
||||
tools=reg, # type: ignore[arg-type]
|
||||
base_url="",
|
||||
base_system="base",
|
||||
workspace_dir=None,
|
||||
skill_binding_role="generalist",
|
||||
)
|
||||
_ = sp.get_executor_prompt_static(
|
||||
store=store,
|
||||
tools=reg, # type: ignore[arg-type]
|
||||
base_url="",
|
||||
base_system="base",
|
||||
workspace_dir=None,
|
||||
skill_binding_role="generalist",
|
||||
)
|
||||
assert calls["n"] == 1
|
||||
|
||||
token["v"] = 2
|
||||
_ = sp.get_executor_prompt_static(
|
||||
store=store,
|
||||
tools=reg, # type: ignore[arg-type]
|
||||
base_url="",
|
||||
base_system="base",
|
||||
workspace_dir=None,
|
||||
skill_binding_role="generalist",
|
||||
)
|
||||
assert calls["n"] == 2
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue