bankai/message

Task-scoped threaded messages (Phase C).

A Message is content-addressed like a Task or Memory: SHA-256 over canonical bytes (task_id + parent_msg_id + author + text + ts; content_hash excluded, a hash cannot include itself). Stored in .bankai/messages.jsonl alongside tasks.jsonl.

Threading: parent_msg_id points to the parent message (or empty string for top-level messages under a task). The CLI renders threaded lists by walking the parent chain.

Types

pub type Message {
  Message(
    id: String,
    task_id: String,
    parent_msg_id: String,
    author: String,
    text: String,
    ts: Int,
    content_hash: identity.Hash,
  )
}

Constructors

  • Message(
      id: String,
      task_id: String,
      parent_msg_id: String,
      author: String,
      text: String,
      ts: Int,
      content_hash: identity.Hash,
    )

Values

pub fn flush(
  messages: List(Message),
  to path: String,
) -> Result(Nil, simplifile.FileError)
pub fn load(from path: String) -> Result(List(Message), String)
pub fn message_bytes(m: Message) -> BitArray

Canonical, deterministic byte encoding (versioned). Excludes content_hash (a hash cannot include itself).

pub fn message_decoder() -> decode.Decoder(Message)
pub fn message_from_json_string(
  s: String,
) -> Result(Message, String)
pub fn message_hash(m: Message) -> identity.Hash
pub fn message_to_json(m: Message) -> json.Json
pub fn message_to_json_string(m: Message) -> String
pub fn new(
  task_id: String,
  parent_msg_id: String,
  author: String,
  text: String,
  ts: Int,
) -> Message

Build a message with a real content hash.

Search Document