# API and behavior
Node types, legacy JSON decoding, and full-node body formatting are delegated
to `kcode-kweb-context-node` and re-exported from this crate. `Context` retains
explicitly loaded nodes. Its optional compatibility mode also retains their
fixed connections as full nodes; explicitly loaded nodes take precedence over
that fixed role.
`Context::apply_load` accepts one fetched node. In compatibility mode it also
requires the full nodes fetched for that node's fixed connections.
`Context::restore` reconstructs the same mode-specific state from stored nodes
and the ordered IDs established by prior `LoadNodes` invocations.
`Context::projection` returns the complete current provider-facing sections as
stable logical keys, names, and text without opening or changing Session
History. Every full node keeps its node ID as its stable key. Every connection
summary is a separate replaceable item keyed by canonical connection ID, so a
consumer using ordinary keyed-state reconciliation emits nothing for an
unchanged reload, adds only newly discovered summaries, and replaces only a
node or summary whose rendered text changed. This is the projection boundary
for box-free subagent contexts; it never emits one cumulative connection state.
`Context::sync_chatend` accepts an already-open Session History session,
the caller's timestamp, and staged updates and creates. It reconciles the
complete provider-facing Kweb projection:
1. one `Loaded` full-node box per explicitly loaded node;
2. in compatibility mode only, one `Fixed` full-node box per distinct fixed
connection not already loaded;
3. one `Staged` full-node box per staged create; and
4. permanent connection-summary boxes containing at most eight globally
deduplicated fixed and recent connections each.
Loaded, compatibility-fixed, and staged boxes share the same body formatter.
They differ only in their declared box name and typed metadata. There is no
active-node role or active-connection field.
For every full node, fixed connections are visited in stored order before
recent connections. The combined stream is globally deduplicated by canonical
ID in first-seen order. Each synchronization places newly discovered summaries
in new boxes instead of filling an existing partial or empty box. Every summary
box retains its exact membership once created. Existing summary boxes are never
retired. When an existing connection's rendered name or short description
changes, its current box receives the new canonical text without changing
membership; an unchanged summary does not revise its box. Caller-selected
summarized or dehydrated representations survive canonical updates. The
returned box IDs are exactly the boxes whose active name or canonical revision
changed, in current projection order.
The compatibility flag has no persistence format and is chosen by the caller.
The caller remains responsible for fetching Kweb data, choosing roots and
staged mutations, deciding when to synchronize, and committing the resulting
Kweb transaction. The crate uses the supplied Session History handle only to
apply its projection; it does not open persistence, use HTTP, or access Kweb.