Skip to main content

Contract-first policy decision CLI for deterministic decision + reason + trace.

Project description

Kernite

Kernite is an AI-operable policy decision gateway for write-path enforcement.

It is built for one job: return a deterministic, machine-operable decision contract before any mutation is executed.

Why Kernite

  • Contract-first outputs: decision, reason_codes, reasons, trace_hash are stable integration surfaces.
  • AI-operable feedback: deny reasons are structured for programmatic remediation, not only human logs.
  • Deterministic evidence: same canonical input and policy context produce stable trace_hash output.
  • Fail-closed for governed scopes: no matching policy on governed scope returns deny.
  • Lightweight runtime: dependencies = [] in pyproject.toml.

Install and Run

uvx kernite serve

Server endpoints:

  • GET /health
  • POST /execute
  • POST /v1/execute
  • POST /validate/execute
  • POST /v1/validate/execute

Quick Start: Execute

Request (governed scope with one policy):

{
  "workspace_id": "workspace-demo",
  "principal": {
    "type": "token",
    "id": "api:ops-bot"
  },
  "object_type": "document",
  "operation": "create",
  "payload": {
    "title": "Quarterly Plan"
  },
  "policy_context": {
    "governed": true,
    "selected_policies": [
      {
        "policy_key": "document_create_default",
        "policy_version": 1,
        "effect": "allow",
        "rules": [
          {
            "rule_key": "require_title",
            "rule_definition": {
              "type": "required_fields",
              "fields": ["title"]
            },
            "reason_code": "missing_required_fields",
            "reason_message": "title is required."
          }
        ]
      }
    ]
  }
}

Response shape:

{
  "ctx_id": "ctx_...",
  "message": "Approved by governance policy.",
  "data": {
    "decision": "approved",
    "reason_codes": [],
    "reasons": [],
    "policy_selection_reason_code": "policy_selected_workspace_default",
    "policy": {
      "policy_key": "document_create_default",
      "policy_version": 1
    },
    "trace_hash": "sha256:...",
    "idempotency_key": "..."
  }
}

Policy Context Model

policy_context is optional, but recommended for production integrations.

Main fields:

  • governed (bool): whether this request must be enforced as governed scope.
  • selected_policies (array): policies selected by your resolver.
  • governed_scopes (array): optional scope list (object_type + operation) to infer governed status.
  • policy_selection_reason_code (string): explicit selection reason, if already known.

Default behavior:

  • governed + no selected policy => denied with no_matching_policy
  • not governed + no selected policy => approved with out_of_scope_phase1

Use Cases (AI and Non-AI)

  • AI-assisted actions: gate tool calls and use reason_codes for automatic retry/remediation.
  • Internal APIs: apply one deterministic write guard across UI/API/workers.
  • SaaS multi-tenant systems: enforce tenant-scoped write decisions and persist evidence.

Compatibility and Conformance

  • Contract policy: docs/compatibility.md
  • Conformance vectors: docs/conformance/v1/execute_vectors.json
  • Reason code semantics: docs/conformance/v1/reason_codes_v1.json

Objective Performance Check (Python)

Kernite includes a dependency-free benchmark harness.

uv run python benchmarks/benchmark_execute.py --iterations 20000

This gives p50/p95 latency and throughput from your actual environment so language/runtime decisions are based on measured data, not assumptions.

Latest measured snapshot is tracked in docs/performance.md.

Design Philosophy

See docs/design-philosophy.md for rationale on deterministic behavior, minimal runtime surface, and measured optimization strategy.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kernite-0.1.1.tar.gz (34.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kernite-0.1.1-py3-none-any.whl (16.5 kB view details)

Uploaded Python 3

File details

Details for the file kernite-0.1.1.tar.gz.

File metadata

  • Download URL: kernite-0.1.1.tar.gz
  • Upload date:
  • Size: 34.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for kernite-0.1.1.tar.gz
Algorithm Hash digest
SHA256 43c85495671ed9e7bd63d1c4971a439a78af3ce261695517cfa39f66da90a202
MD5 8b736e8ee2b70616068a21de79291b87
BLAKE2b-256 65c61872377078b2a1f9353b24cafdd3d19c90de6826929505719e7497fce0c8

See more details on using hashes here.

Provenance

The following attestation bundles were made for kernite-0.1.1.tar.gz:

Publisher: release.yml on sankaHQ/kernite

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file kernite-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: kernite-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 16.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for kernite-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 46912fb419069f6db323d2bb3c173029664550a3b426b2975167b5b7e12a5a4a
MD5 a4eb0355cefef06fc07954b6f2893261
BLAKE2b-256 661935728d3409844b984fda419a8d8fb2be82f290a2355cc551113cd96c2b2d

See more details on using hashes here.

Provenance

The following attestation bundles were made for kernite-0.1.1-py3-none-any.whl:

Publisher: release.yml on sankaHQ/kernite

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page