# Open-format K1 Chatend 0.5.1
`ChatBox` is the canonical immutable box value. It contains a consecutive one-based `BoxId` plus four open UTF-8 strings: `type`, `contents`, `hidden_type`, and `hidden_contents`. `ChatBox::new` and the accessors preserve all strings exactly. Box types are not an enum or a closed registry. The nine familiar public string conventions are `System Message`, `User Message`, `Agent Message`, `User Attachment`, `Agent Attachment`, `Tool Call`, `Tool Message`, `Tool Attachment`, and `Tool Result`. Hidden fields are ordinary accessible data omitted only from default model input for token efficiency; they are not a security boundary.
`Chatend` owns append order, provider rounds, active-arrival FIFO behavior, and K1 tool-call correlation. `accept_box` admits any generic box, including arbitrary attachment, system, and future types. Convenience methods produce `System Message`, `User Message`, and `User Attachment`; attachments always carry caller-supplied contents. `ATTACHMENT_TYPE` remains a source-compatible alias for `USER_ATTACHMENT_TYPE`. Provider stages append optional `Agent Message` output and `Tool Call` boxes. Tool returns append `Tool Result` boxes. Recognized tool conventions use versioned hidden types and owner-defined metadata, while unfamiliar types and hidden conventions remain inert and round-trip unchanged.
Owner-produced `Tool Call` contents expose the complete model-visible metadata as plain text: the lowercase 24-hex nonce and sequence call ID, call name, and raw arguments. Owner-produced `Tool Result` contents expose the call ID, originating call box ID, `Status: ok` or `Status: error`, and raw result. Their hidden fields retain machine correlation and are accessible through the metadata accessors, but are omitted by the default model renderer.
`start_round` enters provider mode without appending a box. Provider-mode arrivals queue in memory. `flush_active_arrivals` appends and returns one finite FIFO snapshot while keeping the round active. `done` appends optional final agent text, exits provider mode, and drains only arrivals still queued. Idle arrivals append immediately. Duplicate calls, unknown or duplicate returns, invalid phases, and ID overflow reject transactionally.
`recover` requires contiguous IDs beginning at one. It validates only recognized K1 tool conventions: call IDs are unique and every result references its unique earlier call. Unknown box types and hidden conventions are accepted unchanged. Recovered state is idle and future IDs continue monotonically.
All retained operations are linear in the boxes or arrivals they inspect or append.