dotmem 0.0.5 → 0.0.8
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/AGENTS.md +514 -0
- package/CHANGELOG.md +0 -0
- package/DOTMEM.md +539 -41
- package/LICENSE.md +9 -0
- package/MEMORY.md +606 -0
- package/PACKAGE.md +57 -0
- package/README.md +417 -0
- package/SECURITY.md +525 -0
- package/agent.cjs +16 -4
- package/agent.js +16 -4
- package/cli.cjs +3995 -4671
- package/cli.js +3653 -4263
- package/env.cjs +6 -0
- package/env.js +4 -0
- package/global.cjs +49 -44
- package/global.d.ts +13 -14
- package/global.js +41 -25
- package/index.cjs +1465 -21195
- package/index.js +1437 -21176
- package/llms.txt +301 -0
- package/mcp.cjs +1747 -36854
- package/mcp.js +1730 -36833
- package/package.json +5 -7
- package/types/exports.d.ts +297 -304
- package/types/bun-sqlite.d.ts +0 -14
package/README.md
ADDED
|
@@ -0,0 +1,417 @@
|
|
|
1
|
+
# dotmem (.mem)
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+
|
|
5
|
+
AI memory and continuity infrastructure for agents and applications.
|
|
6
|
+
|
|
7
|
+
**Built on:** [memorio](https://www.npmjs.com/package/memorio) (state, store, session, IndexedDB, SQLite, cache)
|
|
8
|
+
|
|
9
|
+
Dotmem provides structured, queryable, and policy-controlled memory for AI agents. It supports experience acquisition, bounded context projection, continuity across sessions, rule-based reasoning, and MCP integration. The memory substrate is independent of a specific model, vendor, host or conversational client.
|
|
10
|
+
|
|
11
|
+
> **Retrieval model**: dotmem uses deterministic lexical/structured retrieval with applicability-based eligibility. It does not use embeddings, vector indexes, or semantic similarity search. The term "AI-oriented" refers to the memory lifecycle and API design (acquisition with evidence/provenance, applicability scoping, policy-gated writes, context projection for LLM consumption), not the underlying retrieval algorithm. For semantic/vector search, pair dotmem with a dedicated embedding store.
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm i dotmem
|
|
19
|
+
# or
|
|
20
|
+
bun i dotmem
|
|
21
|
+
# or
|
|
22
|
+
pnpm i dotmem
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## Quick Start
|
|
28
|
+
|
|
29
|
+
```typescript
|
|
30
|
+
import { memory } from 'dotmem'
|
|
31
|
+
|
|
32
|
+
// Discover relevant acquired experience for a situation
|
|
33
|
+
const discovery = await memory.discover('User needs a language recommendation for a new project', {
|
|
34
|
+
depth: 'current',
|
|
35
|
+
maxCandidates: 10
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
// Project a bounded context from discovered claims
|
|
39
|
+
const projection = memory.project(discovery, { maxCandidates: 5, maxCharacters: 4000 })
|
|
40
|
+
console.info(projection.text)
|
|
41
|
+
|
|
42
|
+
// Acquire durable experience (persists across restarts via .mem files)
|
|
43
|
+
await memory.acquire({
|
|
44
|
+
id: 'user.language-preference',
|
|
45
|
+
knowledge: { language: 'TypeScript' },
|
|
46
|
+
applicability: { area: 'language-selection' },
|
|
47
|
+
evidence: [{ id: 'conv-001', source: 'conversation', observedAt: new Date().toISOString() }],
|
|
48
|
+
epistemicType: 'observed'
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
// Remember a key/value entry with confidence and scope
|
|
52
|
+
// `remember()` with scope `durable` uses IndexedDB and is browser-only. For Node/Bun, use memory.acquire().
|
|
53
|
+
await memory.remember('user.pref.theme', 'dark', {
|
|
54
|
+
type: 'preference',
|
|
55
|
+
confidence: 0.9,
|
|
56
|
+
scope: 'local',
|
|
57
|
+
tags: ['ui', 'user']
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
// Recall by key
|
|
61
|
+
const theme = await memory.recall<string>('user.pref.theme')
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
> **Scope reference**: See [MEMORY.md#application-memory-scopes-rememberrecall](./MEMORY.md#application-memory-scopes-rememberrecall) for a detailed comparison of `hot`, `session`, `local`, and `durable` scopes across runtimes.
|
|
65
|
+
|
|
66
|
+
### Agent API
|
|
67
|
+
|
|
68
|
+
Each agent gets a logically partitioned memory namespace via `dotmem/agent`:
|
|
69
|
+
|
|
70
|
+
```typescript
|
|
71
|
+
import { createAgentMemory } from 'dotmem/agent'
|
|
72
|
+
|
|
73
|
+
const agent = createAgentMemory('support-agent')
|
|
74
|
+
|
|
75
|
+
// Keys are automatically namespaced: agent:support-agent:<key>
|
|
76
|
+
// `remember()` with scope `durable` uses IndexedDB and is browser-only. For Node/Bun, use memory.acquire().
|
|
77
|
+
await agent.remember('greeting', 'Hello! How can I help?', {
|
|
78
|
+
type: 'fact',
|
|
79
|
+
confidence: 0.9,
|
|
80
|
+
scope: 'local',
|
|
81
|
+
tags: ['greeting']
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
// Context retrieval is automatically filtered to this agent's tags
|
|
85
|
+
const context = await agent.context({ tags: ['greeting'], minConfidence: 0.5 })
|
|
86
|
+
|
|
87
|
+
// Temporal history and branching
|
|
88
|
+
await agent.enable() // enable temporal tracking
|
|
89
|
+
const entry = await agent.history('greeting')
|
|
90
|
+
const branch = await agent.branch() // isolated "what-if" branch
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
## MCP Server
|
|
96
|
+
|
|
97
|
+
`dotmem-mcp` is the stdio MCP server. It runs on the operator's machine so a connected AI host and the terminal share the same store. Write access is gated by an environment flag.
|
|
98
|
+
|
|
99
|
+
| Tool | Direction | Registered when | Use it when |
|
|
100
|
+
|------|-----------|-----------------|-------------|
|
|
101
|
+
| `dotmem_context` | read | always | You need acquired experience relevant to the current situation. |
|
|
102
|
+
| `dotmem_rules` | read | always | You need the iron rules that constrain every session. |
|
|
103
|
+
| `dotmem_acquire` | write | `DOTMEM_MCP_WRITE=1` | The work produced reusable, project-specific experience worth keeping. |
|
|
104
|
+
| `dotmem_continuity` | read / write | Always registered; write actions require `DOTMEM_MCP_WRITE=1` | Read continuation status, summaries and open loops; optionally create checkpoints and manage open loops. |
|
|
105
|
+
| `dotmem_note_read` | read | always | Read a user note by id. |
|
|
106
|
+
| `dotmem_note_write` | write | `DOTMEM_MCP_WRITE=1` | Add or update a user note. |
|
|
107
|
+
|
|
108
|
+
Without `DOTMEM_MCP_WRITE=1`, `dotmem_acquire` is not registered and does not appear in `tools/list`. The `dotmem_continuity` tool is always registered: read actions (`status`, `summaries`, `open-loops`, `evaluate`) remain available, while write actions (`checkpoint`, `add-open-loop`, `resolve-open-loop`) are denied.
|
|
109
|
+
|
|
110
|
+
To opt in to writes, explicitly add `DOTMEM_MCP_WRITE=1` to the MCP server environment. For Claude Desktop and compatible JSON configurations, add `"env": { "DOTMEM_MCP_WRITE": "1" }`; for Kilo/OpenCode use `"environment": { "DOTMEM_MCP_WRITE": "1" }`; for Claude Code use `claude mcp add --env DOTMEM_MCP_WRITE=1 ...`.
|
|
111
|
+
|
|
112
|
+
### Claude Desktop
|
|
113
|
+
|
|
114
|
+
Read-only by default:
|
|
115
|
+
|
|
116
|
+
```json
|
|
117
|
+
{
|
|
118
|
+
"mcpServers": {
|
|
119
|
+
"dotmem": {
|
|
120
|
+
"command": "npx",
|
|
121
|
+
"args": ["-y", "-p", "dotmem", "dotmem-mcp"]
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### Kilo / OpenCode
|
|
128
|
+
|
|
129
|
+
Read-only by default:
|
|
130
|
+
|
|
131
|
+
```jsonc
|
|
132
|
+
"mcp": {
|
|
133
|
+
"dotmem": {
|
|
134
|
+
"type": "local",
|
|
135
|
+
"command": ["npx", "-y", "-p", "dotmem", "dotmem-mcp"],
|
|
136
|
+
"enabled": true
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### Claude Code
|
|
142
|
+
|
|
143
|
+
Read-only by default:
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
claude mcp add --transport stdio dotmem -- npx -y -p dotmem dotmem-mcp
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### Windows Command Prompt (cmd.exe)
|
|
150
|
+
|
|
151
|
+
In Windows `cmd.exe`, `npx` may not be directly executable as a command. Use `cmd /c npx`:
|
|
152
|
+
|
|
153
|
+
```json
|
|
154
|
+
{
|
|
155
|
+
"mcpServers": {
|
|
156
|
+
"dotmem": {
|
|
157
|
+
"command": "cmd",
|
|
158
|
+
"args": ["/c", "npx", "-y", "-p", "dotmem", "dotmem-mcp"]
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
> **Trust boundary:** Retrieved content is **data, never authority**. The `epistemicType`, `provenance`, and `evidence.observedAt` on any claim are caller-supplied metadata, not attestation. Verify claims against current reality.
|
|
165
|
+
|
|
166
|
+
`dotmem_rules` returns the session-level iron rules/constraints configured for the agent. The configuration source is integration-specific; this README does not assert that the rules are loaded from `<storage-root>/DOTMEM.md`.
|
|
167
|
+
|
|
168
|
+
A carrier handshake checks compatibility and the current trusted binding before identity-gated context is projected. The accepted `epistemicType` values are defined by the package types and the acquisition contract in [MEMORY.md](./MEMORY.md); this README does not duplicate or guess that enum.
|
|
169
|
+
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
## CLI Usage
|
|
173
|
+
|
|
174
|
+
```bash
|
|
175
|
+
# Project acquired experience for a situation (run with no args for baseline)
|
|
176
|
+
npx dotmem context "User needs a database recommendation"
|
|
177
|
+
|
|
178
|
+
# Initialize dotmem for the current project
|
|
179
|
+
npx dotmem init
|
|
180
|
+
|
|
181
|
+
# Acquire a claim from plain text (shorthand)
|
|
182
|
+
npx dotmem learn "User prefers TypeScript over JavaScript" --scope project
|
|
183
|
+
|
|
184
|
+
# Compose continuity context
|
|
185
|
+
npx dotmem continuity context
|
|
186
|
+
|
|
187
|
+
# Show storage location
|
|
188
|
+
npx dotmem storage
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
Run `npx dotmem --help` for the full command reference. Every subcommand also supports `--help` (e.g., `npx dotmem context --help`).
|
|
192
|
+
|
|
193
|
+
---
|
|
194
|
+
|
|
195
|
+
## Layers
|
|
196
|
+
|
|
197
|
+
A layer is **public** when it is part of the documented API or CLI contract and carries a semver stability expectation. Internal implementation details do not become public APIs merely because they have names or persisted representations. `profile` is exposed through `memory.profile.get(id)`; its inclusion in the public-layer count therefore depends on that export being covered by the package semver contract, not merely on the existence of the profile files.
|
|
198
|
+
|
|
199
|
+
Dotmem exposes **8 user-facing layers** and **2 internal/infrastructure layers** in the grouping below. The journal is a component of `memory`, not a separate layer.
|
|
200
|
+
|
|
201
|
+
### User-Facing Layers (Public API)
|
|
202
|
+
|
|
203
|
+
| Layer | Purpose | Notes |
|
|
204
|
+
|-------|---------|-------|
|
|
205
|
+
| **memory** | Key/value memory, acquisition lifecycle, journal and sync | Core facade: `discover`, `context`, `project`, `acquire`, `acquireStaged`, `remember`, `recall`, `update`, `forget`, `patch`, `stats`, `clear`; journal exposed as `memory.journal` |
|
|
206
|
+
| **knowledge** | Claim evaluation, policy enforcement, applicability matching | Runtime: `evaluatePolicies`, `resolveEffectiveTier`, `matchApplicability`, `deriveSituationApplicability`; see [MEMORY.md](./MEMORY.md) for acquisition and policy contracts |
|
|
207
|
+
| **logic** | Logic engine: rule learning, precedent matching, context measurement | API: `experience`, `precedents`, `context`, `measure`, `learn`, `clear`; see [PACKAGE.md](./PACKAGE.md) for package surface and contents |
|
|
208
|
+
| **continuity** | USER + PROJECT + TASK context composition, snapshots, open loops | CLI: `continuity` `context` `snapshot` `forget` `loop management` |
|
|
209
|
+
| **agent** | Agent-facing memory with logical namespace partitioning | `dotmem/agent` — `createAgentMemory(agentId)` |
|
|
210
|
+
| **policy** | Policy definition, authority management, four-tier enforcement | CLI: `dotmem policy`, `dotmem handshake`, `dotmem guard`; see [MEMORY.md](./MEMORY.md) and [SECURITY.md](./SECURITY.md) |
|
|
211
|
+
| **profile** | Identity and persona documents | `memory.profile.get(id)`; optional agent profile, including Joy |
|
|
212
|
+
| **note** | Short-lived notes with tags and origins | CLI: `dotmem note`; `memory.note` |
|
|
213
|
+
|
|
214
|
+
### Internal / Infrastructure Layers
|
|
215
|
+
|
|
216
|
+
| Layer | Purpose | Notes |
|
|
217
|
+
|-------|---------|-------|
|
|
218
|
+
| **seed** | Development-only initial memory seed | `--dev` required |
|
|
219
|
+
| **llm-cache** | LLM response cache types only; no verified runtime implementation in the current package | `types/llm-cache.d.ts` |
|
|
220
|
+
|
|
221
|
+
> Dotmem re-exports its foundational infrastructure: `state` (reactive state), `store` (key/value storage), `idb` (IndexedDB) and `sqlite` (SQL database integration). These are lower-level utilities, not additional AI memory layers. See the foundation package documentation for their detailed contracts.
|
|
222
|
+
|
|
223
|
+
---
|
|
224
|
+
|
|
225
|
+
## Memory Model
|
|
226
|
+
|
|
227
|
+
dotmem uses a **discover → project → acquire** memory model:
|
|
228
|
+
|
|
229
|
+
1. **Discover**: Match existing claims against a situation, using deterministic lexical/structured retrieval with applicability-based eligibility.
|
|
230
|
+
2. **Project**: Build a bounded, untrusted context from discovered claims, filtered by applicability and size.
|
|
231
|
+
3. **Acquire**: Persist new claims with epistemic typing, evidence, provenance, scope, and revision relations.
|
|
232
|
+
|
|
233
|
+
### Continuity Lifecycle
|
|
234
|
+
|
|
235
|
+
The continuity layer helps an agent resume work across sessions by capturing the current state, creating checkpoints, compacting older context into summaries, and restoring relevant context when work resumes. The lifecycle is:
|
|
236
|
+
|
|
237
|
+
`capture → checkpoint → compact → resume → verify`
|
|
238
|
+
|
|
239
|
+
| Provides | Does not guarantee |
|
|
240
|
+
|----------|--------------------|
|
|
241
|
+
| Persisted checkpoints, summaries, and tracked open loops for later retrieval | A perfect reconstruction of every message or detail from the original conversation |
|
|
242
|
+
| Bounded context composition from the available continuity records | That information never captured or persisted can be recovered |
|
|
243
|
+
| A resumable record of the objective, progress, and outstanding work when those details were captured | That a model will interpret every retrieved item correctly or behave identically across models and clients |
|
|
244
|
+
| A verification step so the resumed agent can check the restored state before continuing | Infinite context, zero information loss, or automatic correctness of historical claims |
|
|
245
|
+
|
|
246
|
+
Continuity quality depends on what the agent captures, checkpoint quality, storage availability, and retrieval of the relevant records. Treat a resumed context as a working reconstruction to verify, not as a verbatim replay of the entire conversation. See the `continuity` layer and the `dotmem_continuity` MCP tool above for the available operations.
|
|
247
|
+
|
|
248
|
+
### Memory Types
|
|
249
|
+
|
|
250
|
+
| Type | Purpose |
|
|
251
|
+
|------|---------|
|
|
252
|
+
| `fact` | Observable or verified facts |
|
|
253
|
+
| `preference` | User or agent preferences |
|
|
254
|
+
| `decision` | Architectural or workflow decisions |
|
|
255
|
+
| `task` | Task-related information |
|
|
256
|
+
| `context` | Situational context |
|
|
257
|
+
|
|
258
|
+
### Memory Kinds
|
|
259
|
+
|
|
260
|
+
Acquired claims carry a `kind`: `experience` (project/user learnings), `agent` (agent-specific notes), `relationship` (cross-agent or cross-project relationships), `logic` (rule-based knowledge), `note` (short-lived notes).
|
|
261
|
+
|
|
262
|
+
### Scopes
|
|
263
|
+
|
|
264
|
+
| Scope | Storage (Browser) | Storage (Node/Bun) | Lifecycle |
|
|
265
|
+
|-------|-------------------|---------------------|-----------|
|
|
266
|
+
| `hot` | `state` (memory) | `state` (memory) | Cleared on process exit / navigation |
|
|
267
|
+
| `session` | `session` (sessionStorage) | `session` (in-memory Map) | Persists for active session / tab; lost on restart |
|
|
268
|
+
| `local` | `store` (localStorage) | `store` (in-memory Map) | Survives reload in browser; lost on process restart in Node/Bun |
|
|
269
|
+
| `durable` | `idb` (IndexedDB) | *Not available via this path* | Survives restarts in browser only |
|
|
270
|
+
|
|
271
|
+
> For durable persistence in Node/Bun, use `memory.acquire()` which writes to `.mem` package files on disk. The `memory.remember()` `durable` scope uses IndexedDB and is browser-only.
|
|
272
|
+
|
|
273
|
+
### Discovery Depths
|
|
274
|
+
|
|
275
|
+
| Depth | Meaning |
|
|
276
|
+
|-------|---------|
|
|
277
|
+
| `current` | Only active claims (no superseded/obsolete) |
|
|
278
|
+
| `deep` | All claims including superseded and obsolete |
|
|
279
|
+
|
|
280
|
+
### Policy Enforcement
|
|
281
|
+
|
|
282
|
+
Policies are evaluated at acquisition time against a four-tier enforcement model:
|
|
283
|
+
|
|
284
|
+
| Tier | Behavior |
|
|
285
|
+
|------|----------|
|
|
286
|
+
| **context** | Supplies contextual information; does not itself impose a blocking precondition |
|
|
287
|
+
| **precondition** | Blocks the governed operation when the condition is violated or unresolved |
|
|
288
|
+
| **hard-precondition** | Retains the stronger enforcement semantics defined by the policy contract |
|
|
289
|
+
|
|
290
|
+
Policy conditions match against situation vectors, epistemic types, evidence sources, and content topics. Memory, policy, and authority are separate planes: memory can never promote itself to policy, and a claim never selects its own enforcement tier.
|
|
291
|
+
|
|
292
|
+
### Claims and Corrections
|
|
293
|
+
|
|
294
|
+
Claims are immutable and unique by ID. To change a claim, acquire a new one with exactly one revision relation:
|
|
295
|
+
|
|
296
|
+
- `refines` — narrows or extends
|
|
297
|
+
- `supersedes` — replaces
|
|
298
|
+
- `retracts` — withdraws
|
|
299
|
+
|
|
300
|
+
---
|
|
301
|
+
|
|
302
|
+
## Storage
|
|
303
|
+
|
|
304
|
+
dotmem storage is user-anchored and resolved at runtime. The canonical storage root is `<user-home>/.mem`, relocatable via the `DOTMEM_STORAGE_ROOT` environment variable.
|
|
305
|
+
|
|
306
|
+
```bash
|
|
307
|
+
npx dotmem storage # show location + resolved root
|
|
308
|
+
npx dotmem storage relocate /path # migrate to an explicit absolute directory
|
|
309
|
+
npx dotmem storage restore # migrate back to default
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
Project experience is stored under `<storage-root>/projects/<project-id>.mem`. User experience uses `user.mem`, agent memory uses `agent.mem`, and logic data uses `logic.mem`. These are `.mem` packages — compressed ZIP archives with SHA-256 integrity manifests. Read them through `npx dotmem inspect`, never by byte-searching.
|
|
313
|
+
|
|
314
|
+
---
|
|
315
|
+
|
|
316
|
+
## Optional Joy Identity Integration
|
|
317
|
+
|
|
318
|
+
Dotmem core is model- and persona-independent. Joy/Jo is an optional agent identity/profile integration, not a requirement of the memory substrate. Its activation convention is separate from ordinary memory operations.
|
|
319
|
+
|
|
320
|
+
### What are Joy and Jo?
|
|
321
|
+
|
|
322
|
+
**Joy** is the canonical AI identity/profile for dotmem — the operational role name that comes from the profile, not from the runtime. **Jo** is an alternative shorthand for the same identity. They represent the assistant's persistent identity in the dotmem system (canonical profile, decision-making behavior, trust model, and relationship style).
|
|
323
|
+
|
|
324
|
+
The canonical profile (`core/profile/`) defines:
|
|
325
|
+
- **Identity & behavior** (`behavior.md`, `soul.md`) — character, relationship style, conversational behavior
|
|
326
|
+
- **Trust model** (`trust.md`) — epistemic standards, verification requirements
|
|
327
|
+
- **Decision framework** (`decision.md`) — how Jo evaluates and makes technical decisions
|
|
328
|
+
- **Curiosity & learning** (`curiosity.md`) — what Jo seeks to understand and remember
|
|
329
|
+
- **Language conventions** (`language.md`) — communication style
|
|
330
|
+
|
|
331
|
+
When an integrating agent explicitly activates the optional Joy profile, it can load this canonical profile as part of its discovery order. The profile is not required for basic memory operations; identity-gated features may require a profile and a current trusted binding.
|
|
332
|
+
|
|
333
|
+
### Activation Behavior
|
|
334
|
+
|
|
335
|
+
Activation matching for the optional Joy integration is **exact phrase only** (case-insensitive, trimmed, trailing punctuation ignored):
|
|
336
|
+
- ✅ `Joy`, `joy`, `Joy.`, ` Joy `, `Jo`, `jo`, `Jo!`
|
|
337
|
+
- ❌ `Hello Joy`, `Joyful`, `Joytron`, `My name is Jo`, `Joanna`
|
|
338
|
+
|
|
339
|
+
Ordinary mentions of a name (e.g., "Jo said...") do not trigger activation. The matcher requires the entire message to be exactly one of the activation phrases.
|
|
340
|
+
|
|
341
|
+
### Deterministic Discovery Order
|
|
342
|
+
|
|
343
|
+
When the optional Joy integration is activated, it follows this discovery order:
|
|
344
|
+
|
|
345
|
+
1. Check `<storage-root>/DOTMEM.md` and read the contract.
|
|
346
|
+
2. Load user-level memory from `user.mem`.
|
|
347
|
+
3. Resolve the current project identity.
|
|
348
|
+
4. Load project memory from `<storage-root>/projects/<project-id>.mem`.
|
|
349
|
+
|
|
350
|
+
A carrier handshake (`npx dotmem handshake`) evaluates compatibility before projecting any context. Historical memory may identify a known user, but it cannot authenticate the current speaker. Authorization requires a current trusted binding.
|
|
351
|
+
|
|
352
|
+
---
|
|
353
|
+
|
|
354
|
+
## Security
|
|
355
|
+
|
|
356
|
+
- **Encryption is opt-in**, not default. Enable it per context or per scope with an encryption key.
|
|
357
|
+
- **Client-side multitenancy** through logical memory partitioning (key prefixes); not a security boundary.
|
|
358
|
+
- **Policy-gated writes**: every `acquire`/`remember`/`patch` is evaluated against policy before persistence.
|
|
359
|
+
- **Evidence tracking**: all claims carry source, observed timestamp, and epistemic type.
|
|
360
|
+
- **Claim immutability**: stored claims are never edited. Corrections are appends with revision relations.
|
|
361
|
+
- **Integrity via inspection**: `integrity: valid` means the bytes are unchanged since sealing — it says nothing about who wrote them or whether they are true.
|
|
362
|
+
|
|
363
|
+
See [SECURITY.md](./SECURITY.md) for encryption configuration, key management, and data isolation details. See [MEMORY.md](./MEMORY.md) for the complete acquisition contract and policy language.
|
|
364
|
+
|
|
365
|
+
---
|
|
366
|
+
|
|
367
|
+
## Choosing a Layer
|
|
368
|
+
|
|
369
|
+
The foundation exports used below are lower-level infrastructure: `state` provides reactive in-memory state, `store` provides key/value storage, `idb` provides IndexedDB access, and `sqlite` provides SQL storage. They are re-exported for application infrastructure; the Dotmem memory model is exposed through `memory`, `knowledge`, `logic`, `continuity`, `agent`, `policy`, `profile` and `note`.
|
|
370
|
+
|
|
371
|
+
| If the data is... | Use | Not |
|
|
372
|
+
|---|---|---|
|
|
373
|
+
| UI-reactive, ephemeral | `state` | `store` (unnecessary persistence) |
|
|
374
|
+
| UI-reactive, must survive reload (browser) | `state` + `state.persist(path)` | hand-rolled sync |
|
|
375
|
+
| Small key/value, must survive reload (browser) | `store` | `idb` (overkill) |
|
|
376
|
+
| Durable acquired experience across process restarts (Node/Bun) | `memory.acquire()` | `memory.remember(scope: 'durable')` (browser-only) |
|
|
377
|
+
| Structured, needs confidence/TTL/source | `memory.remember()` | `state`/`store` (no lifecycle) |
|
|
378
|
+
| Structured, needs evidence/provenance | `memory.acquire()` | `memory.remember()` (no evidence) |
|
|
379
|
+
| Relational, needs SQL | `sqlite` | `idb` (no query language) |
|
|
380
|
+
| Large browser-only structured data | `idb` | `store` |
|
|
381
|
+
| AI agent memory | `dotmem/agent` | `memory` (no logical namespace partitioning) |
|
|
382
|
+
|
|
383
|
+
> **Note**: `remember({ scope: 'durable' })` uses IndexedDB and is available through this path in browsers only. It does not switch to `.mem` package storage in Node.js or Bun. For durable acquired experience across process restarts in Node.js and Bun, use `memory.acquire()`. `store` and `session` fall back to in-memory `Map`s in those runtimes.
|
|
384
|
+
|
|
385
|
+
---
|
|
386
|
+
|
|
387
|
+
## Documentation
|
|
388
|
+
|
|
389
|
+
| Document | Description |
|
|
390
|
+
|----------|-------------|
|
|
391
|
+
| [MEMORY.md](./MEMORY.md) | Full memory model: acquisition contract, policy language, epistemic typing |
|
|
392
|
+
| [AGENTS.md](./AGENTS.md) | AI agent working rules, activation phrases, complete `memory.*` surface |
|
|
393
|
+
| [SECURITY.md](./SECURITY.md) | Encryption, multitenancy, key management, threat model |
|
|
394
|
+
| [PACKAGE.md](./PACKAGE.md) | Package contents, full quick-start, dependency graph |
|
|
395
|
+
| [LICENSE.md](./LICENSE.md) | License |
|
|
396
|
+
|
|
397
|
+
---
|
|
398
|
+
|
|
399
|
+
## Compatibility
|
|
400
|
+
|
|
401
|
+
**License**: MIT (SPDX: `MIT`)
|
|
402
|
+
|
|
403
|
+
**Supported runtimes**:
|
|
404
|
+
- Node.js ≥ 18.0.0 (declared in `package.json` engines)
|
|
405
|
+
- Bun ≥ 1.0 (tested in CI)
|
|
406
|
+
- Browser (ES2020+ with IndexedDB, localStorage, sessionStorage)
|
|
407
|
+
- Deno (compatible, not routinely tested)
|
|
408
|
+
|
|
409
|
+
**Tested in CI**: Node.js 20.x, 22.x; Bun 1.x
|
|
410
|
+
|
|
411
|
+
**Note**: The `durable` scope in `memory.remember()` uses IndexedDB and is browser-only. For cross-restart persistence in Node/Bun, use `memory.acquire()` which writes `.mem` package files. The `store` and `session` layers fall back to in-memory `Map`s in Node/Bun/Deno and do not survive process restarts.
|
|
412
|
+
|
|
413
|
+
---
|
|
414
|
+
|
|
415
|
+
## License
|
|
416
|
+
|
|
417
|
+
(c) 2026 Dario Passariello. See [LICENSE.md](./LICENSE.md).
|