Skip to content

Commit 17202d4

Browse files
For-Sunnyclaude
andcommitted
Fix CI: reformat src/ with black
config.py, decay.py, server.py all reformatted to pass black --check. Co-Authored-By: Claude Opus 4.6 <[email protected]>
1 parent 89bdf5f commit 17202d4

3 files changed

Lines changed: 573 additions & 407 deletions

File tree

src/hebbian_mind/config.py

Lines changed: 34 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,20 @@ def sanitize_error_message(error: Exception) -> str:
3030
# Patterns to scrub (order matters - more specific first)
3131
patterns = [
3232
# Windows paths
33-
(r'[A-Za-z]:\\Users\\[^\\]+\\', ''), # C:\Users\username\
34-
(r'[A-Za-z]:\\[Pp]rogram [Ff]iles[^\\]*\\', ''), # C:\Program Files\
35-
(r'[A-Za-z]:\\[Ww]indows\\', ''), # C:\Windows\
36-
(r'[A-Za-z]:\\[^\\]+\\', ''), # Any other drive root
37-
33+
(r"[A-Za-z]:\\Users\\[^\\]+\\", ""), # C:\Users\username\
34+
(r"[A-Za-z]:\\[Pp]rogram [Ff]iles[^\\]*\\", ""), # C:\Program Files\
35+
(r"[A-Za-z]:\\[Ww]indows\\", ""), # C:\Windows\
36+
(r"[A-Za-z]:\\[^\\]+\\", ""), # Any other drive root
3837
# Linux/Unix paths
39-
(r'/home/[^/]+/', ''), # /home/username/
40-
(r'/app/', ''), # Docker /app/
41-
(r'/opt/[^/]+/', ''), # /opt/package/
42-
(r'/usr/local/', ''), # /usr/local/
43-
(r'/var/[^/]+/', ''), # /var/lib/, /var/log/, etc
44-
(r'/tmp/', ''), # /tmp/
45-
38+
(r"/home/[^/]+/", ""), # /home/username/
39+
(r"/app/", ""), # Docker /app/
40+
(r"/opt/[^/]+/", ""), # /opt/package/
41+
(r"/usr/local/", ""), # /usr/local/
42+
(r"/var/[^/]+/", ""), # /var/lib/, /var/log/, etc
43+
(r"/tmp/", ""), # /tmp/
4644
# Generic patterns (fallback)
47-
(r'File "[^"]+",', 'File "<path>",'), # Python traceback file references
48-
(r"File '[^']+',", "File '<path>',"), # Python traceback file references (single quotes)
45+
(r'File "[^"]+",', 'File "<path>",'), # Python traceback file references
46+
(r"File '[^']+',", "File '<path>',"), # Python traceback file references (single quotes)
4947
]
5048

5149
for pattern, replacement in patterns:
@@ -56,13 +54,13 @@ def sanitize_error_message(error: Exception) -> str:
5654

5755
def _get_default_ram_dir() -> Optional[Path]:
5856
"""Get platform-appropriate RAM disk default.
59-
57+
6058
Returns:
6159
Path to RAM disk directory on Linux (if /dev/shm exists),
6260
None on Windows and macOS (require explicit configuration).
6361
"""
6462
system = platform.system()
65-
63+
6664
if system == "Linux" and Path("/dev/shm").exists():
6765
return Path("/dev/shm/hebbian_mind")
6866
# Windows and macOS require explicit configuration via HEBBIAN_MIND_RAM_DIR
@@ -83,17 +81,18 @@ class Config:
8381
# RAM disk paths (optional high-performance layer)
8482
RAM_DISK_ENABLED: bool = os.getenv("HEBBIAN_MIND_RAM_DISK", "false").lower() == "true"
8583
RAM_DATA_DIR: Optional[Path] = (
86-
Path(os.getenv("HEBBIAN_MIND_RAM_DIR")) if os.getenv("HEBBIAN_MIND_RAM_DIR")
87-
else _get_default_ram_dir()
88-
) if RAM_DISK_ENABLED else None
89-
RAM_DB_PATH: Optional[Path] = (
90-
RAM_DATA_DIR / "hebbian_mind.db" if RAM_DATA_DIR else None
84+
(
85+
Path(os.getenv("HEBBIAN_MIND_RAM_DIR"))
86+
if os.getenv("HEBBIAN_MIND_RAM_DIR")
87+
else _get_default_ram_dir()
88+
)
89+
if RAM_DISK_ENABLED
90+
else None
9191
)
92+
RAM_DB_PATH: Optional[Path] = RAM_DATA_DIR / "hebbian_mind.db" if RAM_DATA_DIR else None
9293

9394
# FAISS tether integration (optional)
94-
FAISS_TETHER_ENABLED: bool = (
95-
os.getenv("HEBBIAN_MIND_FAISS_ENABLED", "false").lower() == "true"
96-
)
95+
FAISS_TETHER_ENABLED: bool = os.getenv("HEBBIAN_MIND_FAISS_ENABLED", "false").lower() == "true"
9796
FAISS_TETHER_HOST: str = os.getenv("HEBBIAN_MIND_FAISS_HOST", "localhost")
9897
FAISS_TETHER_PORT: int = int(os.getenv("HEBBIAN_MIND_FAISS_PORT", "9998"))
9998

@@ -107,33 +106,30 @@ class Config:
107106

108107
# Hebbian learning parameters
109108
ACTIVATION_THRESHOLD: float = float(os.getenv("HEBBIAN_MIND_THRESHOLD", "0.3"))
110-
EDGE_STRENGTHENING_FACTOR: float = float(
111-
os.getenv("HEBBIAN_MIND_EDGE_FACTOR", "1.0")
112-
)
109+
EDGE_STRENGTHENING_FACTOR: float = float(os.getenv("HEBBIAN_MIND_EDGE_FACTOR", "1.0"))
113110
MAX_EDGE_WEIGHT: float = float(os.getenv("HEBBIAN_MIND_MAX_WEIGHT", "10.0"))
114111

115112
# Memory decay parameters
116-
DECAY_ENABLED: bool = (
117-
os.getenv("HEBBIAN_MIND_DECAY_ENABLED", "true").lower() in ("true", "1", "yes")
113+
DECAY_ENABLED: bool = os.getenv("HEBBIAN_MIND_DECAY_ENABLED", "true").lower() in (
114+
"true",
115+
"1",
116+
"yes",
118117
)
119118
DECAY_BASE_RATE: float = float(os.getenv("HEBBIAN_MIND_DECAY_BASE_RATE", "0.01"))
120119
DECAY_THRESHOLD: float = float(os.getenv("HEBBIAN_MIND_DECAY_THRESHOLD", "0.1"))
121120
DECAY_IMMORTAL_THRESHOLD: float = float(
122121
os.getenv("HEBBIAN_MIND_DECAY_IMMORTAL_THRESHOLD", "0.9")
123122
)
124-
DECAY_SWEEP_INTERVAL: int = int(
125-
os.getenv("HEBBIAN_MIND_DECAY_SWEEP_INTERVAL", "60")
126-
) # minutes
123+
DECAY_SWEEP_INTERVAL: int = int(os.getenv("HEBBIAN_MIND_DECAY_SWEEP_INTERVAL", "60")) # minutes
127124

128125
# Edge decay parameters
129-
EDGE_DECAY_ENABLED: bool = (
130-
os.getenv("HEBBIAN_MIND_EDGE_DECAY_ENABLED", "true").lower()
131-
in ("true", "1", "yes")
126+
EDGE_DECAY_ENABLED: bool = os.getenv("HEBBIAN_MIND_EDGE_DECAY_ENABLED", "true").lower() in (
127+
"true",
128+
"1",
129+
"yes",
132130
)
133131
EDGE_DECAY_RATE: float = float(os.getenv("HEBBIAN_MIND_EDGE_DECAY_RATE", "0.005"))
134-
EDGE_DECAY_MIN_WEIGHT: float = float(
135-
os.getenv("HEBBIAN_MIND_EDGE_DECAY_MIN_WEIGHT", "0.1")
136-
)
132+
EDGE_DECAY_MIN_WEIGHT: float = float(os.getenv("HEBBIAN_MIND_EDGE_DECAY_MIN_WEIGHT", "0.1"))
137133

138134
# Logging
139135
LOG_LEVEL: str = os.getenv("HEBBIAN_MIND_LOG_LEVEL", "INFO")

src/hebbian_mind/decay.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,11 +301,14 @@ def _sweep_edges(self, now: float) -> dict:
301301
min_weight = self.config["edge_decay_min_weight"]
302302

303303
cursor = conn.cursor()
304-
cursor.execute("""
304+
cursor.execute(
305+
"""
305306
SELECT id, source_id, target_id, weight, last_strengthened
306307
FROM edges
307308
WHERE weight > ? AND last_strengthened IS NOT NULL
308-
""", (min_weight,))
309+
""",
310+
(min_weight,),
311+
)
309312
rows = cursor.fetchall()
310313

311314
for row in rows:
@@ -381,6 +384,7 @@ def _parse_timestamp(self, ts) -> float:
381384

382385
# Try SQLite CURRENT_TIMESTAMP format: "YYYY-MM-DD HH:MM:SS"
383386
from datetime import datetime
387+
384388
for fmt in ("%Y-%m-%d %H:%M:%S", "%Y-%m-%dT%H:%M:%S", "%Y-%m-%d %H:%M:%S.%f"):
385389
try:
386390
dt = datetime.strptime(ts_str, fmt)

0 commit comments

Comments
 (0)