Skip to content

Commit 9fe37bc

Browse files
test: add harness matrix agent and test_harness_matrix.py
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent b307773 commit 9fe37bc

3 files changed

Lines changed: 425 additions & 1 deletion

File tree

packages/studyctl/tests/harness/__init__.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,13 @@ def test_start(study_session):
1515
study_session.assert_agent_running()
1616
"""
1717

18-
from .agents import fast_exit_agent, long_running_agent, parking_agent, topic_logger_agent
18+
from .agents import (
19+
fast_exit_agent,
20+
long_running_agent,
21+
matrix_agent,
22+
parking_agent,
23+
topic_logger_agent,
24+
)
1925
from .study import StudySession
2026
from .tmux import TmuxHarness
2127

@@ -24,6 +30,7 @@ def test_start(study_session):
2430
"TmuxHarness",
2531
"fast_exit_agent",
2632
"long_running_agent",
33+
"matrix_agent",
2734
"parking_agent",
2835
"topic_logger_agent",
2936
]

packages/studyctl/tests/harness/agents.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,3 +121,38 @@ def crash_agent(tmp_path: Path) -> str:
121121
""",
122122
)
123123
return f"{script} {{persona_file}}"
124+
125+
126+
def matrix_agent(tmp_path: Path) -> str:
127+
"""Agent for the autoresearch test matrix.
128+
129+
Logs 2 topics (1 win with substantive note, 1 learning) and parks
130+
a question, then stays alive until SIGTERM. The win note is >= 15
131+
chars so ``write_session_flashcards`` picks it up.
132+
"""
133+
script = _write_script(
134+
tmp_path / "mock-agent-matrix.sh",
135+
"""#!/usr/bin/env bash
136+
trap 'exit 0' TERM INT
137+
echo "Matrix agent started (persona: $1)"
138+
sleep 2 # wait for sidebar to initialise
139+
140+
# Win topic — note must be >= 15 chars for flashcard generation
141+
studyctl topic "Decorator Pattern" --status win \
142+
--note "Understanding how Python decorators wrap functions using closures"
143+
sleep 1
144+
145+
# Learning topic
146+
studyctl topic "First-Class Functions" --status learning \
147+
--note "exploring the concept of first-class functions"
148+
sleep 1
149+
150+
# Park a question via IPC file (more reliable in tests than CLI)
151+
PARKING_FILE="$HOME/.config/studyctl/session-parking.md"
152+
echo "- How do decorators interact with class methods?" >> "$PARKING_FILE"
153+
154+
# Stay alive until killed
155+
while true; do sleep 1; done
156+
""",
157+
)
158+
return f"{script} {{persona_file}}"

0 commit comments

Comments
 (0)