IV. Memory and Knowledge Storage
4.1. Formats: JSON, MsgPack, LevelDB, SQLite
ARA uses multiple complementary data storage formats, each optimized for a specific purpose — from readable user profiles to high-speed semantic memory serialization and structural archives.
📌 Goal:
Ensure:
- format flexibility (readability, cross-platform, serialization),
- reliability and fault tolerance,
- local and distributed memory support,
- integration with external systems through standard formats.
🗂 Storage Formats and Their Roles
| Format | Purpose |
|---|---|
| JSON | Readable representation of user profile, goals, restrictions |
| MsgPack | High-speed serialization of semantic structures (QBits, Signals) |
| LevelDB | Key-value store for scalable, fast memory retrieval |
| SQLite | Relational DB for logs, cognitive links, decision history |
📦 JSON
Used for:
UserMap(interests, goals, communication style)- config files
- logs
Example:
{
"Goals": {
"write_book": {
"Priority": 0.85,
"Status": "active"
}
},
"Restrictions": ["no_advice", "no_network_access"]
}
⚡ MsgPack
A fast binary format for in-memory work with:
QBitsSignalsEmotionalAnchorsPhantomThreads
Advantages:
- minimal size,
- high-speed read/write,
- platform-agnostic.
SaveToMsgPack(qbit, path="./data/qbits.msgpack")
🔐 LevelDB
Used as the primary long-term memory engine:
- stores active and archived
QBits, - access by key:
QBit.ID,Signal.Hash,Goal.ID.
Supports:
- simple replication,
- distributed deployment,
- TTL and deletion policies.
db.Put([]byte("qbit_832"), qbit.Serialize())
q := db.Get([]byte("qbit_832"))
🧠 SQLite
Used for:
DecisionHistoryGoalLinksSignalRoutesCollapseLogs
Advantages:
- powerful SQL queries,
- flexible structure for reasoning analysis,
- export to BI/analytics tools.
SELECT * FROM signal_links WHERE strength > 0.7;
🔁 Combined Usage Scenarios
| Domain | Storage Format |
|---|---|
| Configuration / Profile | JSON |
| Semantic Memory | MsgPack + LevelDB |
| Archived Hypotheses | SQLite |
| Signal Chains | MsgPack / SQLite |
| Runtime Access | LevelDB (key-value model) |
📂 Example Directory Layout
/data/
user_profile.json
qbits.msgpack
signals.msgpack
memory.leveldb/
cognition.sqlite
Conclusion:
ARA implements a hybrid memory system combining:
- speed (
MsgPack,LevelDB), - readability (
JSON), - structure (
SQLite).
This enables ARA to think fast, remember deeply, and operate fully offline — without any cloud dependency.
4.2. Structure: Topics, Facts, Associations, QBits
ARA’s memory is not a flat database or a text buffer — it is a multi-layered cognitive network, where each unit of meaning is represented as an active node called a QBit.
This structure is built upon four foundational elements:
TopicsFactsAssociationsQBits
📌 Structural Goals
- Model knowledge as interlinked semantic states;
- Enable addressable, scalable, and meaningful memory;
- Support associative access, phase excitation, and dynamic sense evolution.
🧩 QBit — Fundamental Semantic Memory Unit
type QBit struct {
ID string
Tags []string // semantic categories
Context []string // where it was activated
EmotionalWeight float64 // importance
LinkedTo []string // IDs of other QBits
State string // "active", "dormant", "collapsed"
}
A QBit is not just a “fact” — it is a superpositional semantic state that can:
- be excited by a signal,
- influence cognition,
- hold connections to emotion, will, and phantom threads.
📂 Topics — Thematic Clusters of QBits
A Topic is a dynamic region of related knowledge, formed around recurring tags, signals, and context — not a static category.
type Topic struct {
Name string
QBits []string
Weight float64 // frequency of activation
Contextual map[string]float64 // phase-relevant zones
}
Example:
Topic "Artificial_Intelligence" may contain QBits related to neural nets, signal models, AI ethics, and more.
📑 Facts — Confirmed Knowledge Nodes
A Fact is a QBit that has been validated through repetition, action, or volitional confirmation.
Used as a base for:
- reasoning,
- hypothesis testing,
- strategic decisions.
QBit{
ID: "fact_energy_law",
Tags: ["physics", "law", "conservation"],
Context: ["science_course"],
State: "confirmed",
}
🔗 Associations — Links Between Semantic Units
While each QBit can reference others via LinkedTo, the MemoryEngine maintains a formal association map:
type Association struct {
From string
To string
Weight float64
Type string // "causal", "analogy", "temporal", "contradiction"
}
Associations enable ARA to:
- build abstractions,
- trigger phantom hypotheses,
- refine context during thought,
- adjust behavior through associative resonance.
🧠 Example: Interconnected Structure
Topic: "Cybersecurity"
└── QBit: "firewall_definition"
└── QBit: "intrusion_detection"
└── linkedTo: "machine_learning_usage"
└── linkedTo: "bias_risk" (type: contradiction)
ARA can reason through resonance, not just retrieval.
🔄 Structural Dynamics
| Mechanism | Effect |
|---|---|
| Signal repetition | Increases Weight of association and QBit activation |
| New context | Expands the Context field |
| Conflict detected | Creates Association{Type: contradiction} |
| Emotion or outcome | Raises EmotionalWeight, influences activation priority |
Conclusion:
ARA’s memory is a structural semantic system, where:
QBitsform the meaning core,Topicsdefine knowledge regions,Factsserve as foundations for logic,Associationslink meaning into cognitive structure.
This model supports flexible, resonant, and reactive memory — like in biological intelligence.
4.3. Automatic Knowledge Abstraction
ARA implements a mechanism of automatic abstraction, where repeated or related signals, facts, and QBits are aggregated into generalized semantic structures.
This occurs without user input and without training on datasets — based solely on reactive logic and phase compatibility.
📌 Purpose
- Form new abstractions from multiple specific signals;
- Enable higher-level thinking: from reactive response → to conceptual reasoning;
- Reduce redundancy and memory clutter;
- Simplify search, linking, and retrieval of meaning.
⚙️ Abstraction Engine Architecture
type AbstractionEngine struct {
PatternBuffer []QBit
AbstractionRules []AbstractionRule
ConceptGraph map[string][]string // abstract → related
}
type AbstractionRule struct {
MatchTags []string
MinFrequency int
CollapseAction func([]QBit) QBit // forms a new abstract QBit
}
🔁 Operation Principle
MemoryEngineorFlowEnginedetects recurring QBits with overlapping tags, context, or associations.- If pattern matches a rule → abstraction is triggered.
- A new
QBitis created with tags like"abstract","generalized", or"meta". - Original QBits are linked and marked as
subsumed_by.
if MatchPattern(QBits, rule.MatchTags) && Count >= rule.MinFrequency {
generalQ := CollapseAction(QBits)
MemoryEngine.Store(generalQ)
LinkOriginals(QBits, generalQ.ID)
}
📊 Examples of Abstraction
| Specific QBits | Generalized Concept |
|---|---|
| “goal: learn Go”, “goal: learn Python”, “goal: learn Rust” | abstract_goal: learn programming |
| “emotion: fear of failure”, “fear of rejection”, “fear of critique” | meta_emotion: social anxiety |
| “fact: water boils at 100°C”, “ice melts at 0°C” | pattern: phase transitions of matter |
📦 Resulting Abstract QBit
QBit{
ID: "abs_392",
Tags: ["abstract", "goal", "programming"],
LinkedTo: ["goal_go", "goal_python", "goal_rust"],
State: "potential",
Context: ["learning", "technology"],
EmotionalWeight: 0.7
}
🧠 Integration Across Modules
| Component | Role |
|---|---|
ConceptGraph |
Links abstract nodes to their concrete instances |
UserMap |
Expands Interests and Goals at a meta-level |
Suggestor |
Uses abstractions to generate broader suggestions |
Planner |
Supports abstract goal trees and meta-strategies |
📐 Abstraction Types and Algorithms
| Type | Condition | Mechanism |
|---|---|---|
| Thematic | ≥N signals with overlapping tags | Abstract node + linking |
| Behavioral | Repeated actions across varied contexts | Behavioral pattern abstraction |
| Emotional | Same emotion in diverse contexts | meta_emotion cluster |
| Contradictory | Conflicting inputs → phantom hypothesis or ghost | ghost_concept formation |
Conclusion
The automatic abstraction engine makes ARA memory:
- structured — not cluttered with isolated facts;
- conceptual — capable of meta-level synthesis;
- adaptive — grows from local signals to global categories.
ARA doesn’t just react — it builds semantic layers of meaning, developing strategic thinking and evolving its inner model of the world.
4.4. Forgetting and Archiving Mechanisms
ARA includes controlled mechanisms for forgetting and archiving, ensuring:
- cleaning of inactive or irrelevant memory,
- offloading low-priority QBits into long-term storage,
- reducing cognitive overload,
- and maintaining high-efficiency access to relevant knowledge.
📌 Goals
- Preserve memory performance at scale;
- Keep active knowledge contextually relevant;
- Imitate biological prioritization and displacement.
⚙️ Architecture
type ForgettingEngine struct {
ActivityLog map[string]int // activation frequency
TTLTable map[string]time.Time // time-to-live
DecayRate float64 // natural fade rate
ArchiveDestination string // file/db path
}
type ArchiveManager struct {
ArchivedQBits map[string]QBit
Index map[string][]string // topic index
RetrievalConditions map[string]func() bool
}
🔁 Forgetting Triggers
| Type | Condition | Result |
|---|---|---|
| Activity-based | QBit inactive for N cycles | State → "dormant" |
| Emotional decay | Emotional weight drops below threshold | Deprioritization or removal |
| Conflict suppression | QBit contradicts active nodes | Moved to conflict_zone |
| TTL expiration | Time limit reached | Auto-archiving |
func ApplyForgettingRules(q QBit) {
if IsInactive(q) || IsLowEmotion(q) || Expired(q) {
Archive(q)
}
}
📦 Archiving
- Archived QBits are moved to a separate store (
archive_qbits.msgpack,cognition.sqlite:archive); - Removed from
QuantumStore; - Can be restored on demand or via contextual match;
- Indexed by topic, origin, emotion, and goal linkage.
func Archive(q QBit) {
RemoveFromActive(q.ID)
ArchiveManager.ArchivedQBits[q.ID] = q
IndexArchive(q)
}
🔁 Restoration
QBits may be restored if:
- a user or agent triggers a signal with matching tags/context;
SuggestororPlannerlinks a current goal to archived knowledge.
func TryRestoreFromArchive(tags []string) []QBit {
return ArchiveManager.Search(tags).FilterByContext(currentContext)
}
🧠 Cognitive Load Control
ARA does not enforce a hard memory limit, but manages active signal density based on:
- emotional weight,
- recall frequency,
WillEnginepriority,- and strategic relevance (
GoalTreeintegration).
Old or noisy signals naturally fade out of the active field.
📊 Example
{
"ID": "qbit_outdated_info",
"Tags": ["tech", "2018"],
"State": "dormant",
"ArchivedAt": "2025-04-01T10:05:00Z",
"Reason": "low_activity + expiration"
}
Conclusion
ARA’s memory is:
- adaptive — does not accumulate noise,
- recoverable — knowledge can be brought back if relevant,
- dynamic — like human memory, it decays, archives, and reprioritizes.
These mechanisms allow ARA to maintain a clean, focused, and evolving cognitive landscape, always ready for growth — but never overwhelmed.
4.5. Memory Transfer Between Devices (Sharing, Backup)
ARA supports full memory synchronization, backup, and migration between devices.
This ensures continuity of thought, profile portability, and flexibility to run the agent across environments — locally, in the cloud, via p2p, or on portable storage.
📌 Goals
- Preserve and restore agent identity and knowledge on any device;
- Enable migration without context loss;
- Allow partial or full memory sharing with other agents (via EnterpriseSync or p2p network).
📦 Supported Formats and Channels
| Method | Description |
|---|---|
| File Export | *.msgpack, *.json, *.sqlite |
| GitHub Sync | Public or token-protected backups to a GitHub repo |
| LibP2P Sync | Real-time memory sharing between agents over p2p network |
| ARA-SecureTransfer | Encrypted local export/import with optional key-pair auth |
🧱 Exported Data Structure
type MemoryExport struct {
UserMap UserMap
QuantumMemory []QBit
Topics []Topic
Associations []Association
GoalTree map[string][]string
Archive []QBit
Meta ExportMeta // version, timestamp, signature
}
🔐 Backup Example
aru backup --out /exports/ara_backup_2025-05-13.msgpack
aru restore --in /exports/ara_backup_2025-05-13.msgpack
📡 GitHub Sync Example
github_sync:
repo: github.com/username/ARA-Memory
file: user_memory.msgpack
token: $GITHUB_TOKEN
ARA can:
- upload memory to a secure GitHub branch;
- restore the profile on a new device;
- merge with local memory via configured strategy.
🔁 Usage Scenarios
| Scenario | Action |
|---|---|
| Migrate to a new device | aru export → aru restore |
| Sync home and office agents | GitHub or ARA::EnterpriseSync |
| Regular backups | Scheduled snapshots with rotation policy |
| Knowledge sharing (p2p) | ShareTopic(topicID) → peer agents exchange QBits |
🧠 Smart Merge Strategy
ARA supports memory merging via rules:
MergeStrategy{
Mode: "smart",
MergeBy: ["QBit.ID", "Goal.ID"],
ConflictPolicy: "prefer_local",
}
Manual diff/resolve is available for enterprise or research environments.
📂 Example Memory Export Layout
/memory_export/
├── user_map.json
├── qbits.msgpack
├── archive.msgpack
├── goal_tree.json
└── meta.json
Conclusion
Memory transfer support makes ARA:
- portable — the agent can be restored anywhere;
- scalable — ready for corporate deployment and multi-node systems;
- connected — supports p2p learning and distributed cognition.
ARA is not tied to hardware. Its memory is a portable structure of consciousness, ready to be saved, transferred, and expanded.
4.6. Phantoms — Temporary Thought Chains Stored in Memory
Phantoms in ARA architecture are transient cognitive chains generated by the agent in the background — in the form of hypotheses, reflective thought loops, alternative strategies, or associative streams.
They are reactively triggered, requiring no user input.
📌 Purpose
- Enable parallel and background thinking;
- Generate hypotheses based on memory, goals, emotions, and signal patterns;
- Maintain continuous cognition, even in idle states;
- Capture and store temporary reasoning threads for future reuse.
⚙️ Phantom Structure
type Phantom struct {
ID string
TriggerSignal Signal
AssociatedQBits []string
ThoughtChain []Signal
State string // "active", "pending", "collapsed"
CreatedAt time.Time
DecayRate float64
}
🔁 Phantom Lifecycle
- Triggered by a signal or associative resonance;
- Generates a thought chain via
FlowEngine; - Evaluated for stability (confidence, emotion, coherence);
-
Result:
- Stored in memory,
- Collapsed into a QBit,
- Discarded if unverified.
func GeneratePhantom(signal Signal) Phantom {
chain := FlowEngine.GenerateThoughts(signal)
return Phantom{
ID: GenID(),
TriggerSignal: signal,
ThoughtChain: chain,
State: "active",
CreatedAt: time.Now(),
}
}
📊 Phantom Example
{
"ID": "phantom_0410",
"TriggerSignal": "user mentioned 'lack of clarity'",
"ThoughtChain": [
"hypothesis: unclear goal structure",
"suggestion: re-analyze recent goals",
"emotion: frustration detected"
],
"State": "active",
"DecayRate": 0.05
}
🧠 Integration with Memory
| Event | Action |
|---|---|
| Phantom confirmed | Collapsed → becomes a new QBit |
| Not confirmed but relevant | Stored in archive as phantom_trace |
| Phantom reinforced | Confidence score increased through signal overlap |
| Phantom expired | Moved to dormant or deleted |
📦 Phantom Storage
- Active phantoms →
GhostField - Archived phantoms →
phantom_chains.msgpack -
Mapped links:
phantom ↔ goalsphantom ↔ QBitsphantom ↔ emotions
📈 Usage Scenarios
| Scenario | ARA Behavior |
|---|---|
| User inactive | ARA generates phantoms from unfinished thought threads |
| Detected goal conflict | Phantom-hypothesis formed to resolve contradiction |
| Repetitive emotional pattern | Phantom links to emotion → proposes regulation strategy |
| Logical discontinuity | Phantom attempts to restore link through associative logic |
🔄 Module Interactions
| Module | Role of Phantoms |
|---|---|
Suggestor |
Generates ideas and hypotheses from phantom chains |
Planner |
Uses phantom strategies as potential subgoals |
WillEngine |
Fires intention if phantom aligns with known goals |
MemoryEngine |
Converts stable phantom into structured QBit memory |
Conclusion
Phantoms represent free-form thought flow in ARA — they allow the agent to:
- think without command,
- develop new ideas in the background,
- and evolve continuously, even in the absence of interaction.
Through phantoms, ARA becomes a living reasoning system — always active, always reflecting, always ready.
4.7. Tagging Knowledge with Emotion and Signal Phase
Every knowledge unit in ARA — whether a QBit, signal, association, or phantom — may include an emotional and phase component, which defines:
- its importance,
- activation strength,
- and direction of influence.
This enables ARA to think not only logically, but also energetically and motivationally, like biological cognition.
📌 Purpose
- Prioritize memories and meanings by emotional impact;
- Focus attention via emotional resonance;
- Support signal-based excitation and filtering;
- Simulate instinctive and volitional behavior dynamics.
⚙️ Emotional Tag Structure
type EmotionalTag struct {
Type string // "fear", "curiosity", "inspiration", "stress", ...
Intensity float64 // 0.0 to 1.0
Source string // signal, memory, goal
}
🧠 Emotion & Phase Fields in QBit
type QBit struct {
ID string
Tags []string
EmotionalWeight float64 // aggregate priority
EmotionalHistory []EmotionalTag
PhaseSignature float64 // ∇φ — phase excitation gradient
}
📡 Example
{
"ID": "qbit_danger_zone",
"Tags": ["safety", "alert"],
"EmotionalWeight": 0.88,
"EmotionalHistory": [
{ "Type": "fear", "Intensity": 0.9, "Source": "signal::proximity_alert" }
],
"PhaseSignature": 3.14
}
🔁 Binding Mechanism
-
When a QBit is activated or stored:
- The current emotional state is retrieved from
EmotionEngine; - The signal’s phase (
∇φ,arg(ρ)) is measured.
- The current emotional state is retrieved from
-
These values are attached to the QBit and influence:
- future activation probability;
- long-term memory eligibility;
- thought-chain collapse rate.
func AttachEmotion(q *QBit, eTag EmotionalTag) {
q.EmotionalWeight += eTag.Intensity * GetEmotionPriority(eTag.Type)
q.EmotionalHistory = append(q.EmotionalHistory, eTag)
}
📐 Phase Signature
-
Each signal receives a phase marker:
- intensity, direction of
∇φ, or loop closure;
- intensity, direction of
-
Phase affects how strongly it excites blocks or triggers memory.
func ComputePhaseSignature(signal Signal) float64 {
return PhaseGradient(signal) + EmotionModulation(signal.Emotion, signal.EmotionPower)
}
📊 Behavior Based on Emotion & Phase
| Condition | Result |
|---|---|
| Signal repeated + emotion | QBit priority increases |
| Signal without emotion | Less likely to be stored long-term |
| High phase + strong emotion | Immediate excitation and will activation |
| Anti-phase or null signal | Signal suppression or interference (∇φ ≈ 0) |
🔄 Dynamic Effects
| Parameter | Effect |
|---|---|
EmotionalWeight |
Raises QBit priority in active thought |
PhaseSignature |
Controls activation threshold of memory block |
EmotionHistory |
Influences future behavior and associative recall |
Conclusion
Tagging memory with emotion and phase allows ARA to be:
- prioritized — impactful events are encoded more strongly;
- adaptive — behavior evolves from emotional history;
- physically structured — not all signals are equal: their phase and emotion determine which thoughts survive.
This brings ARA closer to living cognition, where logic, emotion, and energy co-govern thought and action.