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

/execute and /v1/execute are external PEP entrypoints and always run:

  1. payload validation and normalization
  2. deterministic policy evaluation

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

PARC Request Model (Cedar-style)

Kernite uses a Cedar-style PARC shape:

  • principal
  • action (operation)
  • resource
  • context

This keeps policy evaluation explicit and stable for relationship operations like associate.

See docs/parc-model.md for details and examples.

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.3.tar.gz (38.8 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.3-py3-none-any.whl (18.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: kernite-0.1.3.tar.gz
  • Upload date:
  • Size: 38.8 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.3.tar.gz
Algorithm Hash digest
SHA256 71a0333e614d42bd4ef4e86229074e479c20778008c5724b75e033fb59050cb0
MD5 642b49c85157d5664dda6d001d601cdb
BLAKE2b-256 9f4de3b4fe720ad560050c8af1afcad503596e6ce62d34b996e40351f397e903

See more details on using hashes here.

Provenance

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

Publisher: release.yml on kerniteio/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.3-py3-none-any.whl.

File metadata

  • Download URL: kernite-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 18.6 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 078ec4691ab6d91e6fee6f9f9212561398cf9f0344451ef4166d425874a9fda8
MD5 090edfa55dd12a7f2f8240e3741b4c4e
BLAKE2b-256 a21f700cfe1ae36316873cf67411676f5df8adbe081165fb73f2a17e24fe3973

See more details on using hashes here.

Provenance

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

Publisher: release.yml on kerniteio/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