kcode-rust-libs-v2 0.1.0

Manage, validate, and publish complete agent-authored Rust library snapshots
Documentation
# Agent Integration Reference

`kcode-rust-libs-v2` is a synchronous Rust library for creating, opening, completely rewriting, validating, and publishing small agent-authored Rust libraries. An integrating server supplies transport, authentication, discovery, session ownership, concurrency exclusion, and its crates.io token.

```rust
use kcode_rust_libs_v2::{KcodeRustLibs, RustLibFile, RustLibPath};

let token = load_crates_io_token_from_secrets_database()?;
let rust_libs = KcodeRustLibs::new("/srv/kcode-rust-libs", token)?;
let mut opened = rust_libs.open_rust_lib("example-lib")?;

println!("{} {}", opened.name(), opened.version());
for file in opened.files() {
    println!("{}", file.path.as_str());
}
```

## Public operations

| Call | Result |
|---|---|
| `KcodeRustLibs::new(root, crates_io_registry_token)` | Creates or opens the persistent library root and retains a non-empty token in private memory. |
| `create_rust_lib(name)` | Creates a Rust 2024 library at version `0.1.0` and returns its complete snapshot. |
| `open_rust_lib(name)` | Opens an existing library and returns its complete snapshot. |
| `opened.name()` | Returns the managed-library name. |
| `opened.version()` | Returns the canonical root-package version parsed from `Cargo.toml`. |
| `opened.files()` | Returns every UTF-8 file exactly once, sorted by canonical relative path. |
| `opened.write(&files)` | Creates or completely replaces the supplied files; omitted files remain. |
| `opened.check()` | Runs fetch, formatting, build, Clippy, tests, and doc tests in disposable Podman workspaces. |
| `opened.publish()` | Repeats the complete check and publishes the root package to crates.io. |

Construct a write with `RustLibFile::new(RustLibPath::new("src/lib.rs")?, complete_text)`. Paths use `/`, are relative, and reject traversal. There is no deletion, patch, rename, reload, close, listing, or arbitrary-command API.

Every managed library requires root-level `Cargo.toml` and `Documentation.md`. `version()` parses a literal canonical stable `major.minor.patch` from root `[package].version`; workspace inheritance is rejected. `Documentation.md` appears only as the corresponding entry in `files()`. This crate deliberately has no `RustLibDocs`, `docs()`, or second documentation representation. A complete agent-facing open response can therefore be assembled as `name`, `version`, and `files` without repeating documentation text.

`check()` returns source-quality failures as `Ok(CheckResult)` with `passed() == false`; infrastructure failures are `Err`. `publish()` accepts no token argument. The token supplied during construction is trimmed, rejected if empty before filesystem roots are created, retained in a redacted private value, and passed only to the final publication container. It is never discovered from or persisted to a credential file.

The integrating server must enforce at most one active handle per managed library and release that ownership with its session. Run synchronous filesystem and Podman operations on a blocking worker in asynchronous servers. Source, check, publication, registry verification, adoption, deployment, and live behavior are separate states.