import pytest from duck_core.events.store import EventStore from duck_core.tasks.store import TaskStore @pytest.mark.asyncio async def test_task_and_event_store_round_trip(tmp_path): db_path = tmp_path / "duck.sqlite3" tasks = TaskStore(str(db_path)) events = EventStore(str(db_path)) await tasks.init() await events.init() task = await tasks.create_task("hello", "./workspace", True) await events.append(task.task_id, "task_created", {"message": "hello"}) await tasks.complete_task(task.task_id, "done") loaded = await tasks.get_task(task.task_id) timeline = await events.list_events(task.task_id) assert loaded is not None assert loaded.status == "completed" assert loaded.final_response == "done" assert [event.event_type for event in timeline] == ["task_created"]