File size: 2,256 Bytes
6c5f29f | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | """Core data structures for OracleMem.
The benchmark treats memory writing as selection over virtual
experience-representation items. These dataclasses intentionally stay small
and JSON-friendly so exact synthetic instances can be inspected and serialized
without framework dependencies.
"""
from __future__ import annotations
from dataclasses import asdict, dataclass, field
from typing import Any
@dataclass(frozen=True)
class EvidenceUnit:
unit_id: str
kind: str
text: str
proposition_id: str
timestamp: int
state: str = "current"
metadata: dict[str, Any] = field(default_factory=dict)
def to_json(self) -> dict[str, Any]:
return asdict(self)
@dataclass(frozen=True)
class Experience:
experience_id: str
session_id: str
timestamp: int
text: str
visible_unit_ids: tuple[str, ...]
metadata: dict[str, Any] = field(default_factory=dict)
def to_json(self) -> dict[str, Any]:
return asdict(self)
@dataclass(frozen=True)
class CandidateMemory:
candidate_id: str
experience_id: str
representation: str
text: str
cost: int
coverage: dict[str, float]
generator: str = "oracle"
metadata: dict[str, Any] = field(default_factory=dict)
def to_json(self) -> dict[str, Any]:
return asdict(self)
@dataclass(frozen=True)
class Query:
query_id: str
text: str
category: str
required_unit_ids: tuple[str, ...]
answer: str
metadata: dict[str, Any] = field(default_factory=dict)
def to_json(self) -> dict[str, Any]:
return asdict(self)
@dataclass(frozen=True)
class Instance:
instance_id: str
seed: int
units: tuple[EvidenceUnit, ...]
experiences: tuple[Experience, ...]
candidates: tuple[CandidateMemory, ...]
queries: tuple[Query, ...]
metadata: dict[str, Any] = field(default_factory=dict)
def to_json(self) -> dict[str, Any]:
return asdict(self)
@dataclass(frozen=True)
class SolverResult:
method: str
budget: int
selected_ids: tuple[str, ...]
utility: float
cost: int
ratio: float | None = None
ratio_basis: str = "none"
metadata: dict[str, Any] = field(default_factory=dict)
def to_json(self) -> dict[str, Any]:
return asdict(self)
|