kcode-k1-web-cache-resolution 0.1.1

Build one frozen K1 Web cache resolution view
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# Consumer contract

This concrete one-shot leaf builds and materializes the exact dependency view required by `kcode-k1-web-cache`.

```rust
pub struct Digest(pub [u8; 32]);
pub struct ResolutionEntry { pub family: WebFamily, pub selector: DependencySelector, pub resolved: WebId, pub winning: TxId }
pub struct ResolutionView;
impl ResolutionView { pub fn from_snapshot(candidate: &SourcePackage, selected: Vec<(ResolutionEntry, Arc<SourcePackage>)>) -> Result<Self, String>; pub fn entries(&self) -> &[ResolutionEntry]; pub fn route(&self, family: &WebFamily, selector: &DependencySelector) -> Option<&ResolutionEntry>; pub const fn digest(&self) -> Digest; pub fn materialize(&self, empty_root: impl AsRef<Path>) -> Result<(), String>; pub fn inspect(root: impl AsRef<Path>) -> Result<Option<Digest>, String>; }
```

`from_snapshot` accepts packages admitted from one coherent projection snapshot. It validates the reachable family-selector closure, distinct routes, selector and resolved identity agreement, winner consistency, and exact paired package identity. Multiple selectors may select one package. A dependency-free candidate produces the canonical empty frozen view.

The deterministic digest covers a canonical manifest containing every route, winner, resolved identity, materialized file path, and file hash, plus every exact file byte sequence. The empty view uses the header-only manifest `K1WEBRESOLUTION3\n`. `materialize` requires an ordinary empty directory and creates only `manifest` and `web-libs/<authority>/<name>/<version>/`; for the empty view, `web-libs` is the exact empty package tree.

`inspect` accepts either an empty ordinary directory or that exact ordinary layout and returns the inspected view digest. It canonically parses authorities and winners as transaction IDs, names and selectors through the Web package types, and resolved versions as stable SemVer Web identities. It rejects symlinks, special files, unsafe paths, unexpected, missing, extra, or misplaced files, empty package directories, malformed or noncanonical identity fields, duplicate or out-of-order records, inconsistent routes, winners, package identities, or bytes, and every manifest/tree mismatch. Arbitrary exact package bytes remain unchanged.

The leaf has no locks, callbacks, retries, background state, authoritative storage, publication, atomic replacement, dirty fencing, receipt behavior, or projection access. Construction is linearithmic in route and file count plus exact bytes hashed. Materialization and inspection are unbenchmarked local filesystem work linear in exact view size.