Skip to content

Commit 5e430ad

Browse files
authored
Merge pull request #14 from Sankhya-AI/alpha
V2.2.1
2 parents d45c492 + 2db19a9 commit 5e430ad

22 files changed

Lines changed: 82 additions & 179 deletions

CHANGELOG.md

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,23 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](https://keepachangelog.com/), and this project adheres to [Semantic Versioning](https://semver.org/).
66

7-
## [2.1.0] - 2026-03-30 — Production Cognition
7+
## [2.1.0] - 2026-03-30 — Cognition Primitives
88

9-
Dhee V2.1: All 10 cognition capabilities at production A-grade. Every self-improvement loop is closed and verified with 60 tests.
9+
Dhee V2.1: Adds first-class cognitive primitives (episodes, tasks, policies, beliefs, triggers) and a 60-test suite that exercises them. These are internal building blocks — the public API remains the 4-operation surface (remember/recall/context/checkpoint).
1010

11-
### Added — Production Cognition Systems
11+
### Added — Cognitive Primitives (internal, importable from `dhee.core`)
1212

13-
- **Episode System** (`dhee/core/episode.py`): First-class temporal unit of agent experience. Lifecycle: open→active→closed→archived→forgotten. Automatic boundary detection via time gap (>30min) and topic shift (Jaccard <20%). Utility-based selective forgetting with exponential recency decay (7-day half-life), access frequency, outcome value, and connection density scoring. Hard cap at 500 episodes/user.
14-
- **Task State** (`dhee/core/task_state.py`): Structured task tracking with goal/plan/progress/blockers/outcome. Full lifecycle: created→in_progress→blocked→completed/failed. Step-level tracking with `advance_step()`. Blocker management (soft/hard severity). Plan success rate analysis for policy learning.
15-
- **Policy Cases** (`dhee/core/policy.py`): Outcome-linked condition→action rules (not text reflections). Wilson score confidence at 95% interval. Laplace-smoothed win rate. Auto-promotion to VALIDATED (confidence≥0.5, win_rate≥0.6) and auto-deprecation (apply≥5, win_rate<0.4). Policy extraction from completed task patterns.
16-
- **Belief Tracking** (`dhee/core/belief.py`): Bayesian-inspired confidence updates (lr=0.15×evidence_strength). Contradiction detection via keyword Jaccard overlap >0.4 + negation patterns. Revision history with stability metric. Status lifecycle: proposed→held→challenged→revised|retracted. Auto-creation from factual assertions in stored memories.
17-
- **Trigger System** (`dhee/core/trigger.py`): 5 trigger types all returning `TriggerResult(fired, confidence, reason)`. Keyword (overlap scoring + required keywords), Time (after/before/recurring/window modes), Event (type + regex pattern), Composite (AND/OR/NOT with min/max confidence), Sequence (ordered events within time window, tightness-based confidence). Backwards-compatible bridge from legacy Intention format.
18-
- **Test Suite** (`tests/test_cognition_v3.py`): 60 tests across 10 classes covering all capabilities + full pipeline integration.
13+
- **Episode System** (`dhee/core/episode.py`): Temporal unit of agent experience. Lifecycle: open→active→closed→archived→forgotten. Boundary detection via time gap and topic shift. Utility-based selective forgetting. JSON-file-backed persistence (suitable for local-first use; production systems should own their own persistence).
14+
- **Task State** (`dhee/core/task_state.py`): Structured task tracking with goal/plan/progress/blockers/outcome. Step-level tracking. Blocker management. Plan success rate analysis.
15+
- **Policy Cases** (`dhee/core/policy.py`): Outcome-linked condition→action rules with Wilson score confidence. Auto-promotion and auto-deprecation based on win rate.
16+
- **Belief Tracking** (`dhee/core/belief.py`): Confidence updates with evidence tracking. Contradiction detection via keyword overlap + negation patterns. Revision history.
17+
- **Trigger System** (`dhee/core/trigger.py`): 5 trigger types (keyword, time, event, composite, sequence) returning `TriggerResult(fired, confidence, reason)`. Backwards-compatible bridge from legacy intentions.
18+
- **Test Suite** (`tests/test_cognition_v3.py`): 60 tests covering cognition primitives, contrastive pairs, heuristic distillation, meta-learning, and Buddhi pipeline wiring.
1919

20-
### Changed — Closed Self-Improvement Loops
20+
### Changed
2121

22-
- **Contrastive Pairs**: Upgraded from scaffolded to production. Retrieval-time integration in HyperContext, MaTTS scoring, DPO export for training.
23-
- **Heuristic Distillation**: Upgraded from scaffolded to production. Outcome validation loop closed — `reflect()` validates heuristics used in the session and updates confidence.
24-
- **Meta-Learning Gate**: Upgraded from scaffolded to production. Real evaluation via propose/evaluate/promote/rollback cycle verified.
25-
- **Progressive Training**: Upgraded from theoretical to production. Real data flow from Samskara → SFT → DPO → RL pipeline.
26-
- **Buddhi** (`dhee/core/buddhi.py`): HyperContext expanded with `episodes`, `task_states`, `policies`, `beliefs`. `reflect()` now creates contrastive pairs + distills heuristics + validates used heuristics + extracts policies + updates beliefs. `on_memory_stored()` auto-creates beliefs for factual assertions.
27-
- **DheePlugin** (`dhee/adapters/base.py`): `checkpoint()` handles episode closure, task state lifecycle, selective forgetting. System prompt renderer includes Proven Strategies, Established Beliefs, Active Tasks, Recent Experience. New convenience methods: `add_belief()`, `challenge_belief()`, `create_task()`, `advance_task()`.
22+
- **Buddhi**: HyperContext expanded with episodes, task_states, policies, beliefs. `reflect()` creates contrastive pairs, distills heuristics, extracts policies, updates beliefs.
23+
- **DheePlugin**: `checkpoint()` handles episode closure and task lifecycle. System prompt renderer includes strategies, beliefs, tasks, experience.
2824
- **Version**: 2.0.0 → 2.1.0
2925

3026
---
@@ -73,7 +69,7 @@ Dhee V2: Self-Evolving Cognition Plugin. This release transforms Dhee from a mem
7369

7470
- **Version**: 1.0.0 → 2.0.0
7571
- **MCP server** (`dhee/mcp_slim.py`): Refactored to wrap `DheePlugin` as backing singleton.
76-
- **pyproject.toml**: Updated description, keywords, classifier to Production/Stable.
72+
- **pyproject.toml**: Updated description, keywords, classifiers.
7773

7874
### Research References
7975

dhee/__init__.py

Lines changed: 16 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,45 @@
1-
"""dhee — Cognition as a Service. The memory layer that makes ANY agent intelligent.
1+
"""dhee — The cognition layer that turns any agent into a HyperAgent.
22
3-
- FadeMem: Dual-layer (SML/LML) with natural decay
4-
- EchoMem: Multi-modal encoding for stronger retention
5-
- CategoryMem: Dynamic hierarchical category organization
6-
- Universal Engram: Structured facts + context anchoring
7-
- Cognition Engine: Memory-grounded recursive reasoning
8-
- Prospective Scenes: Memory-driven future anticipation
3+
4 operations. Deferred enrichment. Minimal hot-path cost.
4+
Your agent remembers, learns from outcomes, and predicts what you need next.
95
10-
Quick Start (zero-config, no API key):
11-
from dhee import Memory
12-
m = Memory()
13-
m.add("User prefers Python")
14-
results = m.search("programming preferences")
6+
Quick Start:
7+
from dhee import Dhee
158
16-
Tiered Memory Classes:
9+
d = Dhee()
10+
d.remember("User prefers dark mode")
11+
d.recall("what theme does the user like?")
12+
d.context("fixing auth bug")
13+
d.checkpoint("Fixed it", what_worked="git blame first")
14+
15+
Memory Classes:
1716
CoreMemory — lightweight: add/search/delete + decay (no LLM)
1817
SmartMemory — + echo encoding, categories, knowledge graph (needs LLM)
19-
FullMemory — + scenes, profiles, tasks, cognition (everything)
18+
FullMemory — + scenes, profiles, orchestration, cognition (everything)
2019
Memory — alias for CoreMemory (lightest default)
2120
"""
2221

2322
from dhee.memory.core import CoreMemory
2423
from dhee.memory.smart import SmartMemory
2524
from dhee.memory.main import FullMemory
26-
from dhee.simple import Engram, Dhee
25+
from dhee.simple import Dhee
2726
from dhee.adapters.base import DheePlugin
2827
from dhee.core.category import CategoryProcessor, Category, CategoryType, CategoryMatch
2928
from dhee.core.echo import EchoProcessor, EchoDepth, EchoResult
3029
from dhee.configs.base import MemoryConfig, FadeMemConfig, EchoMemConfig, CategoryMemConfig, ScopeConfig
31-
from dhee.core.belief import BeliefNode, BeliefStore, BeliefStatus
32-
from dhee.core.policy import PolicyCase, PolicyStore, PolicyStatus
33-
from dhee.core.task_state import TaskState, TaskStateStore, TaskStatus
34-
from dhee.core.episode import Episode, EpisodeStore, EpisodeStatus
35-
from dhee.core.trigger import TriggerManager, TriggerResult, TriggerContext
3630

3731
# Default: CoreMemory (lightest, zero-config)
3832
Memory = CoreMemory
3933

4034
__version__ = "2.2.0b1"
4135
__all__ = [
42-
# Tiered memory classes
36+
# Memory classes
4337
"CoreMemory",
4438
"SmartMemory",
4539
"FullMemory",
4640
"Memory",
47-
# Simplified interface
41+
# Simplified interface (the 4-operation API)
4842
"Dhee",
49-
"Engram",
5043
# Universal plugin
5144
"DheePlugin",
5245
# CategoryMem
@@ -64,26 +57,4 @@
6457
"EchoMemConfig",
6558
"CategoryMemConfig",
6659
"ScopeConfig",
67-
# Cognitive subsystems
68-
"BeliefNode",
69-
"BeliefStore",
70-
"BeliefStatus",
71-
"PolicyCase",
72-
"PolicyStore",
73-
"PolicyStatus",
74-
"TaskState",
75-
"TaskStateStore",
76-
"TaskStatus",
77-
"Episode",
78-
"EpisodeStore",
79-
"EpisodeStatus",
80-
"TriggerManager",
81-
"TriggerResult",
82-
"TriggerContext",
8360
]
84-
85-
86-
def _load_teaching():
87-
"""Lazy-load teaching module to avoid import overhead when not needed."""
88-
from dhee.teaching import ConceptStore, StudentModel, TeachingMemory, TeachingConfig
89-
return ConceptStore, StudentModel, TeachingMemory, TeachingConfig

dhee/benchmarks/arc_agi.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ def run_arc_benchmark(args: argparse.Namespace) -> Dict[str, Any]:
206206
memory = None
207207
if args.mode == "memory":
208208
from dhee.configs.base import MemoryConfig
209-
from dhee.memory.main import Memory
209+
from dhee.memory.main import FullMemory
210210

211211
tmpdir = tempfile.mkdtemp(prefix="arc_bench_")
212212
config = MemoryConfig(
@@ -221,7 +221,7 @@ def run_arc_benchmark(args: argparse.Namespace) -> Dict[str, Any]:
221221
scene={"enable_scenes": False},
222222
profile={"enable_profiles": False},
223223
)
224-
memory = Memory(config)
224+
memory = FullMemory(config)
225225
print(f"Embedder: {args.embedder_provider}/{args.embedder_model}")
226226
print(f"Memory DB: {tmpdir}")
227227
print()

dhee/cli.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
"""engram CLI — memory layer for AI agents.
1+
"""dhee CLI — cognition layer for AI agents.
22
33
Usage:
4-
engram setup Interactive setup wizard
5-
engram add "text" Add a memory
6-
engram search "query" Search memories
7-
engram list List all memories
8-
engram stats Memory statistics
9-
engram decay Apply forgetting
10-
engram categories List categories
11-
engram export Export to JSON
12-
engram import <file> Import from JSON
13-
engram status Version, config, DB info
4+
dhee setup Interactive setup wizard
5+
dhee add "text" Add a memory
6+
dhee search "query" Search memories
7+
dhee list List all memories
8+
dhee stats Memory statistics
9+
dhee decay Apply forgetting
10+
dhee categories List categories
11+
dhee export Export to JSON
12+
dhee import <file> Import from JSON
13+
dhee status Version, config, DB info
1414
"""
1515

1616
import argparse
@@ -323,7 +323,7 @@ def cmd_benchmark(args: argparse.Namespace) -> None:
323323
from dhee import Memory
324324

325325
print("=" * 60)
326-
print(" engram benchmark")
326+
print(" dhee benchmark")
327327
print("=" * 60)
328328

329329
# Cold start

dhee/cli_config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def get_api_key(provider: str) -> Optional[str]:
8484

8585
def get_memory_instance(config: Optional[Dict[str, Any]] = None):
8686
"""Build a Memory instance from CLI config."""
87-
from dhee.memory.main import Memory
87+
from dhee.memory.main import FullMemory
8888
from dhee.configs.base import (
8989
MemoryConfig,
9090
VectorStoreConfig,
@@ -136,4 +136,4 @@ def get_memory_instance(config: Optional[Dict[str, Any]] = None):
136136
engram=FadeMemConfig(enable_forgetting=True),
137137
)
138138

139-
return Memory(memory_config)
139+
return FullMemory(memory_config)

dhee/configs/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ class EngramExtractionConfig(BaseModel):
460460
class SkillConfig(BaseModel):
461461
"""Configuration for the skill-learning agent memory system."""
462462
enable_skills: bool = True
463-
skill_collection_name: str = "engram_skills"
463+
skill_collection_name: str = "dhee_skills"
464464
min_confidence_for_auto_apply: float = 0.3
465465
enable_mining: bool = True
466466
min_trajectory_steps: int = 3

dhee/configs/presets.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ def minimal_config():
3838
vector_store=VectorStoreConfig(
3939
provider="memory",
4040
config={
41-
"collection_name": "engram_memories",
41+
"collection_name": "dhee_memories",
4242
"embedding_model_dims": 384,
4343
},
4444
),
4545
history_db_path=os.path.join(data_dir, "history.db"),
46-
collection_name="engram_memories",
46+
collection_name="dhee_memories",
4747
embedding_model_dims=384,
4848
engram=FadeMemConfig(enable_forgetting=True),
4949
echo=EchoMemConfig(enable_echo=False),
@@ -99,15 +99,15 @@ def smart_config():
9999
provider="zvec",
100100
config={
101101
"path": os.path.join(data_dir, "zvec"),
102-
"collection_name": "engram_memories",
102+
"collection_name": "dhee_memories",
103103
"embedding_model_dims": dims,
104104
},
105105
)
106106
else:
107107
vs = VectorStoreConfig(
108108
provider="memory",
109109
config={
110-
"collection_name": "engram_memories",
110+
"collection_name": "dhee_memories",
111111
"embedding_model_dims": dims,
112112
},
113113
)
@@ -120,7 +120,7 @@ def smart_config():
120120
llm=LLMConfig(provider=llm_provider, config={}),
121121
vector_store=vs,
122122
history_db_path=os.path.join(data_dir, "history.db"),
123-
collection_name="engram_memories",
123+
collection_name="dhee_memories",
124124
embedding_model_dims=dims,
125125
engram=FadeMemConfig(enable_forgetting=True),
126126
echo=EchoMemConfig(enable_echo=has_llm),

dhee/core/__init__.py

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -4,71 +4,19 @@
44
from dhee.core.fusion import fuse_memories
55
from dhee.core.retrieval import composite_score
66
from dhee.core.category import CategoryProcessor, Category, CategoryMatch, CategoryType
7-
from dhee.core.belief import BeliefNode, BeliefStore, BeliefStatus, Evidence, BeliefRevision
8-
from dhee.core.policy import PolicyCase, PolicyStore, PolicyStatus, PolicyCondition, PolicyAction
9-
from dhee.core.task_state import TaskState, TaskStateStore, TaskStatus, TaskStep, Blocker
10-
from dhee.core.episode import Episode, EpisodeStore, EpisodeStatus, EpisodeEvent
11-
from dhee.core.trigger import (
12-
TriggerManager,
13-
KeywordTrigger,
14-
TimeTrigger,
15-
EventTrigger,
16-
CompositeTrigger,
17-
SequenceTrigger,
18-
TriggerResult,
19-
TriggerContext,
20-
)
217

228
__all__ = [
23-
# Decay
249
"calculate_decayed_strength",
2510
"should_forget",
2611
"should_promote",
27-
# Conflict
2812
"resolve_conflict",
29-
# Echo
3013
"EchoProcessor",
3114
"EchoDepth",
3215
"EchoResult",
33-
# Fusion
3416
"fuse_memories",
35-
# Retrieval
3617
"composite_score",
37-
# Category
3818
"CategoryProcessor",
3919
"Category",
4020
"CategoryMatch",
4121
"CategoryType",
42-
# Belief
43-
"BeliefNode",
44-
"BeliefStore",
45-
"BeliefStatus",
46-
"Evidence",
47-
"BeliefRevision",
48-
# Policy
49-
"PolicyCase",
50-
"PolicyStore",
51-
"PolicyStatus",
52-
"PolicyCondition",
53-
"PolicyAction",
54-
# Task State
55-
"TaskState",
56-
"TaskStateStore",
57-
"TaskStatus",
58-
"TaskStep",
59-
"Blocker",
60-
# Episode
61-
"Episode",
62-
"EpisodeStore",
63-
"EpisodeStatus",
64-
"EpisodeEvent",
65-
# Trigger
66-
"TriggerManager",
67-
"KeywordTrigger",
68-
"TimeTrigger",
69-
"EventTrigger",
70-
"CompositeTrigger",
71-
"SequenceTrigger",
72-
"TriggerResult",
73-
"TriggerContext",
7422
]

dhee/core/consolidation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from dhee.core.active_memory import ActiveMemoryStore
1515

1616
if TYPE_CHECKING:
17-
from dhee.memory.main import Memory
17+
from dhee.memory.main import FullMemory
1818

1919
logger = logging.getLogger(__name__)
2020

@@ -25,7 +25,7 @@ class ConsolidationEngine:
2525
def __init__(
2626
self,
2727
active_store: ActiveMemoryStore,
28-
memory: "Memory",
28+
memory: "FullMemory",
2929
config: ActiveMemoryConfig,
3030
):
3131
self.active = active_store

0 commit comments

Comments
 (0)