@simbimbo/memory-ocmemog 0.1.11 → 0.1.13

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 (102) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/README.md +83 -18
  3. package/brain/runtime/__init__.py +2 -12
  4. package/brain/runtime/config.py +1 -24
  5. package/brain/runtime/inference.py +1 -151
  6. package/brain/runtime/instrumentation.py +1 -15
  7. package/brain/runtime/memory/__init__.py +3 -13
  8. package/brain/runtime/memory/api.py +1 -1219
  9. package/brain/runtime/memory/candidate.py +1 -185
  10. package/brain/runtime/memory/conversation_state.py +1 -1823
  11. package/brain/runtime/memory/distill.py +1 -344
  12. package/brain/runtime/memory/embedding_engine.py +1 -92
  13. package/brain/runtime/memory/freshness.py +1 -112
  14. package/brain/runtime/memory/health.py +1 -40
  15. package/brain/runtime/memory/integrity.py +1 -186
  16. package/brain/runtime/memory/memory_consolidation.py +1 -58
  17. package/brain/runtime/memory/memory_links.py +1 -107
  18. package/brain/runtime/memory/memory_salience.py +1 -233
  19. package/brain/runtime/memory/memory_synthesis.py +1 -31
  20. package/brain/runtime/memory/memory_taxonomy.py +1 -33
  21. package/brain/runtime/memory/pondering_engine.py +1 -654
  22. package/brain/runtime/memory/promote.py +1 -277
  23. package/brain/runtime/memory/provenance.py +1 -406
  24. package/brain/runtime/memory/reinforcement.py +1 -71
  25. package/brain/runtime/memory/retrieval.py +1 -210
  26. package/brain/runtime/memory/semantic_search.py +1 -64
  27. package/brain/runtime/memory/store.py +1 -429
  28. package/brain/runtime/memory/unresolved_state.py +1 -91
  29. package/brain/runtime/memory/vector_index.py +1 -323
  30. package/brain/runtime/model_roles.py +1 -9
  31. package/brain/runtime/model_router.py +1 -22
  32. package/brain/runtime/providers.py +1 -66
  33. package/brain/runtime/security/redaction.py +1 -12
  34. package/brain/runtime/state_store.py +1 -23
  35. package/brain/runtime/storage_paths.py +1 -39
  36. package/docs/architecture/memory.md +20 -24
  37. package/docs/release-checklist.md +19 -6
  38. package/docs/usage.md +33 -17
  39. package/index.ts +8 -1
  40. package/ocmemog/__init__.py +11 -0
  41. package/ocmemog/doctor.py +1255 -0
  42. package/ocmemog/runtime/__init__.py +18 -0
  43. package/ocmemog/runtime/_compat_bridge.py +28 -0
  44. package/ocmemog/runtime/config.py +34 -0
  45. package/ocmemog/runtime/identity.py +115 -0
  46. package/ocmemog/runtime/inference.py +163 -0
  47. package/ocmemog/runtime/instrumentation.py +20 -0
  48. package/ocmemog/runtime/memory/__init__.py +91 -0
  49. package/ocmemog/runtime/memory/api.py +1594 -0
  50. package/ocmemog/runtime/memory/candidate.py +192 -0
  51. package/ocmemog/runtime/memory/conversation_state.py +1831 -0
  52. package/ocmemog/runtime/memory/distill.py +282 -0
  53. package/ocmemog/runtime/memory/embedding_engine.py +151 -0
  54. package/ocmemog/runtime/memory/freshness.py +114 -0
  55. package/ocmemog/runtime/memory/health.py +93 -0
  56. package/ocmemog/runtime/memory/integrity.py +208 -0
  57. package/ocmemog/runtime/memory/memory_consolidation.py +60 -0
  58. package/ocmemog/runtime/memory/memory_links.py +109 -0
  59. package/ocmemog/runtime/memory/memory_salience.py +235 -0
  60. package/ocmemog/runtime/memory/memory_synthesis.py +33 -0
  61. package/ocmemog/runtime/memory/memory_taxonomy.py +35 -0
  62. package/ocmemog/runtime/memory/pondering_engine.py +681 -0
  63. package/ocmemog/runtime/memory/promote.py +279 -0
  64. package/ocmemog/runtime/memory/provenance.py +408 -0
  65. package/ocmemog/runtime/memory/reinforcement.py +73 -0
  66. package/ocmemog/runtime/memory/retrieval.py +224 -0
  67. package/ocmemog/runtime/memory/semantic_search.py +66 -0
  68. package/ocmemog/runtime/memory/store.py +433 -0
  69. package/ocmemog/runtime/memory/unresolved_state.py +93 -0
  70. package/ocmemog/runtime/memory/vector_index.py +411 -0
  71. package/ocmemog/runtime/model_roles.py +15 -0
  72. package/ocmemog/runtime/model_router.py +28 -0
  73. package/ocmemog/runtime/providers.py +78 -0
  74. package/ocmemog/runtime/roles.py +92 -0
  75. package/ocmemog/runtime/security/__init__.py +8 -0
  76. package/ocmemog/runtime/security/redaction.py +17 -0
  77. package/ocmemog/runtime/state_store.py +32 -0
  78. package/ocmemog/runtime/storage_paths.py +70 -0
  79. package/ocmemog/sidecar/app.py +421 -60
  80. package/ocmemog/sidecar/compat.py +50 -13
  81. package/ocmemog/sidecar/transcript_watcher.py +327 -242
  82. package/openclaw.plugin.json +4 -0
  83. package/package.json +1 -1
  84. package/scripts/ocmemog-backfill-vectors.py +5 -3
  85. package/scripts/ocmemog-continuity-benchmark.py +1 -1
  86. package/scripts/ocmemog-demo.py +1 -1
  87. package/scripts/ocmemog-doctor.py +15 -0
  88. package/scripts/ocmemog-install.sh +29 -7
  89. package/scripts/ocmemog-integrated-proof.py +374 -0
  90. package/scripts/ocmemog-reindex-vectors.py +5 -3
  91. package/scripts/ocmemog-release-check.sh +330 -0
  92. package/scripts/ocmemog-sidecar.sh +4 -2
  93. package/scripts/ocmemog-test-rig.py +5 -3
  94. package/brain/runtime/memory/artifacts.py +0 -33
  95. package/brain/runtime/memory/context_builder.py +0 -112
  96. package/brain/runtime/memory/interaction_memory.py +0 -57
  97. package/brain/runtime/memory/memory_gate.py +0 -38
  98. package/brain/runtime/memory/memory_graph.py +0 -54
  99. package/brain/runtime/memory/person_identity.py +0 -83
  100. package/brain/runtime/memory/person_memory.py +0 -138
  101. package/brain/runtime/memory/sentiment_memory.py +0 -67
  102. package/brain/runtime/memory/tool_catalog.py +0 -68
package/docs/usage.md CHANGED
@@ -6,7 +6,7 @@ ocmemog is a repo-local OpenClaw memory sidecar backed by SQLite with llama.cpp-
6
6
 
7
7
  - search/get over local memory are supported
8
8
  - provider-backed local embeddings are the primary path
9
- - several advanced brAIn memory flows are copied in but still degraded by missing runtime dependencies
9
+ - some advanced memory flows still depend on compatibility-shimmed runtime surfaces and may run in degraded mode depending on the configured provider/runtime
10
10
 
11
11
  ## Running the sidecar
12
12
 
@@ -21,9 +21,15 @@ scripts/ocmemog-sidecar.sh
21
21
  Manual watcher:
22
22
 
23
23
  ```bash
24
- # defaults to ~/.openclaw/workspace/memory/transcripts if not set
24
+ # if you set OCMEMOG_TRANSCRIPT_DIR, that path is watched; otherwise defaults to
25
+ # ~/.openclaw/workspace/memory/transcripts (or ~/.openclaw/agents/main/sessions when
26
+ # OCMEMOG_SESSION_DIR is set and no transcript path is given)
25
27
  export OCMEMOG_TRANSCRIPT_DIR="$HOME/.openclaw/workspace/memory/transcripts"
26
- export OCMEMOG_INGEST_ENDPOINT="http://127.0.0.1:17891/memory/ingest"
28
+ export OCMEMOG_SESSION_DIR="$HOME/.openclaw/agents/main/sessions"
29
+ export OCMEMOG_INGEST_ENDPOINT="http://127.0.0.1:17891/memory/ingest_async"
30
+ export OCMEMOG_TRANSCRIPT_POLL_SECONDS=30
31
+ export OCMEMOG_INGEST_BATCH_SECONDS=30
32
+ export OCMEMOG_INGEST_BATCH_MAX=25
27
33
  ./scripts/ocmemog-transcript-watcher.sh
28
34
  ```
29
35
 
@@ -42,7 +48,7 @@ Useful environment variables:
42
48
  export OCMEMOG_HOST=127.0.0.1
43
49
  export OCMEMOG_PORT=17891
44
50
  export OCMEMOG_STATE_DIR=/path/to/state
45
- export OCMEMOG_DB_PATH=/path/to/brain_memory.sqlite3
51
+ export OCMEMOG_DB_PATH=/path/to/ocmemog_memory.sqlite3
46
52
  export OCMEMOG_MEMORY_MODEL=gpt-4o-mini
47
53
  export OCMEMOG_OPENAI_API_KEY=sk-...
48
54
  export OCMEMOG_OPENAI_API_BASE=https://api.openai.com/v1
@@ -51,18 +57,30 @@ export OCMEMOG_LOCAL_LLM_BASE_URL=http://127.0.0.1:18080/v1
51
57
  export OCMEMOG_LOCAL_LLM_MODEL=qwen2.5-7b-instruct
52
58
  export OCMEMOG_LOCAL_EMBED_BASE_URL=http://127.0.0.1:18081/v1
53
59
  export OCMEMOG_LOCAL_EMBED_MODEL=nomic-embed-text-v1.5
54
- export BRAIN_EMBED_MODEL_LOCAL=simple
55
- export BRAIN_EMBED_MODEL_PROVIDER=local-openai
60
+ export OCMEMOG_EMBED_MODEL_LOCAL=simple
61
+ export OCMEMOG_EMBED_MODEL_PROVIDER=local-openai
62
+ export OCMEMOG_SESSION_DIR=$HOME/.openclaw/agents/main/sessions
56
63
  export OCMEMOG_TRANSCRIPT_DIR=$HOME/.openclaw/workspace/memory/transcripts
57
64
  export OCMEMOG_TRANSCRIPT_GLOB=*.log
58
- export OCMEMOG_TRANSCRIPT_POLL_SECONDS=1
65
+ export OCMEMOG_TRANSCRIPT_WATCHER=true
66
+ export OCMEMOG_TRANSCRIPT_POLL_SECONDS=30
59
67
  export OCMEMOG_INGEST_KIND=memory
60
68
  export OCMEMOG_INGEST_SOURCE=transcript
61
- export OCMEMOG_TRANSCRIPT_WATCHER=true
69
+ export OCMEMOG_INGEST_ASYNC_WORKER=true
70
+ export OCMEMOG_INGEST_ASYNC_POLL_SECONDS=5
71
+ export OCMEMOG_INGEST_ASYNC_BATCH_MAX=25
72
+ export OCMEMOG_INGEST_BATCH_SECONDS=30
73
+ export OCMEMOG_INGEST_BATCH_MAX=25
74
+ export OCMEMOG_SHUTDOWN_DRAIN_QUEUE=false
75
+ export OCMEMOG_WORKER_SHUTDOWN_TIMEOUT_SECONDS=0.35
76
+ export OCMEMOG_SHUTDOWN_TIMING=true
77
+ export OCMEMOG_SHUTDOWN_DUMP_THREADS=false
62
78
  ```
63
79
 
64
80
  Default state location in this repo is `.ocmemog-state/`.
65
81
 
82
+ On shutdown, set `OCMEMOG_SHUTDOWN_DRAIN_QUEUE=true` to synchronously flush queued ingest entries before exit. This is useful for short-running deployments and tests that expect strong delivery guarantees.
83
+
66
84
  ## Plugin API
67
85
 
68
86
  Health:
@@ -183,15 +201,13 @@ Notes:
183
201
 
184
202
  ## What is not safe to rely on yet
185
203
 
186
- - `brain/runtime/memory/api.py`
187
- - It targets missing/legacy tables and columns.
188
204
  - Provider-backed embeddings
189
- - Available when `BRAIN_EMBED_MODEL_PROVIDER=local-openai` and the local embedding endpoint is reachable.
190
- - Legacy OpenAI-hosted embeddings remain available when `BRAIN_EMBED_MODEL_PROVIDER=openai` and `OCMEMOG_OPENAI_API_KEY` is set.
205
+ - Available when `OCMEMOG_EMBED_MODEL_PROVIDER=local-openai` and the local embedding endpoint is reachable.
206
+ - Legacy OpenAI-hosted embeddings remain available when `OCMEMOG_EMBED_MODEL_PROVIDER=openai` and `OCMEMOG_OPENAI_API_KEY` is set.
191
207
  - Model-backed distillation
192
208
  - Available when `OCMEMOG_OPENAI_API_KEY` is set; otherwise falls back to heuristic distill.
193
209
  - Role-prioritized context building
194
- - `brain.runtime.roles.role_registry` is not bundled here.
210
+ - `brain.runtime.roles.role_registry` is now provided by `ocmemog.runtime.roles` and mirrored in compatibility probes.
195
211
  - Full brAIn memory parity
196
212
  - The repo ships only a subset of the original runtime architecture.
197
213
 
@@ -201,7 +217,7 @@ To inspect memory state quickly:
201
217
 
202
218
  ```bash
203
219
  python3 - <<'PY'
204
- from brain.runtime.memory import store
220
+ from ocmemog.runtime.memory import store
205
221
  store.init_db()
206
222
  conn = store.connect()
207
223
  for table in ("knowledge", "reflections", "directives", "tasks", "candidates", "promotions"):
@@ -215,7 +231,7 @@ To rebuild embeddings for recent knowledge rows:
215
231
 
216
232
  ```bash
217
233
  python3 - <<'PY'
218
- from brain.runtime.memory import vector_index
234
+ from ocmemog.runtime.memory import vector_index
219
235
  print(vector_index.index_memory())
220
236
  PY
221
237
  ```
@@ -223,7 +239,7 @@ PY
223
239
  ## TODO: Missing runtime dependencies
224
240
 
225
241
  - TODO: wire a real inference backend before enabling distill/promote as an operator-facing workflow
226
- - TODO: wire real provider execution if `BRAIN_EMBED_MODEL_PROVIDER` is meant to do anything
227
- - TODO: add or remove role-based context selection; the current import path is absent
242
+ - Provider execution is now native-first through `OCMEMOG_EMBED_MODEL_PROVIDER`; `BRAIN_EMBED_MODEL_PROVIDER` remains as a compatibility alias.
243
+ - Role-based context selection now has native ownership coverage via `ocmemog.runtime.roles` with shim-aware capability reporting.
228
244
  - TODO: harden `/memory/get` with a table allow-list before exposing the sidecar outside trusted local use
229
245
  - TODO: decide whether to expose `runbooks` and `lessons` in the plugin API
package/index.ts CHANGED
@@ -6,6 +6,7 @@ const DEFAULT_TIMEOUT_MS = 30_000;
6
6
  type PluginConfig = {
7
7
  endpoint: string;
8
8
  timeoutMs: number;
9
+ token?: string;
9
10
  };
10
11
 
11
12
  const AUTO_HYDRATION_ENABLED = ["1", "true", "yes"].includes(
@@ -80,6 +81,7 @@ function readConfig(raw: unknown): PluginConfig {
80
81
  typeof cfg.timeoutMs === "number" && Number.isFinite(cfg.timeoutMs) && cfg.timeoutMs > 0
81
82
  ? cfg.timeoutMs
82
83
  : DEFAULT_TIMEOUT_MS,
84
+ token: typeof cfg.token === "string" && cfg.token.trim() ? cfg.token.trim() : undefined,
83
85
  };
84
86
  }
85
87
 
@@ -88,9 +90,14 @@ async function postJson<T>(config: PluginConfig, path: string, body: Record<stri
88
90
  const timeout = setTimeout(() => controller.abort(), config.timeoutMs);
89
91
 
90
92
  try {
93
+ const headers: Record<string, string> = { "content-type": "application/json" };
94
+ if (config.token) {
95
+ headers["x-ocmemog-token"] = config.token;
96
+ }
97
+
91
98
  const response = await fetch(new URL(path, config.endpoint).toString(), {
92
99
  method: "POST",
93
- headers: { "content-type": "application/json" },
100
+ headers,
94
101
  body: JSON.stringify(body),
95
102
  signal: controller.signal,
96
103
  });
@@ -1 +1,12 @@
1
1
  """ocmemog sidecar package."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from importlib.metadata import PackageNotFoundError, version as _package_version
6
+
7
+ try:
8
+ __version__ = _package_version("ocmemog-sidecar")
9
+ except PackageNotFoundError: # pragma: no cover - package metadata may be unavailable in source layouts.
10
+ __version__ = "0.1.12"
11
+
12
+ __all__ = ["__version__"]