mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-21 16:18:55 +00:00
test: add coverage for manual-skill curator guard
Some checks failed
CI / Detect affected areas (push) Has been cancelled
CI / OSV scan (push) Has been cancelled
Deploy Site / deploy-vercel (push) Has been cancelled
Deploy Site / deploy-docs (push) Has been cancelled
auto-fix lint issues & formatting / Generate eslint --fix patch (push) Has been cancelled
Build Skills Index / build-index (push) Has been cancelled
CI / Python tests (push) Has been cancelled
CI / Python lints (push) Has been cancelled
CI / JS & TS checks (push) Has been cancelled
CI / Docs Site (push) Has been cancelled
CI / Deny unrelated histories (push) Has been cancelled
CI / Check contributors (push) Has been cancelled
CI / Check uv.lock (push) Has been cancelled
CI / package-lock.json diff (push) Has been cancelled
CI / Lint Docker scripts (push) Has been cancelled
CI / Build&Test Docker image (push) Has been cancelled
CI / Supply-chain scan (push) Has been cancelled
CI / All required checks pass (push) Has been cancelled
CI / CI timing report (push) Has been cancelled
auto-fix lint issues & formatting / Apply patch (push) Has been cancelled
Build Skills Index / trigger-deploy (push) Has been cancelled
Some checks failed
CI / Detect affected areas (push) Has been cancelled
CI / OSV scan (push) Has been cancelled
Deploy Site / deploy-vercel (push) Has been cancelled
Deploy Site / deploy-docs (push) Has been cancelled
auto-fix lint issues & formatting / Generate eslint --fix patch (push) Has been cancelled
Build Skills Index / build-index (push) Has been cancelled
CI / Python tests (push) Has been cancelled
CI / Python lints (push) Has been cancelled
CI / JS & TS checks (push) Has been cancelled
CI / Docs Site (push) Has been cancelled
CI / Deny unrelated histories (push) Has been cancelled
CI / Check contributors (push) Has been cancelled
CI / Check uv.lock (push) Has been cancelled
CI / package-lock.json diff (push) Has been cancelled
CI / Lint Docker scripts (push) Has been cancelled
CI / Build&Test Docker image (push) Has been cancelled
CI / Supply-chain scan (push) Has been cancelled
CI / All required checks pass (push) Has been cancelled
CI / CI timing report (push) Has been cancelled
auto-fix lint issues & formatting / Apply patch (push) Has been cancelled
Build Skills Index / trigger-deploy (push) Has been cancelled
Adds two tests for the _background_review_write_guard manual-skill check: - refuses delete on a skill with created_by=None (manually authored) - allows delete on a skill with created_by='agent' (agent-created)
This commit is contained in:
parent
6236412294
commit
af6b41b18b
1 changed files with 75 additions and 0 deletions
|
|
@ -976,6 +976,81 @@ class TestExternalSkillMutations:
|
|||
result = json.loads(raw)
|
||||
assert result["success"] is True
|
||||
|
||||
def test_background_review_refuses_manually_authored_skill(self, tmp_path):
|
||||
"""The curator must not archive/edit skills the user placed manually
|
||||
(created_by=None). Only agent-created skills are eligible for
|
||||
autonomous curation."""
|
||||
from tools.skill_provenance import (
|
||||
BACKGROUND_REVIEW,
|
||||
reset_current_write_origin,
|
||||
set_current_write_origin,
|
||||
)
|
||||
|
||||
with _skill_dir(tmp_path):
|
||||
_create_skill("manual-skill", VALID_SKILL_CONTENT)
|
||||
token = set_current_write_origin(BACKGROUND_REVIEW)
|
||||
try:
|
||||
from tools.skill_manager_tool import mark_background_review_skill_read
|
||||
|
||||
mark_background_review_skill_read(tmp_path / "manual-skill" / "SKILL.md")
|
||||
with patch(
|
||||
"tools.skill_usage.load_usage",
|
||||
return_value={"manual-skill": {"created_by": None, "use_count": 50}},
|
||||
), patch(
|
||||
"tools.skill_usage.get_record",
|
||||
side_effect=lambda n: {"created_by": None, "use_count": 50} if n == "manual-skill" else {},
|
||||
):
|
||||
raw = skill_manage(
|
||||
action="delete",
|
||||
name="manual-skill",
|
||||
)
|
||||
finally:
|
||||
reset_current_write_origin(token)
|
||||
|
||||
result = json.loads(raw)
|
||||
assert result["success"] is False
|
||||
assert "manually authored" in result["error"].lower()
|
||||
|
||||
def test_background_review_allows_agent_created_skill(self, tmp_path):
|
||||
"""Agent-created skills (created_by='agent') are NOT blocked by the
|
||||
manual-skill guard — they remain eligible for autonomous curation."""
|
||||
from tools.skill_provenance import (
|
||||
BACKGROUND_REVIEW,
|
||||
reset_current_write_origin,
|
||||
set_current_write_origin,
|
||||
)
|
||||
|
||||
with _skill_dir(tmp_path):
|
||||
_create_skill("agent-skill", VALID_SKILL_CONTENT)
|
||||
token = set_current_write_origin(BACKGROUND_REVIEW)
|
||||
try:
|
||||
from tools.skill_manager_tool import mark_background_review_skill_read
|
||||
|
||||
mark_background_review_skill_read(tmp_path / "agent-skill" / "SKILL.md")
|
||||
with patch(
|
||||
"tools.skill_usage.load_usage",
|
||||
return_value={"agent-skill": {"created_by": "agent", "use_count": 5}},
|
||||
), patch(
|
||||
"tools.skill_usage.get_record",
|
||||
side_effect=lambda n: {"created_by": "agent", "use_count": 5} if n == "agent-skill" else {},
|
||||
), patch(
|
||||
"tools.skill_usage.is_curation_eligible", return_value=True,
|
||||
), patch(
|
||||
"tools.skill_usage.archive_skill", return_value=(True, "archived"),
|
||||
):
|
||||
raw = skill_manage(
|
||||
action="delete",
|
||||
name="agent-skill",
|
||||
absorbed_into="umbrella",
|
||||
)
|
||||
finally:
|
||||
reset_current_write_origin(token)
|
||||
|
||||
result = json.loads(raw)
|
||||
# Should not be blocked by the manual-skill guard (may be blocked by
|
||||
# the consolidation-delete guard if absorbed_into is empty, but the
|
||||
# manual-skill guard must not fire).
|
||||
assert "manually authored" not in result.get("error", "").lower()
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue