mirror of
https://github.com/x1xhlol/system-prompts-and-models-of-ai-tools.git
synced 2026-06-18 15:29:36 +00:00
- API routers, ACA modules, integrations (draft operators) - Docs, landing pages, scripts (launch readiness, scorecard) - Tests and CI workflow updates for Dealix Co-authored-by: Cursor <cursoragent@cursor.com>
42 lines
1.0 KiB
Python
42 lines
1.0 KiB
Python
"""In-memory decision log for platform tools (MVP)."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import itertools
|
|
import threading
|
|
import time
|
|
from typing import Any
|
|
|
|
_counter = itertools.count(1)
|
|
_lock = threading.Lock()
|
|
_entries: list[dict[str, Any]] = []
|
|
|
|
|
|
class ActionLedger:
|
|
"""Thread-safe append-only ledger."""
|
|
|
|
def append_decision(self, *, tool: str, outcome: str, detail: dict[str, Any]) -> dict[str, Any]:
|
|
with _lock:
|
|
entry = {
|
|
"id": next(_counter),
|
|
"ts": time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime()),
|
|
"tool": tool,
|
|
"outcome": outcome,
|
|
"detail": detail,
|
|
}
|
|
_entries.append(entry)
|
|
if len(_entries) > 500:
|
|
del _entries[:-500]
|
|
return entry
|
|
|
|
def recent(self, limit: int = 50) -> list[dict[str, Any]]:
|
|
with _lock:
|
|
return list(_entries[-limit:])
|
|
|
|
|
|
_ledger = ActionLedger()
|
|
|
|
|
|
def get_action_ledger() -> ActionLedger:
|
|
return _ledger
|