mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-06 23:17:17 +08:00
Replaces the flat single-blob memory page with a structured store: - L1 captures raw run traces; L2 holds normalized document records; L3 holds curated slots per surface (chat, notebook, book, TutorBot). - New consolidator pipeline (chunker, guards, parse, references, runs, modes, line-doc, meta) turns traces into versioned line-oriented documents with stable ids and snapshot history. - Per-user isolation flows through PathService; the store API is stateless. UI ships a dedicated /memory workbench with graph / L1 / L2 / L3 / resolve subpages, plus a reusable MemorySection embedded where the legacy panel lived. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
46 lines
1.1 KiB
Python
46 lines
1.1 KiB
Python
"""Snapshot data types.
|
|
|
|
An ``Entity`` is one unit of L1 content for a non-KB surface — e.g. one
|
|
notebook record, one co-writer document, one book, one chat session.
|
|
The snapshot is the *current* set of these on disk; the diff log records
|
|
how that set has changed across refreshes.
|
|
|
|
These types are intentionally pure dataclasses with no I/O. Adapters
|
|
build ``Entity`` lists; ``diff.diff_snapshots`` consumes two ``state``
|
|
dicts to produce ``ChangeEntry`` records.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from dataclasses import asdict, dataclass, field
|
|
from typing import Any, Literal
|
|
|
|
|
|
@dataclass
|
|
class Entity:
|
|
id: str
|
|
label: str
|
|
ts: str
|
|
content: str
|
|
metadata: dict[str, Any] = field(default_factory=dict)
|
|
fingerprint: str = ""
|
|
|
|
def to_dict(self) -> dict[str, Any]:
|
|
return asdict(self)
|
|
|
|
|
|
ChangeKind = Literal["added", "modified", "removed"]
|
|
|
|
|
|
@dataclass
|
|
class ChangeEntry:
|
|
ts: str
|
|
kind: ChangeKind
|
|
entity_id: str
|
|
label: str
|
|
prev_fingerprint: str | None = None
|
|
new_fingerprint: str | None = None
|
|
|
|
def to_dict(self) -> dict[str, Any]:
|
|
return asdict(self)
|