agmem 0.1.2__py3-none-any.whl → 0.1.4__py3-none-any.whl

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 (48) hide show
  1. {agmem-0.1.2.dist-info → agmem-0.1.4.dist-info}/METADATA +144 -14
  2. {agmem-0.1.2.dist-info → agmem-0.1.4.dist-info}/RECORD +48 -28
  3. memvcs/cli.py +10 -0
  4. memvcs/commands/add.py +6 -0
  5. memvcs/commands/audit.py +59 -0
  6. memvcs/commands/clone.py +7 -0
  7. memvcs/commands/daemon.py +45 -0
  8. memvcs/commands/distill.py +24 -0
  9. memvcs/commands/federated.py +59 -0
  10. memvcs/commands/fsck.py +31 -0
  11. memvcs/commands/garden.py +22 -0
  12. memvcs/commands/gc.py +66 -0
  13. memvcs/commands/merge.py +55 -1
  14. memvcs/commands/prove.py +66 -0
  15. memvcs/commands/pull.py +27 -0
  16. memvcs/commands/resolve.py +130 -0
  17. memvcs/commands/timeline.py +27 -0
  18. memvcs/commands/verify.py +74 -23
  19. memvcs/commands/when.py +27 -0
  20. memvcs/core/audit.py +124 -0
  21. memvcs/core/compression_pipeline.py +157 -0
  22. memvcs/core/consistency.py +9 -9
  23. memvcs/core/crypto_verify.py +291 -0
  24. memvcs/core/distiller.py +47 -29
  25. memvcs/core/encryption.py +169 -0
  26. memvcs/core/federated.py +147 -0
  27. memvcs/core/gardener.py +47 -29
  28. memvcs/core/ipfs_remote.py +200 -0
  29. memvcs/core/knowledge_graph.py +77 -5
  30. memvcs/core/llm/__init__.py +10 -0
  31. memvcs/core/llm/anthropic_provider.py +50 -0
  32. memvcs/core/llm/base.py +27 -0
  33. memvcs/core/llm/factory.py +30 -0
  34. memvcs/core/llm/openai_provider.py +36 -0
  35. memvcs/core/merge.py +36 -23
  36. memvcs/core/objects.py +39 -19
  37. memvcs/core/pack.py +278 -0
  38. memvcs/core/privacy_budget.py +63 -0
  39. memvcs/core/remote.py +229 -3
  40. memvcs/core/repository.py +82 -2
  41. memvcs/core/temporal_index.py +9 -0
  42. memvcs/core/trust.py +103 -0
  43. memvcs/core/vector_store.py +15 -1
  44. memvcs/core/zk_proofs.py +158 -0
  45. {agmem-0.1.2.dist-info → agmem-0.1.4.dist-info}/WHEEL +0 -0
  46. {agmem-0.1.2.dist-info → agmem-0.1.4.dist-info}/entry_points.txt +0 -0
  47. {agmem-0.1.2.dist-info → agmem-0.1.4.dist-info}/licenses/LICENSE +0 -0
  48. {agmem-0.1.2.dist-info → agmem-0.1.4.dist-info}/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: agmem
3
- Version: 0.1.2
3
+ Version: 0.1.4
4
4
  Summary: Agentic Memory Version Control System - Git for AI agent memories
5
5
  Home-page: https://github.com/vivek-tiwari-vt/agmem
6
6
  Author: agmem Team
@@ -10,7 +10,7 @@ Project-URL: Homepage, https://github.com/vivek-tiwari-vt/agmem
10
10
  Project-URL: Documentation, https://github.com/vivek-tiwari-vt/agmem#readme
11
11
  Project-URL: Repository, https://github.com/vivek-tiwari-vt/agmem
12
12
  Project-URL: Bug Tracker, https://github.com/vivek-tiwari-vt/agmem/issues
13
- Keywords: ai,agent,memory,version-control,git,vcs,llm
13
+ Keywords: ai,agent,memory,version-control,git,vcs,llm,merkle,audit,encryption,differential-privacy,trust,multi-agent
14
14
  Classifier: Development Status :: 3 - Alpha
15
15
  Classifier: Intended Audience :: Developers
16
16
  Classifier: License :: OSI Approved :: MIT License
@@ -22,6 +22,7 @@ Classifier: Programming Language :: Python :: 3.11
22
22
  Classifier: Programming Language :: Python :: 3.12
23
23
  Classifier: Topic :: Software Development :: Version Control
24
24
  Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
25
+ Classifier: Topic :: Security :: Cryptography
25
26
  Requires-Python: >=3.8
26
27
  Description-Content-Type: text/markdown
27
28
  License-File: LICENSE
@@ -32,6 +33,10 @@ Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
32
33
  Requires-Dist: black==24.10.0; extra == "dev"
33
34
  Requires-Dist: flake8>=5.0.0; extra == "dev"
34
35
  Requires-Dist: mypy>=1.0.0; extra == "dev"
36
+ Requires-Dist: bandit[toml]>=1.7.0; extra == "dev"
37
+ Provides-Extra: llm
38
+ Requires-Dist: openai>=1.0.0; extra == "llm"
39
+ Requires-Dist: anthropic>=0.18.0; extra == "llm"
35
40
  Provides-Extra: mcp
36
41
  Requires-Dist: mcp>=1.0.0; extra == "mcp"
37
42
  Provides-Extra: vector
@@ -46,6 +51,8 @@ Requires-Dist: google-cloud-storage>=2.0.0; extra == "cloud"
46
51
  Provides-Extra: gardener
47
52
  Requires-Dist: scikit-learn>=1.3.0; extra == "gardener"
48
53
  Requires-Dist: openai>=1.0.0; extra == "gardener"
54
+ Provides-Extra: anthropic
55
+ Requires-Dist: anthropic>=0.18.0; extra == "anthropic"
49
56
  Provides-Extra: pii
50
57
  Requires-Dist: presidio-analyzer>=2.2.0; extra == "pii"
51
58
  Provides-Extra: daemon
@@ -58,8 +65,15 @@ Provides-Extra: distill
58
65
  Requires-Dist: openai>=1.0.0; extra == "distill"
59
66
  Provides-Extra: verify
60
67
  Requires-Dist: openai>=1.0.0; extra == "verify"
68
+ Provides-Extra: crypto
69
+ Requires-Dist: cryptography>=41.0.0; extra == "crypto"
70
+ Provides-Extra: ipfs
71
+ Requires-Dist: requests>=2.28.0; extra == "ipfs"
72
+ Provides-Extra: ipfs-daemon
73
+ Requires-Dist: ipfshttpclient>=0.8.0; extra == "ipfs-daemon"
61
74
  Provides-Extra: all
62
75
  Requires-Dist: mcp>=1.0.0; extra == "all"
76
+ Requires-Dist: cryptography>=41.0.0; extra == "all"
63
77
  Requires-Dist: sqlite-vec>=0.1.0; extra == "all"
64
78
  Requires-Dist: sentence-transformers>=2.0.0; extra == "all"
65
79
  Requires-Dist: fastapi>=0.100.0; extra == "all"
@@ -68,8 +82,12 @@ Requires-Dist: boto3>=1.34.0; extra == "all"
68
82
  Requires-Dist: google-cloud-storage>=2.0.0; extra == "all"
69
83
  Requires-Dist: scikit-learn>=1.3.0; extra == "all"
70
84
  Requires-Dist: openai>=1.0.0; extra == "all"
85
+ Requires-Dist: anthropic>=0.18.0; extra == "all"
71
86
  Requires-Dist: watchdog>=3.0.0; extra == "all"
72
87
  Requires-Dist: networkx>=3.0; extra == "all"
88
+ Requires-Dist: tiktoken>=0.5.0; extra == "all"
89
+ Requires-Dist: presidio-analyzer>=2.2.0; extra == "all"
90
+ Requires-Dist: requests>=2.28.0; extra == "all"
73
91
  Dynamic: author
74
92
  Dynamic: home-page
75
93
  Dynamic: license-file
@@ -105,10 +123,23 @@ agmem solves all of these problems with a familiar Git-like interface.
105
123
  - ✅ **Branch/tag names with `/`** — Git-style refs: `feature/test`, `releases/v1` (path-validated)
106
124
  - ✅ **Content-addressable storage** — SHA-256 deduplication like Git
107
125
  - ✅ **Memory-type-aware merging** — Episodic append, semantic consolidate, procedural prefer-new
108
- - ✅ **Remote (file://)** — `clone`, `push`, `pull`, `remote`; pull merges into current branch
126
+ - ✅ **Remote (file://)** — `clone`, `push`, `pull`, `remote`; pull merges into current branch; push conflict detection (non–fast-forward reject)
109
127
  - ✅ **Search** — Semantic with `agmem[vector]`, or plain text over `current/` when vector deps missing
110
128
  - ✅ **Knowledge graph** — `agmem graph` from wikilinks/tags; `--no-similarity`, `--format d3`, `--serve` (optional `agmem[web]`)
111
- - ✅ **Integrity** — `agmem fsck`; path/ref/hash validation throughout (no path traversal)
129
+ - ✅ **Integrity** — `agmem fsck` (objects, refs, vector store, Merkle/signature); `agmem verify --crypto`; path/ref/hash validation (no path traversal)
130
+ - ✅ **Cryptographic commit verification** — Merkle tree over blobs; Ed25519 signing of root; verify on checkout, pull, `verify`, `fsck`; Merkle proofs for single-blob verification
131
+ - ✅ **Encryption at rest** — Optional AES-256-GCM with Argon2id key derivation; hash-then-encrypt preserves deduplication
132
+ - ✅ **Tamper-evident audit trail** — Append-only hash-chained log (init, add, commit, checkout, merge, push, pull, config); `agmem audit` and `agmem audit --verify`
133
+ - ✅ **Multi-agent trust** — Trust store (full / conditional / untrusted) per public key; applied on pull/merge; clone copies remote keys
134
+ - ✅ **Conflict resolution** — `agmem resolve` with ours/theirs/both; conflicts persisted in `.mem/merge/`; path-safe
135
+ - ✅ **Differential privacy** — Epsilon/delta budget in `.mem/privacy_budget.json`; `--private` on `agmem distill` and `agmem garden`; noise applied to counts and frontmatter
136
+ - ✅ **Pack files & GC** — `agmem gc [--repack]` (reachable from refs, prune loose, optional pack file + index); ObjectStore reads from pack when loose missing
137
+ - ✅ **Multi-provider LLM** — OpenAI and Anthropic via `memvcs.core.llm`; config/repo or env; used by gardener, distiller, consistency, merge
138
+ - ✅ **Temporal querying** — Point-in-time and range queries in temporal index; frontmatter timestamps
139
+ - ✅ **Federated collaboration** — `agmem federated push|pull`; real summaries (topic counts, fact hashes); optional DP on outbound; coordinator API in docs/FEDERATED.md
140
+ - ✅ **Zero-knowledge proofs** — `agmem prove` (hash/signature-based): keyword containment (Merkle set membership), memory freshness (signed timestamp)
141
+ - ✅ **Daemon health** — Periodic Merkle verification in daemon loop; safe auto-remediation hooks
142
+ - ✅ **GPU acceleration** — Vector store detects GPU for embedding model when available
112
143
  - ✅ **Optional** — `serve`, `daemon` (watch + auto-commit), `garden` (episode archival), MCP server; install extras as needed
113
144
 
114
145
  ## Quick Start
@@ -227,12 +258,18 @@ All commands are listed below. Highlights: **`agmem blame <file>`** (who changed
227
258
 
228
259
  | Command | Description |
229
260
  |---------|-------------|
230
- | `agmem clone <url> [dir]` | Clone repo (file:// URLs); path-validated |
261
+ | `agmem clone <url> [dir]` | Clone repo (file:// URLs); path-validated; copies remote public keys |
231
262
  | `agmem remote add <name> <url>` | Add remote |
232
263
  | `agmem remote show` | List remotes |
233
- | `agmem push <remote> <branch>` | Push branch (refs validated) |
234
- | `agmem pull [--remote <name>] [--branch <b>]` | Fetch and merge into current branch |
235
- | `agmem fsck` | Check objects, refs, optional vector store |
264
+ | `agmem push <remote> <branch>` | Push branch (refs validated); rejects non–fast-forward |
265
+ | `agmem pull [--remote <name>] [--branch <b>]` | Fetch and merge into current branch; optional crypto/trust checks |
266
+ | `agmem fsck` | Check objects, refs, optional vector store, Merkle roots and signatures |
267
+ | `agmem verify [ref]` | Belief consistency (contradictions); use `--crypto` to verify commit Merkle/signature |
268
+ | `agmem audit [--verify] [--max n]` | Show tamper-evident audit log; `--verify` checks hash chain |
269
+ | `agmem resolve [path]` | Resolve merge conflicts (ours/theirs/both); path under `current/` |
270
+ | `agmem gc [--dry-run] [--repack] [--prune-days n]` | Garbage collection: delete unreachable loose objects; optional pack file creation |
271
+ | `agmem prove --memory <path> --property keyword\|freshness --value <v> [-o out]` | Generate ZK proofs (keyword: Merkle set membership; freshness: signed timestamp) |
272
+ | `agmem federated push\|pull` | Federated collaboration (real summaries, optional DP; requires coordinator in config) |
236
273
 
237
274
  ### Optional (install extras)
238
275
 
@@ -301,7 +338,84 @@ Configure in `.mem/config.json` (e.g. `archive_dir`, consolidation thresholds).
301
338
  agmem fsck
302
339
  ```
303
340
 
304
- Verifies objects, refs, and (if installed) the vector store. Run after cloning or if something looks wrong.
341
+ Verifies objects, refs, and (if installed) the vector store. When commit metadata includes `merkle_root` and optionally `signature`, fsck also runs cryptographic verification. Run after cloning or if something looks wrong.
342
+
343
+ ---
344
+
345
+ ## Security, trust & advanced features
346
+
347
+ The following 18 capabilities are implemented (or stubbed) per the agmem features implementation plan. They are grouped by tier.
348
+
349
+ ### Tier 1 — Security and trust
350
+
351
+ | # | Feature | Description |
352
+ |---|---------|-------------|
353
+ | **1** | **Cryptographic commit verification** | Merkle tree over commit blobs; Ed25519 signing of Merkle root; verification on checkout, pull, `agmem verify --crypto`, and `agmem fsck`. Merkle proofs for single-blob verification. Keys: `.mem/keys/`; private key from env `AGMEM_SIGNING_PRIVATE_KEY` or `AGMEM_SIGNING_PRIVATE_KEY_FILE`. Old commits without `merkle_root` are unverified. |
354
+ | **2** | **Encryption at rest** | Optional AES-256-GCM for object contents; key from passphrase via Argon2id; hash-then-encrypt preserves deduplication. Config in `.mem/encryption.json` or repo config; opt-in. |
355
+ | **3** | **Tamper-evident audit trail** | Append-only, hash-chained log in `.mem/audit/` for init, add, commit, checkout, merge, push, pull, config. **Commands:** `agmem audit` (show entries), `agmem audit --verify` (verify chain). |
356
+
357
+ ### Tier 2 — Multi-agent collaboration
358
+
359
+ | # | Feature | Description |
360
+ |---|---------|-------------|
361
+ | **4** | **Multi-agent trust and identity** | Trust store (full / conditional / untrusted) per public key; applied on pull and merge. Clone copies remote public keys; user adds them to trust store. Identity = keypair (same as commit signing). |
362
+ | **5** | **Federated memory collaboration** | Agents share summaries or aggregated updates via a coordinator. **Command:** `agmem federated push` / `agmem federated pull` (stub). Config: `federated.enabled`, `coordinator_url`. |
363
+ | **6** | **Conflict resolution interface** | Structured resolution: ours / theirs / both per path. **Command:** `agmem resolve [path]`. Conflicts persisted in `.mem/merge/conflicts.json`; path traversal protected. |
364
+
365
+ ### Tier 3 — Privacy
366
+
367
+ | # | Feature | Description |
368
+ |---|---------|-------------|
369
+ | **7** | **Differential privacy** | Epsilon/delta budget per repo in `.mem/privacy_budget.json`. **Usage:** `agmem distill --private`, `agmem garden --private`; blocks when budget exceeded. Config: `differential_privacy.max_epsilon`, `delta`. |
370
+ | **8** | **Zero-knowledge proofs** | zk-SNARK-style proofs for keyword containment and memory freshness. **Command:** `agmem prove --memory <path> --property keyword|freshness --value <v> [-o out]` (stub). |
371
+
372
+ ### Tier 4 — Storage and distribution
373
+
374
+ | # | Feature | Description |
375
+ |---|---------|-------------|
376
+ | **9** | **Decentralized storage (IPFS)** | Push/pull via gateway (POST /api/v0/add, GET /ipfs/<cid>). Bundle/unbundle in `memvcs.core.ipfs_remote`; optional `agmem[ipfs]`. |
377
+ | **10** | **Pack files and garbage collection** | Pack loose objects into pack file + index; GC deletes unreachable; ObjectStore reads from pack. **Command:** `agmem gc [--dry-run] [--repack] [--prune-days n]`. |
378
+ | **11** | **Enhanced cloud remote operations** | Push conflict detection; S3/GCS remotes with distributed locking (acquire before push/fetch, release in finally). Config: `lock_table` for S3. |
379
+
380
+ ### Tier 5 — Intelligence and retrieval
381
+
382
+ | # | Feature | Description |
383
+ |---|---------|-------------|
384
+ | **12** | **Multi-provider LLM** | `memvcs.core.llm`: OpenAI and Anthropic; factory by config or env. Used by gardener, distiller, consistency checker, merge. Credentials via env (e.g. `OPENAI_API_KEY`, `ANTHROPIC_API_KEY`). |
385
+ | **13** | **Enhanced semantic compression** | Multi-stage pipeline in `memvcs.core.compression_pipeline`: chunk, fact extraction, dedup by hash; hybrid retrieval in strategies. |
386
+ | **14** | **Temporal querying and time-travel** | Point-in-time and range in `memvcs.core.temporal_index`; CLI: `agmem when --from/--to`, `agmem timeline --from/--to`. |
387
+ | **15** | **Cross-memory relationship graph** | Knowledge graph: co-occurrence, causal edges; incremental-update docstring in `knowledge_graph.py`. |
388
+
389
+ ### Tier 6 — Operations and maintenance
390
+
391
+ | # | Feature | Description |
392
+ |---|---------|-------------|
393
+ | **16** | **Automated memory health monitoring** | Daemon: configurable `daemon.health_check_interval_seconds` and `AGMEM_DAEMON_HEALTH_INTERVAL`; alert only on verify failure; suggest `agmem fsck`. |
394
+ | **17** | **GPU-accelerated operations** | Vector store `_device()` returns cuda/mps/cpu; model loaded with that device. |
395
+ | **18** | **Test suite and quality** | Tests: crypto (tampered blob, key missing), encryption (wrong key, corrupted ciphertext), privacy budget, pack/GC, ZK prove/verify, federated mock, IPFS bundle; see docs/TEST_REPORT.md. |
396
+
397
+ ### New files and config (summary)
398
+
399
+ | Addition | Purpose |
400
+ |----------|---------|
401
+ | `memvcs/core/crypto_verify.py` | Merkle build/verify, Ed25519 sign/verify, Merkle proofs |
402
+ | `memvcs/core/audit.py` | Tamper-evident audit append and verify |
403
+ | `memvcs/core/trust.py` | Trust store (key → level) |
404
+ | `memvcs/core/privacy_budget.py` | Epsilon/delta budget for DP |
405
+ | `memvcs/core/pack.py` | Pack format, index, GC, repack |
406
+ | `memvcs/core/compression_pipeline.py` | Chunk, fact extraction, dedup; hybrid retrieval |
407
+ | `memvcs/core/zk_proofs.py` | Hash/signature-based proofs (keyword, freshness) |
408
+ | `docs/FEDERATED.md` | Coordinator API for federated push/pull |
409
+ | `memvcs/core/encryption.py` | AES-256-GCM, Argon2id, config |
410
+ | `memvcs/core/llm/` | LLM provider interface and OpenAI/Anthropic |
411
+ | `memvcs/core/zk_proofs.py` | ZK proof stubs |
412
+ | `memvcs/core/federated.py` | Federated push/pull stubs |
413
+ | `.mem/audit/` | Audit log |
414
+ | `.mem/keys/` | Public (and optional private) keys |
415
+ | `.mem/trust/` or config | Trust store |
416
+ | `.mem/privacy_budget.json` | DP budget state |
417
+ | `.mem/merge/conflicts.json` | Unresolved merge conflicts |
418
+ | Commit `metadata` | `merkle_root`, `signature` |
305
419
 
306
420
  ---
307
421
 
@@ -450,10 +564,20 @@ Repository configuration is stored in `.mem/config.json`:
450
564
  "summarizer_model": "default",
451
565
  "max_episode_size": 1048576,
452
566
  "consolidation_threshold": 100
567
+ },
568
+ "differential_privacy": {
569
+ "max_epsilon": 1.0,
570
+ "delta": 1e-5
571
+ },
572
+ "federated": {
573
+ "enabled": false,
574
+ "coordinator_url": ""
453
575
  }
454
576
  }
455
577
  ```
456
578
 
579
+ Optional sections: **`differential_privacy`** (for `--private` on distill/garden); **`federated`** (for `agmem federated`); **`signing`** (public key for commit verification); trust store under `.mem/trust/` or config; encryption in `.mem/encryption.json` when enabled.
580
+
457
581
  ### agmem config (cloud and PII)
458
582
 
459
583
  Optional user/repo config for S3/GCS and PII hooks:
@@ -515,13 +639,17 @@ mypy memvcs/
515
639
  - [x] Basic commands (init, add, commit, status, log, diff, show, reset, tag, stash, reflog, blame, tree, clean)
516
640
  - [x] HEAD~n resolution; branch/tag names with `/` (Git-style)
517
641
  - [x] Branching and checkout; merging with memory-type-aware strategies
518
- - [x] Remote operations (clone, push, pull, remote) — file:// URLs; pull merges into current branch
642
+ - [x] Remote operations (clone, push, pull, remote) — file:// URLs; pull merges into current branch; push conflict detection
519
643
  - [x] Search — semantic with `agmem[vector]`, plain text fallback
520
644
  - [x] Knowledge graph (`agmem graph`) — wikilinks, tags, optional similarity; `--no-similarity`, `--serve`
521
- - [x] Integrity (`agmem fsck`); path/ref/hash validation (security)
645
+ - [x] Integrity (`agmem fsck`); path/ref/hash validation; Merkle/signature verification
522
646
  - [x] Web UI (`agmem serve`); MCP server (`agmem mcp`); daemon (`agmem daemon`); garden (`agmem garden`)
523
- - [ ] Garbage collection
524
- - [ ] Pack files for efficiency
647
+ - [x] Cryptographic commit verification (Merkle tree, Ed25519 signing, verify on checkout/pull/fsck)
648
+ - [x] Tamper-evident audit trail (`agmem audit`); multi-agent trust store; conflict resolution (`agmem resolve`)
649
+ - [x] Encryption at rest (optional AES-256-GCM); differential privacy budget (`--private` on distill/garden)
650
+ - [x] Pack files and garbage collection (`agmem gc`); ZK proofs and federated stubs (`agmem prove`, `agmem federated`)
651
+ - [x] Multi-provider LLM (OpenAI, Anthropic); temporal range queries; daemon health checks; GPU detection; test suite and CI
652
+ - [ ] IPFS remote (stub in place); full ZK circuits and federated coordinator
525
653
 
526
654
  ## Integrations
527
655
 
@@ -614,8 +742,10 @@ agmem graph --serve # Serve knowledge graph UI (same extra)
614
742
 
615
743
  - **Full history:** `agmem log`, `agmem reflog`
616
744
  - **Line-level attribution:** `agmem blame <file>` — see which commit and author last changed each line (e.g. `agmem blame current/semantic/user-preferences.md`)
745
+ - **Tamper-evident audit:** `agmem audit` and `agmem audit --verify` for hash-chained operation log
746
+ - **Cryptographic verification:** `agmem verify --crypto` and `agmem fsck` for Merkle roots and Ed25519 signatures
617
747
  - **Visual audit:** `agmem serve` for browser-based history and diff viewer
618
- - **Integrity:** `agmem fsck` to verify objects and refs
748
+ - **Integrity:** `agmem fsck` to verify objects, refs, and commit signatures
619
749
 
620
750
  ## Ecosystem Plugin Patterns
621
751
 
@@ -1,34 +1,39 @@
1
- agmem-0.1.2.dist-info/licenses/LICENSE,sha256=X_S6RBErW-F0IDbM3FAEoDB-zxExFnl2m8640rTXphM,1067
1
+ agmem-0.1.4.dist-info/licenses/LICENSE,sha256=X_S6RBErW-F0IDbM3FAEoDB-zxExFnl2m8640rTXphM,1067
2
2
  memvcs/__init__.py,sha256=mXwHTSlUPWo4ERqJLGJnxmxtGQQHPSbXb4IpO61l04M,193
3
- memvcs/cli.py,sha256=0bIdOVz23ZON4i8LoAsepiII-DpiGTGysllXFwmG0GI,5771
3
+ memvcs/cli.py,sha256=YF06oMNjKWUmiNahILmfjrIXgoXzU-5BJFmbunSb8Sc,6075
4
4
  memvcs/commands/__init__.py,sha256=A2D6xWaO6epU7iV4QSvqvF5TspnwRyDN7NojmGatPrE,510
5
- memvcs/commands/add.py,sha256=5Bia5nLfaREyp-ujqReDOyZu6zF5WveQk_N8XkWmqnM,8511
5
+ memvcs/commands/add.py,sha256=k9eM7qf2NFvneiJkFQNiAYFB2GgKmyPw_NXmkCxblQE,8736
6
+ memvcs/commands/audit.py,sha256=E6m54B726tqDQR3rrgRXWrjE-seu2UocqrFxN1aHkY4,1680
6
7
  memvcs/commands/base.py,sha256=yWvIYuofRxbHXvChlSd_DL_hJMaQdbZwa2XBDWj5Bio,634
7
8
  memvcs/commands/blame.py,sha256=2tEXyXpAebm_zQFAyw-6d3K09Lnh1GVLYGp6htlEmI0,5605
8
9
  memvcs/commands/branch.py,sha256=ghsK4tnGe7XApxQSgou7V0BASBC8PL8nQs_yBt0notQ,3150
9
10
  memvcs/commands/checkout.py,sha256=xaYZSbCQ-MyLWPtwA2FdH6WqGMI3oF3R2JmCufGBVFg,3182
10
11
  memvcs/commands/clean.py,sha256=e0OhSQdHfFnOPTRbyKbM8IcX4yJD5n_kaBKjIeoaRBo,1973
11
- memvcs/commands/clone.py,sha256=EAeojcUpRyCj1tVLR5zqnbkdF6Cvpza0_gyjZoCHysw,2895
12
+ memvcs/commands/clone.py,sha256=aB0LcugIWJE9IEez6y70KlpZu4eIF2EdXZxE24jXyac,3260
12
13
  memvcs/commands/commit.py,sha256=W4ulVZuEETJh1SHpscaQfNjyQMqeIE0AYZIbMbTrsq4,6801
13
- memvcs/commands/daemon.py,sha256=B9_a7DFXMde9Fphpo7J9-osXqYCby-KfvITObJ3VqIo,8589
14
+ memvcs/commands/daemon.py,sha256=KM9XSCdm4-aVBi4flKjiefpG8SfSrYl10phoMpz0gyk,10707
14
15
  memvcs/commands/decay.py,sha256=QcgOTMJZxrfw_AOz94YHA3LGoNXRMDn69TxWlUrpSw4,2421
15
16
  memvcs/commands/diff.py,sha256=KcgD57_fae4uvQ8G9ZbXmLpAYYIDiWiBuVcjsDtyE1U,5480
16
- memvcs/commands/distill.py,sha256=Inl6igvjewGTT1L4nH48PIi8_oUtlFgJwq1gUTosI9E,2171
17
- memvcs/commands/fsck.py,sha256=PQWEoqmGKhjZEEMYBf1pnORz8j-YaOLFojmQkND3m3Q,6545
18
- memvcs/commands/garden.py,sha256=0ZbohharxBC6-n1Y2Cgpyfpwuzlq_vmWi3Yu0pQRQBA,3269
17
+ memvcs/commands/distill.py,sha256=reOldqg0lMgqIlpYEIKYfN_TxNwsjU9RnI8Uah1VqTQ,3088
18
+ memvcs/commands/federated.py,sha256=Zj4kxHnjdIs1xu4v7B8XosQXNYK8Alv4I0kJQpmJe6Y,1840
19
+ memvcs/commands/fsck.py,sha256=AdJBMLA2myQ0cJJcjUgsYptsE3qvX4JQc9UAwVmSHlA,7772
20
+ memvcs/commands/garden.py,sha256=8JiLe3JRkOhY-N-h-IDuvdJiECiSElnUzXVtxtU2QgY,4050
21
+ memvcs/commands/gc.py,sha256=vLGREkcHjR_rDvTvEh-dwNkAeTB9y4fU-BwBGbXOEg4,1940
19
22
  memvcs/commands/graph.py,sha256=MDi6bK2w0OrpK5VOE8XXw5gQX7BuD7VzUyqJ5Ra9Bsg,4746
20
23
  memvcs/commands/init.py,sha256=TsrLFLXwkDFT0opsYJTfwu0NIxLrNiiba5SpzRtxjDI,1614
21
24
  memvcs/commands/log.py,sha256=eNlLs0-PS2nF0pMAMI8izKGUiEb2m3S0RB4Zh6cUQpE,2859
22
25
  memvcs/commands/mcp.py,sha256=PMfwVD6uHltN58Jh7IOiS1w7oND42tg14QKRCJNudmY,1740
23
- memvcs/commands/merge.py,sha256=kB9bXBagZrZYz1mozVGwelMTJ3ATm9QyINrE90FhXhA,2417
26
+ memvcs/commands/merge.py,sha256=s3QLZp-_I6OvhllLhL9yFZAQ8d4M4FbvxkXV7gUgw5M,4877
24
27
  memvcs/commands/pack.py,sha256=rIDjMpxJG0oxrWnB3vCGHqviCITIeIbdy3nhuHVHzM8,3629
25
- memvcs/commands/pull.py,sha256=qeEtBEuXo-BLsOqBU146V2lUK1WrCNp1d8z6qqWhhyU,2113
28
+ memvcs/commands/prove.py,sha256=qQYYV5GdLd0Av4pwaxNvUCcl5pmiBwCrlXJwRtXVCF4,2141
29
+ memvcs/commands/pull.py,sha256=hn9FIlNc3KUr5EUDo4_66KQSK0BSSXjOn32xaDNxf0Q,3621
26
30
  memvcs/commands/push.py,sha256=0abEdHkCMfHpH_Nmlw3OaU7Hzi0-RXF-cTVHpiSPw6k,5086
27
31
  memvcs/commands/recall.py,sha256=7nwC4mFYpdjKWG-Cs3cpDLr5_SgYJ6HkVSXDOkFke5A,4592
28
32
  memvcs/commands/reflog.py,sha256=j8Rxw_4jZuldS1k1g3wF2EItmPxBEmogWcbccOZrGkw,1117
29
33
  memvcs/commands/remote.py,sha256=4PXDZjoU4YA4IbGrn_1KbFVCSVxVB_pVdI2nIn1NSbw,1761
30
34
  memvcs/commands/repair.py,sha256=OBVa30Zc9rOjUw2GoiSAC6iZrnuCZN_J8nHpCnk5BzM,2312
31
35
  memvcs/commands/reset.py,sha256=3TG7qOu2k1uji-TdSyXsdZ6LV2wqc2MB8aSJ6q71IGk,2778
36
+ memvcs/commands/resolve.py,sha256=SFjCCYlcBqP9pjykWIPrDivtk_714VhsWl1Vt7gjyfM,4093
32
37
  memvcs/commands/resurrect.py,sha256=zi4ErN1jWVCn8I5rV4g_Dlbg1YadGEU6Xhc7srzlwfg,2503
33
38
  memvcs/commands/search.py,sha256=NOMbkQmVurQ-_d7bZVf9vjOH6OgVPeErqpLZiSxsvBA,5322
34
39
  memvcs/commands/serve.py,sha256=n8DroVRIQVm5UO2-o-9JU17pQYF-HYOMIJKycdRcBMs,1408
@@ -37,32 +42,47 @@ memvcs/commands/stash.py,sha256=CD3mRWehcmfVRPGGpndUBdTT_ku4LC_rmSKPvTEOTAo,3193
37
42
  memvcs/commands/status.py,sha256=O6BgzTiW3UHjXx6OKwH8X4g0hP0IlYDgr7As5RmeujU,3447
38
43
  memvcs/commands/tag.py,sha256=CaCnA3JifVrdr8DfX4g0bp-_oRvagJkQFcI4bJbW1uM,3004
39
44
  memvcs/commands/test.py,sha256=HZrpGZQhu9HnGZLjiq8TXi8jfOZqP-wc3bW6mgpP2yk,3926
40
- memvcs/commands/timeline.py,sha256=xdOr2jz-_ArSPY-GxwXBloiwhfBzIfz4MAi-JEhP8H0,3666
45
+ memvcs/commands/timeline.py,sha256=hH4kqd0cHbdtnjMrr_Sw6lt0kmu0yEVctHGOQ2iYK5s,4763
41
46
  memvcs/commands/tree.py,sha256=vdULq4vIXA_4gNfMnHn_Y78BwE0sJoeTBOnFJR3WsZ4,4927
42
- memvcs/commands/verify.py,sha256=aH0FN_7xRulRV2oSLYSB4BiAw_U81IkZ5sFdBRmxdZ0,1858
43
- memvcs/commands/when.py,sha256=MMQ15PFXFCTmjIq7dr0tC0XvGAdndMvckVnnWehc60Y,3692
47
+ memvcs/commands/verify.py,sha256=04CVW5NYWkUlPJ5z1Kci6dfQFM6UmPTGZh9ZextFLMc,3887
48
+ memvcs/commands/when.py,sha256=gbSQHk96zu4TiH1QIdQJUeSsy9WFbjaheh5jjTsGopw,4772
44
49
  memvcs/core/__init__.py,sha256=dkIC-4tS0GhwV2mZIbofEe8xR8uiFwrxslGf1aXwhYg,493
45
50
  memvcs/core/access_index.py,sha256=HhacnzSUASzRV2jhDHkwRFoPS3rtqh9n9yE1VV7JXpk,5596
51
+ memvcs/core/audit.py,sha256=8APkm9Spl_-1rIdyRQz1elyxOeK3nlpwm0CLkpLlhTE,3732
52
+ memvcs/core/compression_pipeline.py,sha256=ejFXBTHfBYbCD86a5V0-0wA39K-SBG7dt09oAy-XP5s,5481
46
53
  memvcs/core/config_loader.py,sha256=j-jgLDp2TRzWN9ZEZebfWSfatevBNYs0FEb3ud1SIR8,8277
47
- memvcs/core/consistency.py,sha256=JUUlrGB8b2DMmozoP7KFNqd6nSLzKDZaHGbYyKlK_l8,7464
54
+ memvcs/core/consistency.py,sha256=YOG8xhqZLKZCLbai2rdcP0KxYPNGFv5RRMwrQ6qCeyc,7462
48
55
  memvcs/core/constants.py,sha256=WUjAb50BFcF0mbFi_GNteDLCxLihmViBm9Fb-JMPmbM,220
56
+ memvcs/core/crypto_verify.py,sha256=-yphuOE4bP-V1_bpMfNnJTLtpAdtKq8OV2hNUlUxiwk,10432
49
57
  memvcs/core/decay.py,sha256=ROGwnqngs7eJNkbKmwyOdij607m73vpmoJqzrIDLBzk,6581
50
58
  memvcs/core/diff.py,sha256=koEHTLciIUxYKVJVuvmY0GDXMgDgGZP_qg5RayhF-iE,13226
51
- memvcs/core/distiller.py,sha256=QBoTz3xFVepwGHOXVuIr5qfln2tkNo1CtcBpKIjsnqc,10337
52
- memvcs/core/gardener.py,sha256=bFMyHU5H5-rYZIahT8j14ZOvBs5LSVhYZiTbyw7SQl4,16080
59
+ memvcs/core/distiller.py,sha256=859NUR3gzYQuvDFxMtGB2NcTGRmRj4VJyOZTlDKvSzI,11683
60
+ memvcs/core/encryption.py,sha256=epny_nlW6ylllv1qxs1mAcFq-PrLIisgfot4llOoAqw,5289
61
+ memvcs/core/federated.py,sha256=RRNzhDVahTM-XQanT__8IBfGsS6fPDbq40b4v327iHg,5374
62
+ memvcs/core/gardener.py,sha256=YKw4amhlPrX34gvg71PNUWmERUhrqvhrCuHnOj229gs,17462
53
63
  memvcs/core/hooks.py,sha256=XF9z8J5sWjAcuOyWQ2nuvEzK0UV8s4ThrcltaBZttzw,5448
54
- memvcs/core/knowledge_graph.py,sha256=fjDZ-68tUHA6AZcn-p0d32r8X3SyrMME1OyuRPxtI_0,12875
55
- memvcs/core/merge.py,sha256=eBdPd8loe7G6F8C3fMNdnm_kvlKgZ4JC5z4xnboteOI,19165
56
- memvcs/core/objects.py,sha256=zlTcNHc3ehFnLm0UoI1Ct2gw5CU4moaRLhN8hZXm3p4,9943
64
+ memvcs/core/ipfs_remote.py,sha256=1Xob0Tiz0-GevgQrBhwUBifnVLO8U0dUIlvJS88BMBk,6651
65
+ memvcs/core/knowledge_graph.py,sha256=6UuSdkaaXQnVti9TK10ak_KeCn8apLOgB70GXN_1I-Q,16370
66
+ memvcs/core/merge.py,sha256=x2eSaxr4f63Eq00FCJ6DDe2TZU8H5yHQpzKzMhYsaFw,19871
67
+ memvcs/core/objects.py,sha256=G6EigwJI0c9NZ9LB36L-3beNYt_MwETNgbtwnrptqMA,11004
68
+ memvcs/core/pack.py,sha256=SiEReq9EMzffd3trnc38REWrh5Vo5HAmErovNgsx01U,9749
57
69
  memvcs/core/pii_scanner.py,sha256=T6gQ1APFrSDk980fjnv4ZMF-UztbJgmUFSwGrwWixEw,10802
70
+ memvcs/core/privacy_budget.py,sha256=fOPlxoKEAmsKtda-OJCrSaKjTyw7ekcqdN7KfRBw1CY,2113
58
71
  memvcs/core/refs.py,sha256=4Nx2ZVRa_DzfUZ4O1AwzOHEjoGAEICJKqSd9GxaiD_g,16754
59
- memvcs/core/remote.py,sha256=MhQTfxpzmH0mAMb7hoQJrTOAoqX0tqZxx1Yq5Q5niS8,10117
60
- memvcs/core/repository.py,sha256=fu6ZxkF3RY7yV1FHRQ2gVOpxkwJzeffna2sZixd8puI,17894
72
+ memvcs/core/remote.py,sha256=HmGXx-NZFw7wgf0rHcwmGOQSWUoHNP85RHP5UaUDuuE,19429
73
+ memvcs/core/repository.py,sha256=NzC2UFPv6ePxi5lfiSKyZFLclH4bJpWJz88pY7tDiv4,20605
61
74
  memvcs/core/schema.py,sha256=_CrEWCdArc0yDJ04GT7fyvjHqkal7gegdFSsFOjVpBc,15287
62
75
  memvcs/core/staging.py,sha256=dptdGi_74lhDkcGqGVU39ZyTkb25j-Rnkz0GWi83W1k,7221
63
- memvcs/core/temporal_index.py,sha256=OmgfznlScItVf2sML7JOj_WaGtKJZMIsP818YKUlMAw,3554
76
+ memvcs/core/temporal_index.py,sha256=81hZHlVElp2UpXjseFVCdDUwxGM45zIU-y1dDlOhFHI,4012
64
77
  memvcs/core/test_runner.py,sha256=7-0jCvji63JRbVfy3LNQWIQ7VL5weulOoG7SY1-YJbw,11496
65
- memvcs/core/vector_store.py,sha256=JqyiPbznxEkuD1CIna5DKm0PwrlQ4tVARJpt6W0mESE,10599
78
+ memvcs/core/trust.py,sha256=msx80Cl3bxyQTY8mFUKWY9P6l3zb1s8FafympgHwtpo,3494
79
+ memvcs/core/vector_store.py,sha256=yUAp5BlaAtjkrtsdY1I-vmAp_YIFgJykBoNlp5hcg0I,11063
80
+ memvcs/core/zk_proofs.py,sha256=dnwMqhGtzDQtaNuO1bhuLchqYyEDnXzbtd-jQH_M0qQ,5512
81
+ memvcs/core/llm/__init__.py,sha256=vnjtE9Xlv9a2pZV88DMT9JaINkZ30hC9VLPL5lJRlps,236
82
+ memvcs/core/llm/anthropic_provider.py,sha256=O1eaCb9r464ajLJz-Gy8lGxBie5ojRUZ_5HdgRXO5KY,1540
83
+ memvcs/core/llm/base.py,sha256=qPzg3KPAMeoyWGc_2JoVR4-plpdft5Rc2g9uO-Z4fJQ,623
84
+ memvcs/core/llm/factory.py,sha256=sRl4XiAHs1eReXjCdwYLvbjUaIxdfQZV93hiME-i8j8,912
85
+ memvcs/core/llm/openai_provider.py,sha256=hGOdEPWf96zP7PqC5FzwISXoNDvLSOXCHJjbRj2HgI8,885
66
86
  memvcs/core/storage/__init__.py,sha256=yJE7bm5G7VlFLpSVFrrTkP4eOyQlWRPfBvEP9T5PW44,1901
67
87
  memvcs/core/storage/base.py,sha256=IK4To8Cb-LHv5ltlaQLdB6LE-69euFK3hNqBtMCe7-g,9956
68
88
  memvcs/core/storage/gcs.py,sha256=-cWuGw1jkFh-Xig-Abmwr9HGwjW5lWQJuF2xcAR1l78,10632
@@ -79,8 +99,8 @@ memvcs/retrieval/recaller.py,sha256=8KY-XjMUz5_vcKf46zI64uk1DEM__u7wM92ShukOtsY,
79
99
  memvcs/retrieval/strategies.py,sha256=26yxQQubQfjxWQXknfVMxuzPHf2EcZxJg_B99BEdl5c,11458
80
100
  memvcs/utils/__init__.py,sha256=8psUzz4Ntv2GzbRebkeVsoyC6Ck-FIwi0_lfYdj5oho,185
81
101
  memvcs/utils/helpers.py,sha256=37zg_DcQ2y99b9NSLqxFkglHe13rJXKhFDpEbQ7iLhM,4121
82
- agmem-0.1.2.dist-info/METADATA,sha256=uIzEeVVPQ36Kdy0NQ0ygJS9pvMSglfYSTo_oNjG5TsM,26608
83
- agmem-0.1.2.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
84
- agmem-0.1.2.dist-info/entry_points.txt,sha256=at7eWycgjqOo1wbUMECnXUsNo3gpCkJTU71OzrGLHu0,42
85
- agmem-0.1.2.dist-info/top_level.txt,sha256=HtMMsKuwLKLOdgF1GxqQztqFM54tTJctVdJuOec6B-4,7
86
- agmem-0.1.2.dist-info/RECORD,,
102
+ agmem-0.1.4.dist-info/METADATA,sha256=IU1QZw4zdsUApbsgLUvoh8BNBtbOc3AeSUINr1GSx80,37487
103
+ agmem-0.1.4.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
104
+ agmem-0.1.4.dist-info/entry_points.txt,sha256=at7eWycgjqOo1wbUMECnXUsNo3gpCkJTU71OzrGLHu0,42
105
+ agmem-0.1.4.dist-info/top_level.txt,sha256=HtMMsKuwLKLOdgF1GxqQztqFM54tTJctVdJuOec6B-4,7
106
+ agmem-0.1.4.dist-info/RECORD,,
memvcs/cli.py CHANGED
@@ -58,6 +58,11 @@ from .commands.decay import DecayCommand
58
58
  from .commands.resurrect import ResurrectCommand
59
59
  from .commands.verify import VerifyCommand
60
60
  from .commands.repair import RepairCommand
61
+ from .commands.audit import AuditCommand
62
+ from .commands.federated import FederatedCommand
63
+ from .commands.resolve import ResolveCommand
64
+ from .commands.prove import ProveCommand
65
+ from .commands.gc import GcCommand
61
66
 
62
67
 
63
68
  # List of available commands
@@ -100,6 +105,11 @@ COMMANDS = [
100
105
  ResurrectCommand,
101
106
  VerifyCommand,
102
107
  RepairCommand,
108
+ AuditCommand,
109
+ FederatedCommand,
110
+ ResolveCommand,
111
+ ProveCommand,
112
+ GcCommand,
103
113
  ]
104
114
 
105
115
 
memvcs/commands/add.py CHANGED
@@ -198,6 +198,12 @@ class AddCommand:
198
198
  print(f"Rejected {rejected_count} file(s) - use --force to override")
199
199
  if staged_count > 0:
200
200
  print("Run 'agmem commit -m \"message\"' to save snapshot")
201
+ try:
202
+ from ..core.audit import append_audit
203
+
204
+ append_audit(repo.mem_dir, "add", {"staged_count": staged_count})
205
+ except Exception:
206
+ pass
201
207
  else:
202
208
  print("No files staged")
203
209
 
@@ -0,0 +1,59 @@
1
+ """
2
+ agmem audit - Tamper-evident audit trail.
3
+
4
+ Read and verify the append-only audit log.
5
+ """
6
+
7
+ import argparse
8
+
9
+ from ..commands.base import require_repo
10
+ from ..core.audit import read_audit, verify_audit
11
+
12
+
13
+ class AuditCommand:
14
+ """Show and verify the tamper-evident audit log."""
15
+
16
+ name = "audit"
17
+ help = "Show and verify the tamper-evident audit log"
18
+
19
+ @staticmethod
20
+ def add_arguments(parser: argparse.ArgumentParser):
21
+ parser.add_argument(
22
+ "-n",
23
+ "--max",
24
+ type=int,
25
+ default=50,
26
+ metavar="N",
27
+ help="Show at most N entries (default 50)",
28
+ )
29
+ parser.add_argument(
30
+ "--verify",
31
+ action="store_true",
32
+ help="Verify the audit chain and report first tampering point",
33
+ )
34
+
35
+ @staticmethod
36
+ def execute(args) -> int:
37
+ repo, code = require_repo()
38
+ if code != 0:
39
+ return code
40
+
41
+ if args.verify:
42
+ valid, first_bad = verify_audit(repo.mem_dir)
43
+ if valid:
44
+ print("Audit log chain is valid.")
45
+ return 0
46
+ print(f"Audit log chain invalid at entry index {first_bad}.")
47
+ return 1
48
+
49
+ entries = read_audit(repo.mem_dir, max_entries=args.max)
50
+ if not entries:
51
+ print("No audit entries.")
52
+ return 0
53
+ for e in entries:
54
+ ts = e.get("timestamp", "")
55
+ op = e.get("operation", "")
56
+ details = e.get("details", {})
57
+ detail_str = " ".join(f"{k}={v}" for k, v in sorted(details.items()) if v is not None)
58
+ print(f"{ts} {op} {detail_str}")
59
+ return 0
memvcs/commands/clone.py CHANGED
@@ -90,5 +90,12 @@ class CloneCommand:
90
90
  }
91
91
  config_file.write_text(json.dumps(config, indent=2))
92
92
 
93
+ # Copy remote's public key to .mem/keys/remotes/origin.pub for trust store
94
+ remote_keys = remote_mem / "keys" / "public.pem"
95
+ if remote_keys.exists():
96
+ keys_remotes = target / ".mem" / "keys" / "remotes"
97
+ keys_remotes.mkdir(parents=True, exist_ok=True)
98
+ shutil.copy2(remote_keys, keys_remotes / "origin.pub")
99
+
93
100
  print(f"Cloned into {target}")
94
101
  return 0
memvcs/commands/daemon.py CHANGED
@@ -203,10 +203,55 @@ class DaemonCommand:
203
203
  signal.signal(signal.SIGTERM, signal_handler)
204
204
  signal.signal(signal.SIGINT, signal_handler)
205
205
 
206
+ # Health monitoring: periodic integrity check (configurable interval)
207
+ last_health_check = 0
208
+ health_check_interval = 3600 # default 1 hour
209
+ try:
210
+ from ..core.config_loader import load_agmem_config
211
+ config = load_agmem_config(repo.root)
212
+ daemon_cfg = config.get("daemon") or {}
213
+ health_check_interval = int(daemon_cfg.get("health_check_interval_seconds", 3600))
214
+ if health_check_interval <= 0:
215
+ health_check_interval = 0
216
+ except Exception:
217
+ pass
218
+ env_interval = os.environ.get("AGMEM_DAEMON_HEALTH_INTERVAL")
219
+ if env_interval is not None:
220
+ try:
221
+ health_check_interval = int(env_interval)
222
+ except ValueError:
223
+ pass
224
+
206
225
  try:
207
226
  while running:
208
227
  time.sleep(1)
209
228
 
229
+ # Periodic health check (Merkle/signature, optional). Alert only; no destructive action.
230
+ if (
231
+ health_check_interval
232
+ and (time.time() - last_health_check) >= health_check_interval
233
+ ):
234
+ try:
235
+ from ..core.crypto_verify import verify_commit, load_public_key
236
+
237
+ head = repo.refs.get_branch_commit(
238
+ repo.refs.get_current_branch() or "main"
239
+ ) or (repo.refs.get_head() or {}).get("value")
240
+ if head:
241
+ ok, err = verify_commit(
242
+ repo.object_store,
243
+ head,
244
+ load_public_key(repo.mem_dir),
245
+ mem_dir=repo.mem_dir,
246
+ )
247
+ if not ok and err:
248
+ sys.stderr.write(f"Health check: {err}\n")
249
+ if "tampered" in (err or "").lower():
250
+ sys.stderr.write("Run 'agmem fsck' for safe integrity check.\n")
251
+ except Exception:
252
+ pass
253
+ last_health_check = time.time()
254
+
210
255
  if handler.pending:
211
256
  elapsed = time.time() - handler.last_change
212
257
  if elapsed >= debounce:
@@ -41,6 +41,11 @@ class DistillCommand:
41
41
  action="store_true",
42
42
  help="Do not create safety branch",
43
43
  )
44
+ parser.add_argument(
45
+ "--private",
46
+ action="store_true",
47
+ help="Use differential privacy (spend epsilon from budget)",
48
+ )
44
49
 
45
50
  @staticmethod
46
51
  def execute(args) -> int:
@@ -48,10 +53,29 @@ class DistillCommand:
48
53
  if code != 0:
49
54
  return code
50
55
 
56
+ use_dp = getattr(args, "private", False)
57
+ dp_epsilon = None
58
+ dp_delta = None
59
+ if use_dp:
60
+ from ..core.privacy_budget import load_budget, spend_epsilon
61
+
62
+ spent, max_eps, delta = load_budget(repo.mem_dir)
63
+ epsilon_cost = 0.1
64
+ if not spend_epsilon(repo.mem_dir, epsilon_cost):
65
+ print(f"Privacy budget exceeded (spent {spent:.2f}, max {max_eps}).")
66
+ return 1
67
+ if spent + epsilon_cost > max_eps * 0.8:
68
+ print(f"Privacy budget low: {spent + epsilon_cost:.2f}/{max_eps}")
69
+ dp_epsilon = 0.05
70
+ dp_delta = delta
71
+
51
72
  config = DistillerConfig(
52
73
  source_dir=args.source,
53
74
  target_dir=args.target,
54
75
  create_safety_branch=not args.no_branch,
76
+ use_dp=use_dp,
77
+ dp_epsilon=dp_epsilon,
78
+ dp_delta=dp_delta,
55
79
  )
56
80
  distiller = Distiller(repo, config)
57
81