zwire 0.1.0

Zero-dependency, no_std-compatible transactional reactive state engine: scoped push-pull arena, rebaseable optimistic layers + STM drafts, exact incremental Top-K collections, and open @zwire/core wire protocols
Documentation
# `zwire`

**Zero-dependency, `#![forbid(unsafe_code)]`, `#![no_std]` (`alloc`), Rust 1.100 (Edition 2024) transactional reactive state engine for Rust** — combining a scoped push-pull arena (`Copy` handles + `SyncScope`), **rebaseable optimistic mutation layers + STM read-verify drafts**, **exact incremental 2-level Chunked B-Tree Top-K collections**, and **open JSON wire protocols** compatible with [`@zwire/core`](https://github.com/kjmin-dev/zwire#readme).

## Feature Flags & Modular Workspace

Use the umbrella `zwire` crate with granular feature flags, or depend directly on any standalone crate:

| Crate | Feature | Standalone? | What It Provides |
| :--- | :--- | :---: | :--- |
| [`zwire-collections`]https://github.com/kjmin-dev/zwire/blob/main/rust/crates/zwire-collections/README.md | `collections` | ✅ | Exact 2-level Chunked B-Tree + `O(1)` Top-K boundary pruning (zero `T: Clone`) |
| [`zwire-core`]https://github.com/kjmin-dev/zwire/blob/main/rust/crates/zwire-core/README.md | `core`, `sync` | ✅ | Zero-global `Scope` + `Copy` handles + deadlock-free `SyncScope` (`Send + Sync`) |
| [`zwire-tx`]https://github.com/kjmin-dev/zwire/blob/main/rust/crates/zwire-tx/README.md | `tx` | `core` | `OptimisticLayer`, RAII `OptimisticGuard`, atomic zero-flicker `try_settle`, STM `Draft` |
| [`zwire-protocol`]https://github.com/kjmin-dev/zwire/blob/main/rust/crates/zwire-protocol/README.md | `protocol` | `core` | Zero-dep JSON `WireValue`, out-of-order `hydrate`/`dehydrate`, `ExternalSource`, `SyncBridge`, `InspectorHook` |

```toml
# Only exact incremental Top-K collections (no_std + alloc, zero deps)
zwire = { version = "0.1", default-features = false, features = ["collections"] }

# Full transactional reactive engine + multi-threaded SyncScope + @zwire/core wire protocol
zwire = "0.1"
```

## Quick Start

```rust
use zwire::prelude::*;

let scope = Scope::new();

// 1. Reactive incremental Top-K collection (O(log N) updates, O(1) boundary skip)
let book = ReactiveCollection::with_filter(
    &scope,
    |o: &(u64, i64, bool)| o.0,
    |a, b| b.1.cmp(&a.1),
    |o| o.2,
);
let top3 = book.top_k_signal(3);
let best_price = scope.computed(move |cx| {
    cx.with(top3, |rows| rows.first().map(|r| r.1).unwrap_or(0))
});

book.upsert_many([(1, 100, true), (2, 120, true), (3, 95, true)]);
assert_eq!(scope.get(best_price), 120);

// 2. Overlapping rebaseable optimistic layers + RAII auto-revert guard
let balance = scope.atom(1_000i64);
let mut l1 = OptimisticLayer::new(&scope);
l1.update(balance, |b| b - 200); // UI: 800

// Authoritative server push arrives concurrently -> active intents auto-rebase!
scope.set(balance, 1_500);
assert_eq!(scope.get(balance), 1_300);

// Atomic zero-flicker settle
l1.settle_with(|| scope.set(balance, 1_300));
assert_eq!(scope.get(balance), 1_300);
```

## Running the Example & Tests

```bash
cd crates
cargo test --workspace --all-targets --all-features
cargo test --workspace --doc
cargo check -p zwire --target wasm32-unknown-unknown --no-default-features --features "core tx collections protocol"
cargo run -p zwire --example orderbook_optimistic
```

See [`docs/RUST-1.100-GUIDELINES.md`](https://github.com/kjmin-dev/zwire/blob/main/docs/RUST-1.100-GUIDELINES.md) for Rust 1.100 patterns, Clippy configuration, and invariants.