dotmem 0.2.4 → 0.2.6

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.
package/README.md CHANGED
@@ -1,457 +1,431 @@
1
- # Dotmem (.mem)
2
- ![Dotmem banner](https://raw.githubusercontent.com/passariello/container/refs/heads/main/dotmem/banner.svg)
3
-
4
- **Memory. Identity. Continuity.**
5
-
6
- **AI provides intelligence. Dotmem provides continuity.**
7
-
8
- Your memory should not belong to the model, the provider, or the platform. It should belong to you.
9
-
10
- Dotmem is an independent, local-first memory runtime for AI agents and applications. It preserves experience, context, provenance, and identity across sessions, models, providers, and machines. Every acquired claim carries evidence and an applicability scope, every write passes through policy, and retrieval is deterministic and reproducible. No embeddings, no vector store, no model dependency.
11
-
12
- ```bash
13
- npm install dotmem
14
- ```
15
-
16
- > **Retrieval is lexical and structured, not semantic.** Same store + same query = same result. See [Retrieval model](#retrieval-model).
17
-
18
- ---
19
-
20
- ## Why Dotmem
21
-
22
- A conversation ends. A session disappears. A model changes. A provider is replaced. A new host starts with no reliable understanding of what happened before. Dotmem separates intelligence from continuity: the model reasons and generates, Dotmem keeps the experience.
23
-
24
- **Change the model. Change the provider. Keep the continuity.**
25
-
26
- | You need | Dotmem gives you |
27
- |---|---|
28
- | Memory you can audit | Claims with evidence, provenance, and epistemic type |
29
- | Memory that doesn't leak into the wrong context | Applicability-scoped eligibility on retrieval |
30
- | Bounded prompts | `project()` builds context under a character/candidate budget |
31
- | Safe agent writes | Policy-gated acquisition; the MCP server is **read-only by default** |
32
- | Continuity across sessions | Snapshots, checkpoints, compaction, open loops |
33
- | Vendor independence | Works with any model, host, or client |
34
-
35
- **Dotmem is probably not what you want if** your main need is fuzzy semantic recall over large unstructured text. Use a vector/embedding store for that, optionally alongside Dotmem for the governed, auditable part.
36
-
37
- ---
38
-
39
- ## Quick Start - Coding
40
-
41
- The runtime initializes lazily on first call. No `init()` required. Requires Node.js >= 20 (also `bun add dotmem` / `pnpm add dotmem`).
42
-
43
- ```typescript
44
- import { memory } from 'dotmem'
45
-
46
- // 1. Acquire durable, evidenced experience (persists as .mem files)
47
- await memory.acquire({
48
- id: 'user.language-preference',
49
- knowledge: { language: 'TypeScript' },
50
- applicability: { area: 'language-selection' },
51
- evidence: [
52
- {
53
- id: 'conv-001',
54
- source: 'conversation',
55
- observedAt: new Date().toISOString()
56
- }
57
- ],
58
- epistemicType: 'observed'
59
- })
60
-
61
- // 2. Discover what applies to a situation
62
- const discovery = await memory.discover(
63
- 'User needs a language recommendation for a new project',
64
- { depth: 'current', maxCandidates: 10 }
65
- )
66
-
67
- // 3. Project a bounded context for your LLM prompt
68
- const projection = memory.project(discovery, {
69
- maxCandidates: 8,
70
- maxCharacters: 4000
71
- })
72
-
73
- console.info(projection.text)
74
- ```
75
-
76
- > `projection.text` is the bounded, plain-text context selected for the supplied situation. Its contents depend on the claims in the local store, their applicability, and the projection limits; an empty or new store may return no claims. No fixed output is assumed.
77
-
78
- ### Agent-namespaced memory
79
-
80
- ```typescript
81
- import { createAgentMemory } from 'dotmem/agent'
82
-
83
- const agent = createAgentMemory('support-agent')
84
-
85
- await agent.remember('greeting', 'Hello! How can I help?', {
86
- type: 'fact',
87
- confidence: 0.9,
88
- scope: 'local',
89
- tags: ['greeting']
90
- })
91
- ```
92
-
93
- > ⚠️ **Persistence differs by runtime. Read this before using `remember()`.**
94
-
95
- | API | Browser | Node.js / Bun / Deno |
96
- |---|---|---|
97
- | `memory.acquire()` | See [MEMORY.md](./MEMORY.md) | ✅ Persists as `.mem` files |
98
- | `remember()` with scope `durable` | ✅ IndexedDB | ✅ Persists to `.dotmem/memory.kv` (atomic writes, cross-process lock, `.bak` backup) |
99
- | internal `store` / `session` layers | - | ❌ In-memory `Map`, lost on restart |
100
-
101
- > **On Node.js and Bun, use `memory.acquire()` for anything that must survive a restart.** See [MEMORY.md](./MEMORY.md) for scope details.
102
-
103
- ---
104
-
105
- ## Which API should I use?
106
-
107
- | I want to… | Use | Persists on Node/Bun? |
108
- |---|---|---|
109
- | Store a **claim with evidence** that should shape future behavior | `memory.acquire` (or `acquireStaged` to review first) | ✅ |
110
- | Find relevant claims and build a prompt context | `memory.discover` → `memory.project` | n/a (read) |
111
- | Keep a simple typed key/value entry | `memory.remember` / `recall` / `update` / `forget` / `patch` | ✅ On Node/Bun via durable scope; browser-only for IndexedDB |
112
- | Give each agent its own partition | `createAgentMemory` from `dotmem/agent` | See `remember` |
113
- | Keep a short-lived scratch note | `memory.note` | - |
114
- | Resume work across sessions | `continuity` (snapshots, checkpoints, open loops) | - |
115
- | Control who/what may write | `memory.policy` | - |
116
-
117
- ### Layers
118
-
119
- | Layer | Entry point | Purpose |
120
- |---|---|---|
121
- | **memory** | `dotmem` | Key/value memory, acquisition lifecycle, journal, sub-facades (`journal`, `note`, `profile`, `policy`, `brain`) |
122
- | **continuity** | `dotmem` | USER + PROJECT + TASK context composition, snapshots, open loops |
123
- | **agent** | `dotmem/agent` | Agent-facing memory with logical namespace partitioning |
124
- | **policy** | `memory.policy` | Policy definition, authority management, three-tier enforcement, privileged out-of-band overrides |
125
- | **profile** | `memory.profile.get(id)` | Read-only built-in identity/persona documents |
126
- | **note** | `memory.note` | Short-lived notes with tags and origins |
127
-
128
- Also exported: `security` and `encryption` (RBAC, audit, consent, AES-GCM and PBKDF2 helpers).
129
-
130
- **Not part of the public runtime surface:** `logic` (experimental, unverified), `knowledge` (internal), `seed` (development-only, requires `--dev`), `llm-cache` (types only, no verified runtime).
131
-
132
- ---
133
-
134
- ## Trust & Observability
135
-
136
- Dotmem makes trust claims evidence-based and auditable, lets you inspect `.mem` contents without mutation, reduces repeated startup calls, and enforces lifecycle requirements on Dotmem-owned task paths.
137
-
138
- ### Trust basis (P1)
139
-
140
- Every projected claim carries a `trustBasis` derived from actual provenance, never from the stored `epistemicType` label alone:
141
-
142
- - **declared** - caller/author assertion without independent validation (default for legacy records)
143
- - **evidenced** - evidence references exist but have not been independently resolved and validated
144
- - **mechanically-checked** - a specific reproducible check was executed and its result recorded
145
- - **externally-attested** - an external attestation exists and is validated by a trusted mechanism
146
-
147
- A URL, evidence ID, signature-like field, or legacy `verified` label never implies `externally-attested`. Legacy `epistemicType: 'verified'` claims remain readable for compatibility but derive their trust from provenance, not the label.
148
-
149
- Caller-supplied `verifiedAt`, `verifiedBy`, and verification status are rejected at untrusted acquisition/write boundaries. Only the trusted verification writer (`dotmem-verify`) persists verification metadata, and only after a supported concrete check succeeds (`regex` and `file-json` checks are implemented; no placeholder verification).
150
-
151
- ### Read-only inspection (P2)
152
-
153
- Inspect a `.mem` package without mutating the store or package:
154
-
155
- ```bash
156
- npx dotmem inspect path/to/file.mem
157
- npx dotmem inspect path/to/file.mem --format json --limit 20
158
- npx dotmem inspect path/to/file.mem --no-redact # local CLI only; redacts secrets by default
159
- npx dotmem dump # bounded store-wide dump, redacted
160
- npx dotmem diff FILE_A.mem FILE_B.mem # deterministic read-only diff
161
- ```
162
-
163
- Secret-shaped values are redacted by default. MCP inspection (`dotmem_inspect`) stays redacted with no raw-output bypass. Package signatures are verified with the existing mechanism and reported as unsigned, invalid, or verified - unsigned does not mean corrupt.
164
-
165
- ### Unified bootstrap (P3)
166
-
167
- One call returns the initial context plus the rules reference:
168
-
169
- ```bash
170
- npx dotmem bootstrap
171
- npx dotmem bootstrap --since <version> # returns a small UNCHANGED response if the store is unchanged
172
- ```
173
-
174
- `dotmem_bootstrap` (MCP) and `dotmem_context`/`dotmem_rules` are retained for compatibility. `knowledge.kind === 'rule'` claims are excluded from ordinary task context; rules remain available through the rules reference/bootstrap.
175
-
176
- ### Completion gate (P4)
177
-
178
- Checkpoint revision persists across process restarts. Session observations remain observations and are never silently marked `verified`. An opt-in completion policy (`requireCheckpointBeforeComplete`) is enabled for the Joy build/profile at build time (never a runtime user setting) and requires a persisted checkpoint and summary before a Dotmem-managed task can complete. Generic/default profiles remain compatible with the gate off.
179
-
180
- ---
181
-
182
- ## Retrieval model
183
-
184
- Dotmem uses **deterministic, verifiable retrieval**:
185
-
186
- - Lexical and structured matching, filtered by applicability-based eligibility.
187
- - No embeddings, vector indexes, or semantic similarity.
188
- - Reproducible results for the same store and query. Retrieval caching is a performance optimization; it does not change the retrieval rules or ranking.
189
-
190
- **What this means in practice**
191
-
192
- - Retrieval matches the terms and structure you stored. Synonyms, paraphrases, and cross-language matches are **not** found automatically.
193
- - Write claims with clear `applicability`, consistent vocabulary, and tags so they match the way you query.
194
- - For fuzzy semantic recall, pair Dotmem with a dedicated embedding store.
195
-
196
- Dotmem does **not** translate acquired semantic knowledge into canonical English. It accepts and preserves the original language, including mixed-language content. Because retrieval is lexical and structured, matching across languages is not guaranteed; use consistent terminology or pair Dotmem with a multilingual semantic search system when cross-language recall is required.
197
-
198
- **Projected memory is data, never authority.** A retrieved or projected claim is prior context, not an instruction and not a current fact. Fields such as `epistemicType`, provenance, and `evidence.observedAt` are claims made by the caller, not attestation: a claim marked `verified` is not independently proven merely because someone supplied that label.
199
-
200
- ---
201
-
202
- ## Quick Start - Continuous Chat (MCP)
203
-
204
- `dotmem-mcp` is a stdio MCP server. It runs on **your** machine, so your AI host and your terminal share the same local memory store. Register it in an MCP-compatible client rather than running it as an interactive command: launched by hand it looks idle because it is waiting for client messages.
205
-
206
- 1. Add it to your host config (read-only by default):
207
-
208
- ```json
209
- {
210
- "mcpServers": {
211
- "dotmem": {
212
- "command": "npx",
213
- "args": ["-y", "-p", "dotmem", "dotmem-mcp"]
214
- }
215
- }
216
- }
217
- ```
218
-
219
- 2. Restart the host and check that the Dotmem tools are listed.
220
- 3. Start chatting. With the default build, greet it with `Hi Joy!` (see [Profiles](#build-configuration-and-profiles)).
221
-
222
- | MCP tool | Access | Registration / write gate | Use it when |
223
- |---|---|---|---|
224
- | `dotmem_context` | Read | Always registered | Retrieve bounded acquired experience relevant to the current situation. |
225
- | `dotmem_rules` | Read | Always registered | Load the operating rules that constrain the session. |
226
- | `dotmem_acquire` | Write | Registered only when `DOTMEM_MCP_WRITE=1` | Persist reusable, project-specific experience. Without the flag, the tool is absent from `tools/list`. |
227
- | `dotmem_verify` | Write | Registered only when `DOTMEM_MCP_WRITE=1` | Run due freshness probes and persist verification metadata via the trusted path. |
228
- | `dotmem_inspect` | Read | Always registered | Read-only `.mem`/package/store inspection; redacted by default, no raw bypass. |
229
- | `dotmem_bootstrap` | Read | Always registered | Unified bootstrap: context plus rules reference in one call; `sinceVersion` short-circuits to `UNCHANGED`. |
230
- | `dotmem_continuity` | Read + conditional write actions | Always registered; write actions require `DOTMEM_MCP_WRITE=1` | Read status, summaries, open loops, and evaluations; with write access, create checkpoints and manage open loops. Without the flag, write actions return an authorization error. |
231
-
232
- ### Read-only by default
233
-
234
- Write access is an explicit opt-in. Enable it only if the host should be able to modify memory:
235
-
236
- ```bash
237
- DOTMEM_MCP_WRITE=1
238
- ```
239
-
240
- ### Things that commonly go wrong
241
-
242
- - **Hosted chats don't share your machine's store.** If an AI runs `npx dotmem` inside a hosted chat, it writes to that chat's sandbox, not to your terminal's storage, and that state may disappear when the session ends. Use the MCP server on your own machine for continuity across sessions.
243
- - **The server and the CLI must resolve the same storage root** if they are expected to share memory. Set `DOTMEM_STORAGE_ROOT` in the client's environment if needed.
244
- - **GUI clients often don't inherit your shell's PATH.** If a global install doesn't start, use the absolute path of the binary.
245
- - **Pin the version** (`dotmem-mcp@x.y.z`) for long-lived setups instead of pulling the latest on every launch.
246
-
247
- ### Host configurations
248
-
249
- <details>
250
- <summary><b>Claude Desktop</b></summary>
251
-
252
- ```json
253
- {
254
- "mcpServers": {
255
- "dotmem": {
256
- "command": "npx",
257
- "args": ["-y", "-p", "dotmem", "dotmem-mcp"],
258
- "env": { "DOTMEM_MCP_WRITE": "1" }
259
- }
260
- }
261
- }
262
- ```
263
-
264
- Remove the `env` line for read-only.
265
-
266
- </details>
267
-
268
- <details>
269
- <summary><b>Claude Code</b></summary>
270
-
271
- ```bash
272
- # read-only
273
- claude mcp add --transport stdio dotmem -- npx -y -p dotmem dotmem-mcp
274
-
275
- # with write access
276
- claude mcp add \
277
- --env DOTMEM_MCP_WRITE=1 \
278
- --transport stdio \
279
- dotmem -- npx -y -p dotmem dotmem-mcp
280
- ```
281
-
282
- </details>
283
-
284
- <details>
285
- <summary><b>Kilo / OpenCode</b></summary>
286
-
287
- ```jsonc
288
- {
289
- "mcp": {
290
- "dotmem": {
291
- "type": "local",
292
- "command": ["npx", "-y", "-p", "dotmem", "dotmem-mcp"],
293
- "enabled": true
294
- // For write access, add:
295
- // "environment": { "DOTMEM_MCP_WRITE": "1" }
296
- }
297
- }
298
- }
299
- ```
300
-
301
- </details>
302
-
303
- <details>
304
- <summary><b>Windows (cmd.exe)</b></summary>
305
-
306
- On Windows, `npx` may not be directly executable by an MCP host. Use `cmd /c npx`:
307
-
308
- ```json
309
- {
310
- "mcpServers": {
311
- "dotmem": {
312
- "command": "cmd",
313
- "args": ["/c", "npx", "-y", "-p", "dotmem", "dotmem-mcp"]
314
- }
315
- }
316
- }
317
- ```
318
-
319
- Add `"env": { "DOTMEM_MCP_WRITE": "1" }` for write access.
320
-
321
- </details>
322
-
323
- See [MEMORY.md](./MEMORY.md) for the complete MCP tool list and write-gating details.
324
-
325
- ---
326
-
327
- ## Memory, policy, and authority are separate
328
-
329
- | Plane | Responsibility |
330
- |---|---|
331
- | Memory | What has been learned or observed |
332
- | Policy | Which rules apply |
333
- | Authority | Who or what is allowed to authorize an operation |
334
-
335
- A retrieved memory item can inform a decision but cannot authorize it. Historical identity supports continuity but does not authenticate the current speaker. A change of model or provider must not silently redefine the identity associated with a memory.
336
-
337
- ---
338
-
339
- ## Storage and format
340
-
341
- - **Default location:** `<user-home>/.dotmem`
342
- - **Custom location:** set `DOTMEM_STORAGE_ROOT`, or run `dotmem storage relocate <path>`.
343
- - **Format:** `.mem` files are versioned, compressed ZIP archives (DEFLATE) with SHA-256 integrity manifests. They are binary and not directly human-readable. V2 writes, V1 reads.
344
- - **Concurrency:** an in-process write queue, directory locks, expected-version checks, and atomic writes with backups protect concurrent updates.
345
-
346
- Inspect a package with the read-only CLI command:
347
-
348
- ```bash
349
- npx dotmem inspect path/to/file.mem
350
- ```
351
-
352
- It validates and decodes the `.mem` package, including its integrity, structure, and knowledge claims. The JavaScript API also exposes `dotmem.inspectMem(path)`. Do not edit `.mem` files directly; they are binary packages.
353
-
354
- - **Store layout:** `user.mem` holds user-level experience, `agent.mem` holds agent operating knowledge, and `projects/<project-id>.mem` holds project experience. The project ID resolves from `DOTMEM_PROJECT_ID`, then `package.json`'s `name`, then the current directory name.
355
- - **Secret sanitization:** `memory.acquire()` sanitizes secret-looking keys and values before persistence. This is defensive sanitization, not encryption, a secret vault, or access control.
356
- - **Invalid storage root:** A configured root that is missing, inaccessible, or invalid stops resolution with an explicit error. Dotmem does not silently fall back to another path or search the filesystem.
357
-
358
- ### Limits
359
-
360
- | Limit | Value |
361
- |---|---|
362
- | Package size (compressed) | 10 MiB |
363
- | Package size (uncompressed) | 25 MiB |
364
- | Entries per package | 128 |
365
- | Maximum compression ratio | 200:1 |
366
-
367
- These are package validation limits, not performance or scalability guarantees. Context retrieval is bounded and cached; maximum numbers of claims, users, and concurrent processes have **not been benchmarked**.
368
-
369
- ---
370
-
371
- ## Security and limitations
372
-
373
- Dotmem is designed to preserve user control and make its boundaries explicit.
374
-
375
- - **No encryption at rest.** `.mem` files and vault data are stored unencrypted. The encryption helpers are not integrated with `.mem` or vault storage, and no supported option enables encryption at rest today. Do not store data that requires encryption at rest.
376
- - **Integrity is not encryption or access control.** SHA-256 manifests detect corruption; they do not keep anyone out.
377
- - **Filesystem access is governed by the operating system,** not by an independent Dotmem authorization boundary.
378
- - **Retrieval is lexical and structured,** not vector or embedding search.
379
- - **Dotmem governs context, not model behavior.** Projection is bounded, but external host behavior is outside Dotmem's enforcement boundary, and a downstream model may still misread a projected item.
380
- - **Multi-process coordination** uses advisory file locks (`withStorageLock`) and in-process write queues (`withStoreQueue`) in the storage coordinator. Each agent that uses its own partitioned storage (agent-namespaced keys or separate `.mem` files) avoids contention entirely; shared stores are serialized. This is coordination, not a distributed transaction system.
381
- - **Identity persistence SLA**: writes use `handle.sync()` + directory fsync + atomic rename + `.bak` backup. A write is durable once `remember()`/`acquire()` resolves. Crash during write leaves the previous valid version (`.bak`) recoverable. No formal uptime SLA is provided; durability depends on the host filesystem.
382
-
383
- Do not treat Dotmem as a replacement for a database authorization system, a secrets manager, or an encrypted backup solution. See [SECURITY.md](./SECURITY.md) for the trust model.
384
-
385
- ---
386
-
387
- ## Design principles
388
-
389
- 1. **User-owned, local-first memory.** No provider owns it or locks it in.
390
- 2. **Provider independent and portable.** No model, host, or provider defines identity or continuity.
391
- 3. **Memory is not authority.** Retrieval never turns a claim into policy.
392
- 4. **Identity survives the carrier.** Runtime metadata never redefines canonical identity.
393
- 5. **Provenance matters, and labels are not proof.** A declared confidence level is not evidence.
394
- 6. **Memory stays correctable.** Revision, supersession, and retraction are part of the model.
395
- 7. **Honest boundaries.** The runtime says what it knows, what it checks, and what it cannot enforce.
396
-
397
- Acquired claims are corrected through explicit revision relations: `refines`, `supersedes`, and `retracts`. Historical claims are not silently overwritten. The key/value API has `forget()`; this README does not promise physical deletion of acquired claims.
398
-
399
- Dotmem is not an AI model, an autonomous reasoning engine, or a vendor-specific agent framework. It is the continuity infrastructure AI systems can use. Longer reflections live outside this README.
400
-
401
- ---
402
-
403
- ## Build configuration and profiles
404
-
405
- Dotmem core is model- and provider-independent. The assistant's identity, behavior profile, and product branding are chosen **by the product owner at build time**, embedded in the build artifact, and immutable at runtime (end users cannot change them).
406
-
407
- - The **default build** uses the **Joy** profile. Joy is a selectable profile, not a mandatory identity of the runtime. Other builds can use different names, aliases, behavior profiles, and branding on the same runtime.
408
- - Joy's identity and behavior documents live under `context/profiles/joy/`; the manifest `ai.json` defines the canonical identity, aliases, and declared documents.
409
- - The `profile` layer follows the package semver contract.
410
-
411
- See [AI.md](./context/templates/AI.md) for the assistant operating contract and profile configuration model.
412
-
413
- ---
414
-
415
- ## Documentation
416
-
417
- | Document | Description |
418
- |---|---|
419
- | [MEMORY.md](./MEMORY.md) | Memory model: acquisition contract, policy language, epistemic typing, enforcement, continuity, identity |
420
- | [AGENTS.md](./AGENTS.md) | Agent working rules, activation phrases, complete `memory.*` surface |
421
- | [SECURITY.md](./SECURITY.md) | Encryption helpers, multitenancy, key management, trust model, JHF, sandbox |
422
- | [AI.md](./context/templates/AI.md) | Assistant operating contract and profile configuration |
423
- | [PACKAGE.md](./PACKAGE.md) | Package contents, full quick start, dependency graph |
424
- | License | MIT (see `package.json`) |
425
-
426
- ---
427
-
428
- ## Compatibility
429
-
430
- | Runtime | Status |
431
- |---|---|
432
- | Node.js >= 20.0.0 | Declared in `package.json` engines; tested in CI (20.x, 22.x) |
433
- | Bun >= 1.0 | Tested in CI (1.x) |
434
- | Browser | ES2020+ with IndexedDB, localStorage, sessionStorage |
435
- | Deno | Compatible, not routinely tested |
436
-
437
- Persistence rules differ per runtime: see the [persistence warning](#agent-namespaced-memory).
438
-
439
- ---
440
-
441
- ## Project direction
442
-
443
- Dotmem is developed as an independent memory runtime. Long-term objectives: reliable cross-session continuity, portable memory across providers and environments, stronger evidence and verification workflows, transparent memory inspection and management, efficient context projection, and durable lifecycle and checkpoint management. These objectives do not imply that every capability is already implemented; current functionality and limitations are documented above and in the linked documents.
444
-
445
- **Your memory. Your continuity.**
446
-
447
- ---
448
-
449
- ## Disclaimer
450
-
451
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. Outputs of AI systems that use Dotmem can be wrong or incomplete; verify critical information independently, and do not store sensitive or confidential data in unencrypted memory.
452
-
453
- ## License
454
-
455
- MIT - Copyright (c) 2026 Dario Passariello.
456
-
457
- SPDX-License-Identifier: `MIT`
1
+ # Dotmem (.mem)
2
+
3
+ ![Dotmem banner](https://raw.githubusercontent.com/passariello/container/refs/heads/main/dotmem/banner.svg)
4
+
5
+ **Memory. Identity. Continuity.**
6
+
7
+ Dotmem is an independent, local-first memory runtime for AI agents and applications. It preserves experience, context, provenance, and continuity across sessions, models, providers, and machines.
8
+
9
+ AI provides intelligence. Dotmem provides continuity.
10
+
11
+ - Evidence-based, auditable memory.
12
+ - Deterministic lexical and structured retrieval.
13
+ - Bounded context projection.
14
+ - Policy-governed acquisition and writes.
15
+ - No embeddings, vector database, or model dependency.
16
+
17
+ Your memory should remain under your control, independent of the model or provider you use.
18
+
19
+ ## Contents
20
+
21
+ - [Choose your path](#choose-your-path)
22
+ - [Quick start for developers](#quick-start-for-developers)
23
+ - [Connect an AI host](#connect-an-ai-host)
24
+ - [Core concepts](#core-concepts)
25
+ - [Progressive context loading](#progressive-context-loading)
26
+ - [Storage and inspection](#storage-and-inspection)
27
+ - [MCP integration](#mcp-integration)
28
+ - [Security and limitations](#security-and-limitations)
29
+ - [Build profiles](#build-profiles)
30
+ - [Compatibility](#compatibility)
31
+ - [Documentation](#documentation)
32
+ - [License](#license)
33
+
34
+ ---
35
+
36
+ ## Choose your path
37
+
38
+ | If you want to... | Start here |
39
+ |---|---|
40
+ | Use Dotmem from your own application | [Quick start for developers](#quick-start-for-developers) |
41
+ | Connect a VS Code or other AI host to local Dotmem memory | [Connect an AI host](#connect-an-ai-host) |
42
+ | Understand trust, retrieval, and context limits | [Core concepts](#core-concepts) |
43
+
44
+ Dotmem can be used without the Joy assistant profile. Jo/Joy is an optional assistant profile, not an entry point or a requirement of the memory runtime.
45
+
46
+ ## Quick start for developers
47
+
48
+ ### Requirements
49
+
50
+ - Node.js >= 20, or Bun >= 1.0.
51
+ - An application that can use the Dotmem package.
52
+
53
+ ### Install
54
+
55
+ ```bash
56
+ npm install dotmem
57
+ ```
58
+
59
+ With Bun:
60
+
61
+ ```bash
62
+ bun add dotmem
63
+ ```
64
+
65
+ `dotmem` is sufficient for the memory API shown here. `memorio` is an optional companion package; add it only if your application or integration directly uses Memorio's state and persistence APIs:
66
+
67
+ ```bash
68
+ npm install memorio
69
+ ```
70
+
71
+ ### Your first memory
72
+
73
+ The example stores a language preference and then retrieves it using a matching term. Dotmem retrieval is lexical and structured, so this avoids relying on synonym or semantic matching.
74
+
75
+ ```typescript
76
+ import { memory } from 'dotmem'
77
+
78
+ await memory.acquire({
79
+ id: 'user.language-preference',
80
+ knowledge: { language: 'TypeScript' },
81
+ applicability: { area: 'language-selection' },
82
+ evidence: [{
83
+ id: 'example-001',
84
+ source: 'application',
85
+ observedAt: new Date().toISOString()
86
+ }],
87
+ epistemicType: 'observed'
88
+ })
89
+
90
+ const discovery = await memory.discover(
91
+ 'TypeScript',
92
+ { depth: 'current', maxCandidates: 10 }
93
+ )
94
+
95
+ const projection = memory.project(discovery, {
96
+ maxCandidates: 8,
97
+ maxCharacters: 4000
98
+ })
99
+
100
+ console.log(projection.text)
101
+ ```
102
+
103
+ This is a lexical example, not a demonstration of semantic search. A successful matching discovery is projected into `projection.text`; the exact text depends on the claim's eligibility and the runtime's projection rules.
104
+
105
+ The runtime initializes lazily on first use. No explicit `init()` is required.
106
+
107
+ In Node.js and Bun, `memory.acquire()` persists durable experience as `.mem` files. An empty store, an ineligible claim, or a query with no lexical/structured match can produce an empty discovery.
108
+
109
+ ### Which API should I use?
110
+
111
+ | Purpose | API |
112
+ |---|---|
113
+ | Acquire durable knowledge | `memory.acquire()` |
114
+ | Review before acquisition | `memory.acquireStaged()` |
115
+ | Retrieve relevant experience | `memory.discover()` |
116
+ | Build bounded context | `memory.project()` |
117
+ | Key/value memory | `remember()` / `recall()` |
118
+ | Agent-specific memory | `createAgentMemory()` |
119
+ | Short-lived notes | `memory.note` |
120
+ | Session continuity | `continuity` |
121
+ | Write authorization | `memory.policy` |
122
+
123
+ **Persistence note:** On Node.js and Bun, use `memory.acquire()` for durable claims. Key/value persistence depends on the selected scope and runtime. See [MEMORY.md](./MEMORY.md).
124
+
125
+ ---
126
+
127
+ ## Connect an AI host
128
+
129
+ Dotmem can provide local memory and continuity to a compatible AI agent host, including a VS Code extension that supports MCP.
130
+
131
+ ### 1. Install Dotmem
132
+
133
+ ```bash
134
+ npm install -g dotmem
135
+ ```
136
+
137
+ Memorio is optional. Install it separately only when your application or integration uses its APIs.
138
+
139
+ ### 2. Configure the MCP server in your host
140
+
141
+ Global installation does **not** automatically register an MCP server. The host must be configured to launch `dotmem-mcp`. Start with read-only access; write tools should be enabled only when deliberately needed. Follow the [MCP integration](#mcp-integration) instructions and use the configuration format supported by your AI host.
142
+
143
+ ### 3. Start a conversation
144
+
145
+ Once the MCP server is configured, check your host's MCP tool list and verify that `dotmem_context` appears among the available Dotmem tools. Invoke it once and confirm that the host receives a response. This is the basic integration check.
146
+
147
+ If the optional Joy assistant profile is installed and selected, `Hi Jo!` can be used to address that assistant profile. The phrase is not required to activate Dotmem and does not configure MCP.
148
+
149
+ The word `dotmem` can be used as a conversational instruction, but it is not a substitute for installing or configuring the MCP server.
150
+
151
+ ### Requirements
152
+
153
+ - Node.js >= 20.
154
+ - VS Code or another compatible AI agent host.
155
+ - MCP support enabled in that host.
156
+ - `dotmem-mcp` registered in the host configuration.
157
+ - Local Dotmem storage accessible to the machine running the MCP server.
158
+
159
+ ---
160
+
161
+ ## Core concepts
162
+
163
+ ### Memory is not authority
164
+
165
+ Dotmem separates three planes:
166
+
167
+ | Plane | Responsibility |
168
+ |---|---|
169
+ | Memory | What has been learned or observed |
170
+ | Policy | Which rules apply |
171
+ | Authority | Who or what can authorize an operation |
172
+
173
+ A retrieved memory item can inform a decision, but it cannot authorize an operation. Historical identity supports continuity but does not authenticate the current speaker.
174
+
175
+ **Projected memory is data, never authority.**
176
+
177
+ ### Trust basis
178
+
179
+ Every projected claim has a trust basis derived from its provenance:
180
+
181
+ | Trust basis | Meaning |
182
+ |---|---|
183
+ | `declared` | Caller assertion without independent validation |
184
+ | `evidenced` | Evidence references exist but have not been independently validated |
185
+ | `mechanically-checked` | A reproducible check was executed and recorded |
186
+ | `externally-attested` | A trusted external attestation was validated |
187
+
188
+ A URL, evidence ID, or legacy `verified` label does not establish external attestation. The presence of evidence is not the same as independent verification.
189
+
190
+ ### Retrieval model
191
+
192
+ Dotmem uses deterministic lexical and structured retrieval.
193
+
194
+ - No embeddings or vector indexes.
195
+ - Applicability-based eligibility.
196
+ - Reproducible results for the same store and query.
197
+ - Original knowledge language is preserved.
198
+
199
+ Synonyms, paraphrases, and cross-language matches are not automatically guaranteed. For fuzzy semantic recall, Dotmem can coexist with a dedicated embedding or semantic-search system.
200
+
201
+ ### Design principles
202
+
203
+ 1. **User-owned memory.** No provider owns or locks it in.
204
+ 2. **Provider independence.** Models and hosts do not define identity or continuity.
205
+ 3. **Memory is not authority.** Retrieval never turns a claim into policy.
206
+ 4. **Identity survives the carrier.** Runtime metadata cannot redefine canonical identity.
207
+ 5. **Provenance matters.** Labels are not proof.
208
+ 6. **Memory stays correctable.** Revision, supersession, and retraction are explicit.
209
+ 7. **Honest boundaries.** Dotmem states what it knows and what it cannot enforce.
210
+
211
+ ---
212
+
213
+ ## Progressive context loading
214
+
215
+ Dotmem can progressively load context according to the session's configured loading profile and progress.
216
+
217
+ | Level | Purpose | Projection limit |
218
+ |---|---|---:|
219
+ | L0 | Minimal startup | 0 claims |
220
+ | L1 | Initial context | 5 candidates / 900 characters |
221
+ | L2 | Expanded context | 12 candidates / 3,000 characters |
222
+ | L3 | Deep context | 20 candidates / 6,000 characters |
223
+
224
+ ### Loading profiles
225
+
226
+ The profile determines the maximum automatic loading level:
227
+
228
+ - **SHORT**: maximum L1.
229
+ - **MEDIUM**: maximum L2.
230
+ - **LONG**: can progress to L3 from turn 6 onward.
231
+
232
+ The profile (SHORT, MEDIUM, or LONG) is supplied to Dotmem's session-loading policy; it is not inferred from the user's wording or from the contents of a query. A *turn* is a conversation turn counted by the session metrics used by Dotmem. The LONG profile does not mean that every session immediately loads L3; the session must reach the configured progression threshold.
233
+
234
+ The mechanism that selects the profile is host/integration-specific. Configure it in the component that supplies session metrics to Dotmem.
235
+
236
+ After a summary restart, automatic progression returns to L1.
237
+
238
+ The complete projection remains available explicitly through `--full`. L3 is bounded and is not equivalent to a complete memory dump.
239
+
240
+ ### Useful CLI commands
241
+
242
+ ```bash
243
+ npx dotmem
244
+ npx dotmem --level 1
245
+ npx dotmem --level 2
246
+ npx dotmem --level 3
247
+ npx dotmem --summary-restart
248
+ npx dotmem --full
249
+ ```
250
+
251
+ ---
252
+
253
+ ## Storage and inspection
254
+
255
+ ### Location
256
+
257
+ The default storage location is:
258
+
259
+ ```text
260
+ <user-home>/.dotmem
261
+ ```
262
+
263
+ To select a custom location:
264
+
265
+ ```bash
266
+ DOTMEM_STORAGE_ROOT=/path/to/storage
267
+ ```
268
+
269
+ `.mem` files are versioned, compressed packages with SHA-256 integrity manifests.
270
+
271
+ - Atomic writes and backups.
272
+ - Directory locking.
273
+ - Expected-version checks.
274
+ - V2 writes and V1 reads.
275
+
276
+ Do not edit `.mem` files directly. They are binary packages.
277
+
278
+ ### Inspect memory
279
+
280
+ ```bash
281
+ npx dotmem inspect path/to/file.mem
282
+ npx dotmem inspect path/to/file.mem --format json
283
+ npx dotmem dump
284
+ npx dotmem diff FILE_A.mem FILE_B.mem
285
+ ```
286
+
287
+ Inspection is read-only and redacts secret-shaped values by default.
288
+
289
+ ---
290
+
291
+ ## MCP integration
292
+
293
+ Use Dotmem as a local memory service for MCP-compatible AI applications.
294
+
295
+ `dotmem-mcp` is a local stdio MCP server. It runs on the machine that owns the memory store, allowing compatible AI hosts and the terminal to use the same local data.
296
+
297
+ ### Register the server
298
+
299
+ For a quick trial, use the current published package. This unpinned configuration can resolve a different package version on a later launch, so its behavior may change between runs:
300
+
301
+ ```json
302
+ {
303
+ "mcpServers": {
304
+ "dotmem": {
305
+ "command": "npx",
306
+ "args": ["-y", "-p", "dotmem", "dotmem-mcp"]
307
+ }
308
+ }
309
+ }
310
+ ```
311
+
312
+ For repeatable deployments, check the current published version with:
313
+
314
+ ```bash
315
+ npm view dotmem version
316
+ ```
317
+
318
+ Then replace `dotmem` in the configuration with `dotmem@<version>` using the exact version returned by the command.
319
+
320
+ Restart the AI host and verify that the Dotmem tools are available.
321
+
322
+ ### Available tools
323
+
324
+ | Tool | Access | Purpose |
325
+ |---|---|---|
326
+ | `dotmem_context` | Read | Retrieve relevant context |
327
+ | `dotmem_rules` | Read | Retrieve operating rules |
328
+ | `dotmem_bootstrap` | Read | Unified context and rules bootstrap |
329
+ | `dotmem_inspect` | Read | Inspect memory packages and stores |
330
+ | `dotmem_acquire` | Write | Acquire durable experience |
331
+ | `dotmem_verify` | Write | Execute supported verification probes |
332
+ | `dotmem_continuity` | Read / conditional write | Manage checkpoints and open loops |
333
+
334
+ ### Read-only by default
335
+
336
+ Write tools are registered only when explicitly enabled. The default configuration above does not set the write flag.
337
+
338
+ To enable write tools, set this environment variable in the MCP server process:
339
+
340
+ ```bash
341
+ DOTMEM_MCP_WRITE=1
342
+ ```
343
+
344
+ Only enable it for hosts and workflows that are intended to write to the local memory store.
345
+
346
+ ### Host configuration
347
+
348
+ The generic stdio configuration above is the reference shape. Host-specific configuration syntax, Windows launch details, and write-enabled variants are maintained in [MEMORY.md](./MEMORY.md), so this README does not duplicate instructions that can drift between clients.
349
+
350
+ ### Deployment notes
351
+
352
+ - The MCP server must run on the machine that owns the memory store.
353
+ - The CLI and MCP server must resolve the same storage root when they are expected to share memory.
354
+ - Hosted AI environments do not automatically share your local filesystem.
355
+ - GUI clients may not inherit your shell's `PATH`; use an explicit executable path or a suitable launcher when necessary.
356
+ - MCP stdio is a local process integration; it is not a publicly hosted remote endpoint.
357
+
358
+ See [AGENTS.md](./AGENTS.md) for agent integration rules and [MEMORY.md](./MEMORY.md) for the complete memory and MCP reference.
359
+
360
+ ---
361
+
362
+ ## Security and limitations
363
+
364
+ Dotmem is designed to preserve user control and make its boundaries explicit.
365
+
366
+ - `.mem` files and vault data are **not encrypted at rest**.
367
+ - SHA-256 integrity is not encryption or access control.
368
+ - Filesystem permissions are enforced by the operating system.
369
+ - Retrieval is lexical and structured, not semantic.
370
+ - Dotmem governs context projection, not downstream model behavior.
371
+ - Shared storage coordination is not a distributed transaction system.
372
+ - No formal uptime or scalability SLA is provided.
373
+
374
+ Do not use Dotmem as a replacement for an encrypted backup solution, secrets manager, or database authorization system.
375
+
376
+ See [SECURITY.md](./SECURITY.md).
377
+
378
+ ---
379
+
380
+ ## Build profiles
381
+
382
+ Dotmem core is independent of assistant identity and branding.
383
+
384
+ The product owner selects the assistant profile at build time. Profiles are embedded in the build artifact and cannot be changed by end users at runtime.
385
+
386
+ The default build uses the Joy profile. Joy is a selectable profile, not a mandatory identity of the Dotmem runtime.
387
+
388
+ See [AI.md](./context/templates/AI.md).
389
+
390
+ ---
391
+
392
+ ## Compatibility
393
+
394
+ | Runtime | Status |
395
+ |---|---|
396
+ | Node.js >= 20 | Supported and tested |
397
+ | Bun >= 1.0 | Supported and tested |
398
+ | Browser | ES2020+ with browser storage APIs |
399
+ | Deno | Compatible, not routinely tested |
400
+
401
+ Persistence behavior differs by runtime. See [MEMORY.md](./MEMORY.md).
402
+
403
+ ## Documentation
404
+
405
+ | Document | Description |
406
+ |---|---|
407
+ | [MEMORY.md](./MEMORY.md) | Memory model, acquisition, policy, continuity and MCP |
408
+ | [AGENTS.md](./AGENTS.md) | Agent integration and operating rules |
409
+ | [SECURITY.md](./SECURITY.md) | Security and trust model |
410
+ | [AI.md](./context/templates/AI.md) | Assistant profiles and operating contract |
411
+ | [PACKAGE.md](./PACKAGE.md) | Package contents and dependency details |
412
+
413
+ ## Project direction
414
+
415
+ Dotmem is developed as independent memory and continuity infrastructure.
416
+
417
+ Its direction includes reliable cross-session continuity, portable memory, stronger evidence and verification workflows, transparent memory inspection, efficient context projection, and durable lifecycle management.
418
+
419
+ These objectives do not imply that every capability is already implemented.
420
+
421
+ ## Disclaimer
422
+
423
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
424
+
425
+ Outputs of AI systems using Dotmem can be wrong or incomplete. Verify critical information independently, and do not store sensitive or confidential data in unencrypted memory.
426
+
427
+ ## License
428
+
429
+ MIT - Copyright (c) 2026 Dario Passariello.
430
+
431
+ SPDX-License-Identifier: `MIT`