TrueHeart Core
Purpose
TrueHeart Core 0.1.1 is a model-independent Python library for governed long-term memory in AI agents. It gives a host application explicit contracts for ingesting source events, materializing derived memories, deterministic recall, retention, lineage, governance, and body-free audit records.
It supports Python 3.11 or newer, is licensed under MIT, has no runtime dependencies outside the standard library, and invokes no model or network.
Guarantees
- Every public operation that acts on scoped data uses an exact caller-supplied
Scope(tenant_id, owner_id, subject_id)and fails closed on mismatches.expire_raw_contentis a whole-database maintenance operation that only expires eligible raw bodies byas_of. - Inputs are validated and bounded; public datetimes are timezone-aware and normalized to UTC.
- Trust is explicit and a derived memory cannot exceed its least-trusted source.
- Materialization, lineage, tombstones, and audit changes are transactional.
- Recall is deterministic: clarity descending, creation time descending, then
memory ID ascending. Clarity is
1.0throughclear_until, then fades linearly to0.0atrecall_until. - Tombstones and audit records contain no event or memory bodies.
- The core performs no model calls, networking, plugin loading, shell execution, vector search, prompt rendering, or background work.
Within the library-controlled SQLite database, body-free tombstones prevent recreation of forgotten or deleted scoped IDs and exact dependency fingerprints. This is not cryptographic erasure and does not remove copied databases, snapshots, backups, WAL or filesystem artifacts, host logs, or provider content.
Five-minute example
Start from a repository checkout because the runnable example is a repository file and is not installed by the wheel:
git clone https://github.com/qingyou0420/trueheart-core.git
cd trueheart-core
python -m pip install -e ".[dev]"
python examples/basic_memory.py
It prints exactly:
1 governed memory recalled at clarity 1.00
The example uses TemporaryDirectory, creates one local file-backed SQLite
database, ingests a RawEventDraft, creates a caller-authored MemoryDraft,
and recalls it with a RecallQuery. It reads no environment variables, makes
no network requests, and removes the temporary database on exit. See
examples/basic_memory.py
for the full code.
The high-level API is TrueHeart:
ingest_event(RawEventDraft)records a source receipt and its local body.materialize_once(MemoryDraft)stores caller-derived content with lineage.recall(RecallQuery)returns an immutable tuple ofRecallItemvalues.govern(GovernanceCommand)seals, restores, forgets, or deletes.expire_raw_content(as_of=...)removes eligible raw bodies.audit(scope, limit=...)returns the newest body-free lifecycle records in that scope.limitis 1 through 100 (default 100) with no pagination.occurred_atis caller-claimed, not write order.
SQLiteRepository is the supported adapter. Stable imports also include the
immutable DTOs and enums (Scope, SourceRef, RetentionPolicy,
RawEventDraft, RawEventReceipt, MemoryDraft, MemoryRecord,
MemoryStatus, RecallQuery, RecallItem, GovernanceCommand,
GovernanceAction, GovernanceResult, EntityType, AuditRecord, and
TrustLevel) and the documented TrueHeartError subclasses
(ValidationError, EntityNotFound, ScopeMismatch,
IdempotencyConflict, EntityDeleted, InvalidTransition,
TrustEscalation, RepositoryBusy, and RepositoryCorruption).
Transient SQLite write-lock contention raises RepositoryBusy so a host
can retry; integrity failures raise RepositoryCorruption.
Lifecycle
- The host supplies an event, exact scope, provenance, trust, and retention.
- The host—not this library—derives a memory and names its source event IDs.
- Recall returns only active, unexpired memories in deterministic order.
- The host explicitly calls raw-body expiry; no scheduler runs in the core.
- Seal and restore are reversible. Forget and delete remove controlled bodies and create non-resurrection tombstones inside the current database.
Deleting a raw event also deletes and tombstones dependent memories in one transaction. Forgetting a memory does not delete its source events.
Installation
TrueHeart Core 0.1.1 is available from PyPI:
python -m pip install trueheart-core==0.1.1
For development from a checkout:
python -m pip install -e ".[dev]"
The default adapter stores bodies as plaintext in local SQLite. Version 0.1 provides no encryption at rest.
Integrations
The maintainer-owned
OpenAI Agents SDK integration example
shows a host-owned, bounded memory integration and depends on openai-agents.
Any explicitly initiated model API calls and associated network traffic occur
in the host application, outside TrueHeart Core's dependency-free,
model-independent, and network-independent runtime boundary.
Security boundaries
The core treats content and metadata as data and never interprets them as instructions. It cannot prevent prompt injection, establish truth, or control how a host constructs prompts or sends content to a provider.
Scope is caller-supplied database isolation, not authentication or
authorization. TrueHeart Core is not a multi-tenant service or API auth layer.
When a requested ID is absent from the exact scope but exists elsewhere in the
same database, materialization and governance can distinguish that one-bit
existence through ScopeMismatch rather than EntityNotFound. IDs are
sensitive; hosts must authenticate and authorize both scope and ID use. The
core does not protect against a malicious local administrator or compromised
host. Body-free audit and tombstone records omit event and memory bodies, but
their identifiers and metadata can still be sensitive.
Metadata is limited to 64 JSON container levels, integer magnitude of at most
4096 bits, and 16 KiB after canonical serialization. The SQLite adapter checks
for the standard json_valid function when it opens a connection and fails
closed if that required capability is unavailable.
Read paths validate persisted rows before they filter or truncate. Any corrupt
memory or lineage row in a scope makes that scope's recall unavailable. Any
tenant's corrupt raw-event row makes whole-database expire_raw_content
unavailable. audit likewise validates every audit row in the requested scope
before returning the newest limit records.
audit timestamps are caller-claimed: materialize uses MemoryDraft.created_at,
governance uses GovernanceCommand.occurred_at, expire uses the supplied
as_of, and ingest uses the service clock. Same-timestamp records are ordered
by random uuid4 audit_id. The API proves that listed lifecycle actions
occurred; it does not provide a reliable total order.
Read the security guarantees, the threat model, and security reporting before using the library with sensitive data.
Architecture
Immutable domain contracts feed the TrueHeart lifecycle service, which uses
an internal repository boundary implemented by SQLiteRepository. Policy and
validation live in the domain/service layer; persistence, transactions, and
projection assembly live in the adapter. See the
architecture.
Development
python -m pytest tests -q
python -m ruff check src/trueheart_core tests examples
python -m ruff format --check src/trueheart_core tests examples
python -m mypy src/trueheart_core
python -m build
Tests and examples use synthetic data and temporary file-backed databases.
Contributing
Contributions are welcome under the requirements in CONTRIBUTING.md. Report ordinary usage questions as described in SUPPORT.md, and report vulnerabilities privately as described in SECURITY.md.
Status
Version 0.1.1 is published on PyPI from this public source repository and keeps
an intentionally small API. A point-in-time
code review of 0.1.0 (in Chinese)
covers main at commit bda22c7; it is a snapshot, not a living guarantee. Semantic search, embeddings, model integration,
service authentication, provider deletion, backup management, and encryption
at rest are out of scope.
Metadata
Release files for trueheart-core 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| trueheart_core-0.1.1.tar.gz | 50.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| trueheart_core-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 73.6 kB
Release files / trueheart_core-0.1.1.tar.gz
| Download URL | trueheart_core-0.1.1.tar.gz |
|---|---|
| Size | 50.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
65be85b40cec274f31a90a728067fe7d34c850e4bc1782c37d4645a5d6d3d95f
|
|
BLAKE2b-256 checksum How to use checksums |
31860b3c88435f8b086e52f6a9df0b024f599c851c0cdfd323d033e28766fbc2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.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 Aug 14, 2026.
Transparency logRelease files / trueheart_core-0.1.1-py3-none-any.whl
| Download URL | trueheart_core-0.1.1-py3-none-any.whl |
|---|---|
| Size | 23.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e983a9f337065c5a7dda22d251386a705865ec0ba4219186c766cd7515a7af9e
|
|
BLAKE2b-256 checksum How to use checksums |
d0b07890b1e7ef7673e7088bd73b700dd6aa807c272f2677c98d20ba6bad3698
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.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 Aug 14, 2026.
Transparency log