Contents

Storage and the Memory Model

View source on GitHub

Why three kinds of memory

The default Starter combines three independent Sources for different access patterns, and the Layered strategy composes them into each turn. This is a useful default, not a Core requirement or a restriction on third-party Sources:

Question Where it lives Reason
What must be known directly on the next turn? Runtime Memory Tiny and injected directly into the prompt
Which design or procedure needs to be read quickly and in full? active Documents Preserves Markdown structure without deep recall
Which historical facts and relationships should persist across sessions? Memory Spaces Independent databases, graph relationships, and on-demand recall
What happens when a long document is rarely used but must remain traceable? archived Documents Mnemon retains an index while the cold layer retains the original text

Recommended query gradient:

text
current request and repository facts
             |
             v
Runtime Memory already in prompt
             |
             v
search active Documents
             |
             v
recall active Memory Spaces
             |
             v
follow an exact cold reference when full text is required

Workspace participation

Storage scope chooses where data lives; excludedWorkspaces chooses which workspace conversations may use Mnemon. Exclusion defaults to an empty list, applies across all storage scopes, and includes child agents even when they use a different cwd. Existing data and conversation history remain intact. The workbench marks exclusions and permits inspection; removing an exclusion restores memory participation.

Cross-agent sharing boundary

Sharing does not broadcast conversations or files. Mnemon-enabled agents can share durable Native facts when each integrates Mnemon and can access the same storage root and recognized Stores. Third-party Providers share through their own workspace, user, bank, project or container scope. Runtime and Documents do not automatically enter other agents' context.

Choose a cross-agent sharing scope says which scope suits which kind of sharing. Concurrent processes rely on the Provider's own consistency guarantees; stop all users before offline copying or directly modifying local databases. See Operations.

Unified Root Directory

text
<storageRoot>/
+-- runtime/
|   +-- memories.json
|   +-- USER.md
|   +-- MEMORY.md
|   +-- archived/                  # local archive, only when no Memory Space could take one
|       +-- MEMORY.md
|       +-- memories.jsonl
+-- documents/
|   +-- index.json
|   +-- active/
|   +-- archived/
+-- skills/                        # Skills; never a Mnemon Pack component
|   +-- ledger.json
|   +-- evals.json
|   +-- trajectories/
|   +-- versions/
|   +-- market/
|   +-- trash/
+-- data/
|   +-- .dsh-memory-bodies.json
|   +-- <memory-space-id>/
|       +-- mnemon.db
+-- state/
    +-- machine.json              # this machine's identity and name; 0600; excluded from Mnemon Packs
    +-- tombstones.json           # deletions this machine has already exported; excluded from Mnemon Packs
    +-- runtime-index.json        # the runtime entries the last export carried; excluded from Mnemon Packs
    +-- review-ledger.json        # reconciliation proposals awaiting a decision; 0600; excluded from Mnemon Packs
    +-- idle-review/              # local per-session attempt/cooldown watermarks; opt-in; never Packed or synced
    +-- memory-providers.json     # third-party connection control plane; 0600; excluded from Mnemon Packs
    +-- sync-git.json             # Git sync configuration; 0600 when it holds a token; excluded from Mnemon Packs
    +-- sync/
        +-- git/                  # disposable Git mirror of the sync branch; never a Pack component

storageScope selects this whole root, not just the Mnemon databases; Storage scopes gives the root each scope resolves to. Opt-in split-root overrides allow individual components to share the global root while keeping MEMORY.md isolated per workspace: runtimeUserScope=global reads USER.md from the global root, documentsScope=global shares the global Project Documents library, and memorySpacesScope=global shares the global Memory Spaces databases and Provider registry. A Mnemon Pack or Git sync still operates on one selected root without silently mixing separate global roots. Workbench tasks use the inspected workspace; conversation tools and lifecycle hooks use their owning session's cwd and pinned View. Host path resolution never creates files or changes old roots.

The files under state/:

  • memory-providers.json stores third-party endpoints, target URIs, identities, and optional credentials. Its mode is 0600; the Host returns configured field names, never saved credential values.
  • sync-git.json holds the Git sync configuration: repository URL, branch, remote directory, commit identity, the automatic sync interval in minutes (autoBackupMinutes, 0 is off) and an optional token that HTTPS remotes use. It follows the same mode 0600 rule and the same redaction, and it is part of neither Config nor a Mnemon Pack.
  • The mirror under sync/git is a disposable Git work tree of the sync branch: push and pull work there so the storage root is never made a Git work tree, and deleting the mirror costs one fetch, never data. The mirror names the repository it was filled from in its own Git config (mnemon.origin) and is rebuilt for another one, so one repository's history never reaches another.
  • sync/last-run.json records when the last sync or merge finished, so the page can still say so after a restart.
  • machine.json records the identity every export is stamped with: a generated id, a label taken from the hostname unless the user renamed the machine, and the creation time.
  • tombstones.json records deletions this machine has already exported, and runtime-index.json records the runtime entries the last export carried; together they let a merge distinguish "this machine deleted it" from "this machine never had it", so an older pack cannot resurrect a deletion.
  • review-ledger.json holds reconciliation proposals and the opinions left on them, newest first, and is capped at 200 entries.

None of machine.json, tombstones.json, runtime-index.json and review-ledger.json is a Pack component, so none of them syncs: a machine's identity and its review history stay on the machine that produced them.

state/idle-review/<sha256(parentSessionId)>.json is a separate version-1 Host file containing the original session ID, safe integer attempts, and lastReviewAttemptAt (milliseconds, or null for an empty state). The root is the runtime graph actually serving that parent, independent of Source/View selection and the global USER.md option. Missing files start empty; malformed JSON, unknown versions, invalid IDs/numbers, files over 16 KiB and non-ENOENT I/O failures pause automatic review. New files use 0600 and the directory 0700 where supported.

Reservations use a short synchronous read/check/atomic-replace critical section guarded by an exclusive per-session <hash>.json.lock directory. Independent Hosts sharing a local root cannot both reserve the same budget: contention immediately pauses the losing automatic review. Locks are never stolen automatically. A crash can leave a reservation consumed or a lock abandoned; stop all affected Hosts before repairing state/removing an abandoned lock, then continue the conversation to check the state again. This is a local-filesystem guarantee; network filesystems must provide equivalent exclusive-directory creation and atomic replacement semantics. A failed replacement preserves the previous file. Watermarks and temporary files stay out of Packs and Git sync. They contain no conversation content or completion replay and have no automatic retention cleanup. Disabling the setting or rolling back does not delete them; manually deleting a session file resets its quota.

Runtime Memory

Semantics

  • target=user: identity, role, long-term preferences, habits, communication style, and explicit collaboration requirements.
  • target=memory: projects, environment, decisions, conventions, tool characteristics, and reusable experience.
  • importance=critical|normal|low: recorded importance, visible in the model projection and used for retention priority during maintenance.
  • branches (optional, target=memory only): a list of git branch names limiting where the entry is projected in the per-turn Runtime snapshot; entries without a branch list are visible on every branch.

There is currently no daily target.

Source of Truth and Projections

Within one root, runtime/memories.json is the sole source of truth. With runtimeUserScope=global, the effective snapshot combines only target=user entries from the global source with only target=memory entries from the selected source. Both JSON files and both Markdown projection pairs remain complete and unchanged; filtering occurs only in the effective Runtime controller. Each record contains:

text
content
created_at
updated_at
target
importance
branches (optional)
pinned (optional)

branches holds an optional list of git branch names for target=memory entries. An entry without branches (or with an empty list) is visible on every branch. When a session's workspace is a git working tree on branch B, the per-turn Runtime snapshot hides memory entries whose branches list does not include B; in non-git workspaces and at detached HEAD, every entry is projected. USER.md entries never carry branches.

USER.md and MEMORY.md are deterministic derived files of the complete store. Each item is normalized to one line, and items are separated by a line containing only §; § is a reserved character. During startup and prompt assembly, the control layer repairs missing or manually modified projections from the JSON source. Branch filtering applies only to the prompt projection, never to these files.

The Runtime Source adds a metadata line before an entry only when it has non-default annotations in the model-facing snapshot:

text
[importance=critical; created=14d; updated=2d]
Prefer concise replies.

created and updated are elapsed whole 24-hour days since the stored timestamps, computed once when the projection is captured. Ages below one day default to 0d and are omitted, as is importance=normal; an entry with no remaining annotations has no metadata line. Future timestamps still show future, and unparseable timestamps show unknown. One capture time covers both roots when the user profile is global. The current turn retains its captured ages; the next turn recalculates them even if the storage revision has not changed.

The model-facing text omits the revision hash, entry counts and storage-quota statistics; revision checks remain in the Source protocol and monitoring stays available through management/UI. File boundaries and all visible entries, including low-importance entries, remain. This format change does not classify or defer memory content.

By default, conversation history keeps a bounded group of complete Mnemon View snapshots as user-role quoted data. Unchanged content in the same authority scope is reused, including after session resume. Runtime additions and age updates append until another snapshot would exceed four snapshots or 64 KiB of UTF-8 text. At that point the group is replaced by the complete current snapshot. A current snapshot larger than 64 KiB is still kept in full, alone.

Removed or corrected Runtime facts, changed permissions, Sources, workspace, branch or opaque ReadGrants trigger a checkpoint by default before the next applicable model request, even if the rendered text is identical. Runtime supplies scope and visible-entry digests in Source-owned provenance; unknown or truncated projections are compared conservatively in full. The latest snapshot represents the current projected state, while absence can still mean filtering or a projection budget, not deletion from storage. Original snapshots and replacement provenance remain in DSH's append-only audit log. Upgrade cleanup recognizes this producer's older recall messages only when they contain the complete built-in Runtime snapshot envelope or a canonical official truncation with known structure and the SDK ellipsis; ordinary recalls, guidance, user messages and other producers remain unchanged. Cleanup requires the plugin to be active and preserves existing pinned View and delegated-agent leases.

The optional snapshot compaction backend keeps updates append-only when complete Runtime snapshots prove that authority and branch visibility are compatible. It filters the original Runtime projection out of the compaction model's input, even when the latest correction has not reached the session tail. The remaining authorized Source fragments and ordinary conversation can still be summarized. Snapshots that predate fragment attribution or fail an authority check are omitted from that summary. On a successful compaction, surviving old copies are retired before the next applicable model request and the current View is restored if needed. The additional metadata belongs to Session events. Existing Runtime and Pack formats require no migration.

These lines annotate the unchanged entry content. old_text / oldText must match content only, excluding the metadata line. Recorded importance and age never outrank current instructions. JSON, on-disk Markdown, content matching, entry order and storage capacity remain unchanged. Annotations count toward the existing model projection character budget, so even the default Strategy can truncate or omit entries when there are many short records. Its guidance states that snapshots are budget-limited and that absence does not mean deletion; light-context can impose a smaller budget.

Pinned Runtime entries

Use Pin / Unpin on the Runtime page. Pins are an explicit human setting, independent of importance; existing records without pinned remain unpinned. Each target shows its pinned count and projection usage. The reserved budget is 1,536 characters per target, including pin labels and importance annotations. A pin that exceeds this quota is refused without changing data. Unpin remains available to recover an oversized imported or manually edited set.

Visible pins from both USER and MEMORY precede all ordinary entries in a turn. The official layered and general Strategies reserve their complete text inside the existing View ceiling, including scoped and light-context configurations. If the ceiling cannot contain the pins, composition returns an explicit error asking to unpin or increase the View budget. A custom Strategy must honor the Source's hints.minimumProjectionCharacters (the public reserveMemoryProjection SDK helper can do this); Runtime refuses to truncate pins. An explicitly disabled/excluded Source, filtered branch or a subagent without Runtime inheritance does not acquire memory through pinning. Pins ensure presence in an admitted projection, not model obedience or authority over current instructions.

Capacity maintenance retains pinned originals in hot memory before importance ranking, and sends only unpinned working-memory entries to Providers or the local archive. USER compaction receives only unpinned entries; the Host and Source retain pinned originals verbatim. If the pinned set and pending write cannot fit the hard storage limit, the operation fails before any model/Provider work. The usual 70% compaction target is soft and gives way to pins. Manual content edits preserve the flag; explicit removal still removes an entry.

Packs, sync merge, overflow packing and metadata-based restore preserve the optional boolean. For identical text, an explicitly newer pin/unpin wins; a legacy copy without the field cannot clear a local decision. Keep all writing/syncing installations on a release with pin support: older versions can discard unknown fields, so downgrade roundtrips are not supported for pins. Updated Sources refuse to enable pins or run pinned maintenance with an older Host SDK; ordinary unpinned use remains available. Markdown exports remain plain derived text and do not carry pin metadata.

Operations

  • add writes an independent new fact; exactly identical content is not added twice.
  • replace and remove first match the normalized full content of old_text within the requested target, then replace or remove that entire item. One exact match takes precedence even when other items contain the same text.
  • When no full-content match exists, a unique substring still locates the item.
  • Runtime collapses legacy duplicates with the same normalized content, target and branch scope. It keeps the newest copy and the latest explicit pin decision. A replacement that would recreate a same-scope duplicate is rejected with instructions to consolidate the entries.
  • Zero matches or ambiguous matches are rejected. Equal text in different branch scopes stays distinct. Branch tags control projection and do not select a mutation target.

Capacity

Capacity maintenance distinguishes entries with the same text by their branch scope. Each scoped pin must be retained, and the local archive keeps the scope of each entry it moves out of Runtime.

Target Default limit Maintenance method
USER.md 4 KiB A local no-tool worker merges conservatively; content never enters a Memory Space
MEMORY.md 10 KiB The Host archives exact committed entries, then deterministically packs the remainder it keeps in runtime memory; with no Memory Space that can take them, the entries it does not keep go to runtime/archived/

Both limits are configurable as runtimeMemory.userLimitBytes and runtimeMemory.memoryLimitBytes; see Runtime Memory budgets. With the Layered strategy, capacity maintenance starts when an authorized write would exceed the limit; other strategies reject that write instead. Named tools, generic Actions, background child Agents and browser management share the same Host workflow. Browser writes use the selected storage scope without requiring an open user conversation. Archive failures preserve runtime memory and return an error. With no Memory Space that could take the archive at all, the Runtime Source moves the entries it does not keep to runtime/archived/ instead, under the same lock and before it commits. Standalone Sources retain their own storage semantics; custom Strategies do not implicitly inherit default archival.

Capacity is measured from the stored content and entry delimiters in UTF-8 bytes, excluding prompt-only metadata. A single item is limited to 8 KiB. On an overflowing add, replace, or remove, the Host rechecks the source revision before any Provider write. With one eligible writable Memory Space it routes without a model; with several spaces, workers see only bounded routing excerpts and return destination ids, never rewritten memory. Mnemon Native reuses exact content from a readonly namespace snapshot, groups identical pending entries, and imports the remaining originals once per destination through a schema-v1 draft with --no-diff. Similar but distinct facts cannot be skipped or semantically replace each other during archival. Other Providers use their adapter write semantics. The Host requires one exact terminal receipt per source (and exact Recall evidence for a skipped duplicate), then selects the retained entries by importance within a byte budget and commits that remainder together with the pending mutation under the original revision fence. A Provider cannot share the local filesystem transaction, so a later revision conflict or concurrent external write may leave already archived duplicates; existing runtime memory entries remain protected by the revision fence.

Project Documents

Purpose

Documents preserve project knowledge that is more complete than a single memory item but should still be quick to read, such as:

  • architecture designs and rationale;
  • evidence-backed investigation findings;
  • operating procedures, release checklists, and incident reviews;
  • implementation handoffs and long-term maintenance notes.

User profiles, ordinary conversation, temporary progress, raw large logs, and secrets should not be stored in Documents.

Control Plane

documents/index.json is the metadata source of truth. It manages IDs, titles, descriptions, status, filenames, source paths, sessions, timestamps, revisions, SHA-256 values, sizes, and Memory Space references. Managed Markdown copies include generated frontmatter.

sourcePaths:

  • may point only inside the current session workspace;
  • are source references only and are never modified by the plugin;
  • are not required to exist by the current implementation;
  • may not point into the managed documents/ directory itself.

Scope

The physical sharing scope of Documents is determined by storageScope:

  • workspace / workspaces: normally isolated with the project;
  • global / custom: multiple workspaces may share the same documents/index.json.

Therefore, “Project Documents” describes the content type and does not guarantee physical isolation by workspace. The current session workspace constrains only sourcePaths on new writes.

Capacity and Hot/Cold Tiering

Item Limit
One body 2 MiB maximum
Total active content 10 MiB maximum, including generated frontmatter
Total archived content Does not count toward the active limit

The actual rendered size is calculated before creation or update. If capacity is insufficient, the least recently accessed active Document is selected by lastAccessedAt and then updatedAt; a Mnemon cold reference is written and verified first, and the original text is moved only if its revision remains unchanged.

Default search covers only active Documents. Search updates lastAccessedAt for matching Documents, so it is read-only with respect to bodies but writes index metadata.

Memory Spaces

A Memory Space is the uniform semantic and routing unit for long-term memory; its provider chooses the data plane:

text
id            generated by the Host or inherited from a discovered Mnemon Store
name          human-readable name
description   routing boundary: what belongs here and when to recall it
active        whether it participates in DSH reads and routing
provider      mnemon-native or one of the registered third-party engines
location      local store/CLI scope, or remote endpoint + provider scope

Read and Write Boundaries

  • After initialization, Mnemon's native layer retains at least one Store and selects one default through <storageRoot>/active; ordinary Mnemon agents continue to use this single-Store model.
  • dsh-mnemon activation is an independent control plane: any 0..N Memory Spaces may be active, and making all inactive changes neither Mnemon's default Store nor remote data.
  • Recall and browse use active spaces only; graph, entity, related, link, and delete behavior follows provider capabilities.
  • Reads explicitly targeting an inactive Memory Space are rejected.
  • Writes may target any registered space with remember; the receipt reflects the provider's exact or asynchronous extraction semantics.
  • After a successful write to an inactive target, the plugin activates it automatically.
  • Without an explicit target, if the number of active Memory Spaces is not exactly one, the deterministic service requires the caller to choose a target first.

Creation, Discovery, and Merge

  • An uninitialized root may remain at zero Stores. The first explicit Memory Space creation uses Mnemon's native default ID while retaining the user-supplied name and routing description; later creations use Host-generated UUIDs.
  • The last native Store cannot be deleted after initialization, but its Memory Space may remain inactive. Before deleting Mnemon's default Store, the plugin switches to another existing Store.
  • An existing <storageRoot>/data/<store>/mnemon.db is discovered and registered without moving the database.
  • Merge imports source content into the target through Mnemon; the source database remains in place, and by default only the source is marked inactive.
  • Pack replacement cannot empty an initialized Store set. If replacement removes the former default Store, the plugin repairs the native default pointer to an existing Store.
  • forget is a soft delete by exact ID, not deletion of a database file.
  • Users create Mnemon Native spaces directly. Enabling or saving a third-party service discovers all visible provider-native namespaces, atomically maps their titles/descriptions and scope into the directory, and makes them available as smart-selection candidates. Disabling the provider removes those local mappings and never provider content.
  • Smart placement treats the allowlist, data boundary, and required capabilities as Host-enforced rules. Soft preference and prompt guide semantic choice only among multiple eligible candidates and cannot override hard rules. The decision receipt is persisted with Memory Space metadata.
  • Merge remains Mnemon Native-specific. Graph, relationships, browsing, exact/async writes, and hard/soft/unsupported deletion follow each provider's declared capabilities; the UI and agents do not pretend missing behavior exists. See the provider matrix.

Cross-Agent Visibility

mnemon.db is Mnemon's native data plane, not a private dsh-mnemon format. Another Mnemon-enabled agent can access the same durable memory when it uses the same storageRoot and Store. dsh-mnemon also discovers compatible Stores already present on disk; DSH-specific names, descriptions, and activation state remain managed by .dsh-memory-bodies.json.

Third-party visibility is determined by its provider scope, such as service plus URI, workspace/peers, bank, project/user, knowledge directory, or container. No provider extends sharing to runtime/ or documents/; “shared third-tier memory” must not be presented as automatic sharing of the complete DSH context.

Skills

Skills manages files DSH already reads; it never joins a turn's View. The skills themselves stay in DSH's skill roots — <project>/.dsh/skills, <project>/.agents/skills, $DSH_HOME/skills (~/.dsh/skills) and $DSH_AGENTS_HOME/skills (~/.agents/skills) — and every write to them is fenced by the file's SHA-256. What Skills keeps about them lives in the storage root's skills/ folder:

Path Holds Kept
ledger.json Suggestions, drafts, the review log, the summaries of recorded conversations, the version index and market installs The newest 200 reviews and 60 drafts
evals.json Test cases and backtest runs 40 cases and 20 runs per skill
trajectories/<id>.json One recorded conversation: its numbered steps and the review's notes on them, with secrets redacted The newest 100; pinned records and those a suggestion or case cites go last
versions/<skill>/<id>.md Each earlier SKILL.md, for comparing and restoring 30 per skill
market/registries.json, market/cache/<id>.json The sources added in the market and the last list each published Until removed; refreshed after six hours
trash/ Skill folders that were deleted, or replaced by an update or a restore Until you delete them by hand

The folder is written under the storage lock with atomic replacement, and it follows the storage scope like the other Sources. It is not part of a Mnemon Pack, so neither ZIP backup nor Git sync carries it; the skills themselves are ordinary files in their roots. Its settings are configuration, under skills in the mnemon entry; see Skills settings.

Update suggestions and drafts add an optional origin to version-1 ledger.json: the absolute skill-file path and, for project skills, the owning workspace. These local paths come from the Source catalog, not model or browser input. Older project records use the exact cited review trajectory when its workspace is unambiguous; unresolved records retain their content and show recovery instructions. Reads do not rewrite the ledger, and no skill files are moved. Older releases can read the additive fields but do not enforce their binding, so downgrading restores the previous cross-workspace limitation. Human management still requires confirmation and revision checks; this metadata grants no model View access.

Four Relationship Types

Mnemon Native preserves temporal, semantic, causal, and entity relationships. Hindsight projects its provider graph, and Holographic derives local entity/semantic relationships. Providers without graph edges contribute bounded disconnected nodes; adapters never invent unsupported relationships. The UI hides Related, Link, Browse, and Forget where the selected provider does not support them.

Data Authority Table

Data Authoritative source Derived/cache
Runtime memory runtime/memories.json USER.md, MEMORY.md
Documents documents/index.json + managed Markdown excerpts, search ranking, status aggregation
Mnemon Native catalog data/.dsh-memory-bodies.json + on-disk Stores Web status aggregation
Third-party connections state/memory-providers.json redacted provider capabilities and status
Git sync configuration state/sync-git.json state/sync/git mirror; the configured remote branch
Machine identity state/machine.json: the id, the name, and labelSource (hostname follows the host name, custom was typed) the machine field of an export and of a sync status
Cross-machine deletions state/tombstones.json state/runtime-index.json, which is what a later export diffs against
Reconciliation proposals state/review-ledger.json the review card; an accepted proposal is applied to the Sources, never to the ledger
Long-term memory Mnemon mnemon.db or remote provider graph projection and cross-provider rank fusion
Skills The SKILL.md folders in DSH's skill roots the catalog the Skills page shows; skills/ versions, installs and market caches
Skill evolution skills/ledger.json, skills/evals.json, skills/trajectories/ the Evolution count, the Status card and the line under each turn
Review quota and cooldown watermarks Host process memory by default; state/idle-review/ when persistence is enabled status-page snapshot; never Packed or synced