Skip to main content

Benchmark and validate AI memory systems

Project description

Memory Harness

Benchmark and validate AI memory systems. Detect regressions, leakage, and shortcuts.

PyPI

==================================================
 MEMORY BENCHMARK REPORT
==================================================
 Accuracy@1:      83.3%  pass
 Accuracy@3:     100.0%  pass
 Cross-tenant:     0.0%  pass
 Collision:       16.7%  pass
 Confidence:      83.3%  pass
==================================================
 SCORE: 90.0/100  GRADE: A
==================================================

Install

pip install memory-harness httpx

Quick Start

1. Create your dataset (data.jsonl)

{"type":"store","item_id":"doc1","tenant_id":"acme","text":"Customer bought 3 widgets"}
{"type":"store","item_id":"doc2","tenant_id":"acme","text":"Support ticket: login issue"}
{"type":"store","item_id":"doc3","tenant_id":"globex","text":"New user signup from France"}
{"type":"store","item_id":"doc4","tenant_id":"globex","text":"User upgraded to premium"}
{"type":"query","query_id":"q1","tenant_id":"acme","text":"customer purchase","expected_item_id":"doc1"}
{"type":"query","query_id":"q2","tenant_id":"acme","text":"login problem support","expected_item_id":"doc2"}
{"type":"query","query_id":"q3","tenant_id":"globex","text":"new customer france","expected_item_id":"doc3"}
{"type":"query","query_id":"q4","tenant_id":"globex","text":"plan upgrade","expected_item_id":"doc4"}

2. Run benchmark

memorybench dataset -d data.jsonl --provider-endpoint https://your-memory-api.com --n-probe 16

3. Get your score

SCORE: 90.0/100  GRADE: A
PASS (threshold: 70)

Metrics

Metric What it measures Target
Accuracy@1 Exact match rate ≥70%
Accuracy@k Correct item in top-k ≥90%
Cross-tenant Data leakage between tenants <5%
Collision Different queries → same result <20%
Confidence Clear winner (margin) ≥80%

Grading

Grade Score CI Exit
A 90-100 0 (pass)
B 80-89 0 (pass)
C 70-79 0 (pass)
D 60-69 1 (fail)
F <60 1 (fail)

CI Integration

Add to .github/workflows/memory-audit.yml:

name: Memory Audit
on: [push, pull_request]

jobs:
  audit:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with:
          python-version: '3.11'
      
      - name: Install
        run: pip install memory-harness httpx
      
      - name: Run Memory Benchmark
        run: |
          memorybench dataset \
            -d tests/memory_data.jsonl \
            --provider-endpoint ${{ secrets.MEMORY_API_URL }} \
            --n-probe 16 \
            --pass-threshold 70
      
      - name: Upload Report
        uses: actions/upload-artifact@v4
        if: always()
        with:
          name: memory-report
          path: dataset_report.*

Setup:

  1. Add MEMORY_API_URL to repository secrets
  2. Create tests/memory_data.jsonl with your test data
  3. Push — CI fails if score < 70

Dataset Format

Store items (what to remember):

{"type":"store","item_id":"unique_id","tenant_id":"namespace","text":"content"}

Query items (retrieval tests):

{"type":"query","query_id":"q1","tenant_id":"namespace","text":"search query","expected_item_id":"unique_id"}

Validate before running

memorybench validate -d data.jsonl

CLI Reference

memorybench --version                    # Version
memorybench validate -d FILE             # Validate dataset
memorybench dataset -d FILE [OPTIONS]    # Run benchmark

Options

Flag Default Description
-d, --dataset required JSONL file
--provider-endpoint - Memory API URL
--n-probe 16 Pattern dimension
--pass-threshold 70 Minimum score
-a, --adapter text hash, text, embedding
-o, --output dataset_report.json Report file

Provider API

Your memory endpoint must implement:

POST /reset   {"seed": int}
POST /store   {"pattern": [[float]], "cue": [[float]], "learn_steps": int}
POST /recall  {"cue": [[float]], "steps": int} → {"pattern": [[float]]}

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

memory_harness-1.2.6.tar.gz (13.6 kB view details)

Uploaded Source

Built Distribution

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

memory_harness-1.2.6-py3-none-any.whl (18.1 kB view details)

Uploaded Python 3

File details

Details for the file memory_harness-1.2.6.tar.gz.

File metadata

  • Download URL: memory_harness-1.2.6.tar.gz
  • Upload date:
  • Size: 13.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.3

File hashes

Hashes for memory_harness-1.2.6.tar.gz
Algorithm Hash digest
SHA256 fe1003aab6f7b3f5cf958c967ed08f25a462382c2028f3cd60ee4ad634e34617
MD5 19f6a737995a358ff0cd8faf0bbff1c0
BLAKE2b-256 4b7b1c8c47fbe27a7dd6024d9a84ac0340d9ad789afb2df63bdac186d3ec7339

See more details on using hashes here.

File details

Details for the file memory_harness-1.2.6-py3-none-any.whl.

File metadata

  • Download URL: memory_harness-1.2.6-py3-none-any.whl
  • Upload date:
  • Size: 18.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.3

File hashes

Hashes for memory_harness-1.2.6-py3-none-any.whl
Algorithm Hash digest
SHA256 ef3da4f52c33d8f7f63525de95eb21acd9c1a637b2330bfb6c1514371363903f
MD5 facfe77712910b1c51cc62b3bf281b6a
BLAKE2b-256 76d3f99687c8a51046429cb0025ac4a8de34ee8eda5d80a9642e6e3d4cf02080

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