Sharing

shmem's sharing model lets a team exchange facts — the unit of memory — without ever giving up control of their private stores. This page is the system overview: the data model, what each verb does, and the invariants every surface (CLI, agent tools, dashboard) maintains. The rules engine that automates nomination has its own page: sharing rules.

The model in one paragraph

A project is a set of facts. Membership in that set is a row in a memberships relation — (fact_id, project, actor, timestamp) — not a column on the fact. Sharing a fact adds a membership; unsharing removes it. A fact keeps one id across every database it reaches: there are no copies, no origin pointers, no forks. Your private capture stream is simply the facts with no memberships (the "default" project — absence means default). Capturing into a marked directory is a share-to-self: the hook writes the fact and its membership in one step.

Identity and replication (the invariant)

Every fact has exactly one id, minted where it was authored, carried verbatim through every replication. A database holds at most one row per fact, ever. What replicates between machines is:

  1. Membership rows — the authoritative record of what belongs to a space, cursored on membership time (sharing an old fact creates a new membership; fact-time cursors would miss it).
  2. Fact bytes — fetched only when a membership references a fact the local database lacks, stored under the fact's own id with its original author preserved. Its provenance stamps (repository, branch, directory, machine) stay with the owner and are never part of a shared copy.

Foreign facts are refcounted by membership: when the last membership that brought a teammate's fact to your machine is retracted, the bytes are deleted too. Your own facts are never deleted by membership changes — unsharing returns them to your private default project.

Spaces, targets, and audiences

A target is where a share goes:

  • A bare name (team-memories) is a project in your own root. It becomes an audience-bearing space when you grant a group access: shmem project share team-memories -g dan/demo-team -p r. The grant IS the standing share — captures and shares into a granted project are visible to the group as they land. r grants read; rw also lets members share into and retract from the project.
  • An owner-qualified ref (dan/team-wiki) is a project in another user's root that you hold a write grant on — a co-writable space. Shares into it go over the wire to the owner's root, gated server-side.

Who can read a space is always the project's grants, managed separately from the act of sharing into it.

The verbs

Verb What it does
shmem share <ids> [--to <target>] Adds memberships placing the facts in the target. A span of ids shares together and is remembered as a span.
shmem share --since 2h [--about topic] Distills a window of your captures into ONE new fact, a step-by-step record of what happened in reported speech (User asked…, Agent ran…; provenance stays private), and shares that.
shmem share <id> --edit Opens $EDITOR; the saved revision is minted as a new fact and that is what ships.
shmem share --amend <id> Retract-and-replace: unshares the fact from every space it's in, opens $EDITOR, mints the revision, shares it to the same spaces.
shmem share show <id> Live visibility: which audience-bearing spaces hold the fact, joined with each project's grants. Computed from memberships, never replayed from history.
shmem unshare <id> Removes the membership. Retracts the whole span by default (--only for one fact); --from picks a space, --everywhere retracts from all. Warns when other granted spaces still hold the fact.
shmem share log [--since 7d] The audience-visible history: share/unshare events across every space you can see. --since narrows it to a window.
shmem share discard <n-id> Turns a nomination down for good. The no is recorded privately, and those facts are never nominated again.
shmem share forget <n-id>... / --all Clears nominations without deciding on them, as if they had never been proposed: a later scan that reads those facts may nominate them again. For starting over after a rule change (--all), or undoing a discard (name it, or --all --discarded). Asks first unless --yes. See Clearing nominations.
shmem share enable / disable Turns sharing on or off for your account on the server. Off, nothing new is nominated or shared; status, log, show, discard, forget and unshare still work on what sharing already did.
shmem share (bare) Status: one block per space you share into (who can read it, the rules aimed at it, its never rules, and how much has been shared, by whom and recently), then the nominations awaiting review. Same as shmem share status.

Events carry no content

Every share and unshare also places a small event fact (kind=share-event) into the space. Events carry ids, counts, and the actor only — never content snippets. The log renders titles by joining each event to the live fact; when the fact has been retracted, the log shows (retracted). That closes the redaction hole: pulling a fact back leaves no residue of its content in the history the audience can see. When you share into, or unshare from, someone else's project, the event goes into their space and a copy into your own account, so the act shows in your share log too, named by the space's owner/name. Your private ledger (shares.db, in your account on the server and never replicated) keeps snippets, provenance, and your discard and forget decisions.

A shared fact carries only the metadata that says what it is: the space log's ids and counts, a title, and an imported record's own fields (repository, number, type, url, state, author, labels, reviewers), plus any key whose name starts with shared.. How you captured it stays with you: session and import bookkeeping, capture stamps (stamp_*), what a distilled fact was made from, the share filters' redaction mark, local markers, and any other key you set. The same allowlist applies to a fact written straight into someone else's project and to what a reader in another account sees.

To give your audience a key of your own, name it under shared.: a fact written with {"shared.branch": "release-2"} carries it to every account it is shared with, and readers there can filter on it. A bare branch stays with you.

Unshare events double as tombstones: when a syncing client pulls an unshare event, it removes its local membership and refcount-deletes foreign orphans. Retraction propagates at sync speed; bytes a machine never re-syncs are, honestly, already theirs.

Deleting your own fact works the same way across your machines, shared or not: the server records the delete as an id-only event (event=delete) in your own memory, and each of your other machines deletes its copy when it next pulls. Events are bookkeeping, not memories: ask, query, and recall_memory never return them.

When a machine syncs

A machine with a hosted remote pulls its own new facts and sweeps the spaces shared with it — new facts in, unshared and deleted ones out — at each of these points:

  • CLI reads: shmem ask, shmem query, and the dashboard pull before answering (up to 10 seconds; on timeout or error the read answers from local data).
  • Local MCP reads: a local shmem-mcp (the one an agent host runs over STDIO) pulls before ask_memory, recall_memory, get_facts, and list_facts_since, with the same 10-second budget, and also syncs in the background every sweep interval while it runs.
  • Prompts: each captured user message starts a detached shmem pull --background when a sweep is due, so the prompt never waits on the network.
  • shmem pull: on demand.

The shared-space sweep runs at most once per SHMEM_SWEEP_INTERVAL (default 2 minutes), and only one sync runs at a time on a machine: a read that finds another sync in progress answers from local data, and an explicit shmem pull waits for it. The hosted server itself never syncs from anywhere.

Where a share came from

What a share was made from is the sharer's alone. A distilled share records its source facts (distilled_from), and a copy that share filters redacted is tied to its original in the ledger; neither travels with the share, so readers see the shared fact and who shared it, never its sources.

The sharer sees them. On the dashboard's Sharing tab, each shared fact and nomination has a sources list, shaped like the Sources under an ask answer: a fact shared as written is its own source, a distilled one lists the facts it was written from, a redacted copy names its original. Clicking a source opens it in full, and every fact id on the tab links to the fact's page (#/fact/<id>), which for a distilled fact lists its sources too. Sources are your own facts, so they reach each of your machines through the normal sync, and deletes do too: a source deleted since the share reads "source no longer available", and one this machine hasn't pulled yet reads "not on this machine yet". The dashboard never fetches a source on its own. A teammate's share says who shared it, and nothing more. share_show reports the same for agents: derived (kind, source ids, and any deleted since) for your own fact, shared_by for anyone else's.

Reading back what you shared

The dashboard's History tab (shmem dashboard, #/history) reads one space back at a time: one moment per share, holding only the facts still in the space, dated by when those facts were written rather than when they were shared. A timeline counts moments per week; below it the moments are grouped by week, newest or oldest first, with a search box and each moment's full text on expand. A moment is titled by its headline when it has one (your own nomination shares, and narrated shares for every reader), else by its first line that isn't a tool call. Your own moments have an Unshare button, which asks before it retracts and goes through the same unshare_facts every other surface uses. This is the place to read what a history replay run with --auto-share (shmem share scan --since all --auto-share) placed, and pull back what shouldn't be there. Like the other sharing views, it needs a shmem server.

Deleting a shared fact

Deleting a fact that sits in a shared space retracts it first. shmem delete, shmem admin project delete, the local dashboard's delete and prune, and a local agent's delete_memory all unshare the fact from every space you can write to, then delete it. Each unshare writes the usual tombstone, so readers drop their copies on their next sync.

  • A space you can only read is left alone. If such a space still holds the fact, it is retracted from your writable spaces but kept, and the delete says so: deleting it locally would be undone by the next sync of that space. Ask the space's owner to remove it.
  • Authorship doesn't matter, write access does: you can delete a teammate's fact out of a space you have rw on, and you cannot pull your own fact out of a space you can only read.
  • With a hosted server, the server does the retracting from your own projects, because that is where their grants live. Its delete_memory and delete_project write the tombstone into every shared project of yours that holds the fact before deleting it, so a project shared from another machine, or by an agent talking to the server directly, is covered too.
  • As a backstop, a sync re-reads a shared space in full when you hold more of its facts than the server says it has, and drops the local copies the space no longer holds. This clears facts deleted before the server wrote tombstones. Against an older server that doesn't report the count, the full re-read runs every few hours instead.
  • In hosted mode shmem delete deletes on the server first. If the server can't be reached or refuses, the delete fails and nothing is deleted, so you can simply retry.

Losing access to a space

When you lose read access to a space, because its owner deleted it, revoked the grant, or removed you from the group, your next sync drops what it brought in. Every local membership in that space goes, and a teammate's fact left with no membership is deleted. Your own facts leave the space but stay in your store. If access comes back, the space is pulled again from the start.

Sync usually runs in the background, so shmem records each space it drops. For 30 days afterwards, shmem admin status and the get_stats tool name the space and how many facts left with it:

Notice: alice/notes is no longer shared with you; sync removed 20000 of its facts from this store on 2026-10-26.

The drop only happens on a complete answer from the server. If the server is unreachable, or could not read some projects while building the list, nothing is dropped that sync.

Concurrency: loud, first-writer-wins

The server arbitrates concurrent cross-user writes under its write lock with one rule: the membership row either exists or it doesn't.

  • A second writer sharing the same fact into the same space is rejected: already in project — pull and re-check.
  • A second writer retracting an already-retracted fact is rejected: not in project (already retracted?).

Nothing forks silently; the loser of a race finds out immediately.

Trust model

Sharing is built for trusted groups. Anyone with rw on a space can share into it and retract any fact from it — including yours. The counterweight is attribution: every membership row and every event is stamped with the actor's identity. The accountability mechanism is the record, not a permission wall.

Unsharing removes the fact from the space you control. It does not chase copies a reader may have re-shared onward into spaces you cannot see. Nobody acts across an access boundary, and that includes a fact's author: reaching into a space you have no access to would make authorship a second, unaccountable permission. Instead, unshare warns you which visible spaces still hold the fact, and --everywhere retracts from all of them.

Safety layers (defense in depth)

  1. Never rules (natural language, in share-rules.yml): what must not be shared. Global rules are content-sensitivity policy; per-project never: rules protect a target — they apply to everything shared INTO that project. The scan skips matching moments, or ships a version that leaves the protected content out: the span with those parts replaced by placeholders, or, when that won't do, a narrated record; never criteria ride into both as strict omissions. A manual single-fact share deliberately bypasses this screening — you named the fact; the system doesn't second-guess you.
  2. Deterministic share filters (.shmemignore: redact / substitute / drop) run at the boundary on every share, fail closed: the rules of the project each fact came from, then the project it's shared into, then your global rules and shmem's built-in credential rules. A redact/substitute hit mints the cleaned content as a new private fact and ships that — every shared fact is byte-identical to a fact in your store. A drop hit blocks the share loudly.
  3. The ledger: every act — shares, unshares, grants, discards, forgets — in an append-only private record.

Turning sharing on

Sharing needs a shmem server: it is how what you share reaches anyone else. With no remote, the sharing verbs and tools say so and nothing scans. Connect one with shmem login; the hosted one, or your own, which is the same shmem-mcp.

Your sharing workspace lives on the server, in your account: your share rules, your nominations, and your private ledger. Every client you use reaches the same one. The CLI's verbs call the server's sharing tools, a local shmem-mcp relays its sharing tools to your remote, and an MCP-only client (one with no shmem binary, such as a claude.ai connector) calls them directly.

Sharing is off until you turn it on for your account:

shmem share enable     # or ask your agent to turn sharing on (set_sharing)
shmem share disable    # stops the scans and the verbs; nothing shared is retracted

With it on, the server runs your share rules over the facts you store, which sends those facts to the server's LLM provider. It only ever NOMINATES: nothing is shared without an explicit share or a share-mode rule you wrote. The server's operator offers sharing by setting SHMEM_SHARING=on on the server. An operator that decides for its users, such as an app built on shmem, also sets SHMEM_ACCOUNT_SHARING=on, and accounts start with sharing on; turning it off still holds.

If sharing was on for your machine (SHMEM_SHARING=on in its environment) before sharing moved to the server, the first sharing command or hook run against the server moves your share rules and history there and turns sharing on for your account, so your rules keep running; it says so once. A setting you already chose on the server stands.

The server scans after your writes reach it, once a scan is due (enough new facts and the cooldown passed, or an hour for a few facts). It reads facts by when it received them, so what a client captured offline and pushed later is still scanned; a backlog older than a week, such as a new client's first push, is not. A scan reads as many facts as one evaluation holds; when more are waiting, the next scan starts right away, without waiting out the cooldown. What a scan nominates or auto-shares reaches your agent with your next message (through the hooks), in the next tool response for an MCP-only client, or from share_updates. SHMEM_SCAN=off silences that delivery on your machine. shmem share scan asks for a scan now.

Scans only read what arrives, so memory written before you turned sharing on, or before you changed your rules, is never evaluated on its own. shmem share scan --since 2026-03-01 (or --since all) replays it: the server cuts that history into stretches and works through several at once in the background, one working session per evaluation, under your current rules, leaving the scans of new memory to carry on as usual. Anything already shared, nominated or discarded is skipped as it would be for new facts. shmem share shows how far the replay has got, and which mode it runs in.

A replay only nominates. What a mode: share rule matches in older memory is staged for your review, aimed at the rule's target, as a draft rule's would be: a replay reads weeks of work in minutes, and shares placed at that rate reach a space's readers before you have looked at one. To have those rules share what the replay finds, as they do for new memory, ask for it by name: shmem share scan --since all --auto-share (for an agent, scan_shares with auto_share). A replay started that way says so when it starts and in shmem share.

Clearing nominations

There are two ways to take a nomination off your review list, and they mean different things:

  • shmem share discard <n-id> is "no, never". The decision is recorded, and no scan nominates those facts again.
  • shmem share forget <n-id>... is "clear it; it may come back". Nothing about the nomination is kept, so a later scan that reads those facts judges them afresh under your rules as they are then.

Forget is for iterating on rules. A replay skips whatever is already nominated, so after changing a rule, the nominations the old rule produced would otherwise stay as they are:

$ shmem share forget --all             # clear everything awaiting review
$ shmem share scan --since 2026-03-01  # replay under the current rules

--all takes only what awaits review. Add --discarded to clear your discards too, so those facts can be nominated again; to undo one discard, name it. Forgetting on its own proposes nothing: scans read only memory that arrived since the last one, so a forgotten moment returns when a replay (shmem share scan --since ...) covers it. Run forget --all once a replay has finished, since one still running goes on nominating.

Forget shares and unshares nothing, and a nomination you already shared can't be forgotten (shmem unshare pulls a share back). Your own facts are untouched. The redacted stand-ins or narrated lines a scan wrote for a forgotten nomination exist only to be shared by it, so they are deleted with it, unless a share placed them somewhere or another nomination still names them; the next nomination of that moment writes its own. Each forget is recorded in your private ledger (shmem share log --all).

For a server's operator: scans run on the server's QA model unless SHMEM_SCAN_PROVIDER / SHMEM_SCAN_MODEL say otherwise, at most SHMEM_SCAN_WORKERS (default 2) run at once, and SHMEM_SCAN=off on the server turns them off. A history replay runs SHMEM_REPLAY_WORKERS (default 8) windows at once for the account that asked for it.

For agents

The MCP server exposes the same flows, so an agent never needs the shell: scan_shares and distill_facts are always safe (nothing is shared); share_status shows what's waiting, share_log is the shared history, and share_show <fact-id> digs into where one fact is visible right now; share_facts requires the user's explicit agreement in conversation (or a share-mode rule); unshare_facts pulls things back. The conversation is the editor: user refinements arrive as share_facts' edited_content, which mints the fact that ships. Re-sharing with changes is unshare_facts followed by share_facts with edited_content. See sharing rules for the rules file agents may be asked to configure.