Skip to main content

Hybrid Governance Architecture — Multi-layer agent memory system with vector quantization, deterministic vault, and semantic neuron routing

Project description

HGA — Hybrid Governance Architecture

PyPI version Python 3.9+ License: MIT

A multi-layer agent memory system that provides intelligent query routing, exact recall, and semantic neuron maturation for LLM-based agents.

Features

  • L1 — RM (Routing Memory: A Vector-Quantization-Based Retrieval Primitive): Vector quantization with K-means centroids, multi-probe retrieval, online EMA adaptation, and drift detection
  • L2 — Deterministic Vault: Exact key-value recall with SHA-256 integrity verification, policy tagging (Public/Internal/Sensitive/Restricted), and full audit trails
  • L3 — Semantic Neuron Layer: 4-stage neuron maturation (Stage 0→3), causal reasoning chains, structural similarity transfer, and safe Stage 3 replay
  • Governance Gate: Intelligent routing across 5 execution paths based on confidence, margin, neuron maturity, and sensitivity
  • Consolidation: Active trace writing + passive LLM-free capability growth (co-occurrence mining, edge finalization, RM reshaping)
  • Real Embeddings: Uses all-MiniLM-L6-v2 (384-dimensional) — no mock or synthetic embeddings

Installation

pip install hga-memory

With LLM provider support:

# Groq
pip install hga-memory[groq]

# OpenAI
pip install hga-memory[openai]

# Everything
pip install hga-memory[all]

Quick Start

from hga import AgentMemory

# Initialize memory system
memory = AgentMemory()

# Store information
memory.store("Project deadline is March 15, 2026", policy_tag="Internal")
memory.store("API key format: sk-xxxx", policy_tag="Sensitive")

# Query with automatic routing
result = memory.recall("When is the project deadline?")
print(result.answer)
print(f"Path: {result.path}, Tokens: {result.tokens_used}")

# The gate automatically routes:
# - Exact facts → Deterministic Vault (0 tokens)
# - Semantic queries → RM retrieval
# - Mature patterns → Stage 3 replay (0 tokens)
# - Sensitive queries → Deterministic path (safe)

Architecture

Query → Governance Gate → Route Decision
              │
              ├── Stage0Path    → Full LLM call (new pattern)
              ├── FastSemantic  → L1 retrieval + LLM
              ├── VerifyPath    → L1 + L3 verify + LLM
              ├── Stage3Path    → Causal replay (no LLM)
              └── Deterministic → L2 exact lookup (no LLM)

Gate Decision Logic

Condition Path
Sensitivity=High OR edge weight < -1 DeterministicPath
Stage 3 + confidence >= 0.6 Stage3Path
Stage 2 + confidence >= 0.6 + margin >= 0.1 VerifyPath
Stage >= 1 + confidence >= 0.6 FastSemanticPath
No matching neuron Stage0Path

Neuron Maturation

Neurons progress through 4 stages based on successful executions:

  • Stage 0→1: weight > 0, 3+ successful hits
  • Stage 1→2: weight > +2, 8+ hits
  • Stage 2→3: weight > +2.5, 5 consecutive clean executions

Edge weights update: w += source_weight × outcome (clipped to [-3, +3])

Configuration

Parameter Default Description
K 64 Number of RM centroids
ALPHA 0.6 Confidence threshold
DELTA_MIN 0.1 Margin threshold
eta 0.01 EMA learning rate
embedding_dim 384 Embedding dimensionality

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hga-0.1.0.tar.gz (46.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hga-0.1.0-py3-none-any.whl (51.2 kB view details)

Uploaded Python 3

File details

Details for the file hga-0.1.0.tar.gz.

File metadata

  • Download URL: hga-0.1.0.tar.gz
  • Upload date:
  • Size: 46.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for hga-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ded7a8248fd1bdfb6c88b23fabbdaef3156f0793d5ac11730326af52e8281706
MD5 bd241b55eb86b2082de2d5036e210f91
BLAKE2b-256 edaba37badf127707de3b81426c0ac04405d05fa09eededa3b0e8e380ffe4be6

See more details on using hashes here.

File details

Details for the file hga-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: hga-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 51.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for hga-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9da24e1aa10ac2ffd78557ee050e38f49764fa2e8a2eca47d5b96b5883948c5a
MD5 71118a4967df5d406e519c0ef26c1056
BLAKE2b-256 d622994cf613184f50c03b396d53e9f6d3550ed5f5393703867b3567794ecccb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page