mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-08 03:01:47 +00:00
fix(skills): lock usage telemetry updates
This commit is contained in:
parent
c2d6b385f1
commit
d12be46df8
2 changed files with 91 additions and 11 deletions
|
|
@ -1,12 +1,21 @@
|
|||
"""Tests for tools/skill_usage.py — sidecar telemetry + provenance filtering."""
|
||||
|
||||
import json
|
||||
import multiprocessing as mp
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
def _bump_view_many(hermes_home: str, skill_name: str, iterations: int) -> None:
|
||||
os.environ["HERMES_HOME"] = hermes_home
|
||||
from tools.skill_usage import bump_view
|
||||
|
||||
for _ in range(iterations):
|
||||
bump_view(skill_name)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def skills_home(tmp_path, monkeypatch):
|
||||
"""Isolated HERMES_HOME with a clean skills/ dir for each test."""
|
||||
|
|
@ -139,6 +148,30 @@ def test_bumps_do_not_corrupt_other_skills(skills_home):
|
|||
assert get_record("skill-b")["use_count"] == 1
|
||||
|
||||
|
||||
def test_concurrent_bump_view_preserves_all_updates(skills_home):
|
||||
from tools.skill_usage import get_record
|
||||
|
||||
process_count = 6
|
||||
iterations = 25
|
||||
ctx = mp.get_context("spawn")
|
||||
processes = [
|
||||
ctx.Process(
|
||||
target=_bump_view_many,
|
||||
args=(str(skills_home), "shared-skill", iterations),
|
||||
)
|
||||
for _ in range(process_count)
|
||||
]
|
||||
|
||||
for process in processes:
|
||||
process.start()
|
||||
for process in processes:
|
||||
process.join(timeout=20)
|
||||
|
||||
for process in processes:
|
||||
assert process.exitcode == 0
|
||||
assert get_record("shared-skill")["view_count"] == process_count * iterations
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# State transitions
|
||||
# ---------------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue