Metadata-Version: 2.4
Name: solcis-sdk
Version: 0.9.0
Summary: Reference Policy Enforcement Point (PEP) client for the Solcis Policy Engine — decide one action and enforce it, fail-closed.
Author: Solcis
License: MIT
Project-URL: Homepage, https://github.com/solcis-ai/policy-engine
Project-URL: Repository, https://github.com/solcis-ai/policy-engine
Project-URL: Issues, https://github.com/solcis-ai/policy-engine/issues
Keywords: policy,enforcement,pep,authorization,agent-safety
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Operating System :: OS Independent
Classifier: Intended Audience :: Developers
Classifier: Topic :: Security
Classifier: Typing :: Typed
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
License-File: THIRD_PARTY_NOTICES.md
Requires-Dist: blake3==1.0.10
Requires-Dist: pynacl==1.6.2
Dynamic: license-file

# Solcis SDK for Python

The Solcis SDK for Python is the `solcis-sdk` package on PyPI: `pip install solcis-sdk`.

The SDK puts a policy check into your agent's code. Right before your agent takes a risky action, such
as replying to a customer, approving an invoice or sending data outside your organization, your code asks
the Solcis Policy Engine whether the action is allowed, and the SDK turns the answer into one of three
outcomes:

- **PROCEED**: run the action.
- **BLOCK**: stop the action.
- **HOLD**: a policy wants a person to look at the action before it runs, so don't run it yet.

Every failure blocks. An error, a timeout or an answer the SDK cannot verify becomes BLOCK, never
PROCEED. The place in your code that asks and then follows the answer is called an **enforcement
point**.

The Python SDK is Experimental. The
[release levels](https://github.com/solcis-ai/policy-engine/blob/main/README.md#release-levels) say what
each level means. The SDKs for Node and .NET take the same settings and return the same decisions.

## Install

Install the package from PyPI. It needs Python 3.9 or later, and no account or token:

```sh
pip install solcis-sdk
```

The package runs nothing at install time. Its two dependencies, `blake3` and `PyNaCl`, check the
signatures on the policy engine's answers.

The SDK's major and minor version are those of the Solcis release it goes with, and its patch number is
its own: `solcis-sdk` `0.9.x` goes with Solcis `0.9`. To get the newest patch for your release, install
a range, such as this one for Solcis 0.9:

```sh
pip install "solcis-sdk~=0.9.0"
```

Before version 1.0, a new minor version can change the SDK's API. Which policy engine versions each SDK
works with is in
[Engine and SDK compatibility](https://github.com/solcis-ai/policy-engine/blob/main/sdks/README.md#engine-and-sdk-compatibility).

## Connect your agent to a policy engine

Your code asks a running policy engine for each decision. The SDK finds the policy engine, and proves
which enforcement point is asking, from settings in your agent's environment. How you get them depends
on whether your organization uses Solcis Compliance Studio.

### With Solcis Compliance Studio

Solcis Compliance Studio registers your agent and gives you every setting it needs, in one block:

1. In the console, open **Developer portal** in the navigation and select **Connect**, then **Connect an
   agent**.
2. On the **Set it up yourself** tab, enter the agent's **Name** and **Key**, pick the **Environment** it
   runs in, and select **Register agent**.
3. Select **Copy settings**, and put the settings wherever your agent's process gets its environment
   variables. The console shows them only once, because they include the agent's channel key, the one
   secret it needs.

The block holds the four settings that [With the policy engine alone](#with-the-policy-engine-alone)
lists, the TLS settings when the policy engine runs on another machine, and the three settings that
[Enrolling with Solcis Compliance Studio](#enrolling-with-solcis-compliance-studio) reads. If you use
Claude Code, the **Let your coding agent do it** tab registers the agent from your editor instead.

If **Developer portal** is not in your navigation, ask your Solcis administrator for the agent developer
role.

### With the policy engine alone

[Getting started](https://github.com/solcis-ai/policy-engine/blob/main/GETTING-STARTED.md#serve-decisions-to-an-agent)
gets the `policy` program, makes the keys and starts a policy engine (`policy serve`), using Docker and
a clone of the Solcis Policy Engine repository. Then set these four variables in your agent's
environment. In these names, `PDP` stands for the policy engine.

| Variable | What to set it to |
| --- | --- |
| `SOLCIS_PDP_ADDR` | The `host:port` of the policy engine, such as `127.0.0.1:9099`. |
| `SOLCIS_PDP_PSK` | The pre-shared key that identifies this enforcement point to the policy engine. It is a secret, so keep it out of logs and command lines. |
| `SOLCIS_CHANNEL_AGENT_ID` | The enforcement point ID the key belongs to: the `id` of the key's entry in the policy engine's key file. |
| `SOLCIS_PDP_TRUST_ANCHOR` | The policy engine's receipt key, as 64 hexadecimal characters or a file that holds them. `policy keygen` prints it, as `public_key`, when it makes the key. |

The policy engine records each decision under the enforcement point ID its key belongs to, whatever the
request's `enforcement_point_id` says, and the SDK checks that the receipt names the ID in
`SOLCIS_CHANNEL_AGENT_ID`. Every other setting, and what happens when one is wrong or missing, is in
[Connection settings](https://github.com/solcis-ai/policy-engine/blob/main/sdks/README.md#connection-settings).
When `SOLCIS_PDP_ADDR` is unset, the SDK has no policy engine to ask and makes a local decision instead,
which blocks with `no_policy_bin` until you set up local decisions for development.

## Use

The SDK connects to the policy engine, sends it the action, and checks the signed receipt that comes
back before it lets the action proceed. `enforce_action` asks and maps the answer in one call. This
agent asks about two exports and prints what the SDK did with each:

```python
import solcis_pep

for destination in ("workspace-internal", "external-endpoint"):
    result = solcis_pep.enforce_action(
        {
            "enforcement_point_id": "agent-1",
            "user_id": "user-1",
            "action": "export",
            "source": "customer-db",
            "destination": destination,
        }
    )
    print(destination, result["outcome"], result["decision"])
```

Against the policy engine that Getting started runs, which allows the first export and denies the
second, it prints:

```text
workspace-internal PROCEED allow
external-endpoint BLOCK deny
```

In your own code, route on the outcome:

```python
result = solcis_pep.enforce_action(action)
if result["outcome"] == solcis_pep.PROCEED:
    ...  # run the action
elif result["outcome"] == solcis_pep.HOLD:
    ...  # a person needs to look first; see "Handling a HOLD"
else:  # solcis_pep.BLOCK
    ...  # stop the action
```

### Calling the SDK from async code

`enforce_action` is synchronous: it waits for the policy engine's answer, for up to
`SOLCIS_PDP_TIMEOUT_MS` (17 seconds by default). In an `asyncio` application, run it in a worker thread
so that the event loop keeps running:

```python
import asyncio

import solcis_pep


async def guard(action):
    return await asyncio.to_thread(solcis_pep.enforce_action, action)
```

Calls from several threads at once are safe, and they share the SDK's open connections to the policy
engine.

Each process holds at most `SOLCIS_PDP_MAX_CONNECTIONS` connections to one policy engine, 8 by default,
and a call over that waits for a connection, within `SOLCIS_PDP_TIMEOUT_MS`. A new connection that the
policy engine's side closes before it answers blocks with `connection_closed_unanswered`, and the SDK
does not send that decision again, because the policy engine may already have made it.
[Connection limits](https://github.com/solcis-ai/policy-engine/blob/main/sdks/README.md#connection-limits)
describes the limits in front of a policy engine, on the same host and on another machine.

## Reading the result

The result is a `dict`. These keys say what was decided and why:

| Key | What it holds |
| --- | --- |
| `outcome` | `PROCEED`, `BLOCK` or `HOLD`. Route on this. |
| `decision` | The policy engine's decision: `allow` maps to PROCEED, `deny` to BLOCK, and `step_up` and `defer` to HOLD. No other value maps to PROCEED. |
| `ok` | `False` when the SDK blocked because something failed, such as a timeout or a receipt that did not verify, rather than because a policy said so. |
| `reason_code` | Why. On a failure it names the failure, such as `receipt_untrusted`. |
| `rule_id` | The rule that decided. It is `POLICY` on an allow that no rule matched, and `""` when the SDK blocked because something failed. |
| `shadow` | `True` when the policy engine is in shadow mode: it recorded what it would have decided without enforcing it. `would_be_verdict` and `would_be_decision` hold that answer, for your logs. |

To map a decision yourself, `solcis_pep.enforce(x)` takes either the decision string or a whole result,
and `solcis_pep.result_to_outcome(result)` does the same for a result. A string it does not recognize
maps to BLOCK. A value of the wrong type, such as `None`, a number, or a `dict` with no string
`decision`, raises a `TypeError` in strict mode and returns BLOCK otherwise. Strict mode is on unless
`SOLCIS_PEP_ENV=production` is set or Python runs with `-O`, and `strict=True` or `strict=False`
sets it for one call.

### The policy that decided

A policy engine enforces a signed policy bundle: a directory of policies signed with a key you hold,
which the policy engine checks before it uses them. These keys say which policies were enforced. They
are `""` when the policy engine did not send them, and they mean nothing when `ok` is `False`:

| Key | What it holds |
| --- | --- |
| `policy_id` | The `id` of the policy that decided: the policy whose rule decided, or whose own policy-level check did. It is `""` when no single policy decided, such as an allow that no rule matched. When several policies objected, it names the one whose outcome was enforced. |
| `version_hash` | The BLAKE3 hash of the signed policy document, which identifies the revision of the whole set of policies enforced, not of the policy `policy_id` names. |
| `action` | The action the policy engine decided on. |
| `verification` | `verified` when the policy engine checked the bundle's signature. |

Read them in this order. If `ok` is `False`, ignore them. An empty `version_hash` means the policy
engine had no signed bundle. A `version_hash` with an empty `policy_id` means
no single policy decided. These keys are labels for display and logs. Nothing authenticates `policy_id`
on its own, so never grant access or route a decision on it.

### Rules the policy engine could not evaluate

When the policy engine cannot evaluate a rule, such as an AI check whose model it could not reach, a
fact the request did not supply, or a policy module that failed, it fails closed, usually by deciding a
hold, which the SDK maps to HOLD. `engine_exceptions` tells that hold apart from one a policy asked for.
It lists one record for each rule, or eval (a check a rule runs) within a rule, that could not be
evaluated, and is `[]` when every rule was evaluated or `ok` is `False`. `engine_exceptions_omitted`
counts any further records the policy engine left out.

| Key | What it holds |
| --- | --- |
| `rule_id` | The rule that could not be evaluated. |
| `eval_id` | The eval within the rule, or `None`. |
| `cause` | Why, such as `model_unavailable`, `model_timed_out`, `model_input_missing`, `model_input_too_long`, `predicate_unevaluable`, `wasm_module_failed` or `rule_has_no_evaluator`. The list can grow, so treat a value you do not recognize as a rule that could not be evaluated. |
| `refusal` | When the policy engine refused to route the rule to a model, which check refused it; otherwise `None`. |
| `capability` | The name the policy's author gave the rule's AI model, never an endpoint; otherwise `None`. |
| `policy_id` | The `id` of the policy the rule belongs to, `""` when no single policy owns it, or `None` on a policy engine started with `--demo`. |
| `deciding` | `True` on the one record, if any, whose failure is the outcome this decision took. |
| `observe_only` | `True` when the rule only observes, so its failure never decides. |

```python
import logging

for record in result["engine_exceptions"]:
    if record["deciding"]:
        logging.warning("%s could not be evaluated (%s)", record["rule_id"], record["cause"])
```

These records explain an outcome and never change it, so keep routing on `outcome`.

### The decision's severity

The policy engine can rate how serious a decision is. `result["severity"]` holds the rating, or `None`
when the decision has none. `None` means not rated, never "low". The rating is the decision's highest,
so it can come from a rule other than `rule_id`: a deny from one rule can have a `high` rating from
another rule that only observes. On a shadowed decision it is the rating the decision would have
had. A rating is a `dict` with these keys:

| Key | What it holds |
| --- | --- |
| `label` | `low`, `medium`, `high` or `critical`. Rank decisions by the label rather than the score. The set can grow. |
| `score` | A whole number from 0 to 100, for sorting and display rather than thresholds. |
| `confidence` | How sure the AI model was, from 0 to 1, or `None`. |
| `source` | What produced the rating: `wasm` (a WebAssembly policy module), `inference` (an AI model) or `deterministic` (a built-in check, or a score the policy's author wrote). The set can grow. |
| `deterministic_check` | The built-in check behind a `deterministic` rating, such as `pii.credit-card`, or `None`. |

To act on a rating at or above a level, use `solcis_pep.severity_at_least(rating, threshold)`. It
ranks `low` below `medium`, `high` and `critical`, counts a label it does not recognize as at least
`high`, so a label the policy engine adds later is never ignored, and returns `False` for `None`. The
threshold must be one of the four labels, spelled exactly: anything else raises `ValueError`, so a
mistyped threshold fails instead of matching nothing. This example logs an allowed decision that has a
`high` or `critical` rating, and serializes the strings the policy engine supplied before it logs them:

```python
import json
import logging

import solcis_pep

result = solcis_pep.enforce_action(action)
severity = result["severity"]
if (
    result["outcome"] == solcis_pep.PROCEED
    and not result["shadow"]
    and solcis_pep.severity_at_least(severity, "high")
):
    logging.warning(
        "allowed with a high rating: %s",
        json.dumps(
            {
                "label": severity["label"],
                "score": severity["score"],
                "source": severity["source"],
                "rule_id": result["rule_id"],
            }
        ),
    )
```

A rating never changes the outcome. To have a rated request blocked or held, give the rule that decides
it an `on_match` of `deny`, which makes the decision BLOCK, or `escalate`, which makes it HOLD. The
[policy language reference](https://github.com/solcis-ai/policy-engine/blob/main/crates/policy-schema/docs/policy-language.md#outcomes-on_match-and-severity)
describes both. On an allow, the rating is the copy the policy engine signed into the receipt. On a deny
or a hold it comes from the policy engine's reply, which is not signed, so treat it as a signal rather
than evidence. The evidence ledger, the record of decisions the policy engine keeps, holds the signed
record. `solcis_pep.parse_severity(raw)` reads a rating you hold yourself, such as one from a receipt,
by the same rules, and returns `None` for a missing or malformed value.

## Handling a HOLD

HOLD means a policy wants a person to look at the action before it runs. The SDK does not run the
action, and your code decides what happens next: send it to your own review step, notify someone, or
don't run it. `decision` says which kind of hold the policy asked for (`step_up` or `defer`),
and `rule_id` and `reason_code` say which rule asked and why. A hold can also mean the policy engine
could not evaluate a rule, which `engine_exceptions` tells apart.

Solcis does not notify anyone about a held action, so your agent needs its own way to ask a person.

## Binding what you run to what was decided

Run exactly the action the policy engine decided on. Code that asks about one request and then runs
another gets no protection from the answer, so check the request you are about to run against the
decision before you run it:

```python
result = solcis_pep.enforce_action(action)
if (
    result["outcome"] == solcis_pep.PROCEED
    and solcis_pep.assert_executed_request(result, action) == solcis_pep.PROCEED
):
    ...  # run exactly this action
```

`assert_executed_request(result, executed_request)` returns PROCEED only when the decision was an allow
and the request matches the decided one. It compares the action and every field a policy's deny or
escalate rule read, which the result lists in `bound_fields`, such as `destination` or `payload.amount`.
It compares values exactly, with no trimming, case folding or number conversion, so code that asks about
`destination="internal"` and then sends to `"external"` gets BLOCK. Every other case, such as a deny,
also returns BLOCK.

`assert_executed_action(result, executed_action)` checks the action name only. It is enough while no
rule in your policies reads a field other than the action.

### Recording each decision

Pass `on_decision` to receive a record of each decision, for logs or telemetry:

```python
import logging

result = solcis_pep.enforce_action(action, on_decision=lambda record: logging.info(dict(record)))
```

The record is read-only. It holds `outcome`, `decision`, `reason_code`, `rule_id`, `policy_id`,
`version_hash`, `action`, `verification`, `shadow`, `would_be_verdict`, `would_be_decision`, `severity`,
`transport` and `ok`, but not `engine_exceptions`, which you read from the result. `transport` says
whether a running policy engine or the local `policy` program made the decision. The hook runs once,
after the decision, and never changes it, and an exception it raises is ignored. The call waits for the
hook to return, so keep it fast. When you call the SDK through `asyncio.to_thread`, the hook runs on the
worker thread.

### Reporting what happened

Every decision the policy engine records in its evidence ledger comes back with a `decision_ref`,
`{"seq", "entryHash", "verified"}`, which names the ledger entry. An allow, a deny and a hold each have
one. Use it to report how the action turned out, or pass it to a tool server or your own logs to tie
their records to the decision:

```python
result = solcis_pep.enforce_action(action)
if result["outcome"] == solcis_pep.PROCEED:
    ...  # run the action, and report SUCCESS only once it has succeeded
    if result.get("decision_ref"):
        solcis_pep.report_outcome(
            result["decision_ref"],
            category=solcis_pep.OutcomeCategory.SUCCESS,
            detail="shipped 3 rows",
        )
```

`category` is one of `SUCCESS`, `FAILURE`, `PARTIAL` or `ERROR`. `verified` is `True` when the
decision's receipt checked out against your receipt key and matched this request. It is a label and
grants nothing: a deny still blocks and a hold still holds. An allow whose receipt does not check out
blocks and has no `decision_ref`, and a result also has none when it failed closed or when the policy
engine sent no receipt. A report is your agent's claim, not proof: the ledger records "the agent
reported success" against the decision. If your agent runs an action despite a deny, or after a person
has looked at a held one, report it against that decision's `decision_ref`.

## A policy engine on another machine

The policy engine listens on a loopback address only, so an agent on another machine reaches it
through a TLS proxy that runs beside the engine. Set `SOLCIS_PDP_ADDR` to the proxy's `host:port`, and
`SOLCIS_PDP_TLS_CA` to a PEM file that holds the certificate authority (CA) that signed the proxy's
certificate:

```sh
SOLCIS_PDP_ADDR=engine.example.com:8443
SOLCIS_PDP_TLS_CA=/etc/solcis/engine-ca.crt
```

`SOLCIS_PDP_TLS_CA_PEM` takes the certificate itself instead of a file, and
`SOLCIS_PDP_TLS_SERVERNAME` sets the name to check the certificate against, when you connect by an IP
address or another name the certificate does not cover. With a CA set, the SDK uses TLS for every
connection and sends its key only once the certificate checks out. When it cannot connect safely, it
blocks with one of these reason codes:

- `non_loopback_addr`: the address is not a loopback address and no CA is set.
- `tls_ca_unreadable`: the CA file could not be read, or the value holds no certificate.
- `tls_handshake_failed`: the proxy's certificate is not signed by that CA, has expired, or does not
  cover the name. Check `SOLCIS_PDP_TLS_SERVERNAME` first when you connect by IP address.

How the proxy limits connections is in
[A policy engine on another machine](https://github.com/solcis-ai/policy-engine/blob/main/sdks/README.md#a-policy-engine-on-another-machine).

## What the policy engine is enforcing

`serve.health()` asks the policy engine which policies it is enforcing, without making a decision. It
returns a `HealthReport`, or `None` when it cannot get one:

```python
from solcis_pep import serve

report = serve.health()
if report is None:
    print("unknown")  # the policy engine could not be reached, or its answer was unreadable
elif report.policy_set_id is None:
    print("no policy bundle yet")
else:
    print(f"enforcing {report.policy_set_id} @ {report.version_hash} ({report.verification})")
```

`policy_set_id` is the `id` of the policy document enforced, or `composed:` followed by your
enforcement point ID for a policy set. `version_hash` and `verification` mean what they mean on a
decision. The report is not part of a signed receipt, so use it for display and logs, never to grant
access. It also does not say that the bundle is current or that it enforces anything: a signed bundle
with no policies has an identity too. Read `None` as unknown, never as "nothing is enforced".

## Enrolling with Solcis Compliance Studio

Solcis Compliance Studio is the commercial product for managing AI guardrails at scale, and its web
interface is the console. [Connect your agent to a policy engine](#with-solcis-compliance-studio) says
how to register an agent there and get its settings.

An agent registered in the console enrolls with the console when it starts. Enrolling ties the running
agent, by its decentralized identifier (DID), to the agent registered in the console, and marks it
active. The DID is not the enforcement point ID. Enrolling is separate from asking for decisions:

```python
from solcis_pep.enroll import EnrollError, enroll

try:
    # Reads SOLCIS_CONTROL_PLANE_URL, SOLCIS_PDP_PSK and SOLCIS_AGENT_DID.
    instance = enroll()
except EnrollError as error:
    if not error.retryable:
        raise  # a wrong credential, a DID already claimed, or an untrusted certificate
    ...  # the console was unreachable or busy: try again
```

`enroll()` takes `base_url`, `credential` and `did` keyword arguments in place of the environment
variables, which
[Enrolling with Solcis Compliance Studio](https://github.com/solcis-ai/policy-engine/blob/main/sdks/README.md#enrolling-with-solcis-compliance-studio)
describes. It returns an `EnrollResult` with `id`, `did`, `first_seen_at` and `status`. Enrolling again
with the same DID is safe, so call it on every start. It raises `EnrollUsageError` when a setting is
missing or the address does not use `https` (plain `http` is allowed on a loopback address), and
`EnrollError`, with `code`, `retryable` and `status`, when the request fails.

The SDK checks the console's certificate against the system OpenSSL trust store. A console with a
certificate from a private CA fails with `tls_untrusted`, which is not retryable. Add the CA to the
system trust store, or set `SSL_CERT_FILE` to a bundle that holds the system CAs with yours appended:
`SSL_CERT_FILE` replaces the default bundle rather than adding to it. `REQUESTS_CA_BUNDLE` has no
effect.

## Local decisions for development

For development, or on a machine with no policy engine running, the SDK can make each decision by
running the `policy` program itself, against a signed policy bundle on the same machine. It does this
whenever `SOLCIS_PDP_ADDR` is unset, so `enforce_action` works unchanged. There is no signed receipt and
no evidence ledger, so use a running policy engine in production. The settings, and the reason codes a
local decision blocks with, are in
[Local decisions for development](https://github.com/solcis-ai/policy-engine/blob/main/sdks/README.md#local-decisions-for-development).

Each setting also has a keyword argument, which wins over the environment variable.
`decide_and_enforce` always makes a local decision, and `decide` returns the decision without an
outcome:

```python
result = solcis_pep.decide_and_enforce(
    action,
    policy_bin="/opt/solcis/bin/policy",  # or SOLCIS_POLICY_BIN
    bundle="/opt/solcis/bundle",  # or SOLCIS_BUNDLE
    trust="/opt/solcis/bundle-trust.pub",  # or SOLCIS_TRUST
)
```

These options apply to local decisions only:

- **The demo policy.** With no bundle and no trust anchor, a local decision blocks with
  `no_bundle_configured`. To try the SDK with the policy engine's built-in demo policy, a permissive
  sample, pass `demo_engine=True` or set `SOLCIS_PEP_DEMO_ENGINE=true`. `demo_engine=False` turns it
  off even when the variable is set. The same setting lets the SDK trust the receipt key of
  `policy serve --demo`, as
  [The demo engine's receipt key](https://github.com/solcis-ai/policy-engine/blob/main/sdks/README.md#the-demo-engines-receipt-key)
  describes, so set it only in a shell you use to try the SDK.
- **The enforcement mode.** `enforcement_mode="shadow"` sets the mode for one call, and wins over
  `SOLCIS_ENFORCEMENT_MODE`. A running policy engine sets its own mode, so the argument has no effect
  there.
- **Async calls.** `decide_async` and `decide_and_enforce_async` run `policy` in a worker thread and
  return the same result, so the event loop keeps running. They never raise, and an `on_decision` hook
  runs on the worker thread. Each call starts its own `policy` process, so limit how many run at once.
- **Verifying the bundle once.** `verify_at_boot(policy_bin, bundle, trust)` verifies the bundle's
  signature once and returns a handle, or `None` when the bundle does not verify. Pass the handle as
  `verified=handle`, and each decision runs `policy decide --assume-verified --expect-bundle-hash
  <hash>`, which skips the signature check but still checks every file against the verified hash.
  `verification` is then `assumed`. Without a handle, each call runs `policy verify` and then
  `policy decide`. Asking to skip the check with `assume_verified=True` and no handle blocks with
  `assume_verified_requires_verify`, or with `assume_verified_requires_bundle` when no bundle is set.
  `version_hash` is a different hash, so never set it as `SOLCIS_EXPECT_BUNDLE_HASH`.

The SDK runs `policy` from an argument list, never through a shell, and sends the request on its
standard input, where other accounts on the machine cannot read it. It reads the decision from the
program's output rather than its exit code, because `policy` exits `0` on a deny too, and any problem
running it becomes BLOCK.

## Reference

These pages have the detail behind this one:

- [The Solcis SDKs](https://github.com/solcis-ai/policy-engine/blob/main/sdks/README.md): the settings
  and behavior the three SDKs share.
- [The decision format](https://github.com/solcis-ai/policy-engine/blob/main/sdks/DECISION_CONTRACT.md):
  the decision the SDK reads, and how each maps to PROCEED, BLOCK or HOLD.
- [The serve protocol](https://github.com/solcis-ai/policy-engine/blob/main/sdks/SERVE_PROTOCOL.md):
  what an SDK and a running policy engine send each other.
- [Getting started](https://github.com/solcis-ai/policy-engine/blob/main/GETTING-STARTED.md): getting
  the `policy` program and running a policy engine.

## License

MIT. The license text is in
[LICENSE](https://github.com/solcis-ai/policy-engine/blob/main/sdks/python/LICENSE).
