Skip to main content

Persistent memory for AI agents. Set up once. Stays out of your way. Local SQLite, auditable, no GPU, no network.

Project description

A figure of shimmering cloud rising from a dark sea, weaving threads of light into a constellation of beliefs

aelfrice

Your AI stops forgetting your rules. Set up once. Stays out of your way.

Local SQLite. Auditable. No GPU, no network.

PyPI Python License CI OSSInsight

Reproducibility

You correct your agent. "Got it," it says. Next session, same mistake.

aelfrice runs in the background and stops the forgetting. You write a rule once and it gets attached to every prompt thereafter — no cross-references for the agent to skip, no markdown files to maintain, nothing to remember to do.

pipx install aelfrice    # or: uv tool install aelfrice
aelf setup               # wire the hook into your agent
aelf onboard .           # scan the current project and ingest beliefs

Then add your first rule and restart your agent:

aelf lock "never push directly to main; use scripts/publish.sh"

That's it. Your next prompt that mentions "push" already has the rule attached. From here on out aelfrice is invisible — no command to remember to run, no file to keep updated.

The aelf lock line above is an example — substitute your own rule. Skip it entirely if you'd rather start with onboarded beliefs only and add locks as you go.


What it does

When you submit a prompt in Claude Code, aelfrice's UserPromptSubmit hook fires before the model sees your message. It runs a two-layer search:

L0: locked beliefs   -> rules you marked permanent (always returned)
L1: FTS5 keyword     -> SQLite full-text search, BM25-ranked

The matching beliefs come back as an <aelfrice-memory> block prepended to your prompt. The agent reads it as part of the prompt — it doesn't have to remember to check a file.

<aelfrice-memory>
[locked] never push directly to main; use scripts/publish.sh
[locked] commits must be SSH-signed with ~/.ssh/id_rrs
         the publish script runs gitleaks before tagging
</aelfrice-memory>

push the release

Default budget is 2,400 tokens per prompt. Locked beliefs are the always-injected pool — every lock ships on every prompt, in full, regardless of relevance score. Lock count is your baseline-context budget knob: if you've locked 200 things, every session opens with all 200, by your design. The non-locked pool (FTS/L1) is BM25-ranked and truncated to fit.


What it remembers

You run It stores
aelf lock "never commit .env files" Permanent rule. Returned on every retrieval.
aelf onboard . Walks the project — git log, README headings, code structure — and ingests structural facts.
aelf feedback <id> used Bayesian feedback. Strengthens the belief's posterior.
aelf feedback <id> harmful Weakens it. After enough independent harmfuls, locks auto-demote.

Each belief carries a (α, β) Beta-Bernoulli posterior. α / (α+β) is the confidence. Locks short-circuit decay; everything else fades over time so stale beliefs eventually drop out of retrieval.

aelf stats
# beliefs:    142   locked: 8   threads: 67
# feedback:   31    avg_confidence: 0.71

Why files don't solve this

The standard workaround for "agent keeps forgetting" is more files: STATE.md, DECISIONS.md, a CLAUDE.md with cross-references to runbooks. Every cross-reference is a bet that the agent will read the file, find the right section, and follow what it says.

The failure modes are predictable. The agent reads the rule and runs git push anyway. Cross-references break silently after compaction. State files rot the moment you forget to update them. Each new failure mode begets another file.

aelfrice replaces the chain with a mechanism. The hook injects matched beliefs as part of your prompt, before the agent sees it. Nothing voluntary. Nothing the agent can skip.

Manual approach What breaks aelfrice
Rules in CLAUDE.md Agent reads them, doesn't follow them Injected per-prompt, not per-session
Cross-references Agent skips or reads the wrong section Matched beliefs injected directly
Hand-maintained state files One missed update breaks the chain State is the SQLite DB; no manual sync

What you get for free

Running in the background. No action required after aelf setup.

  • Determinism. Stdlib + SQLite. No embeddings, no learned re-rankers, no LLM in the retrieval path. Every result traces to the action that wrote it.
  • Local-only. SQLite at <repo>/.git/aelfrice/memory.db. No telemetry, no network calls, no accounts. Per-project isolation by construction. See PRIVACY.md.
  • Removable. aelf uninstall --archive backup.aenc encrypts the DB to a file, then deletes it. Or --purge for a full wipe.

Tradeoff: no fuzzy semantic recall. See PHILOSOPHY.md.


Day-to-day surface

After aelf setup you should rarely type aelf again. The day-to-day commands are six:

aelf onboard .                      # once per project — scan and ingest
aelf lock "never push to main"      # add a permanent rule
aelf locked                          # see what rules are active
aelf search "push to main"           # check what the agent will see
aelf status                          # quick health summary
aelf setup / aelf doctor            # initial install + verification

Everything else (deeper diagnostics, archive/uninstall, migration tools, hook entry-points called by Claude Code itself) is callable but not something you reach for in normal use. aelf --help shows the everyday surface; aelf --help --advanced lists the rest. Full reference: COMMANDS.

The same operations are also available as MCP tools and /aelf:* slash commands — same library underneath. See MCP and SLASH_COMMANDS.


Status

Latest stable: v1.7 — graph-signal retrieval lane (signed Laplacian, heat-kernel authority, Plate FFT HRR primitives), BM25F anchor-text retrieval default-on.

Next: v2.0 — research-line parity + benchmark reproducibility cut.

Per-version detail: docs/ROADMAP.md. Open issues / known limits: docs/LIMITATIONS.md.


Documentation

Citation

@software{aelfrice2026,
  author = {robotrocketscience},
  title  = {aelfrice: deterministic Bayesian memory for AI coding agents},
  year   = {2026},
  url    = {https://github.com/robotrocketscience/aelfrice},
  license = {MIT}
}

MIT

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

aelfrice-2.0.1.tar.gz (6.7 MB view details)

Uploaded Source

Built Distribution

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

aelfrice-2.0.1-py3-none-any.whl (433.0 kB view details)

Uploaded Python 3

File details

Details for the file aelfrice-2.0.1.tar.gz.

File metadata

  • Download URL: aelfrice-2.0.1.tar.gz
  • Upload date:
  • Size: 6.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for aelfrice-2.0.1.tar.gz
Algorithm Hash digest
SHA256 b2a8a701762294667cdf8a6ad45599d48e63e63e2d81c8d45074b32afc46e44c
MD5 f23dcd3e27fdcbbf914dce2afa3f4e90
BLAKE2b-256 f87005a6eb50e5f8c0e623a83e8a6f128df5bf0435be4430df3a4abd888347de

See more details on using hashes here.

Provenance

The following attestation bundles were made for aelfrice-2.0.1.tar.gz:

Publisher: publish.yml on robotrocketscience/aelfrice

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

File details

Details for the file aelfrice-2.0.1-py3-none-any.whl.

File metadata

  • Download URL: aelfrice-2.0.1-py3-none-any.whl
  • Upload date:
  • Size: 433.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for aelfrice-2.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7f8a431147fddbad04396739f55fe2b97c1cf27c01f60350b983b7d6a4dc0866
MD5 73ad3cfa80c0e69a9b2be514cffb6d64
BLAKE2b-256 5d54c7c80bcaaaca2b38513230ffd6f6d815302ae2e2a8d4b620acf028b618ed

See more details on using hashes here.

Provenance

The following attestation bundles were made for aelfrice-2.0.1-py3-none-any.whl:

Publisher: publish.yml on robotrocketscience/aelfrice

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