Skip to main content

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

Metadata

Release files for hga 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hga 0.1.0
File Size Uploaded Provenance
hga-0.1.0.tar.gz 46.1 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for hga 0.1.0
File Interpreter ABI Platform
hga-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 97.3 kB

Release files / hga-0.1.0.tar.gz

Download URL hga-0.1.0.tar.gz
Size 46.1 kB
Tags Source
SHA-256 checksum
How to use checksums
ded7a8248fd1bdfb6c88b23fabbdaef3156f0793d5ac11730326af52e8281706
BLAKE2b-256 checksum
How to use checksums
edaba37badf127707de3b81426c0ac04405d05fa09eededa3b0e8e380ffe4be6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.9

Release files / hga-0.1.0-py3-none-any.whl

Download URL hga-0.1.0-py3-none-any.whl
Size 51.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9da24e1aa10ac2ffd78557ee050e38f49764fa2e8a2eca47d5b96b5883948c5a
BLAKE2b-256 checksum
How to use checksums
d622994cf613184f50c03b396d53e9f6d3550ed5f5393703867b3567794ecccb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.9

Security for hga 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page