Skip to main content

Alethic

A governed cognitive substrate for AI systems.

DOI

Models propose. Alethic decides what may enter state and what may become action.

Alethic places a small, enforceable kernel between reasoning components and external effects. It maintains typed state, links beliefs to evidence, applies declarative constraints, and records why each proposal was committed or invalidated. The kernel contains no model, prompt, tool, task, or domain logic.

Install

The Python distribution is named alethic-kernel; its single import namespace is alethic.

pip install alethic-kernel

Use

from alethic import Kernel

kernel = Kernel()
trace = "episode-001"

kernel.write(
    "tool",
    "percepts",
    "COMMIT",
    "observation",
    {"value": 42, "stale": False, "conflict": False},
    trace,
    confidence=0.9,
)

proposal = kernel.write(
    "planner",
    "beliefs",
    "PROPOSE",
    "threshold_reached",
    {"value": True, "depends_on": ["observation"]},
    trace,
    input_refs=["observation"],
)

committed, reason = kernel.commit_belief_from_proposal(proposal.id, trace)
print(committed, reason)

Pluggable validation

The default EvidenceValidator checks that dependent percepts exist and are not stale or conflicted. Applications may add stricter synchronous validators without adding a model or domain dependency to Alethic itself:

from typing import Any

from alethic import EvidenceValidator, Kernel, ValidationContext, ValidationResult


class EntailmentValidator:
    validator_id = "semantic_entailment"

    def validate_belief_commit(
        self,
        belief_payload: dict[str, Any],
        percepts: dict[str, Any],
        context: ValidationContext,
    ) -> ValidationResult:
        # Call a deterministic, NLI, retrieval, or domain-specific verifier.
        entailed = verify_claim(belief_payload, percepts)
        if not entailed:
            return ValidationResult(
                False,
                "INSUFFICIENT_EVIDENCE",
                "The cited evidence does not entail the proposed belief",
            )
        return ValidationResult(True, "ENTAILED", "The claim is supported")


kernel = Kernel(
    belief_validators=[EvidenceValidator(), EntailmentValidator()],
)

Validators run in order and short-circuit on the first rejection — a belief is a truth claim, so the first disqualifying reason settles it. Exceptions and invalid return values fail closed as VALIDATOR_ERROR. Successful and rejected results are recorded in validation evidence artifacts. Every validator receives a ValidationContext (the kernel's store, trace_id, and now_ms), so a rule can depend on history or the clock, not just the payload it was handed.

Kernel(action_validators=[...]) is the same mechanism for actions, with one difference: the whole chain always runs to completion, even after a gate fails, because an action decision goes to a person who needs every reason it was refused rather than just the first one. See Writing a validator for a complete example (a cooldown gate) and Kernel.decide_action() for the full return shape.

Every worker can propose. Only the kernel can commit. State lives in seven semantic slots: percepts, beliefs, constraints, plans, evidence, predictions, and actions.

Writing a store

Any object satisfying StoreProtocol can back the kernel in place of MemoryStore or SqliteStore. The subtle parts of that contract — lazy TTL expiry, walking candidates past an expired one instead of judging only the oldest, and re-entrant transactions — are exactly where a third backend can quietly diverge from the two that ship. alethic.testing.store_conformance runs the same checks the shipped stores are held to, against a factory for your store:

from alethic.testing import store_conformance
from itertools import count

nth = count()
store_conformance(lambda: MyStore(f"conformance-{next(nth)}.db"))

The factory is called more than once and must return a fresh, empty store every time — a new database per call, not another handle on the one before. It raises AssertionError on the first violation, naming what failed. See src/testing.py for the full list of assertions.

What belongs here

This repository contains only the domain-neutral Alethic substrate:

  • the governed blackboard kernel and typed record schema;
  • evidence, confidence, conflict, constraint, and prediction validation;
  • in-memory and SQLite stores;
  • worker orchestration, sessions, simulation, and adaptive constraints;
  • tests, architectural documentation, and a domain-neutral example.

The controlled study, results, and verification artifacts live separately in governed-cognition.

Documentation

Source layout

The repository name is Alethic exactly once. Setuptools maps src/ directly to the installed alethic namespace.

src/
  __init__.py
  kernel.py
  schema.py
  permissions.py
  context.py
  decision.py
  validators.py
  store_protocol.py
  store.py
  sqlite_store.py
  migrations.py
  worker.py
  orchestrator.py
  session.py
  sim_worker.py
  adaptive_worker.py
  testing.py

Development

python -m pip install -e ".[dev]"
pytest
mypy --strict src

Where this lives

This repository is developed in a private Forgejo and mirrored here: every commit and tag on GitHub arrives from there. Issues and pull requests are welcome on GitHub; an accepted change is applied on Forgejo and comes back through the mirror, so nothing is merged here directly.

CI runs from .forgejo/workflows/, and dependency updates come from Renovate (renovate.json), not Dependabot. A v* tag that matches pyproject.toml publishes to PyPI from .forgejo/workflows/publish.yml on Forgejo (CONTRIBUTING.md, "Releases").

License

MIT © Emil Uzelac

Metadata

Release files for alethic-kernel 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for alethic-kernel 0.4.0
File Size Uploaded Provenance Actions
alethic_kernel-0.4.0.tar.gz 197.0 kB Without provenance Details for alethic_kernel-0.4.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for alethic-kernel 0.4.0
File Interpreter ABI Platform Actions
alethic_kernel-0.4.0-py3-none-any.whl Python 3 none any Details for alethic_kernel-0.4.0-py3-none-any.whl

Total release size: 229.4 kB

Release files / alethic_kernel-0.4.0.tar.gz

Download URL alethic_kernel-0.4.0.tar.gz
Size 197.0 kB
Tags Source
SHA-256 checksum
How to use checksums
33090345cd9341f2b33848e6d22d16afa2a2d3330bb7485cf38830d3585c44ff
BLAKE2b-256 checksum
How to use checksums
0bd324d885c6eae7a21c924f564cc72eab6a01b49ab501eab82048079536e349
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.16

Release files / alethic_kernel-0.4.0-py3-none-any.whl

Download URL alethic_kernel-0.4.0-py3-none-any.whl
Size 32.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
34b9bcc3d4efd05721be934f060d26aea55cabdaea8073eeb239acf90e2567be
BLAKE2b-256 checksum
How to use checksums
24ad5c907c54c7ac21ec4893992c5590a165d51c063c1db3d203fd7e03015f83
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.16

Security for alethic-kernel 0.4.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page