# Consumer contract
This library validates one complete authority-namespaced buildless Web package in memory. All fields of the public types are private.
```rust
pub struct AuthorityId;
impl AuthorityId { pub const fn new(transaction_id: TxId) -> Self; pub const fn transaction_id(&self) -> &TxId; }
pub struct WebFamily;
impl WebFamily { pub fn new(authority: AuthorityId, logical_name: impl Into<String>) -> Result<Self, PackageError>; pub const fn authority(&self) -> AuthorityId; pub fn logical_name(&self) -> &str; }
pub struct WebId;
impl WebId { pub fn new(family: WebFamily, version: Version) -> Result<Self, PackageError>; pub fn family(&self) -> &WebFamily; pub fn version(&self) -> &Version; }
pub struct DependencySelector;
impl DependencySelector { pub fn parse(text: &str) -> Result<Self, PackageError>; pub fn matches(&self, version: &Version) -> bool; }
pub struct WebDependency;
impl WebDependency { pub const fn authority(&self) -> AuthorityId; pub fn name(&self) -> &str; pub fn selector(&self) -> &DependencySelector; }
pub struct SourceFile;
impl SourceFile { pub fn new(path: impl Into<String>, bytes: Vec<u8>) -> Self; pub fn path(&self) -> &str; pub fn bytes(&self) -> &[u8]; }
pub struct SourcePackage;
impl SourcePackage { pub fn new(id: WebId, files: Vec<SourceFile>) -> Result<Self, PackageError>; pub fn id(&self) -> &WebId; pub fn files(&self) -> &[SourceFile]; pub fn entry(&self) -> &str; pub fn tests(&self) -> &str; pub fn dependencies(&self) -> &[WebDependency]; }
pub struct PackageError;
impl PackageError { pub fn message(&self) -> &str; }
```
`AuthorityId` implements `Copy`, `Clone`, `Debug`, `Eq`, `Hash`, `Ord`, and `Display`. `WebFamily`, `WebId`, and `DependencySelector` implement `Clone`, `Debug`, `Eq`, `Hash`, and `Ord`; `DependencySelector` also implements `Display`. `WebDependency` and `SourceFile` implement `Clone`, `Debug`, `Eq`, `Hash`, and `Ord`. `SourcePackage` implements `Debug` and `Eq`. `PackageError` implements `Clone`, `Debug`, `Eq`, `Display`, and `std::error::Error`.
Logical names contain 1–36 bytes of lowercase kebab case. Web versions are stable SemVer without prerelease or build metadata. Selectors are canonical `MAJOR.MINOR.PATCH`, `MAJOR.MINOR`, `MAJOR`, or `*`; they match only stable versions, and `*` spans all majors.
`SourcePackage::new` sorts files by path, rejects duplicate or file/ancestor-colliding safe slash-relative Linux paths, and preserves every file's bytes. Root `k1-web.json` and `Documentation.md` must be UTF-8. The manifest is exactly `{name,version,entry,tests,dependencies:[{authority,name,selector}]}` with no unknown fields; its name and version match the supplied identity, its JavaScript entry and test paths name present UTF-8 `.js` or `.mjs` files, and exact duplicate dependency declarations are rejected. `entry()` and `tests()` return the respective validated manifest paths. Dependencies are sorted by authority, name, selector specificity, and selector value.
No operation performs I/O or external work. The API has not been benchmarked; identity operations and selector matching are constant-time apart from their directly supplied short strings, selector parsing and name validation are linear in input length, `SourceFile::new` moves its inputs, and `SourcePackage::new` is linear in validated bytes plus sorting by file and dependency count.