feat: add tiered durable state and memory bounds

This commit is contained in:
CoolBoy
2026-08-22 14:15:25 +08:00
parent 6eb7ded984
commit 5b1ec4d3eb
11 changed files with 722 additions and 40 deletions

View File

@@ -18,7 +18,13 @@ class SafeConfigOptimizer:
self._qualified = self._learn()
def _learn(self) -> dict[tuple[str, str, str], list[dict[str, Any]]]:
outcomes = read_jsonl(self.outcomes_path)
recent_path = Path(".modelhub_state/recent_outcomes.jsonl")
outcomes_by_key: dict[str, dict[str, Any]] = {}
for item in [*read_jsonl(recent_path), *read_jsonl(self.outcomes_path)]:
task_id = str(item.get("taskId") or "")
if task_id:
outcomes_by_key[task_id] = item
outcomes = list(outcomes_by_key.values())
by_task = {
str(item.get("taskId")): item
for item in outcomes
@@ -117,4 +123,3 @@ class SafeConfigOptimizer:
"evidenceLowerBound": choice["lowerBound"],
"fingerprint": choice["fingerprint"],
}