Initial release: iai-mcp v0.1.0
Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: XNLLLLH <XNLLLLH@users.noreply.github.com>
This commit is contained in:
commit
f6b876fbe7
332 changed files with 97258 additions and 0 deletions
111
tests/test_mcp_curiosity_pending.py
Normal file
111
tests/test_mcp_curiosity_pending.py
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
"""Tests for curiosity_pending dispatch.
|
||||
|
||||
The `curiosity_pending` method was scaffolded by and is now
|
||||
promoted to a first-class MCP tool. Behaviour:
|
||||
|
||||
- Fresh store -> {"questions": [], "count": 0}.
|
||||
- Filters by session_id when provided.
|
||||
- Excludes resolved questions (curiosity_resolved events resolve them).
|
||||
- Orders newest first.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import datetime, timezone
|
||||
from uuid import UUID, uuid4
|
||||
|
||||
import pytest
|
||||
|
||||
from iai_mcp.core import dispatch
|
||||
from iai_mcp.events import write_event
|
||||
from iai_mcp.store import MemoryStore
|
||||
|
||||
|
||||
def test_curiosity_pending_empty_store(tmp_path):
|
||||
store = MemoryStore(path=tmp_path)
|
||||
out = dispatch(store, "curiosity_pending", {})
|
||||
assert out == {"questions": [], "count": 0}
|
||||
|
||||
|
||||
def test_curiosity_pending_returns_unresolved(tmp_path):
|
||||
store = MemoryStore(path=tmp_path)
|
||||
ids = [str(uuid4()) for _ in range(3)]
|
||||
for i, qid in enumerate(ids):
|
||||
write_event(
|
||||
store,
|
||||
kind="curiosity_question",
|
||||
data={
|
||||
"question_id": qid,
|
||||
"text": f"q{i}",
|
||||
"tier": "question",
|
||||
"entropy": 0.9,
|
||||
"turn": i,
|
||||
"triggered_by": [],
|
||||
},
|
||||
severity="info",
|
||||
session_id="s1",
|
||||
)
|
||||
out = dispatch(store, "curiosity_pending", {})
|
||||
assert out["count"] == 3
|
||||
assert len(out["questions"]) == 3
|
||||
for q in out["questions"]:
|
||||
assert "id" in q
|
||||
assert "text" in q
|
||||
assert "tier" in q
|
||||
assert "entropy" in q
|
||||
assert "triggered_by_record_ids" in q
|
||||
|
||||
|
||||
def test_curiosity_pending_filters_session(tmp_path):
|
||||
store = MemoryStore(path=tmp_path)
|
||||
write_event(
|
||||
store,
|
||||
kind="curiosity_question",
|
||||
data={"question_id": str(uuid4()), "text": "a", "tier": "question",
|
||||
"entropy": 0.9, "turn": 1, "triggered_by": []},
|
||||
severity="info",
|
||||
session_id="s1",
|
||||
)
|
||||
write_event(
|
||||
store,
|
||||
kind="curiosity_question",
|
||||
data={"question_id": str(uuid4()), "text": "b", "tier": "question",
|
||||
"entropy": 0.9, "turn": 1, "triggered_by": []},
|
||||
severity="info",
|
||||
session_id="s2",
|
||||
)
|
||||
out = dispatch(store, "curiosity_pending", {"session_id": "s1"})
|
||||
assert out["count"] == 1
|
||||
assert out["questions"][0]["text"] == "a"
|
||||
|
||||
|
||||
def test_curiosity_pending_excludes_resolved(tmp_path):
|
||||
store = MemoryStore(path=tmp_path)
|
||||
qid = str(uuid4())
|
||||
write_event(
|
||||
store,
|
||||
kind="curiosity_question",
|
||||
data={"question_id": qid, "text": "resolved-q", "tier": "question",
|
||||
"entropy": 0.9, "turn": 1, "triggered_by": []},
|
||||
severity="info",
|
||||
session_id="s1",
|
||||
)
|
||||
other_qid = str(uuid4())
|
||||
write_event(
|
||||
store,
|
||||
kind="curiosity_question",
|
||||
data={"question_id": other_qid, "text": "still-open", "tier": "question",
|
||||
"entropy": 0.9, "turn": 1, "triggered_by": []},
|
||||
severity="info",
|
||||
session_id="s1",
|
||||
)
|
||||
# Resolve the first question.
|
||||
write_event(
|
||||
store,
|
||||
kind="curiosity_resolved",
|
||||
data={"question_id": qid},
|
||||
severity="info",
|
||||
session_id="s1",
|
||||
)
|
||||
out = dispatch(store, "curiosity_pending", {})
|
||||
assert out["count"] == 1
|
||||
assert out["questions"][0]["text"] == "still-open"
|
||||
Loading…
Add table
Add a link
Reference in a new issue