# ryo-storage
[](https://crates.io/crates/ryo-storage)
[](https://docs.rs/ryo-storage)
[](#license)
> **Status:** stable. Part of the [ryo](https://github.com/ynishi/ryo-rs) workspace —
> AST-centric Rust programming for AI agents.
Persistent storage and transaction log. Three-layer design: a `Mutation`
function layer, a serializable `MutationRecord` recording layer, and a
content-addressed `StateStore` for file-state snapshots. Sessions are dumped
under `~/.ryo/sessions/` as JSON `TxLog`s for replay / undo / inspection.
## Install
```sh
cargo add ryo-storage
```
## Quickstart
```rust,ignore
use ryo_storage::{RyoStorage, TxLog, TxLogger};
// Create storage at ~/.ryo
let mut storage = RyoStorage::global()?;
storage.ensure_init()?;
// Start logging
let logger = TxLogger::start(project_path, file_count);
logger.log_mutation("Rename", "foo -> bar", 3);
let log = logger.finish();
// Save session and load it back
let session_id = storage.dump(&log)?;
let loaded = storage.load(&session_id)?;
```
## API Summary
| `RyoStorage` | Session persistence over `~/.ryo` |
| `TxLog` / `TxLogger` / `TxAction` | Transaction log primitives |
| `Format` (JSON / JsonCompact) | Session serialization format |
| `SessionIndex` / `SessionMeta` | Session lookup / metadata |
| `StateStore` / `StateRef` / `WorkspaceSnapshot` | Content-addressed state store |
| `ProjectIndex` / `ProjectMeta` | Per-project metadata under `~/.ryo` |
| `FileUuidStorage` | UUID ↔ path indirection |
## Status
API surface considered stable for the v0.1.0 release. `BincodeFormat` was
removed in the run-up to v0.1.0 (incompatible with `serde_json::Value`-carrying
TxActions); JSON formats remain.
## License
Licensed under either of [Apache-2.0](https://github.com/ynishi/ryo-rs/blob/main/LICENSE-APACHE)
or [MIT](https://github.com/ynishi/ryo-rs/blob/main/LICENSE-MIT) at your option.