system-prompts-and-models-o.../dealix/auto_client_acquisition/platform_services/action_ledger.py
Sami Assiri b13cb389cc feat(dealix): sync full Dealix package to repo
- 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>
2026-05-01 21:01:17 +03:00

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