MCPcopy Create free account
hub / github.com/CommonstackAI/UncommonRoute / InMemoryTraceStorage

Class InMemoryTraceStorage

uncommon_route/traces.py:273–294  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

271
272
273class InMemoryTraceStorage(TraceStorage):
274 def __init__(self) -> None:
275 self._rows: list[dict[str, Any]] = []
276
277 def append(self, record: dict[str, Any]) -> None:
278 self._rows.append(dict(record))
279
280 def load_recent_days(
281 self, days: int, *, now: float
282 ) -> list[dict[str, Any]]:
283 return list(self._rows)
284
285 def load_for_request(
286 self, request_id: str, timestamp: float
287 ) -> dict[str, Any] | None:
288 for r in self._rows:
289 if r.get("request_id") == request_id:
290 return dict(r)
291 return None
292
293 def purge(self) -> None:
294 self._rows.clear()
295
296
297def migrate_legacy_json(legacy_path: Path, target_dir: Path) -> bool:

Calls

no outgoing calls