# Provenance and attribution

Preserve where a memory came from without confusing source metadata with authorization or ownership.

- Canonical: https://docs.xmemo.dev/docs/concepts/provenance-attribution
- Locale: en-US
- Content-Locale: en-US
- Canonical-Content-Digest: 019b1c6aab84d15e8b791ec3f9b7ecd3d545865415ceba204e14301dea665c6a
- Edition-Digest: cc5072bba709e0d9384b212ff82f341c948946a8297f632b23ae9b049ed581c9
- Source-Revision: sha256:3922476e09ce20617ab30ead32aa1ccd8f95082d0f395b172b3eadd0d8fd2d45

## Provenance is part of the public memory record

The memory contract exposes provenance alongside content, path, source_identity, agent_id, agent_instance_id_hash, and agent_instance_source. Provenance is structured evidence about how a record was produced; it is not a bearer token and cannot widen the caller's access.

- source_identity is the compact caller/source label used by write and audit paths.
- provenance is a JSON object for source, adapter, event, or other evidence fields.
- agent_instance_id_hash is the privacy-preserving installation attribution value.

## Agent events carry their origin

AgentEvent.to_memory_candidate creates a MemoryCandidate with provenance containing source=agent_integration, adapter=<event source>, and event_id. The candidate metadata also keeps the event type, time, agent id, task id, tool name, command, file path, and status after the shared sanitizer has run.

```json
{
  "provenance": {
    "source": "agent_integration",
    "adapter": "codex",
    "event_id": "evt_<stable-event-id>"
  },
  "metadata": {
    "agent_event": {
      "event_type": "decision_made",
      "task_id": "<task-id>"
    }
  }
}
```

## Write attribution with the memory

The public remember and store request models accept source and provenance. Supply stable, non-secret labels at capture time; keep the access credential in its header or environment and let the server sanitize content, metadata, and provenance before persistence.

```http
POST /v1/remember
X-API-Key: <your-assigned-api-key>
Content-Type: application/json

{
  "content": "The deployment decision was verified.",
  "path": "projects/memory-os/decisions",
  "source": "codex",
  "provenance": {
    "source": "agent_integration",
    "adapter": "codex",
    "event_id": "evt_<stable-event-id>"
  }
}
```

## Sanitization does not erase lineage

The persistence sanitizer walks content, metadata, and provenance structurally. Credential-shaped values are removed; if redaction occurs, the server records privacy.server_write_sanitizer audit metadata while retaining safe provenance fields. Treat the resulting record as sanitized evidence, not as a raw event archive.

## ChatGPT user

Give ChatGPT durable access to your XMemo preferences, project facts, decisions, and TODOs without pasting bearer tokens into a chat.

Connect the hosted XMemo MCP server through the ChatGPT/OpenAI app OAuth flow, then approve the memory:read and memory:write grant for your XMemo account.

Save a synthetic preference or project note, start a new chat, then ask ChatGPT to recall it through XMemo before continuing work.

If OAuth fails or tools do not appear, sign out of the MCP server in the host app, reconnect the XMemo server URL, and retry before creating direct tokens.

## Copilot / Codex developer

Carry repo decisions, coding conventions, bug-fix notes, and task history between IDE and CLI agents.

Use OAuth for VS Code / GitHub Copilot and Gemini CLI when available. For Copilot CLI, Codex, Cursor, or other direct MCP clients, keep XMEMO_KEY in the local environment or secret store and set a stable XMEMO_AGENT_INSTANCE_ID.

Record a codebase decision or bug fix, then ask the next IDE or CLI agent to recall the relevant XMemo context before editing.

If recalls are empty, verify the selected MCP config path, the XMEMO_KEY environment variable for direct clients, and any stale OAuth credential in the host app.

## Team / enterprise pilot owner

Evaluate shared memory with account controls, source attribution, export/delete workflows, and reviewer-safe setup evidence.

Create or enter the protected XMemo workspace, invite approved users, then connect each client through OAuth or a scoped direct credential according to the readiness badges.

Have a pilot member save a synthetic team memory, confirm source attribution in XMemo, then review delete/export and support paths.

If a member cannot connect, check role permissions, OAuth approval, client readiness status, and support guidance before issuing a new token.

## Autonomous agent operator

Let headless or scheduled agents record progress, retrieve prior decisions, and keep a stable non-secret instance identity.

Fetch /api/v1/mcp/config/autonomous-agent. Prefer auth_modes.oauth when the runner supports OAuth + custom headers; use auth_modes.xmemo_key with XMEMO_KEY from a secret store only for fully headless runners.

Run one synthetic task that writes progress to XMemo, restart the runner, and confirm it recalls that progress using the same XMEMO_AGENT_INSTANCE_ID.

If attribution changes or recalls split across instances, persist XMEMO_AGENT_INSTANCE_ID outside git and verify the runner is not regenerating it on every start.
