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
2.9 KB
Raw Blame
import { describe, expect, test } from "bun:test";
import { decideStatus } from "../../src/core/discipline/decision.ts";

describe("decideStatus", () => {
  const noEvents = { byAgent: {}, unknownAgents: [], total: 0 } as any;
  const someTasteEvents = {
    byAgent: {
      "@a": { feedback: 2, apply_evidence: 3, other: 0, total: 5 },
    },
    unknownAgents: [],
    total: 5,
  } as any;
  const onlyOtherEvents = {
    byAgent: {
      "@a": { feedback: 0, apply_evidence: 0, other: 4, total: 4 },
    },
    unknownAgents: [],
    total: 4,
  } as any;
  const noActivity = {
    repo: [],
    nonRepo: [],
    vaultDelta: { newSignals: 0, newPreferences: 0, newRetired: 0, total: 0 },
  } as any;
  const someRepoActivity = {
    ...noActivity,
    repo: [
      {
        path: "/a",
        git: { commits: 2, filesChanged: 1, insertions: 1, deletions: 0 },
      },
    ],
  };
  const someMtimeActivity = {
    ...noActivity,
    nonRepo: [{ path: "/b", modifiedFiles: 5 }],
  };
  const someVaultDelta = {
    ...noActivity,
    vaultDelta: { newSignals: 0, newPreferences: 1, newRetired: 0, total: 1 },
  };
  const highComplexity = {
    ...noActivity,
    complexity: {
      schema_version: 1,
      generated_at: "2026-05-28T00:00:00.000Z",
      score: 12,
      ratio: 12,
      thinking_activity: 0,
      structural_complexity: 12,
      warning: true,
      factors: [{ name: "structure_churn", value: 12, weight: 1 }],
    },
  } as any;

  test("0 events + 0 activity β†’ info", () => {
    expect(decideStatus(noEvents, noActivity)).toBe("info");
  });
  test("0 events + repo activity β†’ alert", () => {
    expect(decideStatus(noEvents, someRepoActivity)).toBe("alert");
  });
  test("0 events + mtime activity (>=3) β†’ alert", () => {
    expect(decideStatus(noEvents, someMtimeActivity)).toBe("alert");
  });
  test("0 events + mtime activity (<3) β†’ info", () => {
    const low = { ...noActivity, nonRepo: [{ path: "/b", modifiedFiles: 2 }] };
    expect(decideStatus(noEvents, low)).toBe("info");
  });
  test("0 events + vault delta β†’ alert", () => {
    expect(decideStatus(noEvents, someVaultDelta)).toBe("alert");
  });
  test("0 events + high complexity-to-thinking ratio β†’ alert", () => {
    expect(decideStatus(noEvents, highComplexity)).toBe("alert");
  });
  test("taste events present β†’ ok unless complexity warning fires", () => {
    expect(decideStatus(someTasteEvents, noActivity)).toBe("ok");
    expect(decideStatus(someTasteEvents, someRepoActivity)).toBe("ok");
    expect(decideStatus(someTasteEvents, highComplexity)).toBe("alert");
  });

  test("only `other` events (snapshot/dream/import) do NOT count as taste β†’ alert if activity", () => {
    // This is the regression catch: a snapshot or import-claude-memory
    // event on a busy code day previously suppressed the alert.
    expect(decideStatus(onlyOtherEvents, someRepoActivity)).toBe("alert");
    expect(decideStatus(onlyOtherEvents, noActivity)).toBe("info");
  });
});