Metadata-Version: 2.4
Name: calethia
Version: 0.8.0
Summary: Calethia SDK for writing compliance policies as code
Author-email: Calethia <support@calethia.ai>
License-Expression: LicenseRef-FSL-1.1-ALv2
Keywords: compliance,security,policy,soc2,cis
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Typing :: Typed
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE.md
License-File: NOTICE.md
Requires-Dist: boto3>=1.34.0
Requires-Dist: requests>=2.31.0
Requires-Dist: urllib3>=2.7.0
Requires-Dist: cryptography>=44.0.1
Requires-Dist: protobuf>=5.29.6
Requires-Dist: asn1crypto==1.5.1
Requires-Dist: tzdata; sys_platform == "win32"
Provides-Extra: mcp
Requires-Dist: mcp<2,>=1.26.0; extra == "mcp"
Provides-Extra: dev
Requires-Dist: pytest>=7.0.0; extra == "dev"
Requires-Dist: moto>=5.0.0; extra == "dev"
Provides-Extra: validation
Requires-Dist: jsonschema>=4.0.0; extra == "validation"
Provides-Extra: aws
Requires-Dist: boto3>=1.34.0; extra == "aws"
Provides-Extra: github
Requires-Dist: PyGithub>=2.2.0; extra == "github"
Provides-Extra: snowflake
Requires-Dist: snowflake-connector-python>=3.0.0; extra == "snowflake"
Provides-Extra: gcp
Requires-Dist: google-api-python-client; extra == "gcp"
Requires-Dist: google-auth; extra == "gcp"
Requires-Dist: google-cloud-compute; extra == "gcp"
Requires-Dist: google-cloud-container; extra == "gcp"
Requires-Dist: google-cloud-functions; extra == "gcp"
Requires-Dist: google-cloud-iam; extra == "gcp"
Requires-Dist: google-cloud-kms; extra == "gcp"
Requires-Dist: google-cloud-logging; extra == "gcp"
Requires-Dist: google-cloud-resource-manager; extra == "gcp"
Provides-Extra: gitlab
Requires-Dist: requests; extra == "gitlab"
Provides-Extra: okta
Requires-Dist: requests; extra == "okta"
Provides-Extra: cloudflare
Requires-Dist: requests; extra == "cloudflare"
Provides-Extra: google-workspace
Requires-Dist: google-api-python-client; extra == "google-workspace"
Requires-Dist: google-auth; extra == "google-workspace"
Provides-Extra: gmail
Requires-Dist: google-api-python-client; extra == "gmail"
Requires-Dist: google-auth; extra == "gmail"
Provides-Extra: resend
Requires-Dist: requests; extra == "resend"
Provides-Extra: bloomfire
Requires-Dist: requests; extra == "bloomfire"
Provides-Extra: pulumi
Requires-Dist: requests; extra == "pulumi"
Provides-Extra: vault
Requires-Dist: requests; extra == "vault"
Provides-Extra: pagerduty
Requires-Dist: requests; extra == "pagerduty"
Provides-Extra: slack
Provides-Extra: jira
Provides-Extra: intune
Provides-Extra: rippling
Provides-Extra: deel
Provides-Extra: gusto
Provides-Extra: entra
Provides-Extra: jamf
Requires-Dist: requests; extra == "jamf"
Provides-Extra: azure
Requires-Dist: requests; extra == "azure"
Provides-Extra: zoom
Provides-Extra: datadog
Provides-Extra: browser
Requires-Dist: playwright>=1.64.1; extra == "browser"
Requires-Dist: pydantic>=2.0; extra == "browser"
Provides-Extra: ai-anthropic
Requires-Dist: anthropic>=0.115.1; extra == "ai-anthropic"
Requires-Dist: pydantic>=2.0; extra == "ai-anthropic"
Requires-Dist: pyyaml>=6.0; extra == "ai-anthropic"
Provides-Extra: ai-openai
Requires-Dist: openai>=2.54.0; extra == "ai-openai"
Requires-Dist: pydantic>=2.0; extra == "ai-openai"
Requires-Dist: pyyaml>=6.0; extra == "ai-openai"
Provides-Extra: ai-gemini
Requires-Dist: google-generativeai>=0.8.3; extra == "ai-gemini"
Requires-Dist: pydantic>=2.0; extra == "ai-gemini"
Requires-Dist: pyyaml>=6.0; extra == "ai-gemini"
Provides-Extra: ai-bedrock
Requires-Dist: httpx>=0.26.0; extra == "ai-bedrock"
Requires-Dist: pydantic>=2.0; extra == "ai-bedrock"
Requires-Dist: pyyaml>=6.0; extra == "ai-bedrock"
Provides-Extra: ai
Requires-Dist: anthropic>=0.115.1; extra == "ai"
Requires-Dist: openai>=2.54.0; extra == "ai"
Requires-Dist: google-generativeai>=0.8.3; extra == "ai"
Requires-Dist: pydantic>=2.0; extra == "ai"
Requires-Dist: pyyaml>=6.0; extra == "ai"
Provides-Extra: penpot
Requires-Dist: requests; extra == "penpot"
Provides-Extra: auth0
Provides-Extra: digitalocean
Requires-Dist: requests; extra == "digitalocean"
Provides-Extra: salesforce
Requires-Dist: pydantic>=2.0; extra == "salesforce"
Provides-Extra: bitbucket
Provides-Extra: sentry
Requires-Dist: pydantic>=2.0; extra == "sentry"
Provides-Extra: all
Requires-Dist: boto3>=1.34.0; extra == "all"
Requires-Dist: PyGithub>=2.2.0; extra == "all"
Requires-Dist: snowflake-connector-python>=3.0.0; extra == "all"
Requires-Dist: google-api-python-client; extra == "all"
Requires-Dist: google-auth; extra == "all"
Requires-Dist: google-cloud-compute; extra == "all"
Requires-Dist: google-cloud-container; extra == "all"
Requires-Dist: google-cloud-functions; extra == "all"
Requires-Dist: google-cloud-iam; extra == "all"
Requires-Dist: google-cloud-kms; extra == "all"
Requires-Dist: google-cloud-logging; extra == "all"
Requires-Dist: google-cloud-resource-manager; extra == "all"
Requires-Dist: playwright>=1.64.1; extra == "all"
Requires-Dist: pydantic>=2.0; extra == "all"
Requires-Dist: requests; extra == "all"
Requires-Dist: anthropic>=0.115.1; extra == "all"
Requires-Dist: openai>=2.54.0; extra == "all"
Requires-Dist: google-generativeai>=0.8.3; extra == "all"
Requires-Dist: pyyaml>=6.0; extra == "all"
Dynamic: license-file

# Calethia SDK

Python SDK for writing compliance policies as code.

## Installation

```bash
pip install "calethia>=0.7.0"
```

For authenticated external API reads, see [External API authentication](docs/external-api.md).

## Quick Start

```python
from calethia import fail, pass_, policy, result, Severity
from calethia.bloomfire import list_posts
from calethia.frameworks import SOC2

@policy(
    id="bloomfire.kb.published_content",
    name="Bloomfire Content Is Published",
    severity=Severity.HIGH,
    frameworks=[SOC2("CC1.4")],
)
def check_published_content():
    """Ensure the applicable knowledge-base posts are published."""
    for post in list_posts():
        if not post.is_published:
            fail(post.to_resource(), "Post is not published")
        else:
            pass_(post.to_resource(), "Post is published")
    return result()
```

## Pass-per-resource contract

Every resource a policy enumerates needs a verdict. Resources returned by a context
fetch method that are never passed, failed or skipped are auto-emitted as
`not_evaluated` findings when `result()` runs, so an enumeration hole is visible
instead of reading as a silent green. When evaluating only a subset is deliberate,
opt out explicitly with `ctx.sampled("why only a subset is evaluated")` — the reason
is recorded in the result metadata, never silent.

## Features

- Decorator-based policy definition
- Type-safe framework control mappings
- Common control framework tagging (`calethia.ccf`) — map a policy once onto a
  framework-neutral control and it counts toward every framework that control satisfies
- AWS context with managed boto3 clients
- Narrative SOC 2 policy documents (`calethia.documents`) — byte-deterministic templates
  that each declare the controls they cover, for the controls a written policy satisfies
- Asset discovery via census policies — enumerate everything a connected provider
  exposes as a signed, timestamped inventory
- Author your own compliance framework (`calethia.frameworks.authoring`): map a
  requirement list onto the CCF spine as typed Python, scaffolded and linted with the
  `calethia framework new | lint | import` command group
- Full IDE autocomplete support

## Common Control Framework

`calethia.ccf` is a framework-neutral spine: engineer-legible controls (`access-mfa`,
`crypto-at-rest`, ...) plus a crosswalk onto the `(framework, control_id)` pairs each
control satisfies. Tag once with `CCF("...")` instead of enumerating frameworks by hand:

```python
from calethia import pass_, policy, result, Severity
from calethia.bloomfire import list_posts
from calethia.ccf import CCF

@policy(
    id="bloomfire.kb.published_content",
    name="Bloomfire Content Is Published",
    severity=Severity.HIGH,
    frameworks=[CCF("access-mfa")],
)
def check_published_content():
    """Tag a facade-first policy with a CCF control."""
    for post in list_posts():
        pass_(post.to_resource(), "Post evaluated")
    return result()
```

An unknown control id raises `ValueError` immediately, exactly like the framework
helpers. The public surface is `CCF`, `get_ccf_controls`, `get_crosswalk`,
`get_ccf_decomposition`, `CCF_DOMAINS`, and `CONTENT_VERSION`. CCF is a spine, not a
compliance framework: it is never selectable and never a reporting target on its own.

## Framework policy packs

First-party policy packs map existing provider policies to compliance frameworks.

- [NIST CSF AWS policy pack](docs/nist-csf-aws-policy-pack.md)
- [GDPR AWS policy pack](docs/gdpr-aws-policy-pack.md)
- [GDPR GitHub policy pack](docs/gdpr-github-policy-pack.md)
- [HIPAA AWS policy pack](docs/hipaa-aws-policy-pack.md)
- [ISO 27001 GitHub policy pack](docs/iso27001-github-policy-pack.md)
- [NIST CSF GitHub policy pack](docs/nist-csf-github-policy-pack.md)
- [PCI-DSS AWS policy pack](docs/pci-dss-aws-policy-pack.md)

## Google Cloud policies

Install GCP dependencies with `pip install 'calethia[gcp]'`. Set
`GOOGLE_APPLICATION_CREDENTIALS` and provide the project ID when you run a policy:

```bash
calethia run examples/gcp_subnet_private_google_access.py --account-id your-project-id
```

GCP service facades collect typed project resources. The built-in policies cover IAM,
Cloud Storage, Compute Engine, VPC, Logging, Monitoring, KMS, Cloud SQL, and GKE.
Missing permissions produce errors. Project checks do not inspect organization policies.
See [GCP integration](https://docs.calethia.ai/integrations/gcp) for permissions and policy IDs.

The [subnet example](examples/gcp_subnet_private_google_access.py),
[bucket example](examples/gcp_bucket_versioning.py), and
[KMS example](examples/gcp_kms_rotation.py) each declare one facade policy.

## Snowflake default policies

The SDK includes 14 Snowflake default policies. See the [policy rules and SOC 2 mappings](docs/snowflake-policies.md).

## PagerDuty default policies

The SDK includes 8 PagerDuty incident-response default policies. See the [policy rules and SOC 2 and ISO 27001 mappings](docs/pagerduty-policies.md).

## Slack default policies

The SDK includes 5 Slack workspace default policies. See the [policy rules and SOC 2 and ISO 27001 mappings](docs/slack-policies.md).

## Jira default policies

The SDK includes 5 Jira default policies in `examples/jira_*.py`. They check anonymous project access, open project administration grants, administrator group size, approval before Done on change workflows, and recent audit records. Each policy maps one SOC 2 control and one ISO 27001 control.

Two cross-provider policies check that each merged GitHub pull request or GitLab merge request links to a Jira issue. See the [Jira change link rules and mappings](docs/jira-change-links.md).

## Intune default policies

The SDK includes 8 Intune device and compliance policies. See the [policy rules, version baselines, and SOC 2 and ISO 27001 mappings](docs/intune-policies.md).

## Entra ID default policies

The SDK includes 11 Microsoft Entra ID policies. Three user policies check MFA registration, stale accounts, and guest access. Four privileged role policies check the Global Administrator count, MFA for role holders, permanent assignments, and PIM use. Three Conditional Access policies check the access control baseline, legacy authentication, and MFA for all users. One application policy checks expiring secrets and certificates. See the [policy rules, parameters, and SOC 2 and ISO 27001 mappings](docs/entra-policies.md).

## Auth0 starter policies

The SDK includes Auth0 tenant MFA, brute-force blocking, and breached-password blocking policies. See the [Auth0 policy rules and parameters](docs/auth0-policies.md).

## Jamf Pro default policies

The SDK includes 4 Jamf Pro computer policies for FileVault encryption, supported macOS versions, screen lock, and management state. See the [policy rules, parameters, and SOC 2 and ISO 27001 mappings](docs/jamf-policies.md).

## Azure Resource Manager reads

The SDK exposes typed [Azure storage, network, Key Vault, role assignment, and Activity Log reads](docs/azure.md). Each read covers every subscription in scope and raises on a failed or incomplete ARM response.

## Rippling lifecycle policies

The SDK exposes typed [Rippling lifecycle models and policy reads](docs/rippling.md). Company-wide workforce reads remain closed while coverage is unknown. Policies can read workers reconciled to the returned user directory through an explicit scoped operation.

## Deel workforce lifecycle reads

The SDK exposes typed [Deel person models and policy reads](docs/deel.md). `list_people()` returns the roster only for a fresh, complete, non-empty collection. Every other collection state raises a provider enumeration error.

## Gusto workforce lifecycle reads

The SDK exposes typed [Gusto employee models and policy reads](docs/gusto.md). `list_employees()` returns the employees only for a fresh, complete, non-empty collection. Every other collection state raises a provider enumeration error.

## Zoom account security reads

The SDK exposes typed [Zoom user, role, and security settings models and policy reads](docs/zoom.md). `list_users()`, `list_roles()`, and `list_role_members()` return data only for a fresh, complete, non-empty population. Every other state raises `ZoomUnavailableError` with a typed reason. A settings property raises the same error when Zoom did not report that field.

## Salesforce security reads

Import `list_users`, `list_permission_assignments`, `list_mfa_methods`, `list_health_check_risks`,
or `list_setup_audit_events` from `calethia.salesforce`. Each read uses the Salesforce organization
bound to the platform policy run. Each resource carries that Organization ID and contract version
`1.0.0`. The setup audit read covers an inclusive 180-day window.

The SDK raises `SalesforceUnavailableError` when it cannot verify a requested population. A complete
query can return an empty list. Findings use identifiers and allowlisted security fields. The public
models omit delegate-user text because the field can contain a name or username.

## Datadog org access reads

The SDK exposes typed [Datadog user, role, and org security settings models and policy reads](docs/datadog.md). `list_users()` and `list_roles()` return data only for a fresh, complete, non-empty population. Every other state raises `DatadogUnavailableError` with a typed reason. A settings property raises the same error when Calethia could not read that SAML setting. The SDK also includes 5 default Datadog access-control policies for MFA, inactive accounts, org management assignment, SAML strict mode, and Okta deprovisioning. See the [default policy pack](docs/datadog.md#default-policy-pack).

## Browser captures

The SDK captures [vendor portal pages with scripted browser steps](docs/browser.md). `BrowserContext.capture()` returns the screenshot, the page text, the final URL, and an action trace, and records the trace as evidence. Every request must reach a declared host and pass the bound destination policy. A failed step, a blocked navigation, or an oversized screenshot raises `BrowserCaptureError`.

The [Penpot WebGL browser AI demo](docs/penpot.md) uses a separate password connection and one typed screenshot interpretation. The rule has no security-framework mapping.

## AI questions

A policy can [ask a model about a screenshot or a text](docs/ai.md). `calethia.ai.ask()` and `calethia.ai.interpret()` read the target into a frozen, typed observation, and the policy code decides pass or fail from its fields. An observation below the confidence threshold records a `needs_review` finding, and a failed call records an `error` finding. A policy declares model use with `@policy(ai=AiRequirement(...))`, and `calethia run` reads the provider key from your environment.

## Narrative policy documents

Not every control is closed by a technical check. `calethia.documents` ships the core
SOC 2 narrative policy documents as byte-deterministic Markdown templates, each of which
declares the `(framework, control_id, aspect_key)` triples it covers, so a generated
document arrives already mapped:

```python
import datetime

from calethia.documents import OrgFacts, get_document_templates, render

template = get_document_templates()["access-control-policy"]
markdown = render(
    template,
    OrgFacts(organization_name="Acme, Inc.", effective_date=datetime.date(2026, 1, 15)),
)
```

`render` is pure: no clock, no environment, no filesystem, no network, no randomness, so
the same inputs produce the same bytes on every machine. The public surface is `render`,
`get_document_templates`, `is_in_coverage_scope`, `format_effective_date`,
`DocumentTemplate`, `OrgFacts`, `ControlMapping`, `ProseSlot`,
`OUT_OF_SCOPE_CONTROL_PREFIXES`, and `DOCUMENT_CONTENT_VERSION`. To author a template of
your own, see [Authoring a narrative policy document template](docs/documents.md).

## Asset discovery (census)

A **census** is a degenerate policy: instead of rendering a pass/fail verdict it enumerates
everything a connected provider exposes and records each resource as `DISCOVERED`. It reuses the
same machine as any other policy — scheduler, executor, provider auth, and evidence signing — so
the inventory it produces is cryptographically signed and timestamped. Because census findings are
non-verdict, they are excluded from every compliance rollup **by kind, not by status**, so a census
passing can never inflate a control's status.

To write one for a provider, see [Writing a census (asset discovery) for a
provider](docs/census.md).

## Resource catalogs

Resource catalogs declare typed provider environments without executing repository code. See
[Resource catalog declarations](docs/resource-catalog.md) for the static-only dialect.
For AWS policies, `@policy(applies_to=...)` filters returned resource models after each normal
context operation. Calethia keeps a complete classification census and stops execution when it
cannot classify a returned resource or read tags required by a matching catalog group.

## Ticketing routes

Declare which Jira project receives each owning team's findings in `policies/ticketing.py`. See
[Ticketing routes](docs/ticketing-routing.md) for the route file format and its lint checks.

## Authoring your own framework

`calethia.frameworks.authoring` lets a GRC engineer declare a compliance framework and
its CCF crosswalk in typed Python, in your own Git repository. The platform never
executes the module: `extract_framework_pack` reads the source statically (AST only) and
returns a frozen pack. The public entry points are `extract_framework_pack`, `Control`,
`CustomFramework`, and `CcfMapping`. The `calethia framework` command group scaffolds a
lint-clean pack, imports one from a CSV of requirements (offline, CSV only), and runs the
identical extractor the platform runs at sync time:

```bash
calethia framework new acme_baseline
calethia framework import requirements.csv --slug acme_baseline
calethia framework lint frameworks/acme_baseline --output text
```

Mutation is a commit, not an API call. For the full field, bounds, and static-only
dialect reference, see the Framework authoring section of the SDK reference.

## Offline verification (`calethia verify`)

`calethia verify` checks an evidence bundle or record on your own machine, with no Calethia
account, no credentials, and no network access. It recomputes every signed digest — including
the per-run population attestation that commits to the full set of resources a run evaluated —
and exits non-zero when a claim does not hold.

For what a passing result proves, and what it deliberately does not, see [Offline evidence
verification and the trust model](docs/verify.md).

## Custom providers

Write your own integration and run it from your laptop against your own system, with no
Calethia account and no platform call. `calethia scaffold provider <name>` emits a complete,
runnable package; `calethia check` lints it offline; the `calethia.testing` fixtures unit-test
it with no network; and `calethia run` evaluates a real policy against your real system using
local credentials.

For the end-to-end loop — scaffold, check, test, and run with the credential-source
precedence — see [Authoring a custom provider](docs/custom-providers.md).

## Google Workspace and Gmail

For typed Google Workspace identity and Gmail policy contexts, including their
platform connector requirements, see [Google Workspace and Gmail](docs/google-workspace.md).
For the versioned default policy pack and its control mappings, see [Google Workspace
default policy pack mappings](docs/google-workspace-policy-pack-mappings.md).

## GitHub review evidence

The SSO and outside-collaborator review policies require signed administrator observations.
See [GitHub review evidence](docs/github-review-evidence.md) for the recording and verification flow.

## GitHub change evidence

Three bundled policies evaluate GitHub change history: merged pull request approvals, Dependabot
alert remediation, and remediation issue tracking. See [GitHub change evidence](docs/github-change-evidence.md)
for the rules, parameters, evidence fields, and required permissions.

## BambooHR-to-Okta access removal SLA

`bamboohr.offboarding.access_removal_sla` is the SDK's first shipped two-provider policy: it
joins the BambooHR terminated-employee population to Okta account state and proves that access
removal met a configured SLA. For the `sla_days` and `termination_timezone` parameters, the
evidence fields, the email/login join rule, and every error outcome, see [BambooHR-to-Okta
access removal SLA](docs/access-removal-sla.md).

## License

Source-available under the [Functional Source License 1.1 with an Apache 2.0 Future
License](LICENSE.md) (FSL-1.1-ALv2). Copyright 2026 Calethia.

In short:

- **You may** read, run, modify, and redistribute this SDK for any purpose except a
  *Competing Use* — reselling it, or shipping it inside a commercial product or service
  that substitutes for Calethia. Internal use at your company, non-commercial education,
  and non-commercial research are all expressly permitted.
- **Your policies are yours.** FSL carries no copyleft or share-alike obligation.
  Importing `calethia` does not encumber the policy code you write against it — keep it,
  relicense it, or take it elsewhere.
- **Every version becomes Apache-2.0** on the second anniversary of its release, so you
  can keep running your compliance checks indefinitely, with or without an account.

FSL is *source-available*, not an OSI-approved open source license. The SDK is provided
**as is**, without warranties, and Calethia's liability is limited — see the Disclaimer
section of [LICENSE.md](LICENSE.md). It assists with compliance verification; it does not
guarantee a passing audit. Third-party dependency licenses are inventoried in
[NOTICE.md](NOTICE.md).

For agent clients, see the [stdio MCP server](docs/mcp.md).
