Metadata-Version: 2.4
Name: credence-governor-core
Version: 0.1.0
Summary: Harness- and domain-neutral Bayesian tool-call governance — a pure wire consumer of the Credence engine (credence-skin).
Author: Guy Freeman
License-Expression: AGPL-3.0-or-later
Project-URL: Homepage, https://github.com/gfrmin/credence-governor
Project-URL: Repository, https://github.com/gfrmin/credence-governor
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.11
Description-Content-Type: text/markdown
Requires-Dist: credence-skin-client>=0.1.0
Provides-Extra: dev
Requires-Dist: pytest>=7.4; extra == "dev"
Requires-Dist: ruff; extra == "dev"

# credence-governor-core

The harness- and domain-neutral Bayesian tool-call governance core for
[credence-governor](https://github.com/gfrmin/credence-governor) — a **pure wire
consumer** of the Credence engine (`credence-skin`). It carries **no probabilistic
code**: all inference runs server-side in the engine, reached over the
protocol-versioned JSON-RPC skin wire; this package only extracts features from a
neutral event and drives `proceed` / `block` / `ask` decisions.

## What's in it

- **`schema.py`** — the harness-neutral contract: `AgentToolEvent`, `Session`,
  `Message`. Every adapter translates its native events into these shapes.
- **`features/` + `safety.py`** — the single source of truth for feature & taint
  extraction (waste loops, repetition, taint-flow, exfil chains). Adapters carry
  none of this; they send a `Session` and the daemon extracts.
- **`session.py`** (`BrainSession`) — boots the warm beliefs and drives the engine's
  `structure_bma` / `structure_observe` / `structure_decide` / `routing_*` verbs.
- **`daemon.py`** — the HTTP surface: `POST /decide` (synchronous, for subprocess-hook
  adapters), `POST /sensor` + `GET /signals` (SSE, for in-process plugins), `/report`,
  `/ready`. stdlib `http.server`; one lock serialises engine calls.
- **`data/`** — "coding-ness" as data: the `bdsl/` feature schema + utility, the
  `brain/*.counts.json` warm beliefs, and `profiles/`. Swappable.

## Install & run

Not yet on PyPI — install from a clone of the repo. The core depends on the engine's
Python wire client (`credence-skin-client`), also unpublished, so install both editable:

```bash
pip install -e packages/governor_core -e ~/git/credence/apps/skin/clients/python
# dev engine: a local checkout of the Credence engine
CREDENCE_ENGINE_DIR=/path/to/credence credence-governor-daemon
# prod: a pinned engine image instead
CREDENCE_SKIN_COMMAND="docker run --rm -i ghcr.io/gfrmin/credence-skin@sha256:<digest>" \
  credence-governor-daemon
# (once published:  pip install credence-governor-core)
```

The daemon listens on `http://127.0.0.1:8787` by default
(`CREDENCE_GOVERNOR_HOST` / `CREDENCE_GOVERNOR_PORT`).

`POST /decide` `{tool_name, input, session:{cwd, project_root, messages}}` →
`{action, features, event_id}`.

## Tests

```bash
python -m pytest tests -q   # parity tests; no engine needed (pure extractor/manifest code)
```

## License

AGPL-3.0-or-later.
