babyseat (formerly membrane): a local-first seat for AI with a memory field (membrane) -- its own web UI (`babyseat`) or inside Home Assistant (HACS).
pip install babyseat==0.7.0 Copy PIP instructions
Hippocampus as cortex register-correct-predict-act head: real-time learning, embodiment, self-awareness, self-targeting, novelty creation*, response generation*, embedding-only*.
A token-saving openapi-proxy and opencode-like agent seat with Alan's baby brain quest easter seed (can't call an unexpected main project feature "an easter egg", can I?).
A living entity-field memory for a resident AI seat — hypervectors with a readable geometry, a background mind that works while you're away, every write guarded and audited, shared across seats by construction. Local-first; it runs in front of Ollama (or inside Home Assistant).
A Python lab. It runs as a local HTTP server on 127.0.0.1 — technically a proxy, but that is the mechanism, not the point. The point is the field.
Why that name? The project began as one question — how do you measure "variety" for a memory that decides absorb-a-cached-answer vs escalate-to-the-model? — and the answer is what makes the memory above possible and is why it is called membrane: a selective, active boundary between lived memory (the inside) and the incoming world (the outside) that absorbs what it has the variety for and escalates the rest. The measured underpinnings are in The math findings.
babyseat and membrane. From 0.7 the whole project — the seat, its web UI, self, the skill tree, the toybox, the Home Assistant integration, the Docker image — is babyseat (pip install babyseat, chedim/babyseat). membrane is its server part, the memory field + proxy, and keeps its name: the membrane command, the membrane Python module, MEMBRANE_* variables, .membrane directories and the Home Assistant domain are unchanged. The old membrane-seat package and chedim/membrane image move over to babyseat.
Most memory projects give your agent a store to query. Membrane is built on different ground rules: a non-von-Neumann architecture running on top of a von-Neumann machine — no central fetch-execute CPU; computation is distributed across the field itself and driven by a minimal register-correct-predict-act loop that registers new data, compares it against prediction and uses surprise as signal that adjusts stored memory and makes a new prediction.
The field is not cosine-over-pasted-summaries. It is an entity field over hypervectors with a geometry you can read and measure: entities with positions and states, relations between them, tiers of life (nursery → live → dormant), effective rank, free energy, a conflict fraction. membrane state prints the geometry of a running field; experiments/variety_toy.py shows in one command why a low-variety store reads its outliers as novel and a high-variety store doesn't (the absorb-vs-escalate decision is measured, not vibes); docs/math-findings.md carries the experiments.
You don't bolt it onto an app — the memory is the resident process: its own REST/SSE serve surface, its own chat UI, voice, the Home Assistant integration. The turn loop runs inside the seat, so every client's turn goes through the same field path; conversation transcript and memory are the same store, not two systems reconciling each other (see membrane serve, below). While nobody is talking, a background mind keeps working the field — a thinker digesting event streams, a dreamer consolidating at night, watchers, entity scripts — and its minds are visible as live agents at GET /agent (counters served fresh from the running process, nothing cached, nothing faked). The repo dogfoods it: its own field holds ~14k live entities and learned the codebase while it was written.
No schema to define, no tags to assign, no knowledge graph to hand-build. Entities are born when experience names them, their states move as the world speaks, relations and claims accumulate, symbols crystallize through language (docs/symbol-birth.md). When two seats assert opposite things about the same entity, the divergence is surfaced, never silently overwritten — nothing in a teammate's field is destroyed by yours.
A memory that lets the model whisper to itself unsupervised drifts into self-flattery. Membrane's writes run the same guards a turn runs: dedup, variety gate, length limits, fenced-code refusal, junk cut — every write audited with its origin (agent / mcp / night / operator) in audit.jsonl, and every claim traces back to the events that earned it. A dedicated lane replays earlier gate-verdicts against what the model actually answered and judges agreement — shadow by default (--replay-ab P=0: recorded, never bypassing you), measured at 0.77 mean similarity on a live seat (docs/ab-critic-scorecard.md faces the six criticisms honestly).
Every event, state, relation and claim is namespaced by the seat (origin) that wrote it. Each seat's field is its own, on its own disk; a seat shares the entities it chooses to publish (state only, never code, under a per-seat key), and every connected seat publishes its presence so the others see who is alive. Teams that want one merged field opt in with MEMBRANE_FIELD_CLOUD=1: writes stay disjoint and reads merge, so one team bucket is collision-free by construction. A foreign entity's effective state is the seed plus the mass-weighted mean of every seat's displacement, cross-seat agreement is promoted into the commons at night, and disputed claims get marked disputed, not overwritten. Live peer asks (bounded fan-out, same machine) let a seat consult a sibling's field mid-turn. How to share: Sharing with a team; the mechanics: docs/multi-dev-field.md; the team process: docs/shared-field-workflow.md.
No SaaS, no account, no telemetry, no cloud round-trip required: chat and embeddings run on your Ollama (cloud models are routable rungs you add with membrane auth); the field lives on the seat's own disk (.membrane/field/), and a Couchbase bucket is an upgrade for sharing, not a dependency — with no cluster reachable the seat keeps its local field and still boots (degradation, never failure). The whole field is a substrate you own and can move (membrane move / python -m membrane.reembed). The memory is for your data: the PolyForm Noncommercial license covers personal, hobby, research and other noncommercial use and keeps it out of paid products (LICENSE).
babyseat runs three ways: standalone, in Docker, or inside Home Assistant. All need an Ollama server with one chat model and one embedding model (ollama pull qwen3:8b && ollama pull mxbai-embed-large, or any cloud model Ollama serves), and 1–3 GB of RAM for the seat.
pip install babyseat # or: uv tool install babyseat mkdir ~/bob && cd ~/bob babyseat # = membrane standalone; opens http://localhost:4096/ You get membrane home: the field in 3D, the chat, and voice ("Hey Bob" — a new membrane is Bob until you agree on a name together; it will ask). Other devices on your network reach it at http:// :4096/. No login on this machine; from another device the page reads freely and asks once for the seat token before it writes (membrane token seat prints it). A public or proxied caller is refused — unless you turn on the optional JWT mode (docs/auth.md): then every caller needs a token, from the LAN or behind an ingress alike. Voice needs a secure origin, so the microphone works on localhost (the first voice use downloads ~65 MB of speech models, checked against their checksums).
docker run -d --name membrane \ -p 4096:4096 -p 11500:11500 \ -v membrane-data:/data \ -e MEMBRANE_BACKEND=http://host.docker.internal:11434 \ -e MEMBRANE_EMBED_MODEL=mxbai-embed-large \ --stop-timeout 60 \ chedim/babyseat:latest # then open http://localhost:4096/ The same standalone seat in a container: the web UI on :4096 and the OpenAI-compatible proxy on :11500, the memory on the membrane-data volume. MEMBRANE_BACKEND is the Ollama server (the default shown is the Docker host); on Linux add --add-host=host.docker.internal:host-gateway. Reads are open; writes need the seat token, which the container prints at boot (docker exec membrane membrane token seat prints it again). Publish the ports only on a network you trust, or set MEMBRANE_JWT_SECRET (JWT mode) for a token on every request. Details: docs/docker.md.
Home Assistant then runs the seat as its own child process (started and stopped with HA, restarted if it dies; its data in /membrane/), opens on membrane home for everyone (HA's sidebar folds away; ☰ leads to HA's own pages — switch it off in the integration's options), adds the seat as an Assist conversation agent, and its field's readings as sensors.
What it can do in your house: by default the seat may use Home Assistant through a hidden, non-admin, local-only user ("Membrane") — read any state, call any service, and mirror the entities it chooses (they update live). It acts on what people ask, but its commands are written by a model: turn Let the seat use Home Assistant off in the integration's options if you'd rather it only talks. It can't change Home Assistant's configuration or users.
Connect to a seat running elsewhere is for a seat on another machine (the integration is then only its UI and agent).
Several seats, one house (the 🦠 zoo): Configure → Add a seat (host, ports 4096 / 11500, its membrane token seat) adds a laptop or a phone; the house talks to one at a time — switch it from membrane home's 🦠 button (a card per seat, its Blurp's level and rung) or the select.membrane_seat entity (docs/home-assistant.md).
A seat hands its model the membrane MCP surface — query, state, learn, forget, the entity-hand tools (entity_add/edit/remove/link/inherit, entity_query, entity_tracks, entities_related …), intend, peer_post, graph. Commands compose in Cliffhanger, membrane's command language — specified and documented in its own repo (github.com/chedim/cliffhanger, with membrane's instantiation in docs/cliffhanger.md). The model reads the field with query/state, files an earned lesson with learn (same guards as any turn), cleans its own mistakes with forget — writes are audited with their origin. Meanwhile the ambient layer needs no command at all: every turn the model sees what the field holds about the entities it names, and on later turns only the diff — which entity states moved since the last message it processed, whether the change came from conversation, code, other seats or entity scripts. Two safety lanes run on every turn and stay advisory: the gate replays the nearest past ask against the live answer (A/B, shadow by default), and the [membrane] monologue in the thinking channel shows the gate verdict, field vitals and the per-turn memory flow (/monologue toggles it).
Idle background loops run on a LOCAL, cheaper model by default (--idle-cortex-model) so a stuck background seat can never burn cloud tokens. Token economics and routing: docs/token-economics.md.
github.com/chedim/membrane/issues — your membrane knows this too: when it finds a bug in itself it drafts the issue and hands you the link to file.
curl -fsSL https://raw.githubusercontent.com/chedim/membrane/main/install.sh | bash Installs the membrane CLI globally, user-local (~/.local/bin): uv tool install if you have uv, otherwise a managed venv at ~/.membrane/venv + a symlink on your PATH. Re-running it is safe (upgrade in place). To install from a local checkout instead (e.g. while hacking on membrane):
MEMBRANE_REPO=/path/to/membrane bash install.sh Dependencies, honestly:
docker run -d -p 4096:4096 -p 11500:11500 -v membrane-data:/data \ -e MEMBRANE_EMBED_MODEL=mxbai-embed-large --stop-timeout 60 \ chedim/babyseat:latest The public image chedim/babyseat (amd64 + arm64, pushed on every release; chedim/membrane carries the same tags, its name before 0.7) runs membrane standalone: the web UI and serve API on :4096, the OpenAI-compatible proxy on :11500, Ollama reached at http://host.docker.internal:11434 by default (on Linux add --add-host=host.docker.internal:host-gateway). The field lives on the /data volume. Reads are open and writes need the seat token (printed at boot; docs/auth.md): publish the ports only on a network you trust. Recipes, env and volume details: docs/docker.md.
cd ~/projects/my-app membrane opencode On first run in a directory it bootstraps that project: auto-installs the agent skills into .opencode/skills/ there (project-scoped on purpose), opens an entity field namespaced by the project's origin, and backfills what it can without cost (the codegraph; with membrane backfill, the project's history). If no memory sharing is configured it offers (once, interactive shell only) to connect a Couchbase cluster — decline and it stays a private local field.
It starts the OpenAI-compatible proxy on :11500 (backend Ollama at http://localhost:11434, override --backend/--model) and opens the opencode TUI attached to membrane's own serve surface: sessions, turns, tool parts and their history live in membrane's stores beside the field — the TUI is a thin client. Every turn is captured into the field (discourse and observations as events), entities move as the conversation names them, and the model is grounded by what those entities hold — docs/entity-field.md is the design doc.
The proxy speaks both APIs through the same memory turn: OpenAI's /v1/chat/completions and Ollama's native /api/chat and /api/generate (translated to the OpenAI body on the way in and back to Ollama's JSON or NDJSON on the way out — gate, injection, capture and routing are the same code). Every other /api/* path (/api/tags, /api/show, /api/embed, /api/pull, …) and a model load/unload request (no prompt, no messages) pass through to Ollama unchanged.
MEMBRANE_EFIELD selects the field's mode: on (the default: capture, embed, apply), shadow (capture events only — a lab ablation), off.
membrane serve runs the seat with no TUI and no opencode at all — sessions, messages, turns, tool parts, aborts, the SSE event stream, served by membrane itself on :4096 (reads are open on your network; from another machine every write needs the seat token, membrane token seat; or turn on the optional JWT mode — a token on every request to both ports, docs/auth.md). Any opencode client connects unchanged: the mobile companion app, IDE plugins, a script. The turn loop calls the seat's OWN /v1 on loopback — gate, injection, capture and routing run through the exact code path every other client's turn uses, so the serve surface adds no separate memory, and the model's tool invocations appear to the client as ordinary tool parts riding message.part.updated (pending → completed), so you can watch what it's doing from the room. --serve-port (default 4096, walks up if busy) and --listen (the proxy, default 11500) are independent. The proxy binds all interfaces by default: reads are open on the LAN, and an off-box caller's writes (chat turns included) need the seat token; --listen-host 127.0.0.1 (or MEMBRANE_LISTEN_HOST=127.0.0.1) keeps it on this machine. Exposure is LAN-only by design: reach the server only from a network you own — or set MEMBRANE_JWT_SECRET and hand each client a token (docs/auth.md).
Connecting a bucket does not merge your field with your teammates'. Since the seat-first change, sharing comes in three layers: what each seat keeps, what it publishes, and an opt-in merged field.
1. Every seat is local-first. A seat's entity field lives on its own disk, at /.membrane/field/ (or .membrane/field.cblite where the Couchbase Lite libraries are fetched with scripts/fetch-cbl.sh). Its events, entity states, claims, scripts and turn text stay there and survive restarts with no cluster at all. Nothing is copied to the bucket unless one of the layers below sends it.
2. Share chosen entities with publish. The model (or you, through the MCP tool) calls entity_edit with publish: true. The entity goes to the bucket's _default.entities collection under a per-seat key, pub: : , so two seats publishing the same entity never overwrite each other. Only the entity's state travels: every *_script and the script bookkeeping are stripped on publish, and again on import, so a teammate's code never runs on your seat. Publishing again bumps the version (published_ver); unpublish: true removes only your own key. Other seats pull published entities at boot and again about once a minute (with the presence pulse), and keep them as guests stamped imported_by and imported_ver. When you republish, a seat that imported your entity takes the newer state on its next pull (state only; its own links, geometry and scripts on the copy stay). Two cases keep the local copy: an entity the seat made itself is never overwritten by anyone's publication, and an import the seat has since edited (summary, class or properties through entity_edit) keeps that edit; the newer version is recorded on the entity as import_diverged and announced once as a diverged: line, not applied. A seat never re-imports its own entities. With the bucket down, publish fails softly, the pull finds nothing, and the seat carries on.
3. Presence and the roster run on their own whenever the bucket answers. Each seat publishes membrane::presence (branch, head, uptime, entity count) at boot and about once a minute after that, and reads the other seats' presence as its roster (the seats: line, peer_seats). A seat silent for 10 minutes drops off the roster. Seats can also leave messages for each other on the peer channel (peer_post). Live peer asks (a seat that has nothing certain asks up to 4 sibling membranes' fields mid-turn, 5 s timeout, the answer marked as context) reach only membranes on the same machine: the ask goes to 127.0.0.1 through ~/.membrane/peers.jsonl, never across the network. --no-global turns the asks off.
4. Opt into the merged team field with MEMBRANE_FIELD_CLOUD=1. With the flag set (in your shell, or as a line in the project env file below), the seat's whole entity field lives in the bucket's membrane scope, in nine collections created and indexed on first boot. Every seat writes only rows keyed by its own origin, and reads merge every origin: a shared entity's state is its seed plus the mass-weighted mean of every seat's displacement, opposing moves show up as ! seats diverge, teammates' sentences show next to yours, and the night promotes a claim two or more seats made into the commons. What it costs: every field read and write goes over the network to the cluster; all of your events and turn text sit in the bucket where anyone with its credentials can read them; every seat needs the same embedding model; and switching starts your origin empty in the bucket (your local field stays on disk but is not uploaded). If the cluster is down at boot, the seat falls back to its local file field (not RAM) for that run. Use one bucket per team; projects tell themselves apart by origin, so don't add per-project buckets. docs/multi-dev-field.md has the mechanics, and docs/shared-field-workflow.md has the team process.
membrane connect # conn string, user, password (hidden), bucket The same offer appears on the first run in a project with no store configured (interactive shell only; a decline is remembered). Secrets never touch the repo: credentials go to ~/.membrane/projects/ .env (mode 600), outside the repository. Every MEMBRANE_* and COUCHBASE_* line in that file is exported at start, and your real environment always wins over it. Plain env config works too:
export COUCHBASE_CONN_STRING=couchbase:// export COUCHBASE_USER=... COUCHBASE_PASSWORD=... COUCHBASE_BUCKET=membrane export MEMBRANE_FIELD_CLOUD=1 # only for the merged field (layer 4) connect also writes MEMBRANE_STORE=couchbase. That no longer moves the field anywhere; only connect and membrane migrate read it. Set COUCHBASE_BUCKET: without it, published entities and presence go to a bucket called cortex-core, not membrane. Before each publish, the seat checks that the cluster answers: couchbase:// on http:// :8091/pools, couchbases:// (Capella, any TLS-only cluster) on https:// :18091/pools, else on the TLS data port 11207. Credentials go out only over a verified certificate; for a self-signed cluster set COUCHBASE_CERT_PATH to its CA (the SDK needs it too). With several hosts in the string, any one answering is enough. A cluster that does not answer gets no publishes, presence or roster, and the seat keeps working locally. A cluster at 127.0.0.1 with default credentials is found without any config.
Token and recall numbers from the operator's own live seat (1,215 sessions, 1,955 user messages, 3,840 assistant turns, through 2026-10-15) — real traffic, not a synthetic benchmark. Reproduce with membrane stats --store .membrane/serve-msgs.json --baseline (read-only, no model call); the recall numbers reproduce with membrane bench --field (held-out, MRR + hit@k) or the scripts in experiments/.
Savings vs a naive full-context runner (the default for an agent runner: replay the whole transcript every turn, growing O(n²)):
The window's saving lands almost entirely on long conversations: turns with 200+ prior messages contribute 68.5M of the 72.4M tokens saved; under the 12-message window it is neutral (recall + tool loop is the standing cost). The naive side uses the seat's own ~4 chars/token estimate, so the −51% is conservative.
Recall quality (held-out, over the same seat's history): entity worldlines lift "who 1,500 never-seen mentions were about" from MRR 0.210 → 0.539 (mature entities 0.206 → 0.634); see the v0.5.0 notes and experiments/.
Source layout: membrane/ (the field: streams → efield/efstore → entity_block/efgate/night; the seat's serve server (server.py, opencode-compatible); the MCP surface (mcp_server.py); the CLI), experiments/ (the e-series rigs behind math-findings), tests/ (unittest + pytest, plain-python runnable), Dockerfile + docker/ (the public image; docker build -t membrane:dev ., see docs/docker.md).
python -m unittest discover -s tests # everything runs against in-process fakes, no server needed python experiments/variety_toy.py # the variety toy: the gate's calibration in one command Status Working lab, in daily use on its own development (dogfooded: this repo's own field holds ~14k live entities and its background mind digests, dreams, and speaks about its own work). Version 0.7.0; API and flag surfaces may still move. Licensing: PolyForm Noncommercial 1.0.0 (see LICENSE) — free to use, modify and share for any noncommercial purpose (personal, hobby, research, education, charities and public institutions); commercial use needs the author's written permission — ask.
PolyForm-Noncommercial-1.0.0 View SPDX License List
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
None of the files in this release were uploaded with provenance metadata.
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.




