membase-core
Copyright (c) 2026 Membase contributors

This product is proprietary software of Unibase (see LICENSE), EXCEPT for the
portions listed below, which are derived from third-party Apache-2.0 software and
remain governed by the Apache License, Version 2.0. A copy of that license is in
licenses/LICENSE-Apache-2.0. Those portions are redistributed under their own terms,
with the notices and statement of changes that license requires.

--------------------------------------------------------------------------------
EverOS — https://github.com/EverMind-AI/EverOS
Copyright 2025 EverMind AI
Licensed under the Apache License, Version 2.0.

VENDORED: src/membase_algo/
      The complete everalgo source tree (147 modules) from the published
      everalgo-user-memory / -agent-memory / -rank / -knowledge / -parser /
      -boundary / -clustering / -core packages. CHANGES MADE: the package was
      renamed from ``everalgo`` to ``membase_algo`` (directory name and every import
      path rewritten accordingly); the name "EverAlgo" in docstrings and comments
      was replaced by "Membase"; the HTTP User-Agent string in parser/_utils.py
      and the optional-dependency install hint in parser/image.py were changed
      to drop the upstream package name. No algorithm, prompt, type or control
      flow was modified. Call sites, all under src/membase_core:

        conversation/extract.py               boundary, user_memory (episode / atomic
                                              fact / profile / foresight), clustering
                                              (cluster_by_geometry)
        knowledge/                            parser, knowledge, rank.category
        agent/                                agent_memory, clustering (cluster_by_llm),
                                              rank.case / rank.skill / rank.agentic
        conversation/membase_modes.py         rank.fusion / hybrid / maxsim / cluster /
                                              agentic / episodic / profile / rerank
        search/recall.py                      rank.protocols (RetrieveFn / RerankFn)
        llm/membase_client.py                 llm (build_client, LLMConfig, providers)
        llm/membase_prompts.py                prompts.validator, the zh prompt sets
        tests/                                testing.fake_llm

Other derived files, and the change made to each (upstream paths are given
relative to the EverOS repository):

  src/membase_core/conversation/hierarchy.py
      Port of src/everos/memory/search/hierarchy.py (heap_expand,
      build_ep_to_fact_parents) and shaper.py::reshape_hybrid_output. Same algorithm;
      output records are this project's dataclasses rather than upstream DTOs, and
      atomic-fact ids are namespaced ("fact:<id>") because this store's row ids are
      per table, not UUIDs.

  src/membase_core/conversation/membase_modes.py
      Follows src/everos/memory/search/manager.py (episode HYBRID / rank fallback),
      agentic.py (maxsim -> hybrid -> cluster -> agentic pipeline and its constants)
      and callbacks.py, on SQLite FTS5 + FAISS instead of LanceDB. One divergence:
      an owner with no clusters falls back to hybrid recall instead of returning
      nothing.

  src/membase_core/search/recall.py
      Port of src/everos/memory/search/recall/base.py (row_to_candidate) and
      callbacks.py (build_rerank_fn, build_skill_rerank_fn, build_case_rerank_fn);
      the reranker is a local cross-encoder rather than a remote provider.

  src/membase_core/store/clusters.py
      Port of src/everos/infra/persistence/sqlite/{tables,repos}/cluster.py
      (same schema and repo operations, synchronous).

  src/membase_core/knowledge/
      Follows src/everos/service/knowledge.py, entrypoints/api/routes/knowledge.py
      (_parse_upload), component/parser/_core.py, memory/extract/parser/*.py and
      infra/persistence/markdown/readers/taxonomy_reader.py (DEFAULT_TAXONOMY
      verbatim). Storage is SQLite + FAISS; the taxonomy override is JSON, not YAML.

  src/membase_core/agent/
      Follows src/everos/service/_boundary.py (message -> ConversationItem),
      memory/strategies/{extract_agent_case,extract_agent_skill,
      trigger_skill_clustering}.py, memory/search/{skill_hybrid,agentic_agent}.py
      and memory/models.py (EntryId). Storage is SQLite + FAISS.

  src/membase_core/conversation/extract.py (clustering / profile blocks)
      Follows memory/strategies/trigger_profile_clustering.py and
      extract_user_profile.py (cluster-selected memcells, old_profile threading).

  src/membase_core/llm/membase_client.py
      Follows src/everos/component/llm/client.py (build_client(LLMConfig),
      _LoggingLLMClient, the separate multimodal client).

  src/membase_core/conversation/prompts/answer_locomo.md
      Verbatim copy of benchmarks/adapters/locomo.py::ANSWER_PROMPT, split at the
      "---" marker so the instruction half serves as a system prompt. No wording
      changed.

  src/membase_core/conversation/prompts/answer_longmemeval.md
      Copy of benchmarks/adapters/longmemeval.py::ANSWER_PROMPT ("precise" variant).

  src/membase_core/conversation/prompts/decider.md
      Verbatim copy of src/everos/memory/search/llm_multiround.py::_DECIDER_PROMPT.
      No wording changed.

  src/membase_core/conversation/answer.py::_extract_final_answer
      Line-for-line port of benchmarks/run.py::_extract_final_answer.

  src/membase_core/conversation/multiround.py
      Independent implementation of the multi-round decider retrieval design in
      src/everos/memory/search/llm_multiround.py: per-sub-query independent RRF,
      core-first assembly with a per-sub-query guarantee, and a max-RRF fill.
      Episode recall runs on SQLite FTS5 + FAISS rather than LanceDB, owner-filtered
      before the limit as upstream; loop defaults follow the upstream [decider] settings.

  src/membase_core/conversation/context.py::pack_context
      Context rendering follows the shape of benchmarks/run.py::_build_context and
      CONTEXT_TEMPLATE.
