Skip to content

Local-first 🧠 memory for Hermes Agent that lives in your Obsidian vault and remembers project context. Nightly 😴 dream passes turn repeat corrections into confirmed preferences with measurable confidence. Adapters ship for Claude Code, Codex, and OpenClaw, with an MCP server for anything else.

TypeScript
1.6 KB
Raw Blame
import { describe, expect, test } from "bun:test";

import {
  BRAIN_OPERATIONS,
  BRAIN_ROLES,
  isBrainOperation,
  isBrainRole,
} from "../../../../src/core/brain/trust/role.ts";

describe("BRAIN_ROLES", () => {
  test("enumerates exactly the four documented roles", () => {
    expect(Object.values(BRAIN_ROLES).toSorted()).toEqual([
      "applier",
      "dreamer",
      "unknown",
      "writer",
    ]);
  });

  test("isBrainRole accepts each canonical role", () => {
    for (const role of Object.values(BRAIN_ROLES)) {
      expect(isBrainRole(role)).toBe(true);
    }
  });

  test("isBrainRole rejects unknown strings and non-strings", () => {
    expect(isBrainRole("admin")).toBe(false);
    expect(isBrainRole("Writer")).toBe(false);
    expect(isBrainRole(undefined)).toBe(false);
    expect(isBrainRole(null)).toBe(false);
    expect(isBrainRole(0)).toBe(false);
  });
});

describe("BRAIN_OPERATIONS", () => {
  test("enumerates exactly the six documented operations", () => {
    expect(Object.values(BRAIN_OPERATIONS).toSorted()).toEqual([
      "evidence_record",
      "feedback_write",
      "log_append",
      "preference_create_unconfirmed",
      "preference_promote_confirmed",
      "preference_retire",
    ]);
  });

  test("isBrainOperation accepts each canonical operation", () => {
    for (const op of Object.values(BRAIN_OPERATIONS)) {
      expect(isBrainOperation(op)).toBe(true);
    }
  });

  test("isBrainOperation rejects unknown strings", () => {
    expect(isBrainOperation("preference_delete")).toBe(false);
    expect(isBrainOperation("")).toBe(false);
    expect(isBrainOperation(42)).toBe(false);
  });
});