mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-09 03:30:48 +08:00
重构主控编排与运行时预热链路,统一工作区提示词/专家调度协议并补齐 wiki 记忆注入与写回闭环。
同时收敛启动与运维脚本默认行为(含 wiki worker)、更新 Admin 可观测性与相关测试,降低首轮时延并提高运行稳定性。 Made-with: Cursor
This commit is contained in:
parent
4a23b715a2
commit
dbbe3add6a
14438 changed files with 2693620 additions and 2546 deletions
34
tests/test_fastapi_startup_prebuild.py
Normal file
34
tests/test_fastapi_startup_prebuild.py
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from fastapi import FastAPI
|
||||
|
||||
from oclaw.interfaces.http import fastapi_app as app_mod
|
||||
|
||||
|
||||
def test_run_startup_hooks_runs_prebuild_warmup(monkeypatch) -> None:
|
||||
class DummyStore:
|
||||
def revoke_all_auth_sessions(self) -> int:
|
||||
return 0
|
||||
|
||||
monkeypatch.setattr(app_mod, "SqliteStore", lambda _p: DummyStore())
|
||||
monkeypatch.setattr(app_mod, "db_path", lambda: "dummy.sqlite")
|
||||
monkeypatch.setattr(app_mod, "prepare_gateway_plugin_bootstrap", lambda **kwargs: {"ok": True})
|
||||
monkeypatch.setattr(app_mod, "resolve_runtime_config", lambda: {})
|
||||
monkeypatch.setattr(app_mod, "skill_runtime_diagnostics", lambda: {"skills_root": "/tmp", "skills_total": 0})
|
||||
monkeypatch.setattr(app_mod, "warm_expert_workspace_cache", lambda: None)
|
||||
monkeypatch.setattr(app_mod, "_relocate_root_scan_artifacts", lambda: None)
|
||||
monkeypatch.setattr(app_mod, "initialize_hooks_runtime", lambda **kwargs: None)
|
||||
monkeypatch.setattr(app_mod, "trigger_hook_event", lambda **kwargs: None)
|
||||
monkeypatch.setattr(app_mod, "_resolve_startup_workspace_dirs", lambda _cfg: [("default", "/tmp/ws")])
|
||||
called: dict[str, object] = {"scheduler": 0}
|
||||
def _run_prewarm(**kwargs):
|
||||
called["prewarm"] = kwargs
|
||||
return {"ok": True, "elapsed_ms": 1, "freeze": {"frozen": True}}
|
||||
|
||||
monkeypatch.setattr(app_mod, "run_runtime_prewarm", _run_prewarm)
|
||||
monkeypatch.setattr(app_mod, "_spawn_periodic_prewarm_loop", lambda: called.__setitem__("scheduler", 1))
|
||||
monkeypatch.setattr(app_mod, "_prewarm_interval_seconds", lambda: 600)
|
||||
|
||||
app_mod._run_startup_hooks(FastAPI())
|
||||
assert "prewarm" in called
|
||||
assert called["scheduler"] == 1
|
||||
Loading…
Add table
Add a link
Reference in a new issue