memtrust-cli 0.3.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.
Files changed (100) hide show
  1. memtrust_cli-0.3.0/.github/CODEOWNERS +3 -0
  2. memtrust_cli-0.3.0/.github/workflows/ci.yml +67 -0
  3. memtrust_cli-0.3.0/.github/workflows/publish-pypi.yml +22 -0
  4. memtrust_cli-0.3.0/.gitignore +28 -0
  5. memtrust_cli-0.3.0/.pre-commit-config.yaml +17 -0
  6. memtrust_cli-0.3.0/CHANGELOG.md +196 -0
  7. memtrust_cli-0.3.0/CONTRIBUTING.md +117 -0
  8. memtrust_cli-0.3.0/LICENSE +202 -0
  9. memtrust_cli-0.3.0/PKG-INFO +624 -0
  10. memtrust_cli-0.3.0/README.md +579 -0
  11. memtrust_cli-0.3.0/SECURITY.md +39 -0
  12. memtrust_cli-0.3.0/docs/assets/dev-to-demos/demo-1-zero-credentials.gif +0 -0
  13. memtrust_cli-0.3.0/docs/assets/dev-to-demos/demo-2-fictional-api-discovery.gif +0 -0
  14. memtrust_cli-0.3.0/docs/assets/dev-to-demos/demo-3-cli-surface.gif +0 -0
  15. memtrust_cli-0.3.0/docs/assets/dev-to-demos/demo-4-temporal-kg-tests.gif +0 -0
  16. memtrust_cli-0.3.0/docs/methodology.md +1719 -0
  17. memtrust_cli-0.3.0/leaderboard/data.json +60 -0
  18. memtrust_cli-0.3.0/leaderboard/index.html +107 -0
  19. memtrust_cli-0.3.0/npm/memtrust-cli/LICENSE +202 -0
  20. memtrust_cli-0.3.0/npm/memtrust-cli/README.md +40 -0
  21. memtrust_cli-0.3.0/npm/memtrust-cli/bin/memtrust.js +47 -0
  22. memtrust_cli-0.3.0/npm/memtrust-cli/package.json +26 -0
  23. memtrust_cli-0.3.0/npm/platforms/@memtrust-cli-darwin-arm64/LICENSE +241 -0
  24. memtrust_cli-0.3.0/npm/platforms/@memtrust-cli-darwin-arm64/package.json +10 -0
  25. memtrust_cli-0.3.0/npm/platforms/@memtrust-cli-darwin-x64/LICENSE +241 -0
  26. memtrust_cli-0.3.0/npm/platforms/@memtrust-cli-darwin-x64/package.json +10 -0
  27. memtrust_cli-0.3.0/npm/platforms/@memtrust-cli-linux-arm64/LICENSE +241 -0
  28. memtrust_cli-0.3.0/npm/platforms/@memtrust-cli-linux-arm64/package.json +10 -0
  29. memtrust_cli-0.3.0/npm/platforms/@memtrust-cli-linux-x64/LICENSE +241 -0
  30. memtrust_cli-0.3.0/npm/platforms/@memtrust-cli-linux-x64/package.json +10 -0
  31. memtrust_cli-0.3.0/npm/platforms/@memtrust-cli-win32-arm64/LICENSE +241 -0
  32. memtrust_cli-0.3.0/npm/platforms/@memtrust-cli-win32-arm64/package.json +10 -0
  33. memtrust_cli-0.3.0/npm/platforms/@memtrust-cli-win32-x64/LICENSE +241 -0
  34. memtrust_cli-0.3.0/npm/platforms/@memtrust-cli-win32-x64/package.json +10 -0
  35. memtrust_cli-0.3.0/npm/scripts/fetch-binary.js +196 -0
  36. memtrust_cli-0.3.0/pyproject.toml +144 -0
  37. memtrust_cli-0.3.0/src/memtrust/__init__.py +11 -0
  38. memtrust_cli-0.3.0/src/memtrust/adapters/__init__.py +62 -0
  39. memtrust_cli-0.3.0/src/memtrust/adapters/base.py +2020 -0
  40. memtrust_cli-0.3.0/src/memtrust/adapters/mem0_adapter.py +456 -0
  41. memtrust_cli-0.3.0/src/memtrust/adapters/mem0_direct_adapter.py +1217 -0
  42. memtrust_cli-0.3.0/src/memtrust/adapters/mempalace_adapter.py +1166 -0
  43. memtrust_cli-0.3.0/src/memtrust/adapters/openviking_adapter.py +570 -0
  44. memtrust_cli-0.3.0/src/memtrust/adapters/zep_graphiti_adapter.py +181 -0
  45. memtrust_cli-0.3.0/src/memtrust/adapters/zep_graphiti_selfhosted_adapter.py +882 -0
  46. memtrust_cli-0.3.0/src/memtrust/cli.py +1201 -0
  47. memtrust_cli-0.3.0/src/memtrust/evals/__init__.py +5 -0
  48. memtrust_cli-0.3.0/src/memtrust/evals/compression.py +235 -0
  49. memtrust_cli-0.3.0/src/memtrust/evals/contradiction.py +451 -0
  50. memtrust_cli-0.3.0/src/memtrust/evals/crash_recovery.py +290 -0
  51. memtrust_cli-0.3.0/src/memtrust/evals/embedder_cost.py +163 -0
  52. memtrust_cli-0.3.0/src/memtrust/evals/embedding_drift.py +273 -0
  53. memtrust_cli-0.3.0/src/memtrust/evals/episode_temporal_leak.py +182 -0
  54. memtrust_cli-0.3.0/src/memtrust/evals/extraction_quality.py +373 -0
  55. memtrust_cli-0.3.0/src/memtrust/evals/filter_injection.py +371 -0
  56. memtrust_cli-0.3.0/src/memtrust/evals/language_degradation.py +189 -0
  57. memtrust_cli-0.3.0/src/memtrust/evals/lock_contention.py +263 -0
  58. memtrust_cli-0.3.0/src/memtrust/evals/locomo.py +392 -0
  59. memtrust_cli-0.3.0/src/memtrust/evals/longmemeval.py +249 -0
  60. memtrust_cli-0.3.0/src/memtrust/evals/mempalace_metadata_scale.py +494 -0
  61. memtrust_cli-0.3.0/src/memtrust/evals/migration_rollback.py +276 -0
  62. memtrust_cli-0.3.0/src/memtrust/evals/orphan_cleanup.py +235 -0
  63. memtrust_cli-0.3.0/src/memtrust/evals/ranking_quality.py +303 -0
  64. memtrust_cli-0.3.0/src/memtrust/evals/resource_sync_safety.py +336 -0
  65. memtrust_cli-0.3.0/src/memtrust/evals/result_consistency.py +239 -0
  66. memtrust_cli-0.3.0/src/memtrust/evals/scale_fixtures.py +189 -0
  67. memtrust_cli-0.3.0/src/memtrust/evals/scale_stress.py +502 -0
  68. memtrust_cli-0.3.0/src/memtrust/evals/stats_accuracy.py +240 -0
  69. memtrust_cli-0.3.0/src/memtrust/evals/temporal_kg_boundary.py +281 -0
  70. memtrust_cli-0.3.0/src/memtrust/receipt.py +318 -0
  71. memtrust_cli-0.3.0/src/memtrust/scoring/__init__.py +1 -0
  72. memtrust_cli-0.3.0/src/memtrust/scoring/cost_tracker.py +199 -0
  73. memtrust_cli-0.3.0/src/memtrust/scoring/llm_judge.py +161 -0
  74. memtrust_cli-0.3.0/tests/fixtures/compression_cases.json +31 -0
  75. memtrust_cli-0.3.0/tests/fixtures/contradiction_cases.json +83 -0
  76. memtrust_cli-0.3.0/tests/fixtures/crash_recovery_cases.json +21 -0
  77. memtrust_cli-0.3.0/tests/fixtures/embedding_drift_cases.json +46 -0
  78. memtrust_cli-0.3.0/tests/fixtures/extraction_quality_cases.json +169 -0
  79. memtrust_cli-0.3.0/tests/fixtures/filter_injection_cases.json +55 -0
  80. memtrust_cli-0.3.0/tests/fixtures/language_degradation_cases.json +62 -0
  81. memtrust_cli-0.3.0/tests/fixtures/locomo_sample.json +49 -0
  82. memtrust_cli-0.3.0/tests/fixtures/longmemeval_sample.json +70 -0
  83. memtrust_cli-0.3.0/tests/fixtures/migration_rollback_cases.json +21 -0
  84. memtrust_cli-0.3.0/tests/fixtures/orphan_cleanup_cases.json +36 -0
  85. memtrust_cli-0.3.0/tests/fixtures/ranking_quality_cases.json +61 -0
  86. memtrust_cli-0.3.0/tests/fixtures/resource_sync_cases.json +85 -0
  87. memtrust_cli-0.3.0/tests/fixtures/result_consistency_cases.json +29 -0
  88. memtrust_cli-0.3.0/tests/test_adapters.py +3610 -0
  89. memtrust_cli-0.3.0/tests/test_cli.py +670 -0
  90. memtrust_cli-0.3.0/tests/test_compression.py +252 -0
  91. memtrust_cli-0.3.0/tests/test_episode_temporal_leak.py +290 -0
  92. memtrust_cli-0.3.0/tests/test_evals.py +3462 -0
  93. memtrust_cli-0.3.0/tests/test_lock_contention.py +274 -0
  94. memtrust_cli-0.3.0/tests/test_mem0_direct_adapter.py +1656 -0
  95. memtrust_cli-0.3.0/tests/test_mempalace_metadata_scale.py +418 -0
  96. memtrust_cli-0.3.0/tests/test_receipt.py +281 -0
  97. memtrust_cli-0.3.0/tests/test_scale_stress.py +359 -0
  98. memtrust_cli-0.3.0/tests/test_scoring.py +269 -0
  99. memtrust_cli-0.3.0/tests/test_stats_accuracy.py +219 -0
  100. memtrust_cli-0.3.0/tests/test_temporal_kg_boundary.py +438 -0
@@ -0,0 +1,3 @@
1
+ # CI/CD workflows are the highest-leverage place for a supply-chain compromise to
2
+ # hide, so changes here always require review.
3
+ /.github/workflows/ @RudrenduPaul
@@ -0,0 +1,67 @@
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,mem0-direct]"
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,mem0-direct]"
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
+ # The mem0-direct group is installed so test_mem0_direct_adapter.py's
52
+ # real-package tests (see its module docstring) actually run here,
53
+ # instead of skipping -- they still make no live network call, they
54
+ # just import and exercise the real mem0ai/boto3/redis/valkey/
55
+ # google-genai/fastembed classes with the vendor SDK boundary mocked.
56
+ - run: pytest --cov=memtrust --cov-report=term-missing --cov-fail-under=80
57
+
58
+ security:
59
+ name: Security (pip-audit)
60
+ runs-on: ubuntu-latest
61
+ steps:
62
+ - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
63
+ - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
64
+ with:
65
+ python-version: "3.12"
66
+ - run: pip install -e ".[dev,mem0-direct]"
67
+ - run: pip-audit
@@ -0,0 +1,22 @@
1
+ name: Publish PyPI
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+
7
+ jobs:
8
+ publish:
9
+ runs-on: ubuntu-latest
10
+ permissions:
11
+ contents: read
12
+ id-token: write
13
+ steps:
14
+ - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
15
+ - uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0
16
+ with:
17
+ python-version: "3.x"
18
+ - run: pip install build
19
+ - run: python -m build
20
+ - uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # v1.14.0
21
+ with:
22
+ packages-dir: dist
@@ -0,0 +1,28 @@
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/
26
+ .claude/
27
+ uv.lock
28
+ memtrust-report-*.json
@@ -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,196 @@
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
+ ## [0.3.0] - 2026-07-17
7
+
8
+ ### Changed
9
+
10
+ - `MemPalaceAdapter` (`adapters/mempalace_adapter.py`) rewritten against the real,
11
+ live-verified `mempalace.mcp_server` API. Every previous version called a fictional
12
+ `mempalace.Palace` class that does not exist in the real installed package (confirmed:
13
+ `hasattr(mempalace, 'Palace')` is `False`) -- `store()`/`query()`/`update()` never
14
+ worked against the real vendor package in this project's history. `delete()`, which
15
+ previously always raised (no primitive existed), now genuinely works via
16
+ `tool_delete_drawer`. New additive `kg_add()`/`kg_invalidate()`/`kg_query()` methods
17
+ wrap the real KG API, including a new `TemporalBoundarySignal` (`CLEAN`/
18
+ `DOUBLE_COUNT`/`NOT_APPLICABLE`) detecting the exact boundary-instant double-counting
19
+ shape MemPalace/mempalace#1913/PR#1914 fixed. `RankingSignal` classification
20
+ re-pointed from fictional `importance`/`emotional_weight`/`weight` fields to the real
21
+ `similarity`/`authored_at` fields `tool_search` actually returns.
22
+ - `--locomo-dataset-path` CLI flag added to `memtrust run` -- `run_locomo()` already
23
+ accepted a `dataset_path` parameter and `docs/methodology.md` already documented it,
24
+ but the CLI never exposed a way to actually pass one in. `load_dataset()` now raises
25
+ actionable errors (missing file / invalid JSON / missing `conversations` key) naming
26
+ the download URL and expected schema, instead of a bare `FileNotFoundError`/
27
+ `KeyError`/`JSONDecodeError`.
28
+
29
+ ### Fixed
30
+
31
+ - `cryptography` dependency ceiling raised from `<47.0` to `<49.0` (floor raised to
32
+ `>=48.0.1`) -- the prior ceiling actively prevented installing the fix for
33
+ GHSA-537c-gmf6-5ccf (vulnerable OpenSSL bundled in the `cryptography` wheel, HIGH,
34
+ CVSS 7.5), found via `pip-audit` during a routine security sweep.
35
+
36
+ ## [0.2.0] - 2026-07-17
37
+
38
+ ### Added
39
+
40
+ - `ZepGraphitiSelfHostedAdapter` (`adapters/zep_graphiti_selfhosted_adapter.py`) -- a second,
41
+ separately-configured Zep/Graphiti adapter (`GRAPHITI_NEO4J_URI` or `GRAPHITI_FALKORDB_URL`)
42
+ that instantiates `graphiti_core.Graphiti` directly in-process, reaching internal
43
+ graphiti-core bugs (getzep/graphiti#1302, #836, #1013, #1001) the existing Zep-Cloud REST
44
+ adapter can never see. Adds `MemoryRecord.attributes` so structured per-record properties
45
+ survive the adapter boundary, and `ConflictSignal.EDGE_INTEGRITY_VIOLATION` for edge records
46
+ with a missing `source_node_uuid`/`target_node_uuid`.
47
+ - `Mem0DirectAdapter` (`adapters/mem0_direct_adapter.py`) -- a direct, in-process `mem0.Memory`
48
+ handle via `Memory.from_config()`, reaching mem0's construction-time `graph_store`/`embedder`/
49
+ `vector_store` config surface that the REST-only `Mem0Adapter`/`Mem0SelfHostedAdapter` cannot.
50
+ Built and tested against the real installed `mem0ai==2.0.12` package: confirms mem0ai/mem0
51
+ #5671, #4362, #4711, and #2304 are fixed in that release, and that #3558 (Kuzu) cannot be
52
+ reproduced because the installed package has no `graph_store` field or kuzu dependency at all.
53
+ Adds `CorruptionSignal` (`CONFIG_REJECTED`/`VECTOR_ZEROED`/`CLEAN`/`NOT_APPLICABLE`) and an
54
+ optional `mem0-direct` dependency group. Opt-in only, registered as `mem0_direct` in
55
+ `ADAPTER_REGISTRY`, not in `cli.ALL_BACKENDS`.
56
+ - `custom_instructions` passthrough constructor argument, threading a caller-supplied
57
+ fact-extraction prompt into `MemoryConfig` (mem0ai/mem0#4573's junk-retention finding;
58
+ `custom_instructions` is the real top-level key after mem0 renamed it away from
59
+ `custom_fact_extraction_prompt` in mem0ai/mem0#4740).
60
+ - Qdrant support (`vector_store_provider="qdrant"`) and a `query(threshold=...)` parameter
61
+ forwarded to `Memory.search()`, giving mem0ai/mem0#4297 (embedding-dimension mismatch,
62
+ confirmed still reachable in the installed package) and #4453 (search-threshold inversion,
63
+ confirmed fixed) a real construction-time surface to reach.
64
+ - Elasticsearch vector-store support (host/api_key/embedding-dims threading) plus a new
65
+ `filter_injection` eval and `FilterInjectionSignal` taxonomy (`FILTER_REJECTED`/
66
+ `FILTER_ACCEPTED_SAFELY`/`INJECTION_SUCCEEDED`/`NOT_APPLICABLE`), built on
67
+ `probe_raw_filter()`/`RawFilterProbeResult` (`adapters/base.py`), which submits an
68
+ adversarial filter dict directly to a backend's filter-building layer. Confirms the
69
+ installed `mem0ai==2.0.12` already carries the `_validate_filter()` fix from
70
+ mem0ai/mem0#5980.
71
+ - Ed25519-signed receipts for `memtrust run` output (`src/memtrust/receipt.py`): canonical JSON
72
+ encoding, Ed25519 sign/verify, PEM keypair I/O, and three new CLI commands (`memtrust keygen`,
73
+ `memtrust run --sign <keyfile>`, `memtrust verify <receipt.json>`). Signing is opt-in and off
74
+ by default; unsigned `memtrust run` output is unchanged.
75
+ - Crash-recovery eval (`evals/crash_recovery.py`, `crash_stress` capability flags in
76
+ `adapters/base.py`) modeling volcengine/OpenViking#2644's silent index-rebuild skip on
77
+ restart, with `CrashRecoverySignal` (`RECOVERED`/`INDEX_LOST_DATA_SURVIVED`/`DATA_LOST`/
78
+ `NOT_APPLICABLE`). Built at the harness level against a fake adapter; no adapter in this repo
79
+ has real process-lifecycle control over a live backend.
80
+ - Embedding-drift/consistency eval (`evals/embedding_drift.py`) for volcengine/OpenViking#1523's
81
+ in-place vector overwrite during an embedder migration, with `EmbeddingDriftSignal`
82
+ (`EMBEDDING_DRIFT`/`CLEAN`/`NOT_APPLICABLE`).
83
+ - Extraction-quality-at-scale eval (`evals/extraction_quality.py`) modeled on a real 32-day mem0
84
+ audit (mem0ai/mem0#4573, jamebobob: 97.8% of 10,134 stored entries were junk) plus a
85
+ documented feedback-loop case (one hallucinated memory re-extracted into 808 duplicate
86
+ stores). Adds `ExtractionQualitySignal` (`RETAINED_JUNK`/`REJECTED_JUNK`/`RETAINED_VALID`/
87
+ `LOST_VALID`/`FEEDBACK_LOOP_DUPLICATE`/`NO_UNEXPECTED_GROWTH`/`NOT_APPLICABLE`).
88
+ - Scale/volume stress-testing eval (`evals/scale_stress.py`, `evals/scale_fixtures.py`,
89
+ `scale_stress`) for volcengine/OpenViking#2850 (BM25 search going silently empty at volume)
90
+ and getzep/graphiti#1275 (O(n) entity-resolution growth silently dropping old episodes), with
91
+ a deterministic large-scale synthetic corpus generator and a `--scale-stress-n-records` CLI
92
+ flag.
93
+ - Migration-rollback-safety eval (`evals/migration_rollback.py`) verifying the concept behind
94
+ MemPalace's real rename-aside swap fix (mempalace/mempalace#1028, PR#935) for an unguarded
95
+ `shutil.rmtree()`-then-`shutil.move()` migration swap that could permanently lose data on a
96
+ partial failure. Adds `MigrationRollbackSignal` (`RESTORED`/`DATA_LOST`/`NOT_APPLICABLE`); no
97
+ real adapter sets the new capability flag since none has filesystem control over a live
98
+ `migrate()` call.
99
+ - New crash-classification signals in `adapters/base.py`'s `CrashSignal`: `UNPACK_ERROR` and
100
+ `TYPE_COMPARISON_ERROR` for graphiti-core's `store()` exceptions (getzep/graphiti#836's
101
+ tuple-unpack `ValueError`, #920's tz-naive/tz-aware `TypeError`), and
102
+ `QUERY_SANITIZATION_ERROR` for FalkorDB RediSearch syntax errors in `query()`
103
+ (getzep/graphiti#1222, superseded by #1475; #1183, merged).
104
+ - MemPalace degraded-retrieval signal: `RetrievalWarning` and `QueryResult.degraded_retrieval`
105
+ (`adapters/base.py`), surfacing MemPalace's real merged `search_memories()` fix
106
+ (mempalace/mempalace#1005) that degrades vector-query failures into a response carrying
107
+ warnings and partial results instead of raising -- a failure mode
108
+ `ConflictSignal.EMPTY_OR_LOST` could not see.
109
+ - MemPalace `authored_at` ranking tie-breaker: `_RANKING_METADATA_KEYS` and query-result parsing
110
+ now recognize `authored_at` (top-level or nested under `metadata`) as a ranking-driving field,
111
+ matching MemPalace's real merged PR#1890/#1889.
112
+ - Retrieval-graded vs. generated-answer accuracy disclosure in `docs/methodology.md`: memtrust's
113
+ LongMemEval/LoCoMo accuracy metric grades raw retrieved-record content directly, with no
114
+ answer-generation step, so it is not the same measurement as the official leaderboards'
115
+ generate-then-judge QA-accuracy scores (closes mempalace/mempalace#367).
116
+
117
+ ### Fixed
118
+
119
+ - MemPalace adapter docstring no longer conflates "no API key required" with "no network
120
+ required" -- `mempalace mine .` can still fail offline because chromadb's default embedder
121
+ downloads its ONNX model on first use (mempalace/mempalace#524). LongMemEval now flags cases
122
+ where `top_k` already covers the whole corpus (`top_k_exceeds_corpus`), so a small haystack
123
+ can no longer read as artificially high recall.
124
+ - Report table width corrected for 12-column output as new evals were added.
125
+ - OpenViking adapter's `BackendAPIError` now reads the real HTTP response body
126
+ (`exc.response.text`) instead of only `httpx`'s status line, across `store`/`query`/`update`/
127
+ `delete`/`list_resource_paths`/`trigger_resync` -- volcengine/OpenViking#1227's server-side
128
+ Pydantic validation detail was previously swallowed down to a useless status-line-only
129
+ message.
130
+
131
+ ## [0.1.2] - 2026-07-16
132
+
133
+ ### Added
134
+
135
+ - `npm/` -- an unpublished npm-distributable CLI wrapper (`npx memtrust ...`) for CI and agent
136
+ runners that have Node.js but not necessarily a Python toolchain. Six per-platform optional
137
+ packages (`@memtrust/darwin-arm64`, `darwin-x64`, `linux-arm64`, `linux-x64`, `win32-arm64`,
138
+ `win32-x64`) each bundle a genuine, SHA-256-verified copy of Astral's `uv` binary
139
+ (github.com/astral-sh/uv, dual-licensed MIT OR Apache-2.0), fetched from uv's own GitHub
140
+ release 0.11.28 at npm package-publish time via a `prepack` script, never at end-user install
141
+ time. The `memtrust` bin shim runs `uv tool run --from memtrust memtrust <args>`, which
142
+ bootstraps a Python interpreter and installs `memtrust` from PyPI on first use. Not yet
143
+ published to npm -- gated on a separate publish step. See the README's "npx (agent-native)"
144
+ section and `npm/` for the wrapper source and third-party attribution.
145
+
146
+ ### Added
147
+
148
+ - `StoreResult.extraction_signal` (`ExtractionSignal`, `adapters/base.py`) -- flags when a `store()`
149
+ call completes without raising but the response carried no usable memory id, the exact
150
+ mem0ai/mem0#5178 "store() succeeded but silently extracted zero facts" shape. `Mem0Adapter`,
151
+ `Mem0SelfHostedAdapter`, and `Mem0DirectAdapter` all now set `FACTS_EXTRACTED`/`EMPTY_EXTRACTION`
152
+ instead of silently returning a normal-looking `StoreResult` with `memory_id=""`. See
153
+ docs/methodology.md's "ExtractionSignal and mem0ai/mem0#5178" section.
154
+
155
+ ### Fixed
156
+
157
+ - PyPI `project.urls` now link each author to their GitHub profile instead of leaving the `Author` field email-less with no way to reach either maintainer
158
+
159
+ ## [0.1.0] - 2026-07-11
160
+
161
+ Initial release.
162
+
163
+ ### Added
164
+
165
+ - Shared `MemoryBackendAdapter` interface (`store()`/`query()`/`update()`) in
166
+ `src/memtrust/adapters/base.py`, plus `ConflictSignal` classification used by the
167
+ contradiction-detection eval.
168
+ - Four backend adapters: MemPalace, Mem0, Zep/Graphiti, OpenViking. Each reads its configuration
169
+ from a single environment variable and raises `BackendNotConfiguredError` (never crashes) when
170
+ it's missing. Confidence level per adapter documented in `docs/methodology.md`.
171
+ - Three eval runners: LongMemEval-style long-horizon recall, LoCoMo-style multi-session recall,
172
+ and memtrust's original multi-hop contradiction-detection eval (flagged / silently-overwrote /
173
+ served-stale / not-applicable).
174
+ - LLM-judge scoring pipeline (`scoring/llm_judge.py`), model-configurable via environment
175
+ variables, with a no-crash `NOT_RUN` fallback when no judge API key is configured.
176
+ - Cost tracker (`scoring/cost_tracker.py`) with a dated, approximate per-model pricing table.
177
+ - `memtrust run` and `memtrust report` CLI commands.
178
+ - Static leaderboard site (`leaderboard/index.html` + `leaderboard/data.json`) with a documented
179
+ schema, shipped as an example rather than fabricated live results.
180
+ - Full test suite: 57 tests, 95% overall coverage, 100% on `adapters/base.py`,
181
+ `evals/contradiction.py`, `evals/longmemeval.py`, and `scoring/`. All tests run fully offline.
182
+ - CI workflow: lint (ruff), type-check (mypy --strict), test (pytest + coverage across Python
183
+ 3.11-3.13), security (pip-audit).
184
+ - `docs/methodology.md`, `CONTRIBUTING.md`, `SECURITY.md`.
185
+
186
+ ### Known limitations (v0.1)
187
+
188
+ - Adapters for MemPalace and OpenViking are built against best-effort interpretations of
189
+ documented product concepts, not a confirmed API reference -- see the confidence table in
190
+ `docs/methodology.md`. They should be verified against a live instance before their output is
191
+ treated as authoritative.
192
+ - LongMemEval and LoCoMo eval runners ship against small, explicitly synthetic sample fixtures
193
+ matching each benchmark's real published schema, not the full public datasets.
194
+ - No live benchmark numbers are published in the README -- running the harness against real
195
+ backends requires vendor API keys not available at the time of this release. See the README's
196
+ "Benchmarks" section for exactly what was and wasn't measured.
@@ -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.
@@ -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.