> ## Documentation Index
> Fetch the complete documentation index at: https://docs.magpiedb.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Magpie is a trace store for AI agents, used as a library (crate `magpiedb`, npm `magpiedb`, PyPI `magpiedb`) or as `magpie-server`, which takes OpenTelemetry (OTLP over HTTP on 127.0.0.1:4318 and gRPC on 127.0.0.1:4317 by default).
> Use only the commands, flags, routes and JSON shapes that these pages show. Do not guess a flag or a query field: if a page does not show it, say that the docs do not show it.
> Packages and server binaries are not published yet: build from source, as the quick start shows. Check the status note on the introduction page before you suggest `cargo add`, `npm install` or `pip install`.
> Only one process may write to a store folder at a time. For many apps, send traces to one `magpie-server`.

# Durability and upgrades

> What an accepted write survives with --durability, and how the store version works.

## Durability

`--durability` says what an accepted write survives. The server answers `200` only after that.

| value | an accepted write survives | use it for |
| - | - | - |
| `disk` (default) | a crash of the machine. The write is in the write log on disk before the answer. | live traffic |
| `os` | a crash of the server process, not of the machine | faster writes, if a machine crash may lose the last moment |
| `none` | nothing after the last commit (the commit is about every 0.5 s) | imports and loads that you can run again |

A restart replays the write log. The crash tests (`kill -9` in the middle of writes, with checked answers) are in [`docs/FINDINGS.md` F17](https://github.com/intojhanurag/magpie/blob/main/docs/FINDINGS.md). A live demo of one: [`docs/DEMO.md`](https://github.com/intojhanurag/magpie/blob/main/docs/DEMO.md), step 7.

> [!NOTE]
>
> On macOS, `disk` flushes with `F_FULLFSYNC`. It is slow, and it slows every other writer on the machine.

## Upgrades and the store version

A store has a format version. The file `store.json` in the folder holds it, and so does each commit. Every build checks it before it changes a byte (the "door"). A build opens only a store of its own version. It refuses an older or a newer one, and says what to do:

```sh theme={null}
mkdir -p other-version && printf '{"format":"magpie-store","compat":12}' > other-version/store.json
magpie-server import --dir ./other-version --format magpie /dev/null 2>&1 | head -n 1
```

```text theme={null}
magpie-server import: cannot open store ./other-version: io: ./other-version/store.json: format version 12, and this build of magpiedb reads format version 14 only. An earlier build of Magpie wrote it, and this build does not read that format (there is no upgrade from a build before release 1). Export the store with the build that wrote it (`Store::export` and `Store::export_scores`, or POST /v1/export and /v1/export/scores of its server), and load the export into a new store with `magpie-server import`. Nothing was changed.. (A server on the same store must be stopped for an import.)
```

The last sentence is a general note of the import; here no server runs. A server, the Node package and the Python package refuse the store with the same message.

So, today:

* **Before release 1 there is no upgrade in place.** A store of an older build is moved with export and import: export with the old build, import with the new one ([Import](https://docs.magpiedb.com/operations/backup-import.md#import), [Backup](https://docs.magpiedb.com/operations/backup-import.md#backup)).
* A newer store in an older build is refused too, and nothing is changed: go back to the newer build.
* A folder with files and no `store.json` is refused. A new store needs an empty folder.
* The plan for upgrades in place after release 1: [`docs/DESIGN-UPGRADE.md`](https://github.com/intojhanurag/magpie/blob/main/docs/DESIGN-UPGRADE.md) (not built).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.