mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-31 19:16:29 +00:00
Systematic prune per AGENTS.md test policy, one pass over every major test tree (gateway, hermes_cli, tools, agent, run_agent, plugins, cli, cron, tui_gateway, honcho/openviking, root-level): - DELETE: source-reading tests (read_text/getsource on prod files), change-detector tests (exact catalog counts, model-name snapshots, config version literals), mock-echo tests (assert a mock returns what it was told), assertion-free/trivial tests, near-duplicate parametrizations (boundaries + one representative kept), async/sync twin duplicates, cosmetic within-file variations. - KEEP (mandatory): security/redaction/approval guards, message-role alternation invariants, prompt-caching/deterministic-call-id invariants, issue-number regression tests (deduped), E2E tests. - 6 test files deleted outright (script-style/no-assert or fully redundant); conftest.py, fakes/, fixtures/ untouched. - tests/acp/conftest.py added: autouse fixture stubs the live models.dev/GitHub/Copilot/Anthropic inventory fetches that ACP server tests performed on every session create — test_server.py 147s → 3.4s, and the tests are now genuinely hermetic. - Sleep-based slowness shrunk where safe (codex_ttfb_watchdog, compression_concurrent_fork, etc.); no wall-clock assertion tightened. Verification: full hermetic suite via scripts/run_tests.sh — 2439 files, 31,130 tests passed, 0 failed, 0 flaky retries, 315s wall (baseline: 583s wall, 13,564s subprocess CPU).
81 lines
2.7 KiB
Python
81 lines
2.7 KiB
Python
"""Behavior contracts for the learning-graph assembler.
|
|
|
|
Asserts invariants (edges resolve to real nodes, clusters cover every node,
|
|
memory cards are represented consistently), never a snapshot of the live skill
|
|
catalog — that catalog grows every release and a count assertion would be a
|
|
change-detector.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from agent import learning_graph
|
|
from hermes_constants import reset_hermes_home_override, set_hermes_home_override
|
|
|
|
|
|
def _node(name: str, category: str, related=None):
|
|
n = learning_graph.SkillNode(name=name, category=category)
|
|
n.related = list(related or [])
|
|
return n
|
|
|
|
|
|
|
|
|
|
def test_density_stats_count_isolated_nodes():
|
|
nodes = {
|
|
"a": _node("a", "x", related=["b"]),
|
|
"b": _node("b", "x", related=["a"]),
|
|
"c": _node("c", "y"),
|
|
}
|
|
stats = learning_graph.density_stats(nodes, learning_graph.build_edges(nodes))
|
|
|
|
assert stats["nodes"] == 3
|
|
assert stats["linked_nodes"] == 2
|
|
assert stats["isolated_pct"] == round(100 / 3, 1)
|
|
|
|
|
|
|
|
|
|
def test_memory_is_cards_split_on_separator(tmp_path):
|
|
home = tmp_path / ".hermes"
|
|
(home / "memories").mkdir(parents=True)
|
|
(home / "memories" / "MEMORY.md").write_text(
|
|
"Project uses pytest with xdist\n§\nUser prefers concise responses",
|
|
encoding="utf-8",
|
|
)
|
|
token = set_hermes_home_override(home)
|
|
try:
|
|
graph = learning_graph.build_learning_graph()
|
|
finally:
|
|
reset_hermes_home_override(token)
|
|
|
|
titles = [c["title"] for c in graph["memory"]]
|
|
assert "Project uses pytest with xdist" in titles
|
|
assert "User prefers concise responses" in titles
|
|
# Memory cards remain typed cards and also appear as memory-kind nodes.
|
|
assert all(c["source"] in {"memory", "profile"} for c in graph["memory"])
|
|
assert all("timestamp" in c for c in graph["memory"])
|
|
assert any(n["kind"] == "memory" for n in graph["nodes"])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_full_payload_shape_and_edge_integrity(tmp_path):
|
|
home = tmp_path / ".hermes"
|
|
home.mkdir()
|
|
token = set_hermes_home_override(home)
|
|
try:
|
|
graph = learning_graph.build_learning_graph()
|
|
finally:
|
|
reset_hermes_home_override(token)
|
|
|
|
ids = {n["id"] for n in graph["nodes"]}
|
|
assert all(e["source"] in ids and e["target"] in ids for e in graph["edges"])
|
|
# Every node's category appears in the cluster list.
|
|
cluster_cats = {c["category"] for c in graph["clusters"]}
|
|
assert all(n["category"] in cluster_cats for n in graph["nodes"])
|
|
skill_nodes = [n for n in graph["nodes"] if n["kind"] == "skill"]
|
|
assert graph["stats"]["nodes"] == len(skill_nodes)
|
|
assert graph["stats"]["memory_nodes"] == len(graph["memory"])
|
|
assert all("timestamp" in n for n in graph["nodes"])
|