# Session Kmap services
This library is the synchronous, typed Kmap capability owned by a Kennedy logical session. It wraps one already-authorized Kweb manager; it does not open a database, choose an application root, authenticate callers, or add host authorization.
## Construction and sharing
`Service::new(manager: kcode_kweb_manager::KwebManager) -> Service` consumes an existing manager capability. `Service` is cloneable. Its clones use the manager's shared underlying database and commit-session state rather than copying Kmap data.
`manager(&self) -> &kcode_kweb_manager::KwebManager` returns that exact manager capability. This preserves the caller boundary for consumers that already use manager operations outside this facade; the library does not narrow or expand the manager's authority.
## Reads and persistence
All operations are synchronous and perform local parsing or envelope work plus the stated Kweb-manager operation:
- `node(&self, node_id: &str) -> Result<kcode_kweb_db::Node, Error>` parses one canonical node ID and performs one node read.
- `file(&self, object_id: &str) -> Result<kcode_server_object_envelopes::StoredFile, Error>` parses one canonical object ID, performs one object read, and decodes the complete stored-file envelope. Historical raw payload behavior and metadata validation are those of the object-envelope decoder.
- `commit_session(&self, input: kcode_commit_session::CommitRequest) -> Result<kcode_commit_session::CommitReceipt, Error>` forwards the complete request once to the manager. Idempotency, atomicity, receipt-database work, and persistence semantics remain owned by the manager and commit-session dependency.
- `save_generated_image(&self, bytes: Vec<u8>, file_name: &str, media_type: &str, model: &str) -> Result<String, Error>` encodes the complete byte buffer as a `generated-image` stored-file envelope with transport kind `image`, stores it once, and returns its canonical object ID. The supplied file name and media type are handled by the object-envelope contract. Storage provenance uses `model` as author, `kennedy-generated-image` as source, the current UTC time as source creation time, and `Image generated or modified through Kennedy intelligence.` as data.
Canonical ID syntax is the valid input domain for reads. Commit inputs use the dependency's complete valid domain. Generated-image inputs are not given additional size, filename, media-type, or model limits by this facade. No operation truncates payloads or results.
Work and allocation for `node` are bounded by one addressed node read. `file` is linear in the addressed object and envelope size and returns the complete decoded file. `save_generated_image` is linear in the supplied bytes and may hold the input plus its encoded envelope while storing it. `commit_session` scales with the complete request according to the manager and commit-session contracts. The facade performs no network or provider calls, starts no tasks, adds no retries or timeouts, and owns no latency guarantee beyond this fixed amount of local forwarding work. Calls may run concurrently when the shared manager permits it; database serialization, collision handling, durability, and recovery remain manager-owned.
## Errors
`Error` implements `Display` and `std::error::Error` and exposes no storage internals. Canonical-ID parse failures and object-envelope encode or decode failures retain their existing caller-visible messages. Kmap `InvalidInput`, `NotFound`, and `Conflict` messages remain caller-visible. Every other Kmap failure is returned as `An unexpected Kmap database error occurred.` This facade does not retry an ambiguous persistence result and does not create intelligence usage receipts.