Add command policy audit trail

This commit is contained in:
2026-05-20 23:03:59 +08:00
parent 45b70d2800
commit 61cdd8bbaf
7 changed files with 364 additions and 12 deletions
+26
View File
@@ -90,3 +90,29 @@ class EventStore:
)
for row in rows
]
async def list_by_type(self, event_type: str, limit: int = 100) -> list[Event]:
await self.init()
async with aiosqlite.connect(self.db_path) as db:
db.row_factory = aiosqlite.Row
cursor = await db.execute(
"""
select * from events
where event_type = ?
order by id desc
limit ?
""",
(event_type, limit),
)
rows = await cursor.fetchall()
return [
Event(
id=row["id"],
task_id=row["task_id"],
sequence=row["sequence"],
event_type=row["event_type"],
payload=json.loads(row["payload_json"]),
created_at=row["created_at"],
)
for row in rows
]