memtrust 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.
- memtrust-0.1.0/.github/workflows/ci.yml +62 -0
- memtrust-0.1.0/.gitignore +25 -0
- memtrust-0.1.0/.pre-commit-config.yaml +17 -0
- memtrust-0.1.0/CHANGELOG.md +58 -0
- memtrust-0.1.0/CLAUDE.md +106 -0
- memtrust-0.1.0/CONTRIBUTING.md +117 -0
- memtrust-0.1.0/LICENSE +202 -0
- memtrust-0.1.0/PKG-INFO +427 -0
- memtrust-0.1.0/README.md +396 -0
- memtrust-0.1.0/SECURITY.md +39 -0
- memtrust-0.1.0/docs/methodology.md +330 -0
- memtrust-0.1.0/leaderboard/data.json +60 -0
- memtrust-0.1.0/leaderboard/index.html +107 -0
- memtrust-0.1.0/npm/memtrust-cli/bin/memtrust.js +34 -0
- memtrust-0.1.0/npm/memtrust-cli/package.json +26 -0
- memtrust-0.1.0/npm/platforms/@memtrust-cli-darwin-arm64/LICENSE +241 -0
- memtrust-0.1.0/npm/platforms/@memtrust-cli-darwin-arm64/package.json +10 -0
- memtrust-0.1.0/npm/platforms/@memtrust-cli-darwin-x64/LICENSE +241 -0
- memtrust-0.1.0/npm/platforms/@memtrust-cli-darwin-x64/package.json +10 -0
- memtrust-0.1.0/npm/platforms/@memtrust-cli-linux-arm64/LICENSE +241 -0
- memtrust-0.1.0/npm/platforms/@memtrust-cli-linux-arm64/package.json +10 -0
- memtrust-0.1.0/npm/platforms/@memtrust-cli-linux-x64/LICENSE +241 -0
- memtrust-0.1.0/npm/platforms/@memtrust-cli-linux-x64/package.json +10 -0
- memtrust-0.1.0/npm/platforms/@memtrust-cli-win32-arm64/LICENSE +241 -0
- memtrust-0.1.0/npm/platforms/@memtrust-cli-win32-arm64/package.json +10 -0
- memtrust-0.1.0/npm/platforms/@memtrust-cli-win32-x64/LICENSE +241 -0
- memtrust-0.1.0/npm/platforms/@memtrust-cli-win32-x64/package.json +10 -0
- memtrust-0.1.0/npm/scripts/fetch-binary.js +196 -0
- memtrust-0.1.0/pyproject.toml +87 -0
- memtrust-0.1.0/src/memtrust/__init__.py +3 -0
- memtrust-0.1.0/src/memtrust/adapters/__init__.py +53 -0
- memtrust-0.1.0/src/memtrust/adapters/base.py +473 -0
- memtrust-0.1.0/src/memtrust/adapters/mem0_adapter.py +431 -0
- memtrust-0.1.0/src/memtrust/adapters/mempalace_adapter.py +226 -0
- memtrust-0.1.0/src/memtrust/adapters/openviking_adapter.py +219 -0
- memtrust-0.1.0/src/memtrust/adapters/zep_graphiti_adapter.py +181 -0
- memtrust-0.1.0/src/memtrust/cli.py +412 -0
- memtrust-0.1.0/src/memtrust/evals/__init__.py +5 -0
- memtrust-0.1.0/src/memtrust/evals/compression.py +235 -0
- memtrust-0.1.0/src/memtrust/evals/contradiction.py +278 -0
- memtrust-0.1.0/src/memtrust/evals/locomo.py +177 -0
- memtrust-0.1.0/src/memtrust/evals/longmemeval.py +146 -0
- memtrust-0.1.0/src/memtrust/evals/resource_sync_safety.py +272 -0
- memtrust-0.1.0/src/memtrust/scoring/__init__.py +1 -0
- memtrust-0.1.0/src/memtrust/scoring/cost_tracker.py +98 -0
- memtrust-0.1.0/src/memtrust/scoring/llm_judge.py +161 -0
- memtrust-0.1.0/tests/fixtures/compression_cases.json +31 -0
- memtrust-0.1.0/tests/fixtures/contradiction_cases.json +56 -0
- memtrust-0.1.0/tests/fixtures/locomo_sample.json +43 -0
- memtrust-0.1.0/tests/fixtures/longmemeval_sample.json +70 -0
- memtrust-0.1.0/tests/fixtures/resource_sync_cases.json +64 -0
- memtrust-0.1.0/tests/test_adapters.py +866 -0
- memtrust-0.1.0/tests/test_cli.py +245 -0
- memtrust-0.1.0/tests/test_compression.py +252 -0
- memtrust-0.1.0/tests/test_evals.py +675 -0
- memtrust-0.1.0/tests/test_scoring.py +208 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main]
|
|
8
|
+
|
|
9
|
+
permissions:
|
|
10
|
+
contents: read
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
lint:
|
|
14
|
+
name: Lint (ruff)
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
|
|
18
|
+
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
|
|
19
|
+
with:
|
|
20
|
+
python-version: "3.12"
|
|
21
|
+
- run: pip install ruff
|
|
22
|
+
- run: ruff check .
|
|
23
|
+
- run: ruff format --check .
|
|
24
|
+
|
|
25
|
+
typecheck:
|
|
26
|
+
name: Type check (mypy --strict)
|
|
27
|
+
runs-on: ubuntu-latest
|
|
28
|
+
steps:
|
|
29
|
+
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
|
|
30
|
+
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
|
|
31
|
+
with:
|
|
32
|
+
python-version: "3.12"
|
|
33
|
+
- run: pip install -e ".[dev]"
|
|
34
|
+
- run: mypy --strict src/memtrust
|
|
35
|
+
|
|
36
|
+
test:
|
|
37
|
+
name: Test (pytest + coverage)
|
|
38
|
+
runs-on: ubuntu-latest
|
|
39
|
+
strategy:
|
|
40
|
+
matrix:
|
|
41
|
+
python-version: ["3.11", "3.12", "3.13"]
|
|
42
|
+
steps:
|
|
43
|
+
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
|
|
44
|
+
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
|
|
45
|
+
with:
|
|
46
|
+
python-version: ${{ matrix.python-version }}
|
|
47
|
+
- run: pip install -e ".[dev]"
|
|
48
|
+
# All tests run fully offline -- no vendor or judge API keys are
|
|
49
|
+
# configured here, and none are required. This is what proves the
|
|
50
|
+
# "never crash on missing credentials" contract on every push.
|
|
51
|
+
- run: pytest --cov=memtrust --cov-report=term-missing --cov-fail-under=80
|
|
52
|
+
|
|
53
|
+
security:
|
|
54
|
+
name: Security (pip-audit)
|
|
55
|
+
runs-on: ubuntu-latest
|
|
56
|
+
steps:
|
|
57
|
+
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
|
|
58
|
+
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
|
|
59
|
+
with:
|
|
60
|
+
python-version: "3.12"
|
|
61
|
+
- run: pip install -e ".[dev]"
|
|
62
|
+
- run: pip-audit
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
__pycache__/
|
|
2
|
+
*.py[cod]
|
|
3
|
+
*.egg-info/
|
|
4
|
+
.eggs/
|
|
5
|
+
build/
|
|
6
|
+
dist/
|
|
7
|
+
.venv/
|
|
8
|
+
venv/
|
|
9
|
+
.env
|
|
10
|
+
.env.*
|
|
11
|
+
!.env.example
|
|
12
|
+
.pytest_cache/
|
|
13
|
+
.mypy_cache/
|
|
14
|
+
.ruff_cache/
|
|
15
|
+
.coverage
|
|
16
|
+
.coverage.*
|
|
17
|
+
htmlcov/
|
|
18
|
+
coverage.xml
|
|
19
|
+
*.log
|
|
20
|
+
.DS_Store
|
|
21
|
+
results/*/
|
|
22
|
+
!results/.gitkeep
|
|
23
|
+
node_modules/
|
|
24
|
+
.idea/
|
|
25
|
+
.vscode/
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
repos:
|
|
2
|
+
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
3
|
+
rev: v0.15.9
|
|
4
|
+
hooks:
|
|
5
|
+
- id: ruff
|
|
6
|
+
args: [--fix]
|
|
7
|
+
- id: ruff-format
|
|
8
|
+
|
|
9
|
+
- repo: https://github.com/pre-commit/mirrors-mypy
|
|
10
|
+
rev: v1.14.1
|
|
11
|
+
hooks:
|
|
12
|
+
- id: mypy
|
|
13
|
+
args: [--strict, src/memtrust]
|
|
14
|
+
pass_filenames: false
|
|
15
|
+
additional_dependencies:
|
|
16
|
+
- httpx>=0.27.0
|
|
17
|
+
- click>=8.1.7
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are documented here. Format loosely follows
|
|
4
|
+
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
|
5
|
+
|
|
6
|
+
## [Unreleased]
|
|
7
|
+
|
|
8
|
+
### Added
|
|
9
|
+
|
|
10
|
+
- `npm/` -- an unpublished npm-distributable CLI wrapper (`npx memtrust ...`) for CI and agent
|
|
11
|
+
runners that have Node.js but not necessarily a Python toolchain. Six per-platform optional
|
|
12
|
+
packages (`@memtrust/darwin-arm64`, `darwin-x64`, `linux-arm64`, `linux-x64`, `win32-arm64`,
|
|
13
|
+
`win32-x64`) each bundle a genuine, SHA-256-verified copy of Astral's `uv` binary
|
|
14
|
+
(github.com/astral-sh/uv, dual-licensed MIT OR Apache-2.0), fetched from uv's own GitHub
|
|
15
|
+
release 0.11.28 at npm package-publish time via a `prepack` script, never at end-user install
|
|
16
|
+
time. The `memtrust` bin shim runs `uv tool run --from memtrust memtrust <args>`, which
|
|
17
|
+
bootstraps a Python interpreter and installs `memtrust` from PyPI on first use. Not yet
|
|
18
|
+
published to npm -- gated on a separate publish step. See the README's "npx (agent-native)"
|
|
19
|
+
section and `npm/` for the wrapper source and third-party attribution.
|
|
20
|
+
|
|
21
|
+
## [0.1.0] - 2026-07-11
|
|
22
|
+
|
|
23
|
+
Initial release.
|
|
24
|
+
|
|
25
|
+
### Added
|
|
26
|
+
|
|
27
|
+
- Shared `MemoryBackendAdapter` interface (`store()`/`query()`/`update()`) in
|
|
28
|
+
`src/memtrust/adapters/base.py`, plus `ConflictSignal` classification used by the
|
|
29
|
+
contradiction-detection eval.
|
|
30
|
+
- Four backend adapters: MemPalace, Mem0, Zep/Graphiti, OpenViking. Each reads its configuration
|
|
31
|
+
from a single environment variable and raises `BackendNotConfiguredError` (never crashes) when
|
|
32
|
+
it's missing. Confidence level per adapter documented in `docs/methodology.md`.
|
|
33
|
+
- Three eval runners: LongMemEval-style long-horizon recall, LoCoMo-style multi-session recall,
|
|
34
|
+
and memtrust's original multi-hop contradiction-detection eval (flagged / silently-overwrote /
|
|
35
|
+
served-stale / not-applicable).
|
|
36
|
+
- LLM-judge scoring pipeline (`scoring/llm_judge.py`), model-configurable via environment
|
|
37
|
+
variables, with a no-crash `NOT_RUN` fallback when no judge API key is configured.
|
|
38
|
+
- Cost tracker (`scoring/cost_tracker.py`) with a dated, approximate per-model pricing table.
|
|
39
|
+
- `memtrust run` and `memtrust report` CLI commands.
|
|
40
|
+
- Static leaderboard site (`leaderboard/index.html` + `leaderboard/data.json`) with a documented
|
|
41
|
+
schema, shipped as an example rather than fabricated live results.
|
|
42
|
+
- Full test suite: 57 tests, 95% overall coverage, 100% on `adapters/base.py`,
|
|
43
|
+
`evals/contradiction.py`, `evals/longmemeval.py`, and `scoring/`. All tests run fully offline.
|
|
44
|
+
- CI workflow: lint (ruff), type-check (mypy --strict), test (pytest + coverage across Python
|
|
45
|
+
3.11-3.13), security (pip-audit).
|
|
46
|
+
- `docs/methodology.md`, `CONTRIBUTING.md`, `SECURITY.md`.
|
|
47
|
+
|
|
48
|
+
### Known limitations (v0.1)
|
|
49
|
+
|
|
50
|
+
- Adapters for MemPalace and OpenViking are built against best-effort interpretations of
|
|
51
|
+
documented product concepts, not a confirmed API reference -- see the confidence table in
|
|
52
|
+
`docs/methodology.md`. They should be verified against a live instance before their output is
|
|
53
|
+
treated as authoritative.
|
|
54
|
+
- LongMemEval and LoCoMo eval runners ship against small, explicitly synthetic sample fixtures
|
|
55
|
+
matching each benchmark's real published schema, not the full public datasets.
|
|
56
|
+
- No live benchmark numbers are published in the README -- running the harness against real
|
|
57
|
+
backends requires vendor API keys not available at the time of this release. See the README's
|
|
58
|
+
"Benchmarks" section for exactly what was and wasn't measured.
|
memtrust-0.1.0/CLAUDE.md
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# CLAUDE.md -- memtrust
|
|
2
|
+
|
|
3
|
+
## Project identity
|
|
4
|
+
|
|
5
|
+
- **What this is:** an independent, reproducible benchmark harness that runs standardized evals
|
|
6
|
+
(LongMemEval, LoCoMo, and an original multi-hop contradiction-detection eval) against
|
|
7
|
+
agent-memory backends (MemPalace, Mem0, Zep/Graphiti, OpenViking) and publishes results with
|
|
8
|
+
full raw logs and a documented methodology.
|
|
9
|
+
- **Repo:** github.com/RudrenduPaul/memtrust
|
|
10
|
+
- **Package:** `memtrust` on PyPI
|
|
11
|
+
- **Language:** Python (`src/memtrust/` layout, PEP 621 `pyproject.toml`)
|
|
12
|
+
- **License:** Apache 2.0
|
|
13
|
+
- **Goal:** be the benchmark someone can point to instead of a vendor's own self-reported number,
|
|
14
|
+
because the methodology, prompts, and raw logs are fully public and reproducible from a fresh
|
|
15
|
+
clone. Trust is earned by being independently reproducible, not claimed.
|
|
16
|
+
|
|
17
|
+
## Git workflow
|
|
18
|
+
|
|
19
|
+
When asked to commit, push, or "update GitHub" -- just do it. No confirmation prompts.
|
|
20
|
+
|
|
21
|
+
- `git add` relevant files -> `git commit` -> `git push origin main` in one shot.
|
|
22
|
+
- Every commit message ends with:
|
|
23
|
+
`Built by Rudrendu Paul and Sourav Nandy, developed with Claude Code`
|
|
24
|
+
- Do not add `Co-Authored-By:` trailers.
|
|
25
|
+
- Prefer small, checkpoint-shaped commits over one giant commit.
|
|
26
|
+
|
|
27
|
+
## Engineering standards (block all tasks until these pass)
|
|
28
|
+
|
|
29
|
+
1. **Lint:** `ruff check . && ruff format --check .`
|
|
30
|
+
2. **Types:** `mypy --strict src/memtrust` -- zero errors, zero unexplained `# type: ignore`.
|
|
31
|
+
3. **Tests:** `pytest --cov=memtrust --cov-report=term-missing --cov-fail-under=80` -- 80% minimum
|
|
32
|
+
overall; 90%+ on `adapters/base.py`, `evals/contradiction.py`, and `scoring/`. Every test must
|
|
33
|
+
run fully offline -- mock or stub any network/vendor call. No test may require a real API key.
|
|
34
|
+
4. **Security:** `pip-audit` -- no unfixed HIGH/CRITICAL CVEs in the dependency tree.
|
|
35
|
+
5. **Reproducibility:** if you changed a scoring prompt, an adapter, or an eval dataset version,
|
|
36
|
+
re-run the affected eval and show the before/after in your response -- never state a number
|
|
37
|
+
without showing the command that produced it.
|
|
38
|
+
|
|
39
|
+
Do not mark a task complete if any of these fail. Fix the root cause; do not suppress errors or
|
|
40
|
+
add a blanket `# type: ignore`.
|
|
41
|
+
|
|
42
|
+
## Planning rules
|
|
43
|
+
|
|
44
|
+
Enter plan mode for any task that:
|
|
45
|
+
- Touches more than 2 files.
|
|
46
|
+
- Changes the `MemoryBackendAdapter` interface or a scoring-pipeline contract.
|
|
47
|
+
- Adds a new eval family or a new tracked backend.
|
|
48
|
+
- Modifies `.github/workflows/ci.yml`.
|
|
49
|
+
|
|
50
|
+
Write the plan before touching code. If something goes wrong mid-task, stop and re-plan rather
|
|
51
|
+
than patching around the original plan.
|
|
52
|
+
|
|
53
|
+
## Anti-sycophancy rules
|
|
54
|
+
|
|
55
|
+
These override default behavior in every session working on this repo:
|
|
56
|
+
|
|
57
|
+
1. **No benchmark number without a fresh, reproducible run.** Before publishing or citing a score
|
|
58
|
+
for any backend, run the eval and show the command output. Never state a number from memory or
|
|
59
|
+
a stale prior run without re-verifying it's current.
|
|
60
|
+
2. **Every eval runs identically across every tracked backend.** No per-vendor prompt tuning, no
|
|
61
|
+
per-vendor dataset subset. If a backend's API genuinely cannot support a given eval, document
|
|
62
|
+
the gap explicitly in the results (`ConflictSignal.NOT_APPLICABLE`, or an equivalent explicit
|
|
63
|
+
marker) rather than silently excluding the backend from that eval's table.
|
|
64
|
+
3. **No "verified"/"safe"/"best" claim about any backend.** This project publishes comparative
|
|
65
|
+
scores across a defined eval set, not an endorsement or a safety certification. Report numbers;
|
|
66
|
+
let the reader draw the conclusion.
|
|
67
|
+
4. **Every methodology decision lives in `docs/methodology.md`, versioned with the code.** Prompt
|
|
68
|
+
templates, dataset versions, scoring rubrics, and adapter confidence levels all belong there. If
|
|
69
|
+
a methodology choice can't be explained in that file, it does not belong in the harness.
|
|
70
|
+
5. **Vendor-pushback check.** Before publishing a run, ask: "if this backend's own maintainers
|
|
71
|
+
read this methodology, could they point to a specific, defensible flaw?" If yes, fix the flaw
|
|
72
|
+
before publishing, not after someone complains publicly.
|
|
73
|
+
|
|
74
|
+
## What Claude must never do in this repo
|
|
75
|
+
|
|
76
|
+
- Publish or cite a benchmark number without a fresh command-output run in the same session.
|
|
77
|
+
- Ship a new eval or backend adapter without a corresponding `docs/methodology.md` entry.
|
|
78
|
+
- Commit with `--no-verify`.
|
|
79
|
+
- Merge a change to scoring logic without re-running the affected eval and showing the delta.
|
|
80
|
+
- Present a best-effort adapter (see the confidence table in `docs/methodology.md`) as a confirmed
|
|
81
|
+
vendor API integration.
|
|
82
|
+
- State or imply that this project's purpose is anything other than the eval harness and
|
|
83
|
+
leaderboard described above.
|
|
84
|
+
|
|
85
|
+
## Key files
|
|
86
|
+
|
|
87
|
+
| File | Purpose |
|
|
88
|
+
|---|---|
|
|
89
|
+
| `src/memtrust/adapters/base.py` | The shared adapter interface every backend implements. Read this before touching any adapter. |
|
|
90
|
+
| `src/memtrust/adapters/` | One adapter per backend (MemPalace, Mem0, Zep/Graphiti, OpenViking). |
|
|
91
|
+
| `src/memtrust/evals/contradiction.py` | The original wedge eval -- the most important file in the repo. |
|
|
92
|
+
| `src/memtrust/evals/` | LongMemEval and LoCoMo runners. |
|
|
93
|
+
| `src/memtrust/scoring/` | LLM-judge scoring pipeline and cost tracker. |
|
|
94
|
+
| `src/memtrust/cli.py` | `memtrust run`, `memtrust report`. |
|
|
95
|
+
| `docs/methodology.md` | Full, versioned methodology -- read before publishing any number. |
|
|
96
|
+
| `leaderboard/` | Static leaderboard site (`index.html` + `data.json`). |
|
|
97
|
+
| `CONTRIBUTING.md` | Read before adding a new backend adapter -- the primary contribution path. |
|
|
98
|
+
| `.github/workflows/ci.yml` | lint -> type-check -> test -> security. |
|
|
99
|
+
|
|
100
|
+
## Session start checklist
|
|
101
|
+
|
|
102
|
+
1. Run `git status` and `git log --oneline -5` to understand current state.
|
|
103
|
+
2. Run `pytest` to confirm the baseline is green before touching anything.
|
|
104
|
+
3. Read `docs/methodology.md`'s relevant section before changing an eval or adapter.
|
|
105
|
+
4. If a score looks off, re-run the specific eval against the specific backend with verbose output
|
|
106
|
+
before assuming the harness (rather than the backend) is wrong.
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
The easiest and most useful way to contribute is adding a new backend adapter. This document
|
|
4
|
+
covers that path in detail, plus the general workflow for everything else.
|
|
5
|
+
|
|
6
|
+
## Adding a new backend adapter
|
|
7
|
+
|
|
8
|
+
Every adapter implements `memtrust.adapters.base.MemoryBackendAdapter`, defined in
|
|
9
|
+
`src/memtrust/adapters/base.py`. Read that file first; it is short and it is the actual contract,
|
|
10
|
+
not a summary of one.
|
|
11
|
+
|
|
12
|
+
### The interface
|
|
13
|
+
|
|
14
|
+
```python
|
|
15
|
+
class MemoryBackendAdapter(ABC):
|
|
16
|
+
name: str
|
|
17
|
+
env_var: str
|
|
18
|
+
supports_update: bool = True
|
|
19
|
+
|
|
20
|
+
def store(self, session_id: str, content: str, metadata: dict[str, str] | None = None) -> StoreResult: ...
|
|
21
|
+
def query(self, session_id: str, query: str, top_k: int = 5) -> QueryResult: ...
|
|
22
|
+
def update(self, session_id: str, memory_id: str, content: str) -> UpdateResult: ...
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Step by step
|
|
26
|
+
|
|
27
|
+
1. **Pick your `env_var`.** Every adapter reads exactly one environment variable in `__init__` and
|
|
28
|
+
raises `BackendNotConfiguredError(self.name, self.env_var)` immediately if it's missing --
|
|
29
|
+
never on the first method call. This is what lets `memtrust run` report SKIPPED instead of
|
|
30
|
+
crashing when a backend isn't configured. If your backend genuinely needs no secret (like
|
|
31
|
+
MemPalace, which is local-first), gate on whatever configuration value it does need instead --
|
|
32
|
+
see `mempalace_adapter.py` for the pattern and `docs/methodology.md` for why.
|
|
33
|
+
|
|
34
|
+
2. **Implement `store()`, `query()`, `update()`** against the vendor's real API. Wrap every
|
|
35
|
+
network/vendor failure in `BackendAPIError(self.name, detail)` -- never let a raw
|
|
36
|
+
`httpx.HTTPError` or vendor SDK exception escape the adapter. `query()` must return a
|
|
37
|
+
`ConflictSignal` (see below).
|
|
38
|
+
|
|
39
|
+
3. **Report `ConflictSignal` honestly.** This is what the contradiction-detection eval reads.
|
|
40
|
+
- `FLAGGED` if your backend's response makes a contradiction visible (returns both old and new
|
|
41
|
+
values, an explicit conflict marker, an invalidation timestamp, etc.)
|
|
42
|
+
- `NOT_APPLICABLE` if you cannot determine this from the response -- do **not** guess `FLAGGED`
|
|
43
|
+
or `SILENT_OVERWRITE` to make a number look better. The contradiction eval independently
|
|
44
|
+
cross-checks your reported signal against the actual retrieved content (see
|
|
45
|
+
`evals/contradiction.py::classify_case`), so an inflated self-report gets caught and
|
|
46
|
+
downgraded, not rewarded.
|
|
47
|
+
- If your backend has no update/contradiction-relevant primitive at all, set
|
|
48
|
+
`supports_update = False` on the class. The eval then records `NOT_APPLICABLE` for every case
|
|
49
|
+
without calling your adapter, and that gap is shown explicitly in results tables -- it is
|
|
50
|
+
never silently dropped.
|
|
51
|
+
|
|
52
|
+
4. **Document your confidence level.** At the top of your adapter file, write a docstring stating
|
|
53
|
+
what you verified against real vendor documentation and what you built as best-effort. Add a
|
|
54
|
+
row to the confidence table in `docs/methodology.md`. If you are not confident about an exact
|
|
55
|
+
endpoint path or method signature, say so in the code comment at the point of use, the same way
|
|
56
|
+
`mempalace_adapter.py` and `openviking_adapter.py` do. A wrong guess that's labeled is useful; a
|
|
57
|
+
wrong guess presented as confirmed is a bug that will mislead every leaderboard reader.
|
|
58
|
+
|
|
59
|
+
5. **Register it.** Add your adapter class to `ADAPTER_REGISTRY` in
|
|
60
|
+
`src/memtrust/adapters/__init__.py`, keyed by the name users will pass to `--backends`.
|
|
61
|
+
|
|
62
|
+
6. **Write tests.** Every adapter test mocks the HTTP layer (`pytest-httpx`) or injects a fake
|
|
63
|
+
object matching your adapter's expected vendor interface -- see `tests/test_adapters.py` for
|
|
64
|
+
the pattern used by all four existing adapters. No test may make a real network call. Cover at
|
|
65
|
+
minimum: `BackendNotConfiguredError` when the env var is missing, a successful `store`/`query`/
|
|
66
|
+
`update` round trip against a mocked response, and a `BackendAPIError` on a failed HTTP call.
|
|
67
|
+
|
|
68
|
+
7. **Run the full check before opening a PR:**
|
|
69
|
+
```bash
|
|
70
|
+
ruff check . && ruff format --check .
|
|
71
|
+
mypy --strict src/memtrust
|
|
72
|
+
pytest --cov=memtrust --cov-report=term-missing --cov-fail-under=80
|
|
73
|
+
pip-audit
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### What a PR adding an adapter should include
|
|
77
|
+
|
|
78
|
+
- The adapter file, following the pattern above.
|
|
79
|
+
- Its registration in `ADAPTER_REGISTRY`.
|
|
80
|
+
- Tests in `tests/test_adapters.py`.
|
|
81
|
+
- A confidence-level entry in `docs/methodology.md`'s adapter table.
|
|
82
|
+
- A one-line addition to the README's backend coverage table.
|
|
83
|
+
|
|
84
|
+
## Adding or extending an eval
|
|
85
|
+
|
|
86
|
+
The three eval families live in `src/memtrust/evals/`. Each is a plain function taking a
|
|
87
|
+
configured `MemoryBackendAdapter` (and an `LLMJudge` for the two that need semantic grading) and
|
|
88
|
+
returning a dataclass of results -- there is no plugin system to learn, just a function signature
|
|
89
|
+
to match. See `evals/contradiction.py` for the simplest example (no LLM judge needed) and
|
|
90
|
+
`evals/longmemeval.py` for the LLM-judged pattern.
|
|
91
|
+
|
|
92
|
+
To extend the contradiction-detection eval's case set, add entries to
|
|
93
|
+
`tests/fixtures/contradiction_cases.json`. Read `docs/methodology.md`'s note on how the
|
|
94
|
+
`contradicting_fact` field should be phrased before adding a case -- a correction that restates
|
|
95
|
+
the old value inside its own text can produce a misleading classification (this happened once
|
|
96
|
+
during the initial build and is documented there in detail).
|
|
97
|
+
|
|
98
|
+
To run the harness against the real, full LongMemEval or LoCoMo datasets instead of the bundled
|
|
99
|
+
synthetic samples, see the "to run against the real dataset" note under each eval in
|
|
100
|
+
`docs/methodology.md` -- both loaders accept a `dataset_path` argument already; only a format
|
|
101
|
+
conversion (or a second loader function) is needed.
|
|
102
|
+
|
|
103
|
+
## General workflow
|
|
104
|
+
|
|
105
|
+
1. Fork, branch, make your change.
|
|
106
|
+
2. Run the full check list above locally before pushing.
|
|
107
|
+
3. Keep PRs scoped to one adapter, one eval change, or one clearly-described fix -- easier to
|
|
108
|
+
review, easier to bisect if something regresses.
|
|
109
|
+
4. Every claim in a PR description about a score or benchmark number must be reproducible from a
|
|
110
|
+
command someone else can run. "I ran X and got Y" needs the X.
|
|
111
|
+
|
|
112
|
+
## Code of conduct
|
|
113
|
+
|
|
114
|
+
Be direct, be specific, assume good faith. Disagreement about a methodology choice is welcome and
|
|
115
|
+
expected -- open an issue with the specific flaw, not a vague complaint. This project exists
|
|
116
|
+
because vague, unverifiable claims about agent-memory backends are the problem it's trying to fix;
|
|
117
|
+
holding contributions to the same standard is the point.
|
memtrust-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|