oclaw/tests/test_workspaces_prompt_contract.py
oliver 420abac9f1 refactor: root-package imports (svc/runtime/interfaces) and fix PYTHONPATH
- Rename platform/ to svc/ to avoid shadowing stdlib platform.
- Replace from oclaw.* with from svc/runtime/interfaces; update -m CLI paths.
- tests/conftest: prepend repo root to sys.path (no parent-folder package name).
- CI: paths and offline_eval script under repo root.
- Ops scripts: PYTHONPATH must be repo root for python -m runtime.* (fixes gateway/WhatsApp sidecar startup).
- Fix default oclaw.json path in tabular/file attachment limits; stabilize attachment test config.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-13 14:51:17 +08:00

58 lines
2 KiB
Python

from __future__ import annotations
from pathlib import Path
from svc.config.paths import PROJECT_ROOT
def _read(path: Path) -> str:
return path.read_text(encoding="utf-8")
def test_main_dynamic_placeholder_only_in_role_system() -> None:
root = (PROJECT_ROOT / "runtime" / "workspaces" / "main").resolve()
role_system = _read(root / "ROLE_SYSTEM.md")
soul = _read(root / "SOUL.md")
assert "{{MANAGER_DYNAMIC_EXPERTS_HINT}}" in role_system
assert "{{" not in soul
for name in ("AGENTS.md", "IDENTITY.md", "USER.md"):
p = root / name
if p.exists():
assert "{{" not in _read(p)
def test_main_hard_routing_rule_only_in_role_system() -> None:
root = (PROJECT_ROOT / "runtime" / "workspaces" / "main").resolve()
role_system = _read(root / "ROLE_SYSTEM.md")
assert "回退 `generalist`" in role_system
for name in ("AGENTS.md", "IDENTITY.md", "USER.md", "SOUL.md"):
p = root / name
if p.exists():
assert "回退 `generalist`" not in _read(p)
def test_every_workspace_has_role_system() -> None:
root = (PROJECT_ROOT / "runtime" / "workspaces").resolve()
for item in root.iterdir():
if not item.is_dir():
continue
if item.name.startswith("__"):
continue
# `_system` holds template fragments/snippets, not routed specialist workspaces.
if item.name.startswith("_"):
continue
assert (item / "ROLE_SYSTEM.md").exists(), f"missing ROLE_SYSTEM.md for {item.name}"
def test_workspace_legacy_prompt_files_removed() -> None:
root = (PROJECT_ROOT / "runtime" / "workspaces").resolve()
legacy = ("AGENTS.md", "IDENTITY.md", "USER.md")
for item in root.iterdir():
if not item.is_dir():
continue
if item.name.startswith("__"):
continue
if item.name.startswith("_"):
continue
for name in legacy:
assert not (item / name).exists(), f"legacy prompt file still exists: {item.name}/{name}"