Skip to main content
The reference client ships in this repo at app/src/main/java/com/onemedical/healthai/ai/AkharaPolicy.kt. It’s built on OkHttp, kotlinx-serialization, and coroutines. See requirements for versions.

Types

Construct the PEP

Always pass your workspace’s baseUrl (https://api.akhara.dev) explicitly. The client attaches Telemetry.sessionId as the session automatically, and the call timeout is 8 seconds.
The in-repo demo build ships with a loopback default for the Android emulator so it can reach a developer’s machine. Production builds must set baseUrl to the managed PDP over HTTPS.

Methods

All are suspend and run on Dispatchers.IO. Call them from a coroutine (e.g. inside a ViewModel’s viewModelScope).

End-to-end example

Permit-gated action

Fail-closed behavior

Any error, non-2xx, or parse failure yields a synthesized BLOCK:
Two known caveats in the shipped client, called out so you can align a production build with the verdict taxonomy:
  1. WARN handling. The PDP returns WARN, but the enum has no WARN member, so PolicyVerdict.valueOf("WARN") throws and trips fail-closed. Add a WARN member (or map WARN → REWRITE) if your attached policies can return it: for example healthcare-0 context-egress rewrites.
  2. Fail-closed policyId. The client cites latch-4, but the canonical Fail-Closed Defaults policy is reliability-4. Align if you rely on the id.