ostrya 0.3.0

Pure-Rust async reimplementation of the ostree repository library
Documentation
# Ostrya

Ostrya \[_n._ a botanical genus within the family Betulaceae, commonly known 
as _ironwood tree_\] is a from-scratch, pure-Rust, async reimplementation of 
the ostree repository library (libostree). It reproduces ostree's on-disk 
format byte-for-byte while presenting an idiomatic Rust API designed for 
asynchronous use and for multiple concurrent transactions within a single 
process.

## Status

Work in progress. The library is being built along a phased roadmap
(`docs/port-plan.md`), and the API is not yet stable. The following paths are
implemented and verified against golden fixtures produced by the `ostree` tool:

- GVariant codec and the typed object-model codec layer
- Core format primitives: checksums, varint, loose paths, `ostree.sizes`
  packing, xattr canonicalization, keyfile parsing
- Object model: commit, dirtree, dirmeta, and file headers (bare, bare-user,
  bare-user-shared, archive; read-only support for bare-split-xattrs)
- Repository open, create, and config parsing
- Reading path: object, commit, and file-content loading, ref resolution and
  listing, tree traversal
- Runtime backend abstraction and the streaming hashing primitives
- Transactions and the two-layer repository lock
- Write path: object writers, in-memory tree assembly, filesystem ingest with
  a commit modifier, commit assembly and durable publication, overlay
  changeset import, and a path-addressed staging tree with tree merge
- Checkout path
- composefs/EROFS image writer and fs-verity digest (`ostrya-composefs`)

In progress and planned: wiring composefs export into the library, tar
import/export, a minimal `ostrya` CLI, prune/fsck/diff, signing, summaries,
static deltas, pull, an `ostree`-compatible CLI for shell-test conformance,
and the S3 and SSH transport extensions. See `docs/port-plan.md` for the full
roadmap.

## Design

- Pure Rust, with two C-linking exceptions: `liblzma`, which the library links
  for xz in static deltas, and PCRE2, which the `ostrya-cli` binary links for
  the `commit --tar-pathname-filter` expression. The library's `lzma-static`
  feature builds xz from source and links it statically; the feature is off by
  default, and a build without it links the system liblzma. `ostrya-cli`
  carries the feature in its default set, so the shipped `ostrya` binary needs
  no runtime liblzma. Each static build requires no C runtime of its own
  beyond the libc `std` already links. PCRE2 belongs to that binary alone,
  which sets `publish = false`. `rustix` provides the syscalls a portable
  async file API cannot express (fd-relative opens and metadata, xattrs,
  statx, FICLONE reflink, `O_TMPFILE` + linkat, OFD-compatible record locks).
  Streaming file I/O goes through the runtime's async file.
- Async throughout. The runtime backend sits behind the internal `ostrya-rt`
  crate: `smol` by default, `tokio` under the `tokio` feature.
- Multiple concurrent transactions within a single process. A `Transaction` is
  an owned handle carrying its own staging directory and counters; `Repo` holds
  only shared state and is cheaply clonable. `Repo`, `Transaction`,
  `FileObject`, and the content readers and writers are `Send + Sync`.
- Byte-exact on-disk format. Field layouts, byte orders, sort orders, and
  checksum algorithms match ostree exactly, verified in both directions: the
  `ostree` tool reads what the library writes, and the library reads what the
  tool writes.
- File content is streamed in bounded-size chunks end to end. Hashing,
  compression, object-store writes, checkout, and transfer never buffer an
  unconstrained blob in memory. Whole-buffer handling is reserved for metadata
  objects, whose size the format caps.
- `#![forbid(unsafe_code)]` everywhere except two audited sites documented in
  `CLAUDE.md`.

## Workspace layout

The project is a Cargo workspace of focused crates:

- `ostrya-gvariant` -- byte-exact GVariant codec for the fixed type set ostree
  uses. No ostree knowledge.
- `ostrya-core` -- object model, checksums, varint, loose paths, xattr
  canonicalization, and format serialization. Depends on `ostrya-gvariant`.
- `ostrya-rt` -- internal async-runtime abstraction (`smol` or `tokio`
  backend). The only crate that knows which backend is compiled.
- `ostrya-sign` -- the signing engines: dummy, ed25519, spki, and the GPG
  signer through the `gpg` binary. Portable, with no repository knowledge.
- `ostrya-fetch` -- the async HTTP/1.1 and HTTP/2 fetcher, with TLS over
  `rustls`. Portable, with no repository knowledge.
- `ostrya-remote` -- the wire protocol and the client sessions of the push
  and of the pull: the messages and their GVariant encoding, the frame
  codec, the chunked object stream, the bodies of the pull, the push client
  session, `StreamSession`, the framed session of a pull over ssh or over a
  pair of byte streams, and `PullSession`, the session of a pull over the
  HTTP fetcher or over a stream session. It also holds the endpoint types
  `Endpoint`, `SshAddress`, and `SshOptions`, and the ssh and HTTP
  transports. It holds
  the walk of a local directory into a tree model. It holds the tree push of
  that directory as one commit, signed when signers are given. The
  transports read no remote key and no file that a remote key names.
  Portable, with no repository knowledge. Depends on `ostrya-sign` and
  `ostrya-fetch`.
- `ostrya-composefs` -- standalone, synchronous EROFS/composefs image writer
  and fs-verity digest. Takes a tree model and emits image bytes.
- `ostrya` -- the library: repo, transactions, commit, checkout, refs,
  reading, the resolution of a remote to an endpoint (`ostrya::endpoint`),
  and the paths listed under Status. Feature-gated.
- `ostrya-cli` -- the command-line front-end (builds the `ostrya` binary).

Feature flags on `ostrya`:

- `smol` (default) and `tokio` -- the runtime selectors.
- `sign-spki` -- the spki signature engine.
- `verify-gpg` -- GPG signature verification.
- `sign-gpg` -- GPG signing. It turns on `verify-gpg`.
- `receive` -- the server side of a push: the receive policy,
  `Repo::receive`, and `Repo::receive_stream`, which reads one one-way stream
  with no reply. The `receive` feature of `ostrya-cli`, in its default set,
  builds `ostrya receive` on it.
- `push` -- the client side of a push from a repository: `Repo::push`,
  `Repo::push_over_stream`, `Repo::export_stream`, which writes one one-way
  stream for `Repo::receive_stream`, and `ostrya::endpoint::resolve_push`,
  which gives the endpoint of a configured remote or of an address. The
  `push` feature of `ostrya-cli`, in its default set, builds `ostrya push`
  and `ostrya push-tree` on it.
- `lzma-static` -- the static xz build.

`ostrya-remote` is a dependency of `ostrya` in every build, re-exported as
`ostrya::remote`. `Repo::send`, the serving side of the pull over ssh, and
`PullSession::over_stream` with `Repo::pull_with_session`, its client side
over a pair of streams, take no feature. The `send` feature of `ostrya-cli`,
in its default set, builds `ostrya send` on `Repo::send`. `Repo::pull` runs
over ssh for an ssh address in `PullOptions::overrides` or in the remote key
`pull-url`, with no feature. `ostrya::endpoint::resolve_pull` reads the keys
and the files of a remote for a pull, with no feature.

Later phases add `s3` and `serve`.

## Clean-room provenance and licensing

Ostrya is a clean-room reimplementation. Its design is grounded only in the
public ostree documentation (https://ostreedev.github.io/ostree/) and the
observed behavior of the `ostree` tool run as a black box. The LGPL libostree
source is not consulted, so the resulting code can be distributed under the MIT
license. The on-disk format Ostrya reproduces is an interoperability interface;
every format fact recorded in `docs/format-reference.md` is verifiable by
running the tool and inspecting the bytes it writes.

## Building and testing

The workspace builds on stable Rust (edition 2024, minimum 1.92).

```sh
cargo build
cargo test
```

A Nix flake builds the `ostrya` binary and supplies the development
shell:

```sh
nix build .#ostrya        # ./result/bin/ostrya
nix develop               # Rust 1.92, the `ostree` tool, gnupg, and the
                          # other binaries the test suite runs
```

The flake exposes the package as an overlay under `overlays.default`, so
another flake can take `pkgs.ostrya`.

The test suite runs under both runtime backends:

```sh
cargo test                                        # smol (default)
cargo test -p ostrya --no-default-features --features tokio
```

The checked-in golden fixtures under `tests/fixtures/` are outside every
crate root, so a crate published to crates.io carries none of them.
Consuming the fixtures from a git checkout needs no `ostree` tool.
Generating or regenerating them with `tests/fixtures/generate.sh` needs the
tool. See `docs/port-plan.md`, "Golden fixtures: layout, packaging, and how
to run them", for the fixture layout and the generator's requirements. The
section also gives the exact test commands. It explains how to tell a
skipped fixture test from a passing one.

## Documentation

The design documents in `docs/` are the source of truth and are kept in sync
with the code:

- `docs/format-reference.md` -- the byte-exact on-disk format
- `docs/port-plan.md` -- architecture, testing strategy, and the phased roadmap
- `docs/api-sketch.md` -- the target Rust-native async API

## License

MIT.