membrane-aol 0.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- membrane_aol-0.2.0/.github/ISSUE_TEMPLATE/bug_report.yml +36 -0
- membrane_aol-0.2.0/.github/ISSUE_TEMPLATE/config.yml +5 -0
- membrane_aol-0.2.0/.github/ISSUE_TEMPLATE/feature_request.yml +19 -0
- membrane_aol-0.2.0/.github/pull_request_template.md +10 -0
- membrane_aol-0.2.0/.github/workflows/membrane-ci.yml +59 -0
- membrane_aol-0.2.0/.github/workflows/release.yml +59 -0
- membrane_aol-0.2.0/.gitignore +39 -0
- membrane_aol-0.2.0/.python-version +1 -0
- membrane_aol-0.2.0/AGENTS.md +24 -0
- membrane_aol-0.2.0/CHANGELOG.md +60 -0
- membrane_aol-0.2.0/CLA.md +40 -0
- membrane_aol-0.2.0/CONTRIBUTING.md +45 -0
- membrane_aol-0.2.0/LICENSE +202 -0
- membrane_aol-0.2.0/NOTICE +4 -0
- membrane_aol-0.2.0/PKG-INFO +846 -0
- membrane_aol-0.2.0/README.md +785 -0
- membrane_aol-0.2.0/SECURITY.md +24 -0
- membrane_aol-0.2.0/benchmarks/__init__.py +1 -0
- membrane_aol-0.2.0/benchmarks/cache_savings.py +114 -0
- membrane_aol-0.2.0/benchmarks/scorecard.py +278 -0
- membrane_aol-0.2.0/benchmarks/token_savings_bench.py +23 -0
- membrane_aol-0.2.0/benchmarks/trimming_bench.py +26 -0
- membrane_aol-0.2.0/docs/architecture.md +127 -0
- membrane_aol-0.2.0/docs/interrupt-protocol.md +17 -0
- membrane_aol-0.2.0/docs/prompt-caching.md +21 -0
- membrane_aol-0.2.0/docs/u-shaped-layout.md +41 -0
- membrane_aol-0.2.0/examples/basic_compile.py +17 -0
- membrane_aol-0.2.0/examples/drop1_membrane_profile.py +28 -0
- membrane_aol-0.2.0/examples/drop3_mcp_and_adapters.md +22 -0
- membrane_aol-0.2.0/examples/free_cli_diagnostics.md +32 -0
- membrane_aol-0.2.0/examples/interrupt_retrieval.py +17 -0
- membrane_aol-0.2.0/examples/multi_turn_chatbot.py +21 -0
- membrane_aol-0.2.0/examples/provider_caching.py +16 -0
- membrane_aol-0.2.0/examples/rag_pipeline.py +21 -0
- membrane_aol-0.2.0/pyproject.toml +86 -0
- membrane_aol-0.2.0/pyrightconfig.json +15 -0
- membrane_aol-0.2.0/src/membrane/__init__.py +209 -0
- membrane_aol-0.2.0/src/membrane/adapters/__init__.py +5 -0
- membrane_aol-0.2.0/src/membrane/adapters/crewai.py +51 -0
- membrane_aol-0.2.0/src/membrane/adapters/haystack.py +51 -0
- membrane_aol-0.2.0/src/membrane/adapters/langchain.py +113 -0
- membrane_aol-0.2.0/src/membrane/adapters/llamaindex.py +90 -0
- membrane_aol-0.2.0/src/membrane/adapters/mcp_resources.py +35 -0
- membrane_aol-0.2.0/src/membrane/adapters/mcp_server.py +451 -0
- membrane_aol-0.2.0/src/membrane/async_preflight.py +118 -0
- membrane_aol-0.2.0/src/membrane/cache/__init__.py +5 -0
- membrane_aol-0.2.0/src/membrane/cache/embedding_cache.py +198 -0
- membrane_aol-0.2.0/src/membrane/cache_format.py +104 -0
- membrane_aol-0.2.0/src/membrane/chunking/__init__.py +21 -0
- membrane_aol-0.2.0/src/membrane/chunking/boundaries.py +90 -0
- membrane_aol-0.2.0/src/membrane/chunking/engine.py +54 -0
- membrane_aol-0.2.0/src/membrane/chunking/strategies.py +229 -0
- membrane_aol-0.2.0/src/membrane/classifier/__init__.py +5 -0
- membrane_aol-0.2.0/src/membrane/classifier/classifier.py +124 -0
- membrane_aol-0.2.0/src/membrane/classifier/features.py +51 -0
- membrane_aol-0.2.0/src/membrane/classifier/weights.json +4 -0
- membrane_aol-0.2.0/src/membrane/cli/__init__.py +1 -0
- membrane_aol-0.2.0/src/membrane/cli/__main__.py +6 -0
- membrane_aol-0.2.0/src/membrane/cli/diagnostics.py +121 -0
- membrane_aol-0.2.0/src/membrane/cli/inspect.py +63 -0
- membrane_aol-0.2.0/src/membrane/cli/main.py +112 -0
- membrane_aol-0.2.0/src/membrane/cli/profile_cmd.py +59 -0
- membrane_aol-0.2.0/src/membrane/cli/quote.py +72 -0
- membrane_aol-0.2.0/src/membrane/compile_wiring.py +136 -0
- membrane_aol-0.2.0/src/membrane/compiler.py +1987 -0
- membrane_aol-0.2.0/src/membrane/config.py +166 -0
- membrane_aol-0.2.0/src/membrane/conversation/__init__.py +5 -0
- membrane_aol-0.2.0/src/membrane/conversation/manager.py +119 -0
- membrane_aol-0.2.0/src/membrane/conversation/summarizer.py +50 -0
- membrane_aol-0.2.0/src/membrane/conversation/window.py +18 -0
- membrane_aol-0.2.0/src/membrane/dedup/__init__.py +5 -0
- membrane_aol-0.2.0/src/membrane/dedup/deduplicator.py +172 -0
- membrane_aol-0.2.0/src/membrane/environment.py +100 -0
- membrane_aol-0.2.0/src/membrane/exceptions.py +28 -0
- membrane_aol-0.2.0/src/membrane/firewall.py +241 -0
- membrane_aol-0.2.0/src/membrane/freshness/__init__.py +16 -0
- membrane_aol-0.2.0/src/membrane/freshness/decay.py +37 -0
- membrane_aol-0.2.0/src/membrane/freshness/manager.py +115 -0
- membrane_aol-0.2.0/src/membrane/glaciator.py +90 -0
- membrane_aol-0.2.0/src/membrane/interrupt.py +46 -0
- membrane_aol-0.2.0/src/membrane/layout.py +107 -0
- membrane_aol-0.2.0/src/membrane/llm_adapters.py +55 -0
- membrane_aol-0.2.0/src/membrane/llm_capabilities.json +38 -0
- membrane_aol-0.2.0/src/membrane/lod.py +132 -0
- membrane_aol-0.2.0/src/membrane/memory_protocol.py +267 -0
- membrane_aol-0.2.0/src/membrane/metrics.py +128 -0
- membrane_aol-0.2.0/src/membrane/observability/__init__.py +16 -0
- membrane_aol-0.2.0/src/membrane/observability/callbacks.py +35 -0
- membrane_aol-0.2.0/src/membrane/observability/collectors.py +60 -0
- membrane_aol-0.2.0/src/membrane/observability/events.py +24 -0
- membrane_aol-0.2.0/src/membrane/observability/profiler.py +61 -0
- membrane_aol-0.2.0/src/membrane/pair_baselines.py +181 -0
- membrane_aol-0.2.0/src/membrane/policies/__init__.py +5 -0
- membrane_aol-0.2.0/src/membrane/policies/engine.py +222 -0
- membrane_aol-0.2.0/src/membrane/profile.py +142 -0
- membrane_aol-0.2.0/src/membrane/provider_registry.py +178 -0
- membrane_aol-0.2.0/src/membrane/ranking_diagnostics.py +133 -0
- membrane_aol-0.2.0/src/membrane/ref_map.py +124 -0
- membrane_aol-0.2.0/src/membrane/runtime/__init__.py +10 -0
- membrane_aol-0.2.0/src/membrane/runtime/signals.py +66 -0
- membrane_aol-0.2.0/src/membrane/schemas/__init__.py +3 -0
- membrane_aol-0.2.0/src/membrane/schemas/kernel_memory_object.schema.json +43 -0
- membrane_aol-0.2.0/src/membrane/serializers.py +246 -0
- membrane_aol-0.2.0/src/membrane/stress.py +72 -0
- membrane_aol-0.2.0/src/membrane/templates/__init__.py +5 -0
- membrane_aol-0.2.0/src/membrane/templates/engine.py +186 -0
- membrane_aol-0.2.0/src/membrane/templates/parser.py +209 -0
- membrane_aol-0.2.0/src/membrane/templates/types.py +60 -0
- membrane_aol-0.2.0/src/membrane/tokenizers/__init__.py +18 -0
- membrane_aol-0.2.0/src/membrane/tokenizers/adapters.py +98 -0
- membrane_aol-0.2.0/src/membrane/tokenizers/registry.py +92 -0
- membrane_aol-0.2.0/tests/test_adapters_langchain.py +19 -0
- membrane_aol-0.2.0/tests/test_cli_diagnostics.py +70 -0
- membrane_aol-0.2.0/tests/test_compile_quote.py +85 -0
- membrane_aol-0.2.0/tests/test_context_compiler_readme.py +43 -0
- membrane_aol-0.2.0/tests/test_firewall_budget_exceeded.py +34 -0
- membrane_aol-0.2.0/tests/test_followup_fixes.py +182 -0
- membrane_aol-0.2.0/tests/test_history_trimming.py +104 -0
- membrane_aol-0.2.0/tests/test_interrupt_protocol.py +22 -0
- membrane_aol-0.2.0/tests/test_kernel_memory_object.py +90 -0
- membrane_aol-0.2.0/tests/test_mcp_server.py +38 -0
- membrane_aol-0.2.0/tests/test_module_regressions.py +543 -0
- membrane_aol-0.2.0/tests/test_open_source_edition.py +56 -0
- membrane_aol-0.2.0/tests/test_prompt_cache_stability.py +232 -0
- membrane_aol-0.2.0/tests/test_ranking_diagnostics.py +49 -0
- membrane_aol-0.2.0/tests/test_review_regressions.py +304 -0
- membrane_aol-0.2.0/tests/test_stale_content_warning.py +96 -0
- membrane_aol-0.2.0/tests/test_templates_chunking.py +27 -0
- membrane_aol-0.2.0/uv.lock +5607 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
name: Bug report
|
|
2
|
+
description: Something in Membrane doesn't work as documented.
|
|
3
|
+
labels: [bug]
|
|
4
|
+
body:
|
|
5
|
+
- type: textarea
|
|
6
|
+
id: what
|
|
7
|
+
attributes:
|
|
8
|
+
label: What happened
|
|
9
|
+
description: What you expected, and what happened instead.
|
|
10
|
+
validations:
|
|
11
|
+
required: true
|
|
12
|
+
- type: textarea
|
|
13
|
+
id: repro
|
|
14
|
+
attributes:
|
|
15
|
+
label: Minimal reproduction
|
|
16
|
+
description: The smallest code that shows the problem. Remove secrets and private data.
|
|
17
|
+
render: python
|
|
18
|
+
validations:
|
|
19
|
+
required: true
|
|
20
|
+
- type: input
|
|
21
|
+
id: version
|
|
22
|
+
attributes:
|
|
23
|
+
label: membrane-aol version
|
|
24
|
+
placeholder: "0.2.0"
|
|
25
|
+
validations:
|
|
26
|
+
required: true
|
|
27
|
+
- type: input
|
|
28
|
+
id: env
|
|
29
|
+
attributes:
|
|
30
|
+
label: Python version, OS and model id
|
|
31
|
+
placeholder: "3.12, macOS 15, openai/gpt-4o"
|
|
32
|
+
- type: textarea
|
|
33
|
+
id: logs
|
|
34
|
+
attributes:
|
|
35
|
+
label: Logs or traceback
|
|
36
|
+
render: text
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
name: Feature request
|
|
2
|
+
description: Suggest an improvement or a new integration.
|
|
3
|
+
labels: [enhancement]
|
|
4
|
+
body:
|
|
5
|
+
- type: textarea
|
|
6
|
+
id: problem
|
|
7
|
+
attributes:
|
|
8
|
+
label: Problem
|
|
9
|
+
description: What are you trying to do, and what gets in the way?
|
|
10
|
+
validations:
|
|
11
|
+
required: true
|
|
12
|
+
- type: textarea
|
|
13
|
+
id: proposal
|
|
14
|
+
attributes:
|
|
15
|
+
label: Proposed solution
|
|
16
|
+
- type: textarea
|
|
17
|
+
id: alternatives
|
|
18
|
+
attributes:
|
|
19
|
+
label: Alternatives you considered
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
## What and why
|
|
2
|
+
|
|
3
|
+
<!-- What does this change, and why? Link the issue if there is one. -->
|
|
4
|
+
|
|
5
|
+
## Checklist
|
|
6
|
+
|
|
7
|
+
- [ ] I have read and agree to the [Contributor License Agreement](https://github.com/adeyomilawal/membrane/blob/main/CLA.md).
|
|
8
|
+
- [ ] `uv run ruff check src tests` and `uv run pytest` pass.
|
|
9
|
+
- [ ] Bug fixes include a test that fails without the fix.
|
|
10
|
+
- [ ] User-visible changes are noted in `CHANGELOG.md`.
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# Install, lint, and test the standalone Membrane package on push/PR.
|
|
2
|
+
name: Membrane CI
|
|
3
|
+
|
|
4
|
+
on:
|
|
5
|
+
push:
|
|
6
|
+
branches: [main]
|
|
7
|
+
pull_request:
|
|
8
|
+
workflow_dispatch:
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
test:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
timeout-minutes: 15
|
|
14
|
+
strategy:
|
|
15
|
+
fail-fast: false
|
|
16
|
+
matrix:
|
|
17
|
+
install: [core, dev]
|
|
18
|
+
python-version: ["3.10", "3.11", "3.12"]
|
|
19
|
+
|
|
20
|
+
steps:
|
|
21
|
+
- name: Checkout
|
|
22
|
+
uses: actions/checkout@v4
|
|
23
|
+
|
|
24
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
25
|
+
uses: actions/setup-python@v5
|
|
26
|
+
with:
|
|
27
|
+
python-version: ${{ matrix.python-version }}
|
|
28
|
+
cache: pip
|
|
29
|
+
cache-dependency-path: pyproject.toml
|
|
30
|
+
|
|
31
|
+
- name: Verify uv lock
|
|
32
|
+
uses: astral-sh/setup-uv@v6
|
|
33
|
+
|
|
34
|
+
- run: uv lock --check
|
|
35
|
+
|
|
36
|
+
- name: Install package (no extras — core matrix)
|
|
37
|
+
if: matrix.install == 'core'
|
|
38
|
+
run: |
|
|
39
|
+
python -m pip install --upgrade pip
|
|
40
|
+
python -m pip install -e .
|
|
41
|
+
python -m pip install "pytest>=7.0.0" "pytest-asyncio>=0.21.0"
|
|
42
|
+
|
|
43
|
+
- name: Install package and dev dependencies
|
|
44
|
+
if: matrix.install == 'dev'
|
|
45
|
+
run: |
|
|
46
|
+
python -m pip install --upgrade pip
|
|
47
|
+
python -m pip install -e ".[dev]"
|
|
48
|
+
|
|
49
|
+
- name: Ruff check
|
|
50
|
+
if: matrix.install == 'dev'
|
|
51
|
+
run: python -m ruff check src tests
|
|
52
|
+
|
|
53
|
+
- name: Pytest (minimal deps — excludes requires_extras)
|
|
54
|
+
if: matrix.install == 'core'
|
|
55
|
+
run: python -m pytest -m "not requires_extras"
|
|
56
|
+
|
|
57
|
+
- name: Pytest (full)
|
|
58
|
+
if: matrix.install == 'dev'
|
|
59
|
+
run: python -m pytest
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# Publish membrane-aol to PyPI when a version tag (v0.2.0, ...) is pushed.
|
|
2
|
+
# Uses PyPI trusted publishing: no API token is stored in GitHub. One-time setup on
|
|
3
|
+
# pypi.org: add a "pending publisher" for project membrane-aol, owner adeyomilawal,
|
|
4
|
+
# repository membrane, workflow release.yml, environment pypi.
|
|
5
|
+
name: Release
|
|
6
|
+
|
|
7
|
+
on:
|
|
8
|
+
push:
|
|
9
|
+
tags: ["v*"]
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
build:
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
timeout-minutes: 15
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v4
|
|
17
|
+
|
|
18
|
+
- uses: astral-sh/setup-uv@v6
|
|
19
|
+
with:
|
|
20
|
+
python-version: "3.12"
|
|
21
|
+
|
|
22
|
+
- name: Check the tag matches the package version
|
|
23
|
+
run: |
|
|
24
|
+
version=$(uv run --no-project python -c "import tomllib; print(tomllib.load(open('pyproject.toml','rb'))['project']['version'])")
|
|
25
|
+
if [ "v${version}" != "${GITHUB_REF_NAME}" ]; then
|
|
26
|
+
echo "Tag ${GITHUB_REF_NAME} does not match pyproject version ${version}" >&2
|
|
27
|
+
exit 1
|
|
28
|
+
fi
|
|
29
|
+
|
|
30
|
+
- name: Lint and test
|
|
31
|
+
run: |
|
|
32
|
+
uv lock --check
|
|
33
|
+
uv sync --locked --extra dev
|
|
34
|
+
uv run ruff check src tests
|
|
35
|
+
uv run pytest
|
|
36
|
+
|
|
37
|
+
- name: Build
|
|
38
|
+
run: uv build
|
|
39
|
+
|
|
40
|
+
- uses: actions/upload-artifact@v4
|
|
41
|
+
with:
|
|
42
|
+
name: dist
|
|
43
|
+
path: dist/
|
|
44
|
+
|
|
45
|
+
publish:
|
|
46
|
+
needs: build
|
|
47
|
+
runs-on: ubuntu-latest
|
|
48
|
+
environment:
|
|
49
|
+
name: pypi
|
|
50
|
+
url: https://pypi.org/project/membrane-aol/
|
|
51
|
+
permissions:
|
|
52
|
+
id-token: write # required for trusted publishing
|
|
53
|
+
steps:
|
|
54
|
+
- uses: actions/download-artifact@v4
|
|
55
|
+
with:
|
|
56
|
+
name: dist
|
|
57
|
+
path: dist/
|
|
58
|
+
|
|
59
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
.DS_Store
|
|
3
|
+
__pycache__/
|
|
4
|
+
*.py[cod]
|
|
5
|
+
*$py.class
|
|
6
|
+
*.so
|
|
7
|
+
.Python
|
|
8
|
+
*.egg
|
|
9
|
+
*.egg-info/
|
|
10
|
+
.eggs/
|
|
11
|
+
dist/
|
|
12
|
+
build/
|
|
13
|
+
sdist/
|
|
14
|
+
wheels/
|
|
15
|
+
pip-wheel-metadata/
|
|
16
|
+
|
|
17
|
+
# Virtual environments
|
|
18
|
+
.venv/
|
|
19
|
+
.venv-hatch/
|
|
20
|
+
.venv-test/
|
|
21
|
+
.venv-smoke/
|
|
22
|
+
.venv-wheel/
|
|
23
|
+
venv/
|
|
24
|
+
ENV/
|
|
25
|
+
|
|
26
|
+
# Testing / coverage
|
|
27
|
+
.pytest_cache/
|
|
28
|
+
.coverage
|
|
29
|
+
htmlcov/
|
|
30
|
+
.mypy_cache/
|
|
31
|
+
.ruff_cache/
|
|
32
|
+
|
|
33
|
+
# Local env / secrets
|
|
34
|
+
.env
|
|
35
|
+
.env.*
|
|
36
|
+
|
|
37
|
+
# Planning & roadmap (local / internal; not shipped with the wheel)
|
|
38
|
+
BUILD_PLAN.md
|
|
39
|
+
future.md
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.12
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# AGENTS.md — Membrane
|
|
2
|
+
|
|
3
|
+
## Scope
|
|
4
|
+
|
|
5
|
+
This repository owns the open-source `membrane` Python distribution (Apache-2.0),
|
|
6
|
+
its tests, benchmarks, examples, and documentation.
|
|
7
|
+
|
|
8
|
+
## Boundaries
|
|
9
|
+
|
|
10
|
+
- Membrane must remain independently installable with no network calls by default.
|
|
11
|
+
- Keep prompt content out of any metrics; only documented aggregate metrics may
|
|
12
|
+
leave the host application, and only through a callback the user configures.
|
|
13
|
+
- Never commit tokens, credentials, virtual environments, build artifacts, or
|
|
14
|
+
downloaded models.
|
|
15
|
+
|
|
16
|
+
## Verification
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
uv lock --check
|
|
20
|
+
uv sync --locked --extra dev
|
|
21
|
+
uv run ruff check src tests
|
|
22
|
+
uv run pytest
|
|
23
|
+
uv build
|
|
24
|
+
```
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are documented here. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
|
4
|
+
|
|
5
|
+
## [0.2.0] — Unreleased
|
|
6
|
+
|
|
7
|
+
First open-source release, published on PyPI as **`membrane-aol`** (imports as `membrane`).
|
|
8
|
+
|
|
9
|
+
- **Default `memory_placement` is now `"end"`**, so system message and history stay cacheable across turns. Pass `memory_placement="system"` for the previous layout (better for local models and one-off calls).
|
|
10
|
+
- End placement trims the oldest history in large, stable chunks when it would crowd out the budget, leaving room for memories (`trim_history=True`, `metadata["history_messages_dropped"]`). Directives are now reserved inside the budget in end placement too.
|
|
11
|
+
|
|
12
|
+
- Relicense under **Apache-2.0** (previously PolyForm Noncommercial).
|
|
13
|
+
- Remove license activation, tier gates, portal analytics, and the CLI `login`, `logout`, `whoami`, `status`, `refresh`, and `token` commands. Every feature is available without activation.
|
|
14
|
+
- Drop the `PyJWT`, `httpx`, and `keyring` runtime dependencies.
|
|
15
|
+
- Remove `CompileMetrics.tier`.
|
|
16
|
+
- Remove from the open-source edition: JTA and other compression strategies, lineage, assertions, replay, diff/version store, export, batch, reranker, visualizer, testing utilities, Langfuse/LangSmith exporters, and the interrupt runner. The `research`, `full`, and `enterprise` profiles are removed with them.
|
|
17
|
+
- Add `FeatureNotAvailable`, raised by `CompileResult.diff()` and `enable_lineage=True` without a `lineage_tracker`.
|
|
18
|
+
- Add `memory_placement="end"` for prompt-cache-stable compiles.
|
|
19
|
+
|
|
20
|
+
### Fixed (code review)
|
|
21
|
+
|
|
22
|
+
- Token budget: the firewall now checks the assembled text, and dynamic directives are reserved inside the budget, so `token_count <= max_tokens` unless `metadata["budget_exceeded"]` is set. That flag is now set in every mode, including `compile_anonymous`. Tight budgets may trim one more memory than before.
|
|
23
|
+
- Prompt-cache metadata reports the real byte-stable prefix (the core in system mode; system plus history in end mode) and `cacheable_prefix_chars`. `prompt_cache_used` is only set when that prefix reaches 1024 tokens, the provider minimum.
|
|
24
|
+
- Unknown or dated model ids (`openai/gpt-4o-2024-08-06`, `gpt-4o`, `claude-sonnet-4-5-20250929`) resolve to their registry entry. Models not in the registry no longer cap `max_tokens` at 8192; a warning is logged once. New `lookup_context_cap()`.
|
|
25
|
+
- `compile_prompt_async(user_id=None)` no longer drops directives, `memory_placement`, retrieved objects, compression or plug-ins.
|
|
26
|
+
- `[Mem:N]` mentioned inside a kept memory no longer pulls a dropped memory into `ref_map`; compressed middles keep the refs they still contain.
|
|
27
|
+
- Redis ref maps are keyed by user and conversation (`user_id=` on `set_/get_ref_map_for_conversation`).
|
|
28
|
+
- Procedural memories without structured steps (e.g. `KernelMemoryObject` tier 1) keep their text.
|
|
29
|
+
- Reranked memories keep caller tier overrides; `middle_extras` keep their order and rank ahead of reranked memories.
|
|
30
|
+
- The classifier step returns copies instead of mutating caller objects, and retiers `KernelMemoryObject`s.
|
|
31
|
+
- Lineage `included_ids` lists only memories that survived trimming.
|
|
32
|
+
- Async compile falls back to `compress_sync` when `compress_async` fails; `compress_sync` errors are logged instead of raised.
|
|
33
|
+
- End placement omits the system message when the core is empty.
|
|
34
|
+
- The capability registry returns copies and publishes reloaded maps atomically.
|
|
35
|
+
|
|
36
|
+
- Removed-profile references: the MCP server defaulted to the removed `research` profile and crashed; MCP and the CLI now use `MembraneProfile.preset()` and offer `minimal`, `coding` and `conversational` (MCP default `coding`).
|
|
37
|
+
- Templates: `for` loop variables and `if` conditions are no longer required arguments; each role block is its own message.
|
|
38
|
+
- Adapters: LlamaIndex no longer turns a low score into the highest-priority tier and returns `NodeWithScore` from a real `BaseNodePostprocessor`; LangChain `format(compiled_context=...)` and non-numeric priorities no longer raise.
|
|
39
|
+
- Conversation manager: hybrid and summarize strategies no longer drop turns, keep earlier summaries, and summarize once per trigger instead of every turn.
|
|
40
|
+
- Policies: condition keys are ANDed; unknown or malformed conditions raise instead of matching everything.
|
|
41
|
+
- Tokenizers: user registrations take precedence; `gpt-4`/`gpt-4-turbo` use `cl100k_base`; a failed bootstrap is not cached.
|
|
42
|
+
- Freshness: relevance 0.0 stays 0.0 and decay is idempotent across compiles.
|
|
43
|
+
- Chunking: recursive chunking keeps text before the first heading with document offsets; fixed chunking no longer mixes tokens and characters; oversized sentences and paragraphs are split.
|
|
44
|
+
- Embedding cache: the batch path uses Redis, keys can be namespaced by `model_id`, embedding runs outside the lock, and duplicates in a batch are embedded once.
|
|
45
|
+
- Classifier features: code detection no longer fires on prose; `user:`/`assistant:` turns are detected.
|
|
46
|
+
- Dedup: no transitive merging; the embedding model is cached; hash fallback is logged.
|
|
47
|
+
- MCP server: documented as single-client; warns when SSE binds to a non-loopback host; per-call profiles override the default.
|
|
48
|
+
- Signal bus and metrics collector: handler errors are logged, and sync handlers work.
|
|
49
|
+
|
|
50
|
+
- The firewall counts with the profile's tokenizer registry when one is set, so the budget matches `token_count`. `PreFlightContextFirewall(count_fn=...)` accepts any counter.
|
|
51
|
+
- Memory text limits are configurable: `MEMBRANE_MEMORY_TEXT_MAX_CHARS` overrides the built-in 200/280/500-character limits, and `0` disables truncation. `metadata["memories_truncated"]` reports how many memories were shortened.
|
|
52
|
+
- Policy actions now take effect: `set_budget` gives each memory kind a first-pass share of the middle (unused space goes to the others), `pin_memory_kind` keeps that kind first, `enable` reverses an earlier `disable`, and `set_max_tokens` / `override: {max_tokens}` set the budget, bounded by the model's context cap. **Breaking:** a policy without a `condition` now raises `ValueError` (write `condition: always`), and unknown action keys or memory kinds raise.
|
|
53
|
+
|
|
54
|
+
## [0.1.1] — 2026-04-11
|
|
55
|
+
|
|
56
|
+
- Add an in-package `tests/` tree (README-style compile, firewall budget edge, interrupt helpers) and document running `pytest` from the package directory.
|
|
57
|
+
- Add GitHub Actions workflow: editable install, **Ruff** on `src`/`tests`, **pytest** on push/PR for `membrane/**`.
|
|
58
|
+
- Patch release after test and packaging verification.
|
|
59
|
+
|
|
60
|
+
[0.1.1]: https://github.com/adeyomilawal/membrane/compare/v0.1.0...v0.1.1
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# Individual Contributor License Agreement
|
|
2
|
+
|
|
3
|
+
This agreement is between you ("Contributor") and Adeyomi Lawal ("Maintainer"), the
|
|
4
|
+
copyright holder of Membrane ("the Project"). It covers every contribution you submit to
|
|
5
|
+
the Project. You agree to it by ticking the CLA box in a pull request.
|
|
6
|
+
|
|
7
|
+
1. **Contribution.** "Contribution" means any original work of authorship, including
|
|
8
|
+
changes to existing work, that you intentionally submit to the Project in any form
|
|
9
|
+
(pull request, patch, issue attachment or similar).
|
|
10
|
+
|
|
11
|
+
2. **You keep your copyright.** You retain all rights, title and interest in your
|
|
12
|
+
Contributions, except for the licenses granted below.
|
|
13
|
+
|
|
14
|
+
3. **Copyright license.** You grant the Maintainer, and recipients of software the
|
|
15
|
+
Maintainer distributes, a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
|
|
16
|
+
irrevocable license to reproduce, prepare derivative works of, publicly display, publicly
|
|
17
|
+
perform, sublicense and distribute your Contributions and derivative works. This
|
|
18
|
+
includes the right to distribute them under licenses other than the Project's current
|
|
19
|
+
license, including commercial licenses.
|
|
20
|
+
|
|
21
|
+
4. **Patent license.** You grant the Maintainer, and recipients of software the Maintainer
|
|
22
|
+
distributes, a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
23
|
+
patent license to make, have made, use, offer to sell, sell, import and otherwise
|
|
24
|
+
transfer your Contributions, for patent claims you can license that are necessarily
|
|
25
|
+
infringed by your Contributions alone or combined with the Project.
|
|
26
|
+
|
|
27
|
+
5. **Your promises.** You confirm that:
|
|
28
|
+
- each Contribution is your original work, or you have the right to submit it under
|
|
29
|
+
this agreement, and you identify any third-party material and its license;
|
|
30
|
+
- if your employer has rights to work you create, you have permission to make the
|
|
31
|
+
Contribution on its behalf, or your employer has waived those rights.
|
|
32
|
+
|
|
33
|
+
6. **No other obligations.** You are not expected to provide support. Contributions are
|
|
34
|
+
provided "as is", without warranties of any kind, except as stated in section 5.
|
|
35
|
+
|
|
36
|
+
7. **No obligation to use.** The Maintainer is not required to use or include any
|
|
37
|
+
Contribution.
|
|
38
|
+
|
|
39
|
+
8. **Changes.** You will notify the Maintainer if any of the promises in section 5 stop
|
|
40
|
+
being true.
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# Contributing to Membrane
|
|
2
|
+
|
|
3
|
+
Thanks for helping. Bug reports, fixes, docs and new adapters are all welcome.
|
|
4
|
+
|
|
5
|
+
## Before you start
|
|
6
|
+
|
|
7
|
+
- For anything bigger than a small fix, open an issue first so we can agree on the approach.
|
|
8
|
+
- Security problems: don't open a public issue. See [SECURITY.md](SECURITY.md).
|
|
9
|
+
|
|
10
|
+
## Contributor License Agreement
|
|
11
|
+
|
|
12
|
+
Every contribution needs a signed [Contributor License Agreement](CLA.md). You keep the
|
|
13
|
+
copyright in your work; the CLA lets the project use and relicense it. Agree to it by
|
|
14
|
+
ticking the CLA box in the pull request template. A pull request without that box ticked
|
|
15
|
+
won't be merged.
|
|
16
|
+
|
|
17
|
+
## Development setup
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
git clone https://github.com/adeyomilawal/membrane.git
|
|
21
|
+
cd membrane
|
|
22
|
+
uv sync --locked --extra dev
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
The package is published as `membrane-aol` and imports as `membrane`.
|
|
26
|
+
|
|
27
|
+
## Before you open a pull request
|
|
28
|
+
|
|
29
|
+
Run the same checks CI runs:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
uv lock --check
|
|
33
|
+
uv run ruff check src tests
|
|
34
|
+
uv run pytest
|
|
35
|
+
uv build
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
- Add a test for every bug fix (it should fail before your change) and for new behavior.
|
|
39
|
+
- Match the surrounding code: naming, comment density and style. Lines are capped at 100.
|
|
40
|
+
- Membrane must make no network calls by default and must keep prompt text out of metrics.
|
|
41
|
+
- Add a line to [CHANGELOG.md](CHANGELOG.md) under the unreleased version for user-visible changes.
|
|
42
|
+
|
|
43
|
+
## Commit messages
|
|
44
|
+
|
|
45
|
+
Short imperative summary (under 72 characters), a blank line, then what changed and why.
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|