chore: finalize repo audit hygiene (#257)

This commit is contained in:
Elliot Chen
2026-06-06 13:59:12 +08:00
committed by GitHub
parent ab23e40b28
commit 00f1dfaec5
27 changed files with 459 additions and 199 deletions

View File

@ -1,8 +1,8 @@
"""
Neural network context features — showing how EverCore expands
Neural network context features — showing how EverOS expands
the persona engine's perception from 8D to 12D.
The 4 additional relationship dimensions from EverCore allow the
The 4 additional relationship dimensions from EverOS allow the
neural network to produce different behavioral signals depending
on the history between user and persona.
@ -13,21 +13,21 @@ Full source: https://github.com/kellyvv/OpenHer/blob/main/engine/genome/genome_e
# 5D Drive System (internal motivation)
# ══════════════════════════════════════════════
DRIVES = ['connection', 'novelty', 'expression', 'safety', 'play']
DRIVES = ["connection", "novelty", "expression", "safety", "play"]
# ══════════════════════════════════════════════
# 8D Behavioral Signals (neural network output)
# ══════════════════════════════════════════════
SIGNALS = [
'directness', # 0=indirect hints → 1=straight talk
'vulnerability', # 0=guarded → 1=emotionally open
'playfulness', # 0=serious → 1=playful/teasing
'initiative', # 0=reactive → 1=proactive leading
'depth', # 0=small talk → 1=deep conversation
'warmth', # 0=cold/distant → 1=warm/caring
'defiance', # 0=compliant → 1=rebellious/stubborn
'curiosity', # 0=indifferent → 1=intensely curious
"directness", # 0=indirect hints → 1=straight talk
"vulnerability", # 0=guarded → 1=emotionally open
"playfulness", # 0=serious → 1=playful/teasing
"initiative", # 0=reactive → 1=proactive leading
"depth", # 0=small talk → 1=deep conversation
"warmth", # 0=cold/distant → 1=warm/caring
"defiance", # 0=compliant → 1=rebellious/stubborn
"curiosity", # 0=indifferent → 1=intensely curious
]
# ══════════════════════════════════════════════
@ -36,31 +36,30 @@ SIGNALS = [
CONTEXT_FEATURES = [
# ── 8D from Critic LLM (per-turn perception) ──
'user_emotion', # -1=negative → 1=positive
'topic_intimacy', # 0=professional → 1=intimate
'time_of_day', # 0=morning → 1=late night
'conversation_depth', # 0=just started → 1=deep conversation
'user_engagement', # 0=dismissive → 1=invested
'conflict_level', # 0=harmonious → 1=conflict
'novelty_level', # 0=routine topic → 1=novel topic
'user_vulnerability', # 0=guarded → 1=open
# ── 4D from EverCore (cross-session relationship) ──
'relationship_depth', # 0=stranger → 1=old friend
'emotional_valence', # -1=negative history → 1=positive history
'trust_level', # 0=no trust → 1=deep trust
'pending_foresight', # 0=nothing pending → 1=unresolved concern
"user_emotion", # -1=negative → 1=positive
"topic_intimacy", # 0=professional → 1=intimate
"time_of_day", # 0=morning → 1=late night
"conversation_depth", # 0=just started → 1=deep conversation
"user_engagement", # 0=dismissive → 1=invested
"conflict_level", # 0=harmonious → 1=conflict
"novelty_level", # 0=routine topic → 1=novel topic
"user_vulnerability", # 0=guarded → 1=open
# ── 4D from EverOS (cross-session relationship) ──
"relationship_depth", # 0=stranger → 1=old friend
"emotional_valence", # -1=negative history → 1=positive history
"trust_level", # 0=no trust → 1=deep trust
"pending_foresight", # 0=nothing pending → 1=unresolved concern
]
# Neural network dimensions
N_DRIVES = len(DRIVES) # 5
N_CONTEXT = len(CONTEXT_FEATURES) # 12 (8 + 4 from EverCore)
N_SIGNALS = len(SIGNALS) # 8
RECURRENT_SIZE = 8 # Internal "mood" state
N_DRIVES = len(DRIVES) # 5
N_CONTEXT = len(CONTEXT_FEATURES) # 12 (8 + 4 from EverOS)
N_SIGNALS = len(SIGNALS) # 8
RECURRENT_SIZE = 8 # Internal "mood" state
INPUT_SIZE = N_DRIVES + N_CONTEXT + RECURRENT_SIZE # 5 + 12 + 8 = 25
HIDDEN_SIZE = 24
# Architecture: 25D input → 24D hidden (tanh) → 8D output (sigmoid)
# The 4 EverCore dimensions mean the same neural network produces
# The 4 EverOS dimensions mean the same neural network produces
# DIFFERENT behavioral signals for strangers vs. old friends,
# even with identical conversation context.

View File

@ -1,14 +1,14 @@
"""
EverMemosMixin — EverCore integration for ChatAgent.
EverMemosMixin — EverOS integration for ChatAgent.
This mixin handles all async memory operations in the ChatAgent lifecycle:
Step 0: Session context loading (first turn)
Step 2.5: Relationship EMA (blend EverCore prior + LLM delta)
Step 2.5: Relationship EMA (blend EverOS prior + LLM delta)
Step 8.5: Collect async search results
Step 11: Fire-and-forget turn storage
Step 12: Async prefetch for next turn
The mixin pattern keeps EverCore concerns cleanly separated from the
The mixin pattern keeps EverOS concerns cleanly separated from the
core persona engine (drives, metabolism, neural network, style memory).
Full source: https://github.com/kellyvv/OpenHer/blob/main/agent/evermemos_mixin.py
@ -20,19 +20,19 @@ import asyncio
class EverMemosMixin:
"""EverCore async memory integration methods."""
"""EverOS async memory integration methods."""
async def _evermemos_gather(self) -> dict:
"""
Step 0: Load EverCore session context (first turn only).
Step 0: Load EverOS session context (first turn only).
Subsequent turns reuse cached _session_ctx.
Returns relationship_4d dict for GenomeEngine context.
"""
empty_4d = {
'relationship_depth': 0.0,
'emotional_valence': 0.0,
'trust_level': 0.0,
'pending_foresight': 0.0,
"relationship_depth": 0.0,
"emotional_valence": 0.0,
"trust_level": 0.0,
"pending_foresight": 0.0,
}
if not (self.evermemos and self.evermemos.available):
@ -75,10 +75,10 @@ class EverMemosMixin:
"""
# Map Critic output keys → context feature keys
delta_map = {
'relationship_depth': rel_delta.get('relationship_delta', 0.0),
'emotional_valence': rel_delta.get('emotional_valence', 0.0),
'trust_level': rel_delta.get('trust_delta', 0.0),
'pending_foresight': 0.0, # No delta for foresight (data-driven only)
"relationship_depth": rel_delta.get("relationship_delta", 0.0),
"emotional_valence": rel_delta.get("emotional_valence", 0.0),
"trust_level": rel_delta.get("trust_delta", 0.0),
"pending_foresight": 0.0, # No delta for foresight (data-driven only)
}
# Initialize EMA on first turn
@ -88,7 +88,7 @@ class EverMemosMixin:
# Compute posterior = clip(prior + delta)
posterior = {}
for k in prior:
lo = -1.0 if k == 'emotional_valence' else 0.0
lo = -1.0 if k == "emotional_valence" else 0.0
posterior[k] = max(lo, min(1.0, prior[k] + delta_map.get(k, 0.0)))
# Depth-modulated alpha: shallow → trust prior, deep → trust LLM
@ -104,9 +104,10 @@ class EverMemosMixin:
return ema
def _evermemos_store_bg(self, user_message: str, reply: str) -> None:
"""Step 11: Fire-and-forget EverCore storage (asyncio.create_task)."""
"""Step 11: Fire-and-forget EverOS storage (asyncio.create_task)."""
if not (self.evermemos and self.evermemos.available):
return
async def _do_store():
try:
await self.evermemos.store_turn(
@ -120,6 +121,7 @@ class EverMemosMixin:
)
except Exception as e:
print(f" [evermemos] ❌ store failed: {type(e).__name__}: {e}")
try:
asyncio.create_task(_do_store())
except Exception as e:
@ -180,7 +182,7 @@ class EverMemosMixin:
self._relevant_facts = facts
self._relevant_episodes = episodes
self._relevant_profile = profile
except asyncio.TimeoutError:
except TimeoutError:
# Graceful degradation: use static session context
self._relevant_facts = ""
self._relevant_episodes = ""

View File

@ -3,9 +3,9 @@ Memory shared types for OpenHer.
These types bridge the two memory providers:
- SoulMem (behavioral memory, always-on SQLite layer)
- EverCore (declarative memory, cross-session persistence)
- EverOS (declarative memory, cross-session persistence)
The SessionContext is the key data structure loaded from EverCore
The SessionContext is the key data structure loaded from EverOS
at session start — it provides relationship priors, user profile,
episode summaries, and foresight data that expand the neural
network's perception from 8D to 12D.
@ -16,12 +16,12 @@ Full source: https://github.com/kellyvv/OpenHer/blob/main/memory/types.py
from __future__ import annotations
from dataclasses import dataclass
from typing import Optional
@dataclass
class Memory:
"""A single memory entry (SoulMem behavioral layer)."""
memory_id: int = 0
user_id: str = ""
persona_id: str = ""
@ -35,7 +35,7 @@ class Memory:
@dataclass
class SessionContext:
"""
EverCore session context (declarative memory).
EverOS session context (declarative memory).
Loaded once at session start, this contains everything the
persona needs to know about the user from past sessions:
@ -53,6 +53,7 @@ class SessionContext:
- Step 5: 4D vector enters neural network as context features
- Step 8.5: Used as fallback when async search times out
"""
user_id: str = ""
persona_id: str = ""
user_profile: str = ""
@ -63,4 +64,4 @@ class SessionContext:
trust_level: float = 0.0
pending_foresight: float = 0.0
has_history: bool = False
raw_data: Optional[dict] = None
raw_data: dict | None = None