Skip to main content

Focused local memory for AI agents with SQLite FTS5 and deterministic context packing.

Project description

image

Memory Kernel

Memory Kernel is a small local memory layer for AI agents.

It helps you save useful things such as decisions, constraints, tasks, facts, and notes in a local SQLite database, then pull back only the few memories that matter for the current task.

Published package name on PyPI: amormorri-memory-kernel CLI command after install: memory-kernel

Practical guide in Ukrainian: docs/OPERATING_GUIDE_UK.md

Release notes: CHANGELOG.md

Contents

What It Does

In plain English, Memory Kernel does 4 things:

  1. Stores memory locally on your machine.
  2. Keeps memory structured enough to stay useful.
  3. Finds relevant records without a heavy vector stack.
  4. Builds a small context pack instead of dumping everything into the prompt.

This project is not trying to create a magical black-box memory. It is trying to create a memory layer you can inspect, control, export, and trust.

Start In 5 Minutes

If you just want to try it, do this:

pip install amormorri-memory-kernel
memory-kernel init
memory-kernel remember --scope my.project --kind decision --title "Keep memory local" --content "We store memory on the user's machine."
memory-kernel search "memory local"
memory-kernel export --format json --output exports\memory.json

What happened there:

  1. init created a local database.
  2. remember saved one clear memory.
  3. search fetched it back.
  4. export created a backup file you can move or restore later.

If you are using the repository instead of PyPI:

pip install -e .[dev]

Typical Workflow

Most people will use it like this:

  1. Save one precise memory with remember.
  2. Feed raw notes or transcripts with ingest.
  3. Before an agent run, fetch only what matters with search, context, or wake-up.
  4. Inspect, fix, or remove single records with show, update, or delete.
  5. Periodically export the database for backup.
  6. Restore it elsewhere with import.

Which Command To Use

remember

Use remember when you already know exactly what should be saved.

Good examples:

  • a decision
  • a rule
  • a user preference
  • a project constraint
memory-kernel remember --scope project.alpha --kind decision --title "Use SQLite FTS5" --content "We use SQLite FTS5 for local retrieval."

ingest

Use ingest when you have raw text and want the system to split it into structured memories.

Good examples:

  • meeting notes
  • a transcript
  • a rough planning document
  • an agent session log
memory-kernel ingest --scope project.alpha --file notes.txt --source sprint-review --tags planning transcript

Add --dry-run to preview the segments and inferred kinds/titles/tags without writing to the database. Useful before committing a long file.

memory-kernel ingest --scope project.alpha --file notes.txt --dry-run
memory-kernel ingest --scope project.alpha --text "..." --dry-run --json

Add --interactive for a guided flow that prompts for scope, source, tags, and the text itself, then shows a preview and asks for confirmation before saving. Helpful for first-time users or for ad-hoc captures from the terminal without remembering the flag names.

memory-kernel ingest --interactive

search

Use search when you want a few relevant exact memories for a query.

memory-kernel search "context budget"

context

Use context when you want a compact pack for an agent prompt.

memory-kernel context "How do we keep memory cheap?" --budget-chars 700

wake-up

Use wake-up when you want a small "hot memory" pack before a task starts.

memory-kernel wake-up --budget-chars 500

stats

Use stats when you want to see database size and whether the native accelerator is active.

memory-kernel stats
memory-kernel stats --since 7d
memory-kernel stats --since 2026-04-01

--since adds recent-activity counts (created and updated since the cutoff) plus a per-kind breakdown for the window. Accepts either a relative form like 7d or an ISO date.

list

Use list to browse recent memories (most recently updated first) with optional filters.

memory-kernel list
memory-kernel list --scope project.alpha --limit 50
memory-kernel list --kind decision --tags rust memory
memory-kernel list --json

Default limit is 20. The output shows id, kind/scope, title, and the timestamps so you can pipe ids into show/update/delete.

show

Use show when you have a memory id (printed by search, remember --json, or export) and want the full record.

memory-kernel show --id 9f1e8c0a4b2d4e7f8a1b2c3d4e5f6a7b
memory-kernel show --id 9f1e8c0a4b2d4e7f8a1b2c3d4e5f6a7b --json

update

Use update to fix specific fields on an existing memory without re-importing the whole database.

memory-kernel update --id 9f1e... --title "Renamed memory" --importance 0.95
memory-kernel update --id 9f1e... --tags rust memory acceleration
memory-kernel update --id 9f1e... --tags

Only the fields you pass change. Pass --tags with no values to clear tags. Pass --kind, --importance, or --certainty to revise validation-bound fields.

delete

Use delete to drop a memory you saved by mistake or that no longer applies.

memory-kernel delete --id 9f1e8c0a4b2d4e7f8a1b2c3d4e5f6a7b

The command exits non-zero if the id does not exist, so wrap it in shell logic if you script around it.

completion

Use completion to print a shell completion script for memory-kernel. The script is generated dynamically from the current parser, so it stays in sync as commands are added.

memory-kernel completion powershell | Out-File -Encoding utf8 $PROFILE.CurrentUserAllHosts -Append
memory-kernel completion bash > ~/.local/share/bash-completion/completions/memory-kernel

After installing, memory-kernel <Tab><Tab> shows all subcommands; memory-kernel remember --<Tab> lists flags for that command; memory-kernel remember --kind <Tab> cycles through valid kind values.

verify

Use verify to check that the database is internally consistent: schema version is current, derived columns (stems_text, fingerprint) match the source content, and the FTS5 index row count matches the memories table.

memory-kernel verify
memory-kernel verify --repair
memory-kernel verify --repair --json

Without --repair, exit code is 0 when healthy and 1 when issues are found. With --repair, mismatches are recomputed in-place and the FTS index is rebuilt if its row count drifted; exit code is 0 if everything was fixed.

Useful after restoring from a manual backup, after editing the database with raw SQL, or as a periodic sanity check in CI.

export

Use export for backup, migration, or inspection.

memory-kernel export --format json --output exports\memory.json
memory-kernel export --scope project.alpha --format jsonl --output exports\project-alpha.jsonl

import

Use import to restore a previous export.

memory-kernel import --file exports\memory.json
memory-kernel import --file exports\project-alpha.jsonl

import is idempotent for the same exported records because it upserts by memory id.

How It Works

The core idea is simple:

  1. Store exact text locally.
  2. Search cheaply with SQLite and FTS5.
  3. Rank results deterministically instead of fuzzily.
  4. Return a small context pack with a hard character budget.

That is how Memory Kernel reduces both blur and overhead.

Data Flow

flowchart TD
    A[Raw input: note, transcript, command] --> B{Entry mode}
    B -->|remember| C[One validated memory]
    B -->|ingest| D[Split into memory candidates]
    D --> E[Infer kind, title, summary, tags, importance, certainty]
    E --> F[Duplicate-aware upsert]
    C --> F
    F --> G[(SQLite + FTS5)]
    G --> H[Search candidates]
    H --> I[Deterministic ranking]
    I --> J[Top memories]
    J --> K[Context pack with hard size limit]
    K --> L[LLM or AI agent]

Component Diagram

flowchart LR
    U[User or Agent] --> CLI[CLI or Python API]
    CLI --> STORE[MemoryStore]
    STORE --> DB[(SQLite + FTS5)]
    STORE --> ACCEL[Optional Rust accelerator]
    STORE --> PACK[Context pack builder]
    PACK --> MODEL[LLM]

Memory Record Schema

MemoryRecord
|- scope
|- kind
|- title
|- summary
|- content
|- tags
|- source
|- importance
|- certainty
|- access_count
|- created_at
|- updated_at
\- last_accessed_at

Ukrainian Inflection Bridging

Search bridges Ukrainian morphology in two layers:

  1. Suffix stemming on the query expands each term to a short stem (вирішиливиріш*). This finds вирішили, вирішення, вирішує, вирішена — anything sharing the same prefix.
  2. Deep stemming of stored content (suffix + prefix stripping) lives in a separate stems_text column inside the FTS5 index. The query also matches against deep stems exactly (stems_text:ріш). This bridges across different prefixes, so a search for рішення also finds вирішили and невирішене — they all collapse to the same ріш stem.

Stored title/summary/content/tags stay exact, so fingerprints, deduplication, ranking, and export all remain deterministic. Only the FTS5 index gains a derived stems_text column.

Disable with:

$env:MEMORY_KERNEL_DISABLE_STEMMER=1

Disabling only affects the query side. stems_text keeps being populated on writes so toggling the env back on does not require a rebuild.

Why It Stays Lightweight

Memory Kernel stays small on purpose:

  • SQLite + FTS5 instead of a mandatory vector database
  • deterministic ranking instead of fuzzy always-on retrieval
  • duplicate-aware updates instead of endless memory growth
  • hard context budgets instead of large prompt dumps
  • optional Rust acceleration only where it actually helps

For embedded Python usage, MemoryStore keeps a long-lived SQLite connection for throughput. Prefer with MemoryStore(...) as store: or call store.close() when you are done.

Who It Is For

This is a good fit when you want:

  • local-first memory on your own machine
  • clear records you can inspect
  • small, predictable retrieval
  • easy export and restore

This is a weaker fit when you want:

  • a fully hosted managed platform
  • zero local setup
  • fully automatic cleanup of messy notes with no review

Project Status

Current stage: working alpha.

Already working:

  • package layout
  • CLI
  • tests
  • export and import
  • optional Rust accelerator
  • Python fallback without Rust

Still in progress:

  • prebuilt wheels for major platforms
  • a simpler guided ingest flow
  • even lighter onboarding for non-technical users

Native Accelerator

The Python implementation is the stable default.

If you want lower overhead on ingest and heuristic hot paths, build the optional Rust module:

.\scripts\build_native.ps1

After that, memory-kernel stats will show whether accelerator: rust is active.

You can benchmark the current hot paths with:

python .\scripts\benchmark_ingest.py
python .\scripts\benchmark_upsert.py

Experimental native ranking is available for profiling:

$env:MEMORY_KERNEL_EXPERIMENTAL_NATIVE_RANK=1

Feedback

Issue tracker: https://github.com/Artem362/memory-kernel/issues

Issue template chooser: https://github.com/Artem362/memory-kernel/issues/new/choose

There is also a first-run feedback template in: .github/ISSUE_TEMPLATE/first-run-feedback.yml

The most useful early report includes:

  • where you installed from
  • your OS and Python version
  • the exact command you ran
  • what you expected
  • what actually happened

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

amormorri_memory_kernel-0.2.0.tar.gz (63.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

amormorri_memory_kernel-0.2.0-py3-none-any.whl (30.3 kB view details)

Uploaded Python 3

File details

Details for the file amormorri_memory_kernel-0.2.0.tar.gz.

File metadata

  • Download URL: amormorri_memory_kernel-0.2.0.tar.gz
  • Upload date:
  • Size: 63.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for amormorri_memory_kernel-0.2.0.tar.gz
Algorithm Hash digest
SHA256 a76438d4f367d0f1f9cfa14cc4cc11bb48dd3cff02276924bcad7d66c11ddd6d
MD5 38d9c4fe55edf7486fe4015f249a62dc
BLAKE2b-256 5d38e4eb3d2d725c39b274011966fcee58b0302d6bfbc72c0d1d129c40e659f5

See more details on using hashes here.

Provenance

The following attestation bundles were made for amormorri_memory_kernel-0.2.0.tar.gz:

Publisher: release.yml on Artem362/memory-kernel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file amormorri_memory_kernel-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for amormorri_memory_kernel-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2f9ea97338f623e74391ce8873c9016716c666c97b7a252fd242d45fb7520e34
MD5 35c9a92b067dc38f8dbbd2f19a142af5
BLAKE2b-256 3d73c41be20a89dc63ea3d8704bbe7658967ff8e5659af61bcd495715cc10bb6

See more details on using hashes here.

Provenance

The following attestation bundles were made for amormorri_memory_kernel-0.2.0-py3-none-any.whl:

Publisher: release.yml on Artem362/memory-kernel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page