ravana-grace 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. ravana_grace-0.1.0/PKG-INFO +474 -0
  2. ravana_grace-0.1.0/README.md +463 -0
  3. ravana_grace-0.1.0/agent/mode_orchestrator.py +470 -0
  4. ravana_grace-0.1.0/agent/ravana_agent_loop.py +435 -0
  5. ravana_grace-0.1.0/agent/test_runner.py +61 -0
  6. ravana_grace-0.1.0/agent/version_manager.py +403 -0
  7. ravana_grace-0.1.0/core/__init__.py +120 -0
  8. ravana_grace-0.1.0/core/active_epistemology.py +392 -0
  9. ravana_grace-0.1.0/core/adaptation.py +356 -0
  10. ravana_grace-0.1.0/core/belief_reasoner.py +388 -0
  11. ravana_grace-0.1.0/core/conversational_repair.py +562 -0
  12. ravana_grace-0.1.0/core/dialogue_context.py +430 -0
  13. ravana_grace-0.1.0/core/dual_process.py +208 -0
  14. ravana_grace-0.1.0/core/embedder.py +188 -0
  15. ravana_grace-0.1.0/core/emotion.py +233 -0
  16. ravana_grace-0.1.0/core/empathy.py +216 -0
  17. ravana_grace-0.1.0/core/environment.py +265 -0
  18. ravana_grace-0.1.0/core/global_workspace.py +240 -0
  19. ravana_grace-0.1.0/core/governor.py +743 -0
  20. ravana_grace-0.1.0/core/human_memory.py +2321 -0
  21. ravana_grace-0.1.0/core/hypothesis_generation.py +406 -0
  22. ravana_grace-0.1.0/core/identity.py +180 -0
  23. ravana_grace-0.1.0/core/intent.py +420 -0
  24. ravana_grace-0.1.0/core/meaning.py +223 -0
  25. ravana_grace-0.1.0/core/memory.py +116 -0
  26. ravana_grace-0.1.0/core/memory_reconstructor.py +229 -0
  27. ravana_grace-0.1.0/core/meta2_cognition.py +666 -0
  28. ravana_grace-0.1.0/core/meta2_integration.py +263 -0
  29. ravana_grace-0.1.0/core/meta_cognition.py +434 -0
  30. ravana_grace-0.1.0/core/occam_layer.py +355 -0
  31. ravana_grace-0.1.0/core/planning.py +198 -0
  32. ravana_grace-0.1.0/core/predictive_world.py +390 -0
  33. ravana_grace-0.1.0/core/reality_friction.py +583 -0
  34. ravana_grace-0.1.0/core/resolution.py +185 -0
  35. ravana_grace-0.1.0/core/sleep.py +1726 -0
  36. ravana_grace-0.1.0/core/social_epistemology.py +760 -0
  37. ravana_grace-0.1.0/core/state.py +411 -0
  38. ravana_grace-0.1.0/core/strategy.py +421 -0
  39. ravana_grace-0.1.0/core/strategy_learning.py +369 -0
  40. ravana_grace-0.1.0/core/surgical_probes.py +353 -0
  41. ravana_grace-0.1.0/core/vector_index.py +271 -0
  42. ravana_grace-0.1.0/dialogue/__init__.py +16 -0
  43. ravana_grace-0.1.0/dialogue/dialogue_engine.py +799 -0
  44. ravana_grace-0.1.0/interface_agent/scripts/interview_mode.py +431 -0
  45. ravana_grace-0.1.0/interface_agent/scripts/llm_interpreter.py +418 -0
  46. ravana_grace-0.1.0/interface_agent/scripts/memory_learner.py +723 -0
  47. ravana_grace-0.1.0/interface_agent/scripts/ravana_agent.py +331 -0
  48. ravana_grace-0.1.0/interface_agent/scripts/ravana_wrapper.py +260 -0
  49. ravana_grace-0.1.0/interface_agent/scripts/reality_grounding.py +862 -0
  50. ravana_grace-0.1.0/interface_agent/scripts/telegram_reporter.py +412 -0
  51. ravana_grace-0.1.0/interface_agent/scripts/version_manager.py +301 -0
  52. ravana_grace-0.1.0/probes/constraint_stress.py +94 -0
  53. ravana_grace-0.1.0/probes/exploration_pressure.py +98 -0
  54. ravana_grace-0.1.0/probes/learning_signal.py +122 -0
  55. ravana_grace-0.1.0/pyproject.toml +20 -0
  56. ravana_grace-0.1.0/ravana_grace.egg-info/PKG-INFO +474 -0
  57. ravana_grace-0.1.0/ravana_grace.egg-info/SOURCES.txt +110 -0
  58. ravana_grace-0.1.0/ravana_grace.egg-info/dependency_links.txt +1 -0
  59. ravana_grace-0.1.0/ravana_grace.egg-info/requires.txt +3 -0
  60. ravana_grace-0.1.0/ravana_grace.egg-info/top_level.txt +8 -0
  61. ravana_grace-0.1.0/research/__init__.py +0 -0
  62. ravana_grace-0.1.0/research/core_k0/__init__.py +0 -0
  63. ravana_grace-0.1.0/research/core_k0/agent_loop.py +218 -0
  64. ravana_grace-0.1.0/research/core_k0/agent_loop_k1.py +206 -0
  65. ravana_grace-0.1.0/research/core_k0/agent_loop_k1_2.py +133 -0
  66. ravana_grace-0.1.0/research/core_k0/agent_loop_k1_3.py +291 -0
  67. ravana_grace-0.1.0/research/core_k0/agent_loop_k2.py +307 -0
  68. ravana_grace-0.1.0/research/core_k0/agent_loop_k3.py +438 -0
  69. ravana_grace-0.1.0/research/core_k0/agent_loop_k3_belief.py +330 -0
  70. ravana_grace-0.1.0/research/core_k0/apply_three_fixes.py +86 -0
  71. ravana_grace-0.1.0/research/core_k0/checkpoint.py +49 -0
  72. ravana_grace-0.1.0/research/core_k0/conftest.py +18 -0
  73. ravana_grace-0.1.0/research/core_k0/debug_agent_state.py +99 -0
  74. ravana_grace-0.1.0/research/core_k0/env_scheduler.py +70 -0
  75. ravana_grace-0.1.0/research/core_k0/k3_research_framework.py +4 -0
  76. ravana_grace-0.1.0/research/core_k0/long_horizon_stability_test.py +502 -0
  77. ravana_grace-0.1.0/research/core_k0/long_horizon_stability_test_v2.py +420 -0
  78. ravana_grace-0.1.0/research/core_k0/metrics.py +83 -0
  79. ravana_grace-0.1.0/research/core_k0/run_k0_test.py +109 -0
  80. ravana_grace-0.1.0/research/core_k0/run_k1_1_test.py +87 -0
  81. ravana_grace-0.1.0/research/core_k0/run_k1_2_multi.py +312 -0
  82. ravana_grace-0.1.0/research/core_k0/run_k1_2_test.py +173 -0
  83. ravana_grace-0.1.0/research/core_k0/run_k1_test.py +89 -0
  84. ravana_grace-0.1.0/research/core_k0/run_k3_research_suite.py +117 -0
  85. ravana_grace-0.1.0/research/core_k0/test_k1_3.py +223 -0
  86. ravana_grace-0.1.0/research/core_k0/test_k2_breakers.py +128 -0
  87. ravana_grace-0.1.0/research/core_k0/test_k2_learning.py +160 -0
  88. ravana_grace-0.1.0/research/core_k0/test_k2_robustness.py +362 -0
  89. ravana_grace-0.1.0/research/core_k0/test_k3_exp1_isolation.py +149 -0
  90. ravana_grace-0.1.0/research/core_k0/test_k3_exp2_coupling.py +163 -0
  91. ravana_grace-0.1.0/research/core_k0/test_k3_exp3_metastability.py +269 -0
  92. ravana_grace-0.1.0/research/core_k0/test_k3_regime_shift.py +210 -0
  93. ravana_grace-0.1.0/research/core_k0/test_k3_trajectory.py +216 -0
  94. ravana_grace-0.1.0/research/core_k0/test_latent_regime.py +173 -0
  95. ravana_grace-0.1.0/research/core_k0/verify_formula.py +165 -0
  96. ravana_grace-0.1.0/research/experiments_k0/__init__.py +0 -0
  97. ravana_grace-0.1.0/research/experiments_k0/classroom_env.py +143 -0
  98. ravana_grace-0.1.0/research/experiments_k0/deceptive_env.py +152 -0
  99. ravana_grace-0.1.0/research/experiments_k0/delayed_env.py +117 -0
  100. ravana_grace-0.1.0/research/experiments_k0/latent_regime_env.py +235 -0
  101. ravana_grace-0.1.0/research/experiments_k0/resource_env.py +174 -0
  102. ravana_grace-0.1.0/scripts/__init__.py +0 -0
  103. ravana_grace-0.1.0/scripts/classroom_data_pilot.py +169 -0
  104. ravana_grace-0.1.0/scripts/consolidate_research.py +78 -0
  105. ravana_grace-0.1.0/scripts/generate_student_data.py +94 -0
  106. ravana_grace-0.1.0/setup.cfg +4 -0
  107. ravana_grace-0.1.0/tests/test_grace_layer.py +283 -0
  108. ravana_grace-0.1.0/tests/test_memory_integration.py +82 -0
  109. ravana_grace-0.1.0/tests/test_mode_orchestrator.py +174 -0
  110. ravana_grace-0.1.0/tests/test_phase_a.py +157 -0
  111. ravana_grace-0.1.0/tests/test_reality_grounding.py +85 -0
  112. ravana_grace-0.1.0/training/pipeline.py +215 -0
@@ -0,0 +1,474 @@
1
+ Metadata-Version: 2.4
2
+ Name: ravana-grace
3
+ Version: 0.1.0
4
+ Summary: RAVANA GRACE -- 27-phase cognitive architecture (Governor, Identity, Sleep, Emotion, World Model, Meaning, Human Memory, Dialogue)
5
+ License: MIT
6
+ Requires-Python: >=3.9
7
+ Description-Content-Type: text/markdown
8
+ Requires-Dist: numpy>=1.20
9
+ Requires-Dist: feedparser
10
+ Requires-Dist: requests
11
+
12
+ # RAVANA — Recursive Learning Model
13
+
14
+ > **A pressure-driven cognitive ML framework where learning emerges from self-organization, not gradient descent.**
15
+
16
+ [![Python](https://img.shields.io/badge/Python-3.10%2B-blue)](https://python.org)
17
+ [![NumPy](https://img.shields.io/badge/NumPy-1.20%2B-orange)](https://numpy.org)
18
+ [![License](https://img.shields.io/badge/License-MIT-green)](LICENSE)
19
+ [![Status](https://img.shields.io/badge/Status-Research%20Prototype-yellow)]()
20
+
21
+ ---
22
+
23
+ ## What Is RAVANA?
24
+
25
+ RAVANA is a **cognitive architecture research project** proposing *pressure-driven self-organization* as an alternative to gradient descent for machine learning. Instead of minimizing loss functions via backpropagation, RAVANA learns through **cognitive dissonance minimization**: prediction errors create internal pressure (free energy), and the system self-organizes to reduce that pressure.
26
+
27
+ ```
28
+ Traditional ML: Loss(θ) = f(prediction, target) → ∇Loss → θ ← θ - η∇Loss
29
+ RAVANA: Prediction Error → Free Energy (Pressure) → Hebbian Plasticity + Sleep → Equilibrium
30
+ ```
31
+
32
+ ### Core Philosophy
33
+
34
+ | Traditional ML | RAVANA |
35
+ |----------------|--------|
36
+ | **Loss functions** → gradients | **Free energy** (pressure) → self-organization |
37
+ | **Backpropagation** | **Hebbian/anti-Hebbian plasticity** + structural plasticity |
38
+ | **Weight decay, regularization** | **Identity** + homeostatic sleep consolidation |
39
+ | **Batch/layer normalization** | **SWS + REM sleep cycles** with dream sabotage |
40
+ | **Dense weight matrices** | **ConceptGraph** (typed edges, inhibition, hierarchy) |
41
+ | **Global attention** | **Spreading activation** (local, bounded, typed) |
42
+ | **Static weights / RAG** | **Episodic → Semantic → Graph bridge** |
43
+ | **External reward functions** | **Intrinsic motivation** (Meaning = f(-Dissonance, Identity, Prediction)) |
44
+ | **No emotion/identity** | **VAD emotion engine** + momentum-based identity |
45
+
46
+ ---
47
+
48
+ ## Two Architectures, One Codebase
49
+
50
+ RAVANA now contains **two complementary cognitive architectures**:
51
+
52
+ ### 1. **RAVANA v2** — GRACE Cognitive Core (`ravana-v2/`)
53
+ The original GRACE (General Recursive Adaptive Cognitive Engine) with 27 phases (A–P) implementing:
54
+ - **Governor regulation** (Phases A–C) — Hard constraints, predictive dampening, center-seeking homeostasis
55
+ - **Strategy & Intent** (Phases D–J) — 4 strategy modes, planning, hypotheses, Occam layer
56
+ - **World Model & Epistemology** (Phases F–G.5) — Belief reasoning, active probes, VoI-driven action
57
+ - **Emotion & Sleep** (Phases K–L.5) — VAD emotion, empathy, 4-stage sleep, dual-process
58
+ - **Meaning & Consciousness** (Phases M–N) — Intrinsic motivation, global workspace
59
+ - **Human Memory & Dialogue** (Phases O–P) — Episodic/semantic persistence, conversational repair
60
+
61
+ ### 2. **RAVANA Modular** — Decoder-First Chat (`ravana/`) **NEW**
62
+ A streamlined, package-oriented architecture focused on **continuous web learning** and **decoder-first generation**:
63
+ - **CognitiveCore** (`ravana/core/`) — VAD emotion, Identity, Meaning, Dual-process, Global Workspace, Meta-cognition, Sleep, **Multi-user BeliefStore**
64
+ - **GraphEngine** (`ravana/graph/`) — Concept graph, spreading activation, hippocampal indexing, curiosity scoring
65
+ - **DecoderEngine** (`ravana/decoder/`) — Neural decoder, vocab building, seed corpus + web article training
66
+ - **WebLearner** (`ravana/web/`) — Multi-API search (circuit breaker), background learning, curiosity-driven exploration (Phase 18)
67
+ - **BootstrapManager** (`ravana/bootstrap/`) — Consolidated concept seeding (3 methods unified)
68
+ - **RLMv2 Decomposed** (`ravana/nn/rlm/`) — RelationPredictor, PropagationEngine, Plasticity
69
+ - **ChatInterface** (`ravana/chat/`) — CLI, response pipeline, reasoning loop
70
+
71
+ ---
72
+
73
+ ## Key Innovations (Shared)
74
+
75
+ ### 🧠 Pressure-Driven Learning
76
+ No loss functions, no gradients, no backpropagation. Learning driven by **5-channel free energy accumulator** tracking semantic, linguistic, episodic, contradiction, and abstraction prediction errors.
77
+
78
+ ### 🕸️ ConceptGraph with Typed Edges
79
+ Heterogeneous graph of concept nodes with **active/core/genesis vectors** connected by typed relation edges (semantic, causal, temporal, analogical, contextual, inferred, inhibitory). Each edge carries weight, confidence, relation vector, predicate token, EWC importance, and Bayesian posterior.
80
+
81
+ ### 💤 Sleep Consolidation (SWS + REM)
82
+ Two-phase sleep modeled on mammalian sleep:
83
+ - **SWS**: Structural stabilization, adaptive homeostatic downscale, hierarchical abstraction compression, inhibitory edge formation, hippocampal replay
84
+ - **REM**: Creative recombination via 20% counterfactual reversals, 10% emotional valence flipping, 1.5× failure oversampling
85
+
86
+ ### 🔄 Sleep-Time Interleaved Replay
87
+ Domain-tagged experiences buffered during training, replayed during SWS+REM. **Eliminates catastrophic forgetting entirely** (12% → 0% retention drop) in lifelong streaming benchmarks.
88
+
89
+ ### 🏛️ GRACE Governor (v2 only)
90
+ Closed-loop regulation with four layers: hard constraints (non-negotiable), predictive dampening (look-ahead), boundary pressure (air resistance), center-seeking homeostasis. **Fully observable** with clamp diagnostics.
91
+
92
+ ### 🎭 VAD Emotion Engine
93
+ 3D affective state (Valence, Arousal, Dominance) via differential equations. Modulates inference: high arousal → exploration, positive valence → trust predictions, high dominance → stronger concepts.
94
+
95
+ ### 🧩 RLMv2 — Triple Decomposition Architecture
96
+ Brain-inspired: decomposes input into **(subject, relation_type, object)** triples. Enables vector arithmetic analogy: `subject_embed + offset(verb) ≈ target_embed`. **Spreading activation is the sole inference mechanism**.
97
+
98
+ ### 📖 GloVe Semantic Embeddings
99
+ Token embeddings initialized from pre-trained GloVe (100D) projected via QR-based orthogonal projection. Replaces character n-gram embeddings for genuine semantic relationships.
100
+
101
+ ### 🎯 Verb-Stem Offset Predictor
102
+ New inference path: `offset(verb) = avg(target - subject)` over training pairs. Each verb gets its own offset. **RP-only cross-domain top-10: 3.3% → 6.7%**.
103
+
104
+ ### 🌐 Continuous Web Learning (Modular only)
105
+ `WebLearner` fetches → extracts → trains decoder online. Knowledge grows **without retraining from scratch**. Curiosity-driven (free energy + contradiction + novelty + serendipity).
106
+
107
+ ### 👥 Multi-User Belief Merging (Modular only)
108
+ `BeliefStore` tracks *who believes what*, detects contradictions, merges across users — `cross_reference_users()`, `find_agreement()`, `find_disagreement()`.
109
+
110
+ ---
111
+
112
+ ## Quick Start
113
+
114
+ ### Installation
115
+
116
+ ```bash
117
+ # Primary (Codeberg)
118
+ git clone https://codeberg.org/oxiverse/ravana.git
119
+ # Mirror (GitHub)
120
+ git clone https://github.com/oxiverse-ecosystem/ravana.git
121
+ cd ravana
122
+ pip install -e ravana/ # NumPy only (modular package)
123
+ pip install tiktoken # Optional: BPE tokenizer
124
+ ```
125
+
126
+ ### Modular Package — Decoder-First Chat (NEW)
127
+
128
+ ```bash
129
+ # Interactive chat with web learning
130
+ python -m ravana.chat
131
+
132
+ # Batch mode for testing
133
+ python -m ravana.chat --chat "hello|what is trust|explain oxiverse|bye" --strategy
134
+
135
+ # With ablation flags
136
+ python -m ravana.chat --chat "what causes rain" --no-vad --no-rlm --no-beliefs --no-curiosity
137
+ ```
138
+
139
+ **Key flags:**
140
+ - `--no-vad` — Disable VAD emotion modulation
141
+ - `--no-rlm` — Disable RLMv2 triple verification
142
+ - `--no-beliefs` — Disable belief store
143
+ - `--no-curiosity` — Disable autonomous curiosity-driven learning
144
+ - `--mode` — `stochastic` | `deterministic` | `exploratory`
145
+ - `--trace` — Print chain traces
146
+ - `--data-dir` — Custom data directory
147
+ - `--user` — Multi-user isolation
148
+
149
+ ### GRACE Cognitive Core (v2)
150
+
151
+ ```python
152
+ from ravana_v2.cognitive import CognitiveFramework
153
+
154
+ fw = CognitiveFramework()
155
+ state = fw.initialize()
156
+
157
+ for episode, (inp_vec, tgt_vec) in enumerate(training_data):
158
+ concepts = fw.perceive(state, inp_vec)
159
+ predictions = fw.predict(state, concepts)
160
+ state = fw.learn(state, predictions, tgt_vec, episode)
161
+ if episode % 100 == 0:
162
+ state = fw.sleep(state)
163
+
164
+ result = fw.infer(state, test_vec) # Inference without state change
165
+ ```
166
+
167
+ ### RLMv2 — Language Model (Shared)
168
+
169
+ ```python
170
+ from ravana.nn import RLM
171
+ from ravana_ml.tokenizer import WordTokenizer
172
+ import numpy as np
173
+
174
+ tok = WordTokenizer()
175
+ tok.encode("heat causes expansion")
176
+
177
+ model = RLM(
178
+ vocab_size=tok.vocab_size,
179
+ embed_dim=64,
180
+ concept_dim=64,
181
+ n_concepts=100,
182
+ latent_dim=64, # Set equal to embed_dim for entity adapter compatibility
183
+ )
184
+ inp = np.array(tok.encode("heat causes"), dtype=np.int64)
185
+ tgt = np.array(tok.encode("expansion"), dtype=np.int64)
186
+ model.learn(inp, tgt)
187
+ model.sleep_cycle()
188
+ logits = model.forward(inp)
189
+ ```
190
+
191
+ **Note:** The `latent_dim` parameter controls the world model latent dimension. For the entity-specific adapter (enables test-time adaptation for held-out subjects) to work without additional projection overhead, set `latent_dim=embed_dim`. If they differ, the model automatically projects embeddings to latent space before applying the adapter.
192
+
193
+ ---
194
+
195
+ ## Benchmarks (External)
196
+
197
+ All benchmarks are run via external benchmarking infrastructure. See [`docs/EXPERIMENTS.md`](docs/EXPERIMENTS.md) for reproduction instructions and expected results.
198
+
199
+ ### External Benchmark Harness (NEW)
200
+
201
+ ```bash
202
+ # Quick run (PCX + Graph, ~2 min)
203
+ python external_benchmark.py --quick
204
+
205
+ # Full suite (PCX + Lifelong + Graph, ~10 min)
206
+ python external_benchmark.py
207
+
208
+ # Individual surfaces
209
+ python external_benchmark.py --quick --skip-lifelong # PCX + Graph
210
+ python external_benchmark.py --quick --skip-pcx # Lifelong + Graph
211
+ ```
212
+
213
+ **Key external validation results:**
214
+
215
+ | Metric | Result |
216
+ |--------|--------|
217
+ | Cross-domain transfer Top-1 | **75.0%** |
218
+ | Cross-domain transfer Top-10 | **100%** |
219
+ | Held-out Science Top-1 / Top-10 | 8.3% / 25.0% (n=12) |
220
+ | Held-out Social Top-1 / Top-10 | 0.0% / 8.3% (n=36) |
221
+ | Graph Inference P95 / P99 | 2.7 ms / 2.9 ms |
222
+ | Graph Peak Memory / Throughput | 0.3 MB / 556 QPS |
223
+ | W_rel Causal / Semantic Alignment | 0.68 / 0.55 |
224
+ | Lifelong forgetting (permuted MNIST) | **0%** (with sleep) |
225
+ | Within-domain triple top-10 | 80.9% |
226
+
227
+ ---
228
+
229
+ ## Documentation
230
+
231
+ | Document | Description |
232
+ |----------|-------------|
233
+ | [`docs/ARCHITECTURE.md`](docs/ARCHITECTURE.md) | Complete architecture reference — GRACE, RLMv2, Phases A–P, GloVe, verb-stem offset |
234
+ | [`docs/GETTING_STARTED.md`](docs/GETTING_STARTED.md) | Quickstart tutorial — install to first model in 5 minutes |
235
+ | [`docs/ML_FRAMEWORK.md`](docs/ML_FRAMEWORK.md) | ravana_ml deep dive — tensors, modules, ConceptGraph, RLM v1/v2 |
236
+ | [`docs/COGNITIVE_CORE.md`](docs/COGNITIVE_CORE.md) | ravana-v2 reference — all 27 GRACE modules, configurations |
237
+ | [`docs/UNIFIED_PACKAGE.md`](docs/UNIFIED_PACKAGE.md) | ravana/ package — PyTorch API, CognitiveFramework, serialization |
238
+ | [`docs/API_REFERENCE.md`](docs/API_REFERENCE.md) | Complete function/class reference for all three layers |
239
+ | [`docs/CONCEPTS.md`](docs/CONCEPTS.md) | Theoretical foundations — pressure, free energy, Hebbian, sleep, VAD, triples |
240
+ | [`docs/EXPERIMENTS.md`](docs/EXPERIMENTS.md) | Running experiments — cross-domain, Phase 4, RLMv2 benchmarks, cognitive phases, **modular ablations, per-triple eval** |
241
+ | [`docs/ADVANCED_TOPICS.md`](docs/ADVANCED_TOPICS.md) | Customization — tokenizers, plasticity, sleep, governor, multi-agent, lifelong |
242
+ | [`docs/TUTORIALS.md`](docs/TUTORIALS.md) | 8 step-by-step tutorials — Hello World to visualization |
243
+ | [`docs/DEVELOPER_GUIDE.md`](docs/DEVELOPER_GUIDE.md) | Contributing — code standards, testing, architecture principles, release process |
244
+
245
+ ---
246
+
247
+ ## Running Tests
248
+
249
+ ```bash
250
+ # Modular package tests (NEW)
251
+ python -m pytest tests/test_cognitive_rlm.py -v
252
+ python -m pytest tests/test_dialogue_system.py -v
253
+ python -m pytest tests/test_dialogue_engine_integration.py -v
254
+ python -m pytest tests/ -k "not slow" -v
255
+
256
+ # RLMv2 unit tests (shared)
257
+ python -m pytest tests/test_rlm_v2.py -v
258
+ python -m pytest tests/test_rp_only.py -v
259
+ python -m pytest tests/test_rp_contrastive.py -v
260
+ python -m pytest tests/test_structural_transfer.py -v
261
+
262
+ # GRACE cognitive core tests (v2)
263
+ python -m pytest ravana-v2/tests/ -v
264
+
265
+ # All tests
266
+ python -m pytest tests/ ravana-v2/tests/ -v
267
+ ```
268
+
269
+ **Current status: 169 tests passing** (15 cognitive + 49 dialogue + 15 integration + ML framework tests)
270
+
271
+ ---
272
+
273
+ ## Running Experiments
274
+
275
+ ### Modular Package Experiments (NEW)
276
+
277
+ ```bash
278
+ # Ablation study — all config combinations
279
+ python scripts/run_ablation.py --queries "hello|what is trust|explain oxiverse|bye" --runs 3
280
+ python scripts/run_ablation.py --quick --modes # Baseline + single flag removals + mode variants
281
+
282
+ # Per-triple evaluation harness
283
+ python scripts/triple_eval.py --data-dir ./data --output triple_eval_report.json
284
+ python scripts/triple_eval.py --triples-file my_triples.json --output report.json
285
+ ```
286
+
287
+ ### GRACE / ML Framework Experiments
288
+
289
+ ```bash
290
+ # Cross-domain transfer
291
+ python experiments/experiment_cross_domain.py
292
+
293
+ # Phase 4 integrated (triplet margin + wake-sleep)
294
+ python experiments/experiment_phase4_integrated.py
295
+
296
+ # RLMv2 triple benchmark
297
+ python experiments/experiment_triple_benchmark_v6.py
298
+
299
+ # Diagnostic tests
300
+ python tests/test_rp_only.py
301
+ python tests/test_rp_contrastive.py
302
+ python tests/test_structural_transfer.py
303
+
304
+ # Cognitive architecture experiments
305
+ cd ravana-v2 && python experiments/runner.py
306
+ ```
307
+
308
+ ### Custom Experiments
309
+
310
+ See [`docs/EXPERIMENTS.md`](docs/EXPERIMENTS.md#custom-experiments) for templates and configuration reference.
311
+
312
+ ---
313
+
314
+ ## Project Structure
315
+
316
+ ```
317
+ ravana/
318
+ ├── README.md # This file
319
+ ├── ravana/ # Unified pip-installable package (NEW)
320
+ │ ├── __init__.py # import ravana
321
+ │ ├── core/ # CognitiveCore
322
+ │ │ ├── emotion.py # VADEmotionEngine (VAD dynamics)
323
+ │ │ ├── identity.py # IdentityEngine (self-coherence)
324
+ │ │ ├── meaning.py # MeaningEngine (dissonance reduction)
325
+ │ │ ├── dual_process.py # DualProcessController (System 1/2)
326
+ │ │ ├── global_workspace.py # GlobalWorkspace (broadcast)
327
+ │ │ ├── meta_cognition.py # MetaCognition (bias detection)
328
+ │ │ ├── sleep.py # SleepConsolidation (hippocampal replay)
329
+ │ │ ├── belief_store.py # BeliefStore (multi-user merging)
330
+ │ │ └── __init__.py
331
+ │ ├── graph/ # GraphEngine
332
+ │ │ ├── engine.py # Concept graph, spreading activation, hippocampal indexing
333
+ │ │ └── __init__.py # + backward compat: ConceptGraph, ConceptNode, etc.
334
+ │ ├── decoder/ # DecoderEngine
335
+ │ │ ├── engine.py # Neural decoder, vocab, training, generation
336
+ │ │ └── __init__.py
337
+ │ ├── web/ # WebLearner
338
+ │ │ ├── learner.py # Multi-API search, background learning, curiosity
339
+ │ │ └── __init__.py
340
+ │ ├── bootstrap/ # BootstrapManager
341
+ │ │ ├── manager.py # Consolidated: auto_expand, seed_from_curiosity, bootstrap_domain
342
+ │ │ └── __init__.py
343
+ │ ├── nn/rlm/ # RLMv2 Decomposed
344
+ │ │ ├── relation_predictor.py # RelationPredictor (W_rel, verb-stem offset)
345
+ │ │ ├── propagation.py # PropagationEngine (multi-phase spread)
346
+ │ │ ├── plasticity.py # Plasticity (Hebbian/Anti-Hebbian/Structural)
347
+ │ │ └── __init__.py
348
+ │ ├── chat/ # ChatInterface
349
+ │ │ ├── interface.py # CLI, response pipeline, reasoning loop
350
+ │ │ └── __init__.py
351
+ │ └── pyproject.toml # numpy>=1.20
352
+ ├── ravana_ml/ # ML Framework (~5,200 lines)
353
+ │ ├── nn/rlm_v2.py # RLMv2 (triple decomposition, GloVe)
354
+ │ ├── graph.py # ConceptGraph (3,678 lines)
355
+ │ ├── tensor.py # StateTensor / RawTensor / Parameter
356
+ │ ├── plasticity.py # Hebbian, Anti-Hebbian, Structural
357
+ │ └── ... (tokenizer, embedder, free_energy, currencies, propagation)
358
+ ├── ravana-v2/ # GRACE Cognitive Core (~19,500 lines)
359
+ │ ├── core/ # 27 Phases A–P modules
360
+ │ │ ├── governor.py # Central regulation
361
+ │ │ ├── identity.py # Momentum-based self-concept
362
+ │ │ ├── sleep.py # 4-stage SWS+REM
363
+ │ │ ├── emotion.py # VAD differential equations
364
+ │ │ ├── human_memory.py # Episodic/Semantic (2,321 lines)
365
+ │ │ ├── global_workspace.py # Consciousness bottleneck
366
+ │ │ ├── meaning.py # Intrinsic motivation
367
+ │ │ ├── dual_process.py # System 1 / System 2
368
+ │ │ └── ... (20 more modules)
369
+ │ ├── experiments/phases/ # Phase runners
370
+ │ └── tests/ # Unit tests
371
+ ├── experiments/ # Cross-domain & Phase 4 experiments (18 files)
372
+ ├── scripts/ # Analysis & evaluation tools
373
+ │ ├── run_ablation.py # Ablation study runner (NEW)
374
+ │ ├── triple_eval.py # Per-triple evaluation harness (NEW)
375
+ │ └── ...
376
+ ├── tests/ # ML framework tests (17 files)
377
+ ├── docs/ # Full documentation (12 files)
378
+ ├── data/glove/ # GloVe embeddings (download required)
379
+ ├── results/ # Benchmark outputs & diagnostics
380
+ ├── ablation_results.json # Ablation study outputs
381
+ ├── triple_eval_report.json # Per-triple diagnostic reports
382
+ └── RAVANA_DEV_PLAN.md # Development roadmap
383
+ ```
384
+
385
+ ---
386
+
387
+ ## Ablation Study Framework (NEW)
388
+
389
+ The modular package includes a systematic ablation runner (`scripts/run_ablation.py`):
390
+
391
+ ```bash
392
+ # Full factorial (4 flags × 3 modes = 48 configs)
393
+ python scripts/run_ablation.py --queries "hello|what is trust|explain oxiverse|bye" --runs 3
394
+
395
+ # Quick mode (baseline + 4 single removals + 2 mode variants = 7 configs)
396
+ python scripts/run_ablation.py --quick --modes
397
+
398
+ # Output: ablation_results.json + markdown comparison table
399
+ ```
400
+
401
+ **What it tests:**
402
+ | Flag | Component |
403
+ |------|-----------|
404
+ | `--no-vad` | VAD emotion modulation |
405
+ | `--no-rlm` | RLMv2 triple verification |
406
+ | `--no-beliefs` | Multi-user belief store |
407
+ | `--no-curiosity` | Autonomous curiosity-driven learning |
408
+
409
+ **Metrics tracked:** Success rate, avg latency, total time, error modes per config.
410
+
411
+ ---
412
+
413
+ ## Per-Triple Evaluation Harness (NEW)
414
+
415
+ Detailed diagnostics instead of averaged metrics (`scripts/triple_eval.py`):
416
+
417
+ ```bash
418
+ # Default 10 triples (semantic, causal, contrastive)
419
+ python scripts/triple_eval.py --data-dir ./data --output triple_eval_report.json
420
+
421
+ # Custom triples
422
+ python scripts/triple_eval.py --triples-file my_triples.json --output report.json
423
+ ```
424
+
425
+ **Per-triple metrics:**
426
+ - **Relation type**: semantic / causal / contrastive / possessive / temporal / analogical
427
+ - **Prediction error (PE)**: how well the model predicts the object
428
+ - **Confidence**: model's confidence in the prediction
429
+ - **Top-1 / Top-5 accuracy**: exact match / in top 5
430
+ - **Rank**: position of correct object in predictions
431
+ - **Graph edge**: weight, confidence, type, `prediction_free_energy`
432
+ - **Source**: where learned — `seed` | `web` | `user` | `sleep` | `inference` | `unknown`
433
+
434
+ **Aggregated diagnostics:**
435
+ - Overall metrics + by relation type + by source
436
+ - Edge health summary (avg weight, confidence, PE, type distribution)
437
+
438
+ ---
439
+
440
+ ## License
441
+
442
+ MIT — Built for the RAVANA-AGI-Research initiative.
443
+
444
+ ---
445
+
446
+ ## About
447
+
448
+ RAVANA explores an alternative paradigm for machine learning — where cognition emerges from **internal pressure**, not gradient optimization; where knowledge **self-organizes** through Hebbian plasticity and sleep consolidation; and where **identity, emotion, and meaning** are first-class citizens of the learning dynamics.
449
+
450
+ **The core thesis**: *"Cognition as pressure-driven self-organization."*
451
+
452
+ This is the center of gravity. Everything else is implementation detail.
453
+
454
+ ---
455
+
456
+ ## Citation
457
+
458
+ If you use RAVANA in research, please cite:
459
+
460
+ ```bibtex
461
+ @misc{ravana2026,
462
+ title={RAVANA: Pressure-Driven Self-Organization for Cognitive Machine Learning},
463
+ author={RAVANA Research Team},
464
+ year={2026},
465
+ url={https://codeberg.org/oxiverse/ravana}
466
+ }
467
+ ```
468
+
469
+ ---
470
+
471
+ ## Links
472
+
473
+ - **Documentation**: [`docs/`](docs/)
474
+ - **External Audit**: [`docs/EXTERNAL_AUDIT.md`](docs/EXTERNAL_AUDIT.md)