MCPcopy
hub / github.com/aiming-lab/MetaClaw / save

Method save

metaclaw/memory/policy_store.py:52–60  ·  view source on GitHub ↗
(self, state: MemoryPolicyState, reason: str = "update")

Source from the content-addressed store, hash-verified

50 return _state_from_dict(data)
51
52 def save(self, state: MemoryPolicyState, reason: str = "update") -> None:
53 self.path.parent.mkdir(parents=True, exist_ok=True)
54 self.path.write_text(
55 json.dumps(asdict(state), indent=2, ensure_ascii=False, sort_keys=True),
56 encoding="utf-8",
57 )
58 revision = MemoryPolicyRevision(timestamp=_utc_now_iso(), reason=reason, state=state)
59 with self.history_path.open("a", encoding="utf-8") as handle:
60 handle.write(json.dumps(_revision_to_dict(revision), ensure_ascii=False) + "\n")
61
62 def history(self) -> list[MemoryPolicyRevision]:
63 if not self.history_path.exists():

Callers 7

_promote_candidateMethod · 0.95
rollbackMethod · 0.95
from_configMethod · 0.95
_refresh_policyMethod · 0.45

Calls 3

_utc_now_isoFunction · 0.70
_revision_to_dictFunction · 0.70