Documentation Index
Fetch the complete documentation index at: https://ahvn.top/llms.txt
Use this file to discover all available pages before exploring further.
Capsules are trusted-local executable manifests. Store only code you own or have reviewed.
What a Capsule is
A Capsule is the durable form of a Python callable. It stores enough metadata to restore and run a function later, including:- identity: namespace, name, and explicit version
- signature: parameters, return annotation, and JSON schema
- restore layers: source, import path, and optional
cloudpicklepayload - dependencies: Python version and imports found in source
- capabilities: whether it can be used locally, exported to MCP, or exported for Anthropic programmatic tools
- trust and fingerprints: local-only execution flags and hashes for review
Store a function
Load and run it elsewhere
Docstrings and formats
Capsules parse callable docstrings during capture and can synthesize a callable docstring from the stored signature metadata.Capsule.from_str(...) restores JSON and YAML manifest strings back into a Capsule.
Architecture data flow
The Capsule flow is explicit and layered:- Python callable ->
CallableSerializationstrategy inspects source, import path, docstring, signature, dependencies, and optional binary fallback. - Strategy ->
CapsuleManifestrecords identity, schema, restore layers, capabilities, trust flags, and fingerprints. capsule.register()-> hidden registry workspace stores the activecapsulerow and appends acapsule-revisionrow.Capsule.load(...)-> manifest is read by id or by namespace/name/version.Capsule.to_func()-> restore policy tries source, then import path, then trusted-local binary payload.ToolandToolkitwrap Capsules for local calls, MCP serving, and programmatic tool exports.
heavenbase.capsule.serialize strategy. When a callable cannot be captured as a Capsule, it falls back to a lightweight module.qualname reference instead of failing generic JSON serialization.
Registry records
Capsules are stored as normal HeavenBase entities in a hidden registry workspace:capsule: active manifest rowcapsule-revision: append-only manifest revisions
heavenbase.capsule.registry. You can pass registry_config=... when a demo, test, or application should keep executable data in a dedicated file.
Most application code should prefer capsule.register(...) and Capsule.load(...). CapsuleRegistry remains available for advanced registry administration and inspection.
Trust model
Capsules do not verify themselves against the current content of the original Python function. The registry checksum only verifies that a loaded Capsule payload still matches the hashes stored with that same manifest. It is a record-integrity check, not a code-safety proof. HeavenBase caches successful checksum checks in a thread-safe in-memory LRU cache, so a process verifies a Capsule payload once per cache key instead of recalculating hashes every time the Capsule is loaded or restored. If someone edits the registry database after the first cached verification, edits both executable content and stored hashes, registers malicious code, or loads a manual source/binary payload directly, HeavenBase does not make safety guarantees. Use source-only Capsules by default.include_cloudpickle defaults to False; enable binary payloads only for reviewed local code that cannot be represented by source or import path. If source-only restore fails, HeavenBase reports that no trusted-local binary fallback is stored.
Demo
Run the math demo from the source checkout:add, mul, sub, div, mod, and fibonacci as Capsules, stores a Toolkit, loads it through the public API, and validates the MCP server with a FastMCP client.
The cross-directory consumer check is covered by the test suite; the demo itself stays focused on the public API.

