重构主控编排与运行时预热链路,统一工作区提示词/专家调度协议并补齐 wiki 记忆注入与写回闭环。

同时收敛启动与运维脚本默认行为(含 wiki worker)、更新 Admin 可观测性与相关测试,降低首轮时延并提高运行稳定性。

Made-with: Cursor
This commit is contained in:
oliver 2026-04-26 08:34:33 +08:00
parent 4a23b715a2
commit dbbe3add6a
14438 changed files with 2693620 additions and 2546 deletions

View file

@ -3,7 +3,12 @@ from __future__ import annotations
import json
from pathlib import Path
from oclaw.runtime.hooks_runtime import resolve_runtime_config
from oclaw.runtime.hooks.eligibility_from_metadata import hook_eligibility_from_message_metadata
from oclaw.runtime.hooks_runtime import (
_reset_hooks_runtime_state_for_test,
initialize_hooks_runtime,
resolve_runtime_config,
)
def test_resolve_runtime_config_from_env_json(monkeypatch) -> None:
@ -32,3 +37,69 @@ def test_resolve_runtime_config_from_config_path(monkeypatch, tmp_path: Path) ->
== 99
)
def test_initialize_hooks_runtime_passes_remote_eligibility(monkeypatch, tmp_path: Path) -> None:
_reset_hooks_runtime_state_for_test()
empty_bundled = tmp_path / "empty-bundled"
empty_bundled.mkdir(parents=True, exist_ok=True)
monkeypatch.setattr("oclaw.runtime.hooks_runtime.runtime_hooks_bundled_root", lambda: str(empty_bundled))
monkeypatch.setattr("oclaw.runtime.hooks.merge_skill_hook_dirs.discover_workspace_skill_manifests", lambda: ())
ws = tmp_path / "workspace"
hook_dir = ws / "hooks" / "demo"
hook_dir.mkdir(parents=True, exist_ok=True)
(hook_dir / "HOOK.md").write_text(
"---\n"
"name: demo\n"
"description: demo\n"
"metadata:\n"
" oclaw:\n"
" events: [\"command:new\"]\n"
" requires:\n"
" bins: [\"git\"]\n"
"---\n",
encoding="utf-8",
)
(hook_dir / "handler.py").write_text("def handle(event):\n return None\n", encoding="utf-8")
cfg = {"hooks": {"internal": {"enabled": True, "entries": {"demo": {"enabled": True}}}}}
loaded = initialize_hooks_runtime(
cfg=cfg,
workspace_dir=str(ws),
eligibility={"remote": {"hasBin": lambda _bin: False, "hasAnyBin": lambda _bins: False}},
)
assert loaded == 0
def test_initialize_hooks_runtime_loads_when_metadata_bins_present_reports_requirement(
monkeypatch, tmp_path: Path
) -> None:
_reset_hooks_runtime_state_for_test()
empty_bundled = tmp_path / "empty-bundled"
empty_bundled.mkdir(parents=True, exist_ok=True)
monkeypatch.setattr("oclaw.runtime.hooks_runtime.runtime_hooks_bundled_root", lambda: str(empty_bundled))
monkeypatch.setattr("oclaw.runtime.hooks.merge_skill_hook_dirs.discover_workspace_skill_manifests", lambda: ())
ws = tmp_path / "workspace"
hook_dir = ws / "hooks" / "demo"
hook_dir.mkdir(parents=True, exist_ok=True)
(hook_dir / "HOOK.md").write_text(
"---\n"
"name: demo\n"
"description: demo\n"
"metadata:\n"
" oclaw:\n"
" events: [\"command:new\"]\n"
" requires:\n"
" bins: [\"oclaw_fake_hook_bin\"]\n"
"---\n",
encoding="utf-8",
)
(hook_dir / "handler.py").write_text("def handle(event):\n return None\n", encoding="utf-8")
cfg = {"hooks": {"internal": {"enabled": True, "entries": {"demo": {"enabled": True}}}}}
elig = hook_eligibility_from_message_metadata(
{"hookEligibility": {"remote": {"binsPresent": ["oclaw_fake_hook_bin"]}}},
)
assert elig is not None
loaded = initialize_hooks_runtime(cfg=cfg, workspace_dir=str(ws), eligibility=elig)
assert loaded == 1