Files
patrickandClaude Sonnet 5.5 9c4f7366eb
test / pytest (3.11) (push) Canceled after 0s
test / pytest (3.13) (push) Canceled after 0s
feat: Phase 6 prompt versioning with test area, retention
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-06 02:17:01 +01:00

27 lines
834 B
Python

import time
from typing import Callable
from .db import Database
AuditFn = Callable[[str, str, str, str | None, str | None], None]
def record(db: Database, user: str, action: str, target: str,
old: str | None = None, new: str | None = None) -> None:
db.execute(
"INSERT INTO audit(ts, user, action, target, old_value, new_value) VALUES (?,?,?,?,?,?)",
(int(time.time()), user, action, target, old, new),
)
def recorder(db: Database) -> AuditFn:
return lambda user, action, target, old=None, new=None: record(db, user, action, target, old, new)
def recent(db: Database, limit: int = 100) -> list[dict]:
rows = db.query(
"SELECT ts, user, action, target, old_value, new_value FROM audit ORDER BY id DESC LIMIT ?",
(limit,),
)
return [dict(row) for row in rows]