md-first memory extraction framework for AI agents. Markdown is the single source of truth; SQLite holds state and LanceDB provides the rebuildable vector + BM25 + scalar index. The codebase follows a single-direction DDD layering (entrypoints -> service -> memory -> infra, with component / core / config cross-cutting) enforced by import-linter. Engineering surface: - Coding conventions in .claude/rules/ (path-scoped) and workflows in .claude/skills/ (/commit, /new-branch, /pr). - GitHub Actions CI runs make lint + test + integration; pre-commit mirrors the gates locally (ruff, hygiene hooks, gitlint commit-msg). - Commit messages follow Conventional Commits, enforced by gitlint. - make lint also enforces datetime two-zone discipline and OpenAPI drift.
31 lines
898 B
Python
31 lines
898 B
Python
"""Lifespan provider abstract base.
|
|
|
|
A LifespanProvider is one unit of startup / shutdown work invoked by the
|
|
FastAPI lifespan factory. Providers are registered explicitly (no DI
|
|
auto-discovery) and executed in ``order`` ascending on startup, reverse
|
|
on shutdown.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from abc import ABC, abstractmethod
|
|
from typing import Any
|
|
|
|
from fastapi import FastAPI
|
|
|
|
|
|
class LifespanProvider(ABC):
|
|
"""One unit of startup / shutdown work."""
|
|
|
|
def __init__(self, name: str, order: int = 0) -> None:
|
|
self.name = name
|
|
self.order = order
|
|
|
|
@abstractmethod
|
|
async def startup(self, app: FastAPI) -> Any:
|
|
"""Startup hook; return value is stored on ``app.state.lifespan_data[name]``."""
|
|
|
|
@abstractmethod
|
|
async def shutdown(self, app: FastAPI) -> None:
|
|
"""Shutdown hook; called in reverse order during application teardown."""
|