Skip to content

feat: CaseMemoryStore SPI — semantic fact index alongside the ledger #27

@mdproctor

Description

@mdproctor

What

Add a CaseMemoryStore SPI to casehub-platform-api as a general foundation capability,
following the same pattern as PreferenceProvider and CurrentPrincipal.

The ledger records what happened tamper-evidently. CaseMemoryStore is the queryable
semantic layer — what the platform knows about entities from prior cases.

Why This Is a General Platform Capability

Every CaseHub case currently starts cold. Facts established in one case — about an entity,
an agent's behaviour, a recurring pattern — are invisible to the next case unless explicitly
passed as parameters. This creates repeated research, missed context, and weaker case routing.

CaseMemoryStore solves this for all CaseHub consumers: devtown, clinical, aml, and any
future application repo. It is not an OpenClaw-specific feature.

Design (from research spec docs/specs/2026-05-25-openclaw-casehub-integration.md in casehubio/parent)

SPI contract (casehub-platform-api):

  • Permission-aware recall: enforces CurrentPrincipal + GroupMembershipProvider
    boundaries — not delegated to the backend
  • Domain isolation: facts from one domain (health, finance, household) must not be
    recallable by agents in another domain
  • Fact emission: completed cases emit structured facts (mechanism TBD — CDI observer
    pattern consistent with existing ledger capture)

Module structure (mirrors existing platform pattern):

platform-api          — CaseMemoryStore SPI (zero-dep, alongside CurrentPrincipal)
platform              — @DefaultBean no-op (zero overhead when no backend installed)
memory-memori/        — SQL-native Postgres adapter (default — zero extra infra)
memory-mem0/          — Vector + BM25 adapter (Docker + pgvector)
memory-graphiti/      — Temporal knowledge graph adapter (regulated domains)

Backend adapters — all REST-based (Quarkus RestClient):

Adapter Backend Infrastructure Best for
Default Memori Postgres only Zero-cost entry; all deployments
Standard Mem0 Docker + pgvector Vector retrieval; 48k GitHub stars
Temporal Graphiti (Zep) Graphiti + Neo4j/FalkorDB/Kuzu Regulated domains; temporal queries

Critical constraint: all three backends scope memory by their own userId/sessionId model.
CaseHub's permission model and domain isolation must be enforced at the SPI layer, not assumed
from the backend.

Distinct From

  • casehub-ledger — tamper-evident immutable history (what happened). CaseMemoryStore is
    queryable semantic context (what we know). They are complementary, not competing.
  • ChannelContextWindow (casehub-openclaw) — short-term TTL buffer for OpenClaw agent
    context injection. CaseMemoryStore is long-term indefinite semantic memory for all consumers.

Consumer Issues

  • casehubio/devtown — PR review context and contributor history
  • casehubio/clinical — patient history and site compliance patterns
  • casehubio/aml — entity history and prior investigation context

Open Questions (from research spec)

  • Fact emission mechanism: CDI observer vs explicit API call vs automatic ledger extraction
  • Module placement: as above (platform modules) or standalone casehub-memory repo
  • How domain isolation interacts with ChannelContextWindow context injection

References

Research spec: docs/specs/2026-05-25-openclaw-casehub-integration.md §4.3, §4.3a, §9.1
in casehubio/parent — full backend evaluation, adapter strategy, and open questions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    size:LSubstantial feature

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions