Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:24kchengYe MemoMind Extension

From Leeroopedia
Knowledge Sources
Domains Software_Architecture, Extensibility
Last Updated 2026-10-28 00:00 GMT

Overview

Abstract base class for all MemoMind extensions, defining the lifecycle (on_startup/on_shutdown) and controlled context access for plugin modules.

Description

The Extension ABC is the foundation of MemoMind's plugin system. All extensions (tenant, operation_validator, http, mcp) extend this base class. Extensions receive a configuration dict from environment variables and an `ExtensionContext` providing controlled API access to system internals. The lifecycle methods `on_startup()` and `on_shutdown()` allow extensions to manage external resources.

Usage

Subclass this base class when creating a new extension type. Extensions are loaded via environment variables (e.g., `HINDSIGHT_API_MY_EXTENSION=mypackage:MyExtension`) and receive config from prefixed env vars.

Code Reference

Source Location

  • Repository: MemoMind
  • File: engine/hindsight_api/extensions/base.py
  • Lines: L1-81

Signature

class Extension(ABC):
    def __init__(self, config: dict[str, str]): ...
    def set_context(self, context: ExtensionContext) -> None: ...
    @property
    def context(self) -> ExtensionContext: ...
    async def on_startup(self) -> None: ...
    async def on_shutdown(self) -> None: ...

Import

from hindsight_api.extensions.base import Extension

I/O Contract

Inputs

Name Type Required Description
config dict[str, str] Yes Configuration from prefixed env vars

Outputs

Name Type Description
context ExtensionContext Controlled system API access (set via set_context)

Usage Examples

Creating a Custom Extension

from hindsight_api.extensions.base import Extension

class MyExtension(Extension):
    async def on_startup(self) -> None:
        # Initialize external connections
        self.db = await connect_to_external_db(self.config.get("db_url"))

    async def on_shutdown(self) -> None:
        await self.db.close()

Related Pages

Implements Principle

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment