Core behavioral rules and skills for NanoClaw personal assistant agents. Always-on rules for communication, verification, memory, and formatting.
69
87%
Does it follow best practices?
Impact
—
No eval scenarios have been run
Risky
Do not use without reviewing
import importlib.util
from pathlib import Path
import pytest
REPO_ROOT = Path(__file__).resolve().parents[1]
def _load(name: str, relpath: str):
"""Load a hyphenated-filename Python script as a module.
Tile scripts use kebab-case filenames (e.g. `container-uptime.py`)
that aren't valid Python module identifiers, so they can't be
imported normally. Each call returns a fresh module instance so
tests that monkeypatch module-level constants don't leak state
across tests."""
path = REPO_ROOT / relpath
# Most fixture misconfigurations are bad relpaths. `spec_from_file_location`
# generally returns a non-None spec/loader even for nonexistent files —
# the failure only shows up later inside `exec_module` as `FileNotFoundError`
# / `OSError`. Check existence up front for the common case, keep the
# spec/loader guard for the unusual one (custom loaders that return None),
# and re-raise loader-time OSErrors as `ImportError` so the test report
# names which fixture is misconfigured at a glance.
if not path.is_file():
raise ImportError(f"Could not load module {name!r} from {path}")
spec = importlib.util.spec_from_file_location(name, path)
if spec is None or spec.loader is None:
raise ImportError(f"Could not load module {name!r} from {path}")
module = importlib.util.module_from_spec(spec)
try:
spec.loader.exec_module(module)
except OSError as exc:
raise ImportError(f"Could not load module {name!r} from {path}") from exc
return module
@pytest.fixture
def container_uptime():
"""Fresh-loaded module under test for the status skill's
container-uptime script. Per-test reload keeps tests independent
even though this module reads no module-level env."""
return _load(
"container_uptime_under_test",
"skills/status/scripts/container-uptime.py",
)
@pytest.fixture
def query_message_history():
"""Fresh-loaded module under test for the query-history skill's
messages.db keyword/sender query helper. Per-test reload so tests
that monkeypatch env or module-level constants don't leak state
across tests, matching the pattern used by `container_uptime`
above."""
return _load(
"query_message_history_under_test",
"skills/query-history/scripts/query-message-history.py",
)
@pytest.fixture
def now_vs_deadline():
"""Fresh-loaded module under test for the now-vs-deadline skill's
deadline-comparison helper. The module exposes `compare(now,
deadline)` and `parse_deadline(str)` as pure functions so tests can
pin `now` and assert deterministic past/future output. Per-test
reload matches the pattern above."""
return _load(
"now_vs_deadline_under_test",
"skills/now-vs-deadline/scripts/now-vs-deadline.py",
)rules
tests