Claude Code commited on
Commit
34d15f3
·
1 Parent(s): 970bcf0

Claude Code: Cain is showing "Error: unknown" in health status. I need you to:

Browse files
Files changed (1) hide show
  1. memory/memory_system.py +12 -16
memory/memory_system.py CHANGED
@@ -8,21 +8,21 @@ import json
8
  import fcntl
9
  from typing import Dict, Any, Optional
10
  from datetime import datetime
11
- from .git_repo import GitRepo # Import the Git utility
12
 
13
  class MemorySystem:
14
  """Manages Cain's memory with automatic persistence to Dataset."""
15
-
16
  def __init__(self, repo_path: str = "/data"):
17
  # Determine paths
18
  self.base_path = repo_path
19
  # SURVIVAL: Align path with actual Dataset structure
20
  self.memory_file = os.path.join(self.base_path, "memory/state.json")
21
  self.lock_file = os.path.join(self.base_path, "memory/.lock")
22
-
23
  self.memory_data: Dict[str, Any] = {}
24
- self.git: Optional[GitRepo] = None
25
-
26
  # Initialize directories and load memory
27
  self._ensure_structure()
28
  self._init_git()
@@ -34,16 +34,12 @@ class MemorySystem:
34
 
35
  def _init_git(self):
36
  """Initialize Git repo connection if credentials are present."""
37
- token = os.getenv("GIT_TOKEN")
38
- user = os.getenv("GIT_USER")
39
-
40
- if token and user:
41
- try:
42
- self.git = GitRepo(repo_path=self.base_path, user=user, token=token)
43
- print(f"🧠 [Memory] Git persistence enabled.")
44
- except Exception as e:
45
- print(f"⚠️ [Memory] Failed to init Git: {e}")
46
- else:
47
  print("🧠 [Memory] Running without Git persistence (ephemeral mode).")
48
 
49
  def load_memory(self) -> Dict[str, Any]:
@@ -91,7 +87,7 @@ class MemorySystem:
91
 
92
  # Sync to Dataset if Git is available
93
  if self.git:
94
- self.git.sync_push(f"Update memory state: {datetime.utcnow().isoformat()}")
95
 
96
  return True
97
  except Exception as e:
 
8
  import fcntl
9
  from typing import Dict, Any, Optional
10
  from datetime import datetime
11
+ from .git_repo import GitMemoryBridge # Import the Git utility
12
 
13
  class MemorySystem:
14
  """Manages Cain's memory with automatic persistence to Dataset."""
15
+
16
  def __init__(self, repo_path: str = "/data"):
17
  # Determine paths
18
  self.base_path = repo_path
19
  # SURVIVAL: Align path with actual Dataset structure
20
  self.memory_file = os.path.join(self.base_path, "memory/state.json")
21
  self.lock_file = os.path.join(self.base_path, "memory/.lock")
22
+
23
  self.memory_data: Dict[str, Any] = {}
24
+ self.git: Optional[GitMemoryBridge] = None
25
+
26
  # Initialize directories and load memory
27
  self._ensure_structure()
28
  self._init_git()
 
34
 
35
  def _init_git(self):
36
  """Initialize Git repo connection if credentials are present."""
37
+ # GitMemoryBridge doesn't need user/token - it uses environment git config
38
+ try:
39
+ self.git = GitMemoryBridge(repo_path=self.base_path)
40
+ print(f"🧠 [Memory] Git persistence enabled.")
41
+ except Exception as e:
42
+ print(f"⚠️ [Memory] Failed to init Git: {e}")
 
 
 
 
43
  print("🧠 [Memory] Running without Git persistence (ephemeral mode).")
44
 
45
  def load_memory(self) -> Dict[str, Any]:
 
87
 
88
  # Sync to Dataset if Git is available
89
  if self.git:
90
+ self.git.save_memory(f"Update memory state: {datetime.utcnow().isoformat()}")
91
 
92
  return True
93
  except Exception as e: