Metadata-Version: 2.4
Name: endoxa
Version: 0.10.0
Summary: SMT-checked premises, verified revision proposals, and independent calibration instruments for agents.
Keywords: agent,belief-revision,calibration,llm,smt,truth-maintenance
Author: noise01
License-Expression: Apache-2.0
License-File: LICENSE
Classifier: Development Status :: 2 - Pre-Alpha
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Typing :: Typed
Requires-Dist: unsat>=0.3.0
Requires-Dist: networkx[default]>=3.6.1 ; extra == 'coverage'
Requires-Dist: pydantic>=2.12.5 ; extra == 'trace'
Requires-Python: >=3.14
Project-URL: Homepage, https://github.com/noise01/endoxa
Project-URL: Repository, https://github.com/noise01/endoxa
Project-URL: Changelog, https://github.com/noise01/endoxa/blob/main/CHANGELOG.md
Project-URL: Issues, https://github.com/noise01/endoxa/issues
Provides-Extra: coverage
Provides-Extra: trace
Description-Content-Type: text/markdown

# endoxa

**SMT-checked premises, verified revision proposals, and independent calibration instruments.**
Callers own adopted membership, confidence updates, history, storage, and application.

> **Status: pre-alpha.** Releases before 1.0 may change the public API.
> Review the [changelog](CHANGELOG.md) before upgrading across minor versions.

## The problem

An LLM agent will assert that a door is open, contradict itself twenty turns
later, and never notice. Keeping track inside its own context mixes claims,
standing rules, and confidence scores in one mutable prompt, with no check that
adopted premises hold together or which records conflict when they do not.

endoxa checks submitted premises outside the prompt and proposes minimal,
verified revisions without taking ownership of your store.

## What it does

- **Checks.** Submitted assertions, closed TPTP FOF rules, and ground functional
  exclusions go to `unsat`, returning `SAT`, `UNSAT`, or `UNKNOWN` under explicit
  per-check instantiation limits (`max_rounds`, `max_matches`).
- **Proposes.** `propose_revision` evaluates candidate adoption or repair trials
  across complete inputs under explicit priorities (`RevisionPolicy`) and bounded
  budgets (`max_withdrawals`, `max_checks`), returning `Adopt` / `Withdraw` data
  without mutating anything.
- **Holds.** Equal-ranked repairs and inconclusive `UNKNOWN` checks defer
  explicitly rather than flipping a coin or applying partial search results.
- **Measures.** Independent `endoxa.instruments.calibration` and
  `endoxa.instruments.coverage` compute Brier, transition, and rule-graph
  metrics without touching governance state.

## Example

```python
from endoxa.governance import Assertion, PremiseSet, propose_revision

premises = PremiseSet(
    assertions=(
        Assertion(id="observation-1", atom="open(door)", truth_value=True, confidence=0.8),
        Assertion(id="observation-2", atom="open(door)", truth_value=False, confidence=0.3),
    )
)
outcome = propose_revision(premises)
assert outcome.decision == "proposed"
assert outcome.changes[0].target.id == "observation-2"
assert outcome.final.status == "SAT"
# Withdraw removes this ID from adoption. Its original negative claim stays negative.
# Nothing has been applied or saved.
```

See [examples/](examples/README.md) and the docstrings under `endoxa.governance`
for premise checks (`check_consistency`, `check_entailment`, `check_support`),
input validators (`canonical_atom`, `validate_id`, `validate_confidence`),
`functional_scope` retention, ranking rules, and safe atomic application via
`RevisionBinding`.

## Install

Requires Python 3.14 or newer.

```bash
pip install endoxa
```

The core takes one dependency (`unsat`). Two optional extras add trace records
or rule-graph coverage measurements:

```bash
pip install "endoxa[trace]"     # ordered trace records and async store protocol
pip install "endoxa[coverage]"  # rule-network predicate coverage over unsat.Expr
```

## What this is not

- **Not a reasoner.** endoxa does not decide whether a claim is true in the
  world. You hand it assertions and FOF rules, and it checks whether they hold
  together and what minimal withdrawal restores consistency. It makes no model
  calls and reads no external context.
- **Not a knowledge base or ledger.** Callers own storage, persistence schemas,
  adopted membership, confidence accounting, and historical replay. No database
  codec or state store ships here.
- **Not a general-purpose SMT solver.** Satisfiability checking is delegated to
  `unsat` over Boolean formulas and uninterpreted first-order logic with
  equality. For arithmetic, bit-vectors, arrays, or strings, call `unsat` or Z3
  directly.
- **Not a new idea.** Truth maintenance is Doyle (1979) and de Kleer (1986), and
  belief revision has decades of AGM theory behind it. This is that machinery
  packaged as a typed, immutable checking and proposal layer with independent
  calibration instruments.
- **Not measured against an alternative.** There is no benchmark claiming that
  an agent using endoxa is more accurate or better calibrated than one without
  it. What is checked lives in the test suite: contract invariants, boundary
  isolation, and consistency-checking behavior.

## Design notes

- **Backed by `unsat`.** `unsat>=0.3.0` provides the SMT engine and TPTP FOF
  parser. `parse_premise_fof`, `parse_query_fof`, and
  `endoxa.instruments.coverage` exchange `unsat.Expr` values directly.
- **Pure proposals, caller-owned application.** `propose_revision` never mutates
  inputs; callers validate `RevisionBinding` against current records and apply
  changes atomically.
- **Instruments sit above everything.** `endoxa.instruments` is never imported by
  lower layers, enforced by `import-linter` in CI.
- **One error hierarchy.** Every exception raised on the package's behalf derives
  from `endoxa.errors.EndoxaError` (and standard built-ins such as `ValueError`
  or `TypeError`), wrapping external parser failures as `RuleSyntaxError`.

## Development & Issues

```bash
uv sync --locked --all-extras --dev
uv run ruff check . && uv run ruff format --check . && uv run ty check && uv run lint-imports && uv run rumdl check . && uv run pytest --cov=endoxa
```

Bug reports and PRs are welcome on GitHub issues (maintained on a best-effort
basis). Report security vulnerabilities through
[private advisories](https://github.com/noise01/endoxa/security/advisories/new)
rather than public issues.

## License

Apache-2.0. See [LICENSE](LICENSE).
