bankai/storage/store

The content-addressed store: a Hash -> Task index.

Per ADR-0001 amendment, this is bankai’s own dict-backed store (not aarondb). Every Task version is stored under its own content_hash, so the full history graph is addressable. Persistence to .bankai/tasks.jsonl lives in Phase 6 (bankai/sync); this module is the in-memory index + a to_list/from_list seam.

Types

pub opaque type Store

Values

pub fn current_tasks(store: Store) -> List(types.Task)

The current task per id (latest version by updated_at). The content-addressed store retains ALL versions (the history); this is the “HEAD” view over it — what list/ready/find_by_id operate on.

pub fn find_by_id(
  store: Store,
  id: String,
) -> Result(types.Task, Nil)

Find the current (latest) task version for an id — O(n) scan.

pub fn from_list(tasks: List(types.Task)) -> Store
pub fn get(
  store: Store,
  hash: identity.Hash,
) -> Result(types.Task, Nil)

Fetch a task version by its content hash.

pub fn get_by_hex(
  store: Store,
  hex: String,
) -> Result(types.Task, Nil)

Fetch by hex key (used by CLI inspect <hash> and JSONL reload).

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

Hex string of a Hash — the stable store key (Hash is opaque).

pub fn list(store: Store) -> List(types.Task)

All stored versions, ordered by hash key for stable output.

pub fn new() -> Store
pub fn put(store: Store, task: types.Task) -> Store

Store a task version under its content_hash.

pub fn size(store: Store) -> Int
pub fn to_list(store: Store) -> List(types.Task)

Persistence seam for Phase 6 (JSONL reload/flush).

Search Document