bioma-micro
B.I.O.M.A. Micro-Kernel — a lean efficiency & resilience core for LLM infrastructure, written in Rust, exposed to Python via PyO3.
Exactly two proven primitives, nothing else:
- Context apoptosis — autonomous history dehydration. Long agent sessions accumulate low-value ballast (verbose tool logs, stale turns). The kernel assigns each message a metabolic weight by class, applies half-life decay, and purges dead weight before the payload hits the API. Microsecond-scale, GIL-released, allocation-light.
- Hormonal bus — lock-free in-memory signal injection (~2M signals/s, ~5 µs).
Plus saturation_scan(), an O(n) repetition detector for cognitive-DDoS / flood inputs.
Install
pip install bioma-micro
Prebuilt wheel for Windows (Python ≥ 3.8, abi3). Other platforms build from the sdist
(requires a Rust toolchain: pip will invoke maturin automatically).
Quick start
import bioma_micro as bm
messages = [
("You are a precise operations copilot.", bm.SYSTEM), # never purged
("FACT: the deploy freeze ends on 2026-07-18.", bm.FACT), # never purged
("[tool log] 40 KB of verbose audit output ...", bm.TOOL), # prime target
("Round 1: any anomaly?", bm.USER),
("Nothing above baseline.", bm.ASSISTANT),
# ... hundreds of turns later ...
("What is the freeze end date?", bm.USER),
]
result = bm.dehydrate(messages, half_life=6.0, safe_threshold=0.35)
print(result["reduction"]) # fraction of input tokens purged (0..1)
print(result["kernel_latency_us"]) # pure-Rust decision pass, microseconds
prompt = "\n".join(result["kept"]) # dispatch this instead of the full history
Flood detection:
bm.saturation_scan(suspicious_text) # ~1.0 = repetitive flood, ~0.0 = natural text
The honest contract
Measured, auditable behavior (full methodology and raw data in the framework repo):
| Client behavior | Measured effect |
|---|---|
| Naive tool-calling agent (resends growing history) | −84% input tokens |
| Generic long session (16 rounds, resends everything) | −95.8% input tokens |
| Claude Code (already self-manages context) | ~0% — safe no-op |
- Values tagged
FACTand recent turns survive; answer quality stays at parity with the full-context baseline (verified with objective probes against real online models). - Durable info buried in old untagged turns is purged by design — tag it
FACT. - Against an already-lean agent the kernel is a no-op: it never helps, never hurts.
This is a safety net for agents that do not manage their own context — not a universal "−X%" claim.
API surface
| Symbol | Kind | Purpose |
|---|---|---|
dehydrate(messages, half_life=6.0, safe_threshold=0.35, stable_prefix=0) |
function | one-shot history dehydration; stable_prefix = cache-aware zone kept verbatim; returns kept blocks + audit dict |
saturation_scan(text, window=8) |
function | duplicate-shingle flood score (0..1) |
consolidation_gain(prefix_tokens, purgeable_tokens, calls_ahead=8, ...) |
function | cache economics: is rewriting a cached prefix worth it? net gain + break-even calls |
effort_gauge(text) |
function | O(n) task-complexity score → recommended thinking budget (tier, budget_tokens, raw signals) |
ContextApoptosis(half_life, safe_threshold, capacity, state_capacity=64) |
class | stateful engine (insert / dehydrate(absorb=) / render) + purpose contract (set_purpose) + STATE ledger (note_state, state_entries) |
HormonalBus, HormonalSignal |
class | lock-free signal bus |
SYSTEM, USER, ASSISTANT, FACT, TOOL, THINKING |
flags | metabolic signal classes |
Cache-aware dehydration & thinking budgets (1.1.0)
Two cost phases, two levers:
- Input (prefill): apoptosis is deletion-only and order-preserving, so a durable
prefix stays byte-identical. With provider prompt caching, pass
stable_prefixto guarantee it, and askconsolidation_gain()when purging cached ballast actually pays off (cache reads at 0.1× make stale prefixes cheap — break-even is often 15+ calls away; the kernel does this arithmetic for you). - Reasoning (decode): thinking tokens are output-priced (~5×) and sequential.
effort_gauge()scores each request with cheap lexical signals and returns the budget to forward asbudget_tokens(Anthropic) /reasoning_effort(OpenAI) — trivial turns ("yes", "continue") stop paying for a full thinking budget.
License
FSL-1.1-MIT — Functional Source License 1.1 with MIT future license. Free for internal use, non-commercial use, and professional services; converts to MIT two years after each release.
Metadata
Release files for bioma-micro 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| bioma_micro-1.1.0.tar.gz | 18.3 kB | Details |
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| bioma_micro-1.1.0-cp38-abi3-win_amd64.whl | CPython 3.8 | abi3 | Windows x86-64 | Details |
| bioma_micro-1.1.0-cp38-abi3-manylinux_2_34_x86_64.whl | CPython 3.8 | abi3 | Linux glibc 2.34+ x86-64 | Details |
| bioma_micro-1.1.0-cp38-abi3-macosx_11_0_arm64.whl | CPython 3.8 | abi3 | macOS 11.0+ ARM64 | Details |
Total release size: 762.2 kB
Release files / bioma_micro-1.1.0.tar.gz
| Download URL | bioma_micro-1.1.0.tar.gz |
|---|---|
| Size | 18.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5b542b14a421b93522acb79922cc77136403eb7930e034ddc3fe97b813ffa87a
|
|
BLAKE2b-256 checksum How to use checksums |
714ae3aaa0c6c641fa3d1b9d5e61bc8ded7490c845ff2655c44d2675eb9198cc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Provenance
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 20, 2026.
Transparency logRelease files / bioma_micro-1.1.0-cp38-abi3-win_amd64.whl
| Download URL | bioma_micro-1.1.0-cp38-abi3-win_amd64.whl |
|---|---|
| Size | 201.8 kB |
| Tags | CPython 3.8 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
6a0d9ddab3854580a5bb10a2260769aaab7df438accbdfcc34b6fa4d58814541
|
|
BLAKE2b-256 checksum How to use checksums |
f068435b8bd093df9108c4e1649f24e1bb76d93ea7188ff0452a111bcf8f7134
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Provenance
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 20, 2026.
Transparency logRelease files / bioma_micro-1.1.0-cp38-abi3-manylinux_2_34_x86_64.whl
| Download URL | bioma_micro-1.1.0-cp38-abi3-manylinux_2_34_x86_64.whl |
|---|---|
| Size | 282.7 kB |
| Tags | CPython 3.8 Linux glibc 2.34+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
fa670e037a36f2afdd25f5d539632041518e1944830f50b9d83e2a23b95f7fe5
|
|
BLAKE2b-256 checksum How to use checksums |
a9d7b4ab754159c0ec95993b465c02bc001111c024186200ad0c4e4fe34a7ab9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Provenance
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 20, 2026.
Transparency logRelease files / bioma_micro-1.1.0-cp38-abi3-macosx_11_0_arm64.whl
| Download URL | bioma_micro-1.1.0-cp38-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 259.4 kB |
| Tags | CPython 3.8 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
f9d9ba5e43f2ef462f99b38886bdbd717102f074216d7fc7d374744c8f3e4a45
|
|
BLAKE2b-256 checksum How to use checksums |
48caa670f614764cc9586b36301111965261a8f330b997611f4bd465c353b4a5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Provenance
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 20, 2026.
Transparency log