bankai/builder

Ergonomic Task construction. Builds a draft then rehashes so the content_hash is always correct. Reused by graph/actor/CLI layers.

Values

pub fn build(
  id: String,
  title: String,
  description: String,
  status: types.TaskStatus,
  assignee: option.Option(String),
  priority: Int,
  created_at: Int,
  updated_at: Int,
  relationships: List(types.Relationship),
) -> types.Task
pub fn build_full(
  id: String,
  title: String,
  description: String,
  status: types.TaskStatus,
  assignee: option.Option(String),
  priority: Int,
  created_at: Int,
  updated_at: Int,
  relationships: List(types.Relationship),
  labels: List(String),
  parent_id: option.Option(String),
  kind: types.TaskKind,
) -> types.Task
pub fn build_with_derived_id(
  title: String,
  description: String,
  status: types.TaskStatus,
  assignee: option.Option(String),
  priority: Int,
  created_at: Int,
  updated_at: Int,
  relationships: List(types.Relationship),
  labels: List(String),
  parent_id: option.Option(String),
  kind: types.TaskKind,
) -> types.Task

Build a Task whose id is DERIVED from its own (placeholder) content hash, not from the clock. The id is taken from a draft’s hash (placeholder id "__pending__", REAL labels so the derived id is label-aware), then the task is rebuilt with the real id + rehashed. No circularity: the id references the placeholder-hash, not the final hash.

pub fn short_id_from_hash(h: identity.Hash) -> String

Short, human-readable id derived from a content hash: “bk-” + first 4 hex (G12). Replaces the timestamp ids (BUG-08: ms ids collided under rapid creates; ns ids were 19 digits). A hash-prefix id is readable AND collision- resistant — the draft includes a ns created_at, so identical content made at different instants hashes to different ids. 4 hex matches the documented bk-a3f8 form.

pub fn update(
  task: types.Task,
  mutate: fn(types.Task) -> types.Task,
) -> types.Task

Apply a field change and return a rehashed Task (hash advances). A Task(..t, ...) spread carries labels through automatically.

Search Document