Metadata-Version: 2.4
Name: kyvvu-engine
Version: 1.0.0
Summary: Standalone policy evaluation engine for AI governance under the EU AI Act
Author-email: "Kyvvu B.V." <info@kyvvu.com>
License: Business Source License 1.1
        
        Parameters
        
        Licensor:             Kyvvu B.V.
        
        Licensed Work:        Kyvvu Engine. The Licensed Work is © 2026 Kyvvu B.V.
                              The Licensed Work consists of the contents of the
                              kyvvu-engine/ directory of the Kyvvu monorepo,
                              including all source code, configuration, atomic
                              behavior definitions, and accompanying files.
        
        Additional Use Grant: You may make use of the Licensed Work, provided that
                              your use does not constitute a "Production Use." A
                              "Production Use" is any use of the Licensed Work other
                              than for development, testing, research, evaluation,
                              or personal non-commercial purposes. Production Use of
                              the Licensed Work requires a commercial subscription
                              to Kyvvu's hosted service or a separate commercial
                              license agreement with Licensor.
        
                              Notwithstanding the foregoing, you may not use the
                              Licensed Work to offer a commercial product or service
                              to third parties whose value derives, in whole or in
                              substantial part, from the policy enforcement,
                              behavioral interception, or runtime governance
                              functionality of the Licensed Work.
        
        Change Date:          Four (4) years from the date the specific version of
                              the Licensed Work is first made publicly available by
                              the Licensor.
        
        Change License:       Apache License, Version 2.0
        
        -----------------------------------------------------------------------------
        
        Terms
        
        The Licensor hereby grants you the right to copy, modify, create derivative
        works, redistribute, and make non-production use of the Licensed Work. The
        Licensor may make an Additional Use Grant, above, permitting limited
        production use.
        
        Effective on the Change Date, or the fourth anniversary of the first publicly
        available distribution of a specific version of the Licensed Work under this
        License, whichever comes first, the Licensor hereby grants you rights under
        the terms of the Change License, and the rights granted in the paragraph
        above terminate.
        
        If your use of the Licensed Work does not comply with the requirements
        currently in effect as described in this License, you must purchase a
        commercial license from the Licensor, its affiliated entities, or authorized
        resellers, or you must refrain from using the Licensed Work.
        
        All copies of the original and modified Licensed Work, and derivative works
        of the Licensed Work, are subject to this License. This License applies
        separately for each version of the Licensed Work and the Change Date may vary
        for each version of the Licensed Work released by Licensor.
        
        You must conspicuously display this License on each original or modified copy
        of the Licensed Work. If you receive the Licensed Work in original or
        modified form from a third party, the terms and conditions set forth in this
        License apply to your use of that work.
        
        Any use of the Licensed Work in violation of this License will automatically
        terminate your rights under this License for the current and all other
        versions of the Licensed Work.
        
        This License does not grant you any right in any trademark or logo of
        Licensor or its affiliates (provided that you may use a trademark or logo of
        Licensor as expressly required by this License).
        
        TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
        AN "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
        EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
        MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
        TITLE.
        
        MariaDB hereby grants you permission to use this License's text to license
        your works, and to refer to it using the trademark "Business Source License",
        as long as you comply with the Covenants of Licensor below.
        
        -----------------------------------------------------------------------------
        
        Covenants of Licensor
        
        In consideration of the right to use this License's text and the "Business
        Source License" name and trademark, Licensor covenants to MariaDB, and to all
        other recipients of the licensed work to be provided by Licensor:
        
        To specify as the Change License the GPL Version 2.0 or any later version, or
        a license that is compatible with GPL Version 2.0 or a later version, where
        "compatible" means that software provided under the Change License can be
        included in a program with software provided under GPL Version 2.0 or a later
        version. Licensor may specify additional Change Licenses without limitation.
        
        To either: (a) specify an additional grant of rights to use that does not
        impose any additional restriction on the right granted in this License, as the
        Additional Use Grant; or (b) insert the text "None" to specify a Change Date.
        
        Not to modify this License in any other way.
        
        -----------------------------------------------------------------------------
        
        Notice
        
        The Business Source License (this document, or the "License") is not an Open
        Source license. However, the Licensed Work will eventually be made available
        under an Open Source License, as stated in this License.
        
        License text copyright © 2024 MariaDB plc, All Rights Reserved.
        "Business Source License" is a trademark of MariaDB plc.
        
Project-URL: Documentation, https://docs.kyvvu.com/
Project-URL: Changelog, https://docs.kyvvu.com/reference/changelog
Project-URL: Issues, https://github.com/Kyvvu/issues/issues
Keywords: ai,compliance,eu-ai-act,policy-enforcement,governance
Classifier: Development Status :: 5 - Production/Stable
Classifier: License :: Other/Proprietary License
Classifier: Intended Audience :: Developers
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pydantic>=2.0
Requires-Dist: rfc8785>=0.1.4
Requires-Dist: pyyaml>=6.0
Requires-Dist: google-re2>=1.1
Requires-Dist: opentelemetry-api>=1.20.0
Requires-Dist: opentelemetry-sdk>=1.45.0
Requires-Dist: opentelemetry-exporter-otlp-proto-http>=1.45.0
Provides-Extra: dev
Requires-Dist: pytest>=7.4.0; extra == "dev"
Requires-Dist: jsonschema<5,>=4.23; extra == "dev"
Requires-Dist: rfc3339-validator>=0.1.4; extra == "dev"
Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
Requires-Dist: httpx>=0.24.0; extra == "dev"
Requires-Dist: types-PyYAML>=6.0; extra == "dev"
Requires-Dist: mypy>=1.0.0; extra == "dev"
Provides-Extra: serve
Requires-Dist: fastapi>=0.100.0; extra == "serve"
Requires-Dist: uvicorn>=0.23.0; extra == "serve"
Dynamic: license-file

# kyvvu-engine

Runtime policy evaluation for AI agents. The engine checks an intended
behaviour against the ordered history of its task, returning allow, warn, or
block with the policy outcomes that explain the decision.
A behaviour's `kind` identifies the action being governed, such as a model
call, resource access, or decision gate.

It powers the [Kyvvu Python client](https://pypi.org/project/kyvvu/) and can also
be embedded directly or served over HTTP. The model is described in
[*Runtime Governance for AI Agents: Policies on Paths*](https://arxiv.org/abs/2603.16586).

## Installation

```bash
pip install kyvvu-engine
```

Most Python agents should install `kyvvu` for decorators and task management.
For a local HTTP server, install the command with `uv tool install kyvvu-cli` and run `kyvvu serve`.

## Project probe

Run `python -m kyvvu_engine.info` with the Python interpreter used by your
agent to print one JSON object describing its installed Kyvvu environment.
`probe_version` is the output format version (currently `1`); `interpreter` is
the interpreter's executable path; `distributions` lists the names and versions
of installed distributions whose names start with `kyvvu`; and `templates`
lists each `kyvvu.templates` entry point's name, declaring distribution, and
template path. The output contract is the JSON schema shipped in the package as
`kyvvu_engine/project_probe.schema.json` (read it with
`importlib.resources.files("kyvvu_engine") / "project_probe.schema.json"`).

## Templates

The template system that maps a framework's events to behaviours is not part
of the engine. It is the Apache-2.0
[`kyvvu-templates`](https://pypi.org/project/kyvvu-templates/) package,
imported as `kyvvu_templates`. The engine keeps only the `KV_TEMPLATE_LOCATION`
setting, which points an integration at a custom template, and the project
probe above, which lists the templates installed integrations declare.

## Quickstart

Start with a local policy file. Evaluation needs no account or API key.

### 1. Offline — no account, no API key, no network

Write a manifest. This is the same format the manifests in [`Kyvvu/manifests`](https://github.com/Kyvvu/manifests) are written in, so anything there runs locally too:

```yaml
# my-policies.yaml
name: My first policy set
version: "1.0.0"
policies:
  - name: Code execution requires a preceding gate
    rule_type: step_requires_gate
    params:
      target_kinds: ["step.exec"]
    severity: critical
    enforcement_point: step_execution
```

Point a runner at it and evaluate:

```python
from kyvvu_engine import KyvvuBlockedError, KyvvuRunner
from kyvvu_engine import Behavior, EvalContext, ActionKind

runner = KyvvuRunner(policy_file="my-policies.yaml", log_location="none")

# Load now, and check what is actually being enforced before trusting any
# verdict. Policies otherwise load lazily on the first evaluate(), so a
# load_report() read before that reports `unavailable` — nothing has been
# asked to load yet.
status = runner.ensure_policies()
print(status.load_state.value, status.policies_offered, status.policy_count)
# enforcing 1 1

ctx = EvalContext(
    agent_id="local-agent",
    task_id="task-1",
    # Declare the agent's tools. Not needed by the policy above, but the
    # OWASP set's allowlist policy reads this field (NOT the agent payload's
    # declared_tools) and fails closed: leave it unset there and every
    # step.resource / step.exec / step.credential blocks on "Tool calls must
    # be in the declared allowlist".
    agent_allowed_tools=["run_script"],
)

# A task is opened by recording its task.start; every other write needs it.
runner.record(Behavior(
    agent_id="local-agent",
    task_id="task-1",
    kind=ActionKind.task_start,
    step_name="task.start",
))

intended = Behavior(
    agent_id="local-agent",
    task_id="task-1",
    kind=ActionKind.step_exec,
    step_name="run_script",
    input={"code": "rm -rf /"},
)

try:
    runner.evaluate(intended, ctx)
except KyvvuBlockedError as exc:
    print(exc)          # Step 'run_script' blocked (risk_score=1.00): …
    # The runner has already recorded the blocked step (exc.result.recorded_seq);
    # do not record it again.
```

### 2. Platform-connected

Follow the [first-agent guide](https://docs.kyvvu.com/getting-started/first-agent)
for agent registration and credentials, or the
[REST integration guide](https://docs.kyvvu.com/integrations/rest-api) for a
non-Python harness. To expose local policies over HTTP, see
[kyvvu serve](https://docs.kyvvu.com/cli/serve).

## Documentation

- [Architecture and policies on paths](https://docs.kyvvu.com/concepts/architecture)
- [Behaviour kinds and properties](https://docs.kyvvu.com/concepts/behaviours)
- [Task lifecycle and history](https://docs.kyvvu.com/concepts/tasks)
- [Policy rules](https://docs.kyvvu.com/policies/rules-reference) and [compound policies](https://docs.kyvvu.com/policies/compound)
- [Runtime configuration](https://docs.kyvvu.com/deployment/configuration)
- [Trace export and provenance](https://docs.kyvvu.com/reference/trace-export)
- [Policy diagnostics](https://docs.kyvvu.com/cli/doctor)
- [Interface stability](https://docs.kyvvu.com/reference/stability)
- [Changelog](https://docs.kyvvu.com/reference/changelog)
- [Report an issue](https://github.com/Kyvvu/issues/issues)

The supported Python interface is the names in `kyvvu_engine.__all__`.
Import them from `kyvvu_engine`; submodule paths are internal. Breaking that
interface requires a major version under the stability policy linked above.

## Licence

The engine is source-available under the Business Source License 1.1 (BSL 1.1).
Free use covers development, testing, research, evaluation, and personal
non-commercial purposes. Production use requires a commercial subscription or
separate agreement. Each release converts to Apache-2.0 four years after
publication. See [licensing](https://docs.kyvvu.com/reference/licensing) and
contact [licensing@kyvvu.com](mailto:licensing@kyvvu.com) for commercial terms.
