mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-19 01:43:17 +08:00
feat(ops): add UME alarm playbook skill and tool guardrails
- Add ops-netx-ume-playbook skill (zh-CN) with presets, paging and SQL safety defaults - Strengthen ops identity disclosure rules (always 'oclaw智能运维') - Improve netx UME anchor context and add raw/aggregate/SQL tooling ergonomics Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
5b925854f0
commit
f538409c08
6 changed files with 636 additions and 48 deletions
|
|
@ -12,19 +12,21 @@ from oclaw.runtime.direct_loop import _build_model_context
|
|||
def test_ops_role_injects_netx_batch_anchor_into_system(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
import oclaw.runtime.tools.experts.network_ops.netx_tools as nt
|
||||
|
||||
def _fake_latest() -> dict:
|
||||
def _fake_anchor() -> dict:
|
||||
return {
|
||||
"ok": True,
|
||||
"batch_id": "batch-inject-test",
|
||||
"batch_row": {
|
||||
"created_at": "2026-05-01T00:00:00",
|
||||
"source_file": "alarms.xlsx",
|
||||
"status": "ok",
|
||||
"total_rows": 42,
|
||||
"anchor": {
|
||||
"status": "done",
|
||||
"trigger_mode": "auto",
|
||||
"started_at": "2026-05-01T00:00:00",
|
||||
"ended_at": "2026-05-01T00:01:00",
|
||||
"pulled_count": 42,
|
||||
"inserted_count": 3,
|
||||
"updated_count": 5,
|
||||
},
|
||||
}
|
||||
|
||||
monkeypatch.setattr(nt, "_resolve_latest_import_batch_id", _fake_latest)
|
||||
monkeypatch.setattr(nt, "_resolve_ume_anchor", _fake_anchor)
|
||||
nt._OPS_NETX_SYS_CTX_CACHE.clear() # type: ignore[attr-defined]
|
||||
|
||||
store = SqliteStore(str(tmp_path / "n.sqlite"))
|
||||
|
|
@ -48,20 +50,20 @@ def test_ops_role_injects_netx_batch_anchor_into_system(tmp_path: Path, monkeypa
|
|||
)
|
||||
assert msgs and msgs[0].get("role") == "system"
|
||||
sys_text = str(msgs[0].get("content") or "")
|
||||
assert "batch-inject-test" in sys_text
|
||||
assert "alarms.xlsx" in sys_text
|
||||
assert "UME告警锚点" in sys_text
|
||||
assert "42/3/5" in sys_text
|
||||
|
||||
|
||||
def test_non_ops_role_skips_netx_inject(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
calls: dict[str, int] = {"n": 0}
|
||||
|
||||
def _spy_latest() -> dict:
|
||||
def _spy_anchor() -> dict:
|
||||
calls["n"] += 1
|
||||
return {"ok": True, "batch_id": "x", "batch_row": {}}
|
||||
return {"ok": True, "anchor": {}}
|
||||
|
||||
import oclaw.runtime.tools.experts.network_ops.netx_tools as nt
|
||||
|
||||
monkeypatch.setattr(nt, "_resolve_latest_import_batch_id", _spy_latest)
|
||||
monkeypatch.setattr(nt, "_resolve_ume_anchor", _spy_anchor)
|
||||
|
||||
store = SqliteStore(str(tmp_path / "g.sqlite"))
|
||||
sess = store.create_session("s")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue