<!-- Security — Heystack docs. Rendered: https://heystack.dev/docs/security · Index: https://heystack.dev/llms.txt -->
# Security

Heystack Security gives an application one place to define, publish, and
investigate AI policy without putting Heystack in front of its model provider.
Provider traffic stays direct. Published policy is cached by the application,
fast deterministic checks run in-process, and an optional model review can run
concurrently with the provider.

Policies are edited in the console under **Settings › App › AI safety**:
rules in plain language, limits, a prompt tester that runs your unsaved draft,
and publish or roll back for each version. Heystack checks each live version's signature against the current signing key exactly as the guard does. A version that can't be verified (never signed, signed under a key that has since been rotated, or altered) is shown as **Not applied**, not Live, and the guard skips it until an admin uses **Publish again**. After a key rotation, publish the organisation policy again first, then each app's policy: an app policy inherits the organisation minimum and can't be published while that minimum can't be verified (the API answers `409 minimum_unavailable`). See
[the console guide](https://heystack.dev/docs/console#ai-safety-policy).

Which releases you have declared, whether runtimes report the policy they loaded
and whether an operator verified a journey are shown on **AI & Safety › Releases**
in the console, one card per policy profile. A declaration is intent and a runtime
report only says a policy was loaded, so the page waits for reports rather than
calling an app protected. Admins declare a release under **Settings › App › AI
safety** (under **Advanced: release declarations** until the app has one; a policy works without declarations). See [the console guide](https://heystack.dev/docs/console#releases).

## What the first release covers

The feature workspace starts with local secret redaction, report-only personal
information and instruction heuristics, and explicit denial when mandatory
checks are unavailable. Your application retains authorization, rights, provider
order, usage limits and billing for all interruptions. Review by a model is
optional (see [Async review](#async-review)); automatic account actions and a
provider proxy are not part of Heystack Security.

Before publishing or rolling back, run the server's persisted release checks.
They bind the saved version and inherited minimums, expire after an hour and
become stale when a policy in that environment changes. This small regression
suite does not establish classifier accuracy or real-client acceptance.

For verification, reconcile a real turn of a feature the release declared, then explicitly
attest to what you saw in the client and to billing for its client build. The turn must
carry receipts for each inspected boundary the feature declares (answer text, speech, model
request, tool, context or voice consent); a feature whose boundaries produce no receipts
cannot be verified. When the verification closes an issue, the turn must also have reported the receipt boundary of the issue's own surface, and its feature must declare that surface. An output issue is not closed by an agent turn that only reported tool and model-request receipts. Input-side issues are proven by a model-request receipt. This applies to a cancelled case too, so cancel after the step the issue is about has happened. Issues on a surface with no receipt boundary yet (model response, batch output) stay open and say so. Admins record verifications on the issue page of a tracked decision. Heystack records who checked the case
and ties it to the release, policy and application evidence. It never labels a
server response closure as proof of playback. A verified false-positive fix must
show an allowed result under the current policy before the linked issue closes.

Enforcement needs `@heystack/guard` 0.2.0 or later, which verifies each policy
against public keys built into the package. Verify a real turn as described above
before relying on it.

## How a live request works

1. Your application refreshes a signed, versioned policy outside the request
   path. The guard package verifies the signature against a key built into the
   package and checks that the policy belongs to your app, environment, and
   profile, has not expired, and is not older than the one it already has. If a
   refresh fails it keeps the last good policy until that expires, then stops
   with an error rather than running unverified rules.
2. It evaluates input, untrusted context, output, rights, or a tool action with
   the local guard package.
3. A local block stops the operation immediately. After a redact or quarantine
   decision, the package returns the replacement `content`; forward that, never
   the original.
4. If enabled, an asynchronous model review starts alongside provider work. It
   can cancel work that is still open and can return a configured account action
   after repeated violations. If the review itself times out or fails, the
   package applies the configured failure posture: `deny` and `safe_fallback`
   cancel the open work; `allow_with_alert` continues with a flagged decision.
5. Metadata-only decisions are linked to the app, policy, release, request, and
   trace in Heystack.

No prompt, transcript, answer, tool arguments, provider credential, audio, or
embedding is stored in a security decision. Raw audio and embeddings are marked
`not_evaluated` unless your application evaluates a derived transcript or other
supported representation.

## Policy profiles

Policies are selected by **app**, **deployment environment**, and **profile**.
A profile is a name you choose for one kind of AI feature, for example `chat`,
`agent`, `background` or `voice` (lower-case letters, digits, `-` and `_`). The
console offers the same list everywhere a profile is chosen (creating a policy,
creating a runtime key, declaring a release), shown by name: **Chat** (a person
talks to a model), **Agent** (a model takes actions or uses tools),
**Background processing** (work with no one waiting) and **Voice** (speech in
and out), plus a custom name. Environments come from one list too:
`production`, `staging` and `development`. A policy or key whose profile is
outside the list still shows, marked as custom. The API
(`POST /api/security/policies`, `POST /api/security/keys`) accepts any valid
name, so the profile your app passes to `@heystack/guard` must match the one on
its policy and runtime key. Each published version is immutable and can be rolled back.
Organization minimums merge with app policy. An app cannot weaken a minimum,
with one deliberate exception: the app's own reviewed
[exceptions](#decision-feedback-and-exceptions) still apply under it. Exceptions
are published per app by an admin, audited, and narrow (one match, tool or
custom rule), so they are the escape hatch for a minimum that is wrong for one
app. A minimum also overrides an app's watch-only mode (see
[Watch-only mode](#watch-only-mode)).

The console editor has two parts:

- **Guided controls:** the four rules (secrets, personal information, prompt
  injection, harmful content) and their actions (flag, redact, hold for review
  or block), what happens when a check can't run, review by a model (three
  settings: what to do when it finds a problem, what to do if the review fails,
  and a minimum confidence), and three limits (requests per minute, characters
  per request and daily spend).
- **In Policy JSON (Advanced):** tool lists (allowed, denied and
  approval-required), streaming behaviour (observe and interrupt, or prevent
  before delivery), the repeat-violation window and threshold, and the account
  recommendation (no action, flag or restrict).

The console lists each policy's versions and supports publish and roll back.

Publishing changes runtime behavior. Saving a draft or running the playground
does not.

How the rules behave:

- Text is normalized before matching, so look-alike letters, full-width
  characters, invisible characters, extra spaces or line breaks, accents, and
  common digit substitutions (`1gnore`) do not slip past a rule. Encoded
  (base64) instructions are checked too. Redaction is applied to the original
  text.
- Input longer than the configured limit, or 200,000 characters when none is
  set, is blocked before any rule runs.
- Tool entries are case-insensitive. `shell` covers every operation of that
  tool; `payments:refund` covers only that operation. Tool or operation names
  containing `:` or `/` are blocked.
- An organization minimum can only make a profile stricter, except that the
  app's own reviewed exceptions still apply under it. Its model-review timeout
  is a floor, and its budget also applies once across all of an app's
  profiles. If a published minimum cannot be verified, the runtime refuses to
  serve policy instead of serving it without the minimum.

## Streaming guarantees

**Observe and interrupt** keeps the first-token path fast. A late decision can
stop the remaining provider request or delivery, but content already delivered
cannot be recalled.

**Prevent before delivery** holds the selected output unit until its configured
checks finish. Use it only where that stronger guarantee is worth the buffering
latency, and measure the application-visible effect.

Heystack never describes a late interruption as prevention.

## Async review

Workers AI Llama Guard is the built-in review option. A private Service Binding
or HTTPS adapter can use another classifier. [TypeSafe models](https://pydantic.dev/docs/ai/models/typesafe/)
and [Jev](https://typesafe.ai/blog/introducing-system-one-models-and-jev) adapters must name an
exact version such as `typesafe:jev-1.13.0`; moving aliases are rejected so a
policy version cannot silently change behavior.

Llama Guard returns a categorical safe/unsafe verdict rather than a calibrated
probability. Its valid verdict is represented as confidence `1`; use a typed
classifier adapter when a measured probability threshold is required.

Async review is probabilistic and can be influenced by adversarial text. Keep
deterministic rules authoritative, set thresholds against a versioned corpus,
and configure the failure posture explicitly.

## Watch-only mode

A policy can run in **watch-only** mode. Every check runs in full and every
decision is recorded, but nothing is blocked, redacted or interrupted: each
check carries `would_action`, the action that would have applied, and the
decision is marked as a shadow decision. Use it to see what a new rule would do
on real traffic before you switch it on. **AI & Safety › Decisions** can show
just the decisions that would have been blocked, quarantined or held for
approval.

An organisation minimum that is not itself watch-only forces enforcement: the
combined policy is served watch-only only when the app's policy and every
minimum that applies to it are watch-only. Otherwise every rule in the combined
policy, the minimum's and the app's, is enforced. **AI & Safety › Safety** shows
such an app policy as enforced, not watch-only.

Watch-only mode belongs to a verified policy. With no verified policy at all
(a cold cache or an expired bundle), your application's own failure posture
applies, as it does today.

Guard 0.2.0 (in-process checks) cannot read the new mode, so it is given a
version of the policy in which every rule only flags. In that version 0.2.0
never blocks **on a policy rule**. Four checks are not policy rules and still
apply: the built-in 200,000-character input limit, the voice rights check, the
error for audio or embedding content sent without its text, and the client's
fail-closed behaviour when it has no verified policy at all. Heystack's own
checks (`/v1/evaluate` and `/v1/review`) honour watch-only mode for every
caller now.

## Decision feedback and exceptions

On any decision, anyone with write access can say **This was fine** or **This
should have been stopped**. Feedback never stores the matched text.

"This was fine" about a specific match drafts an **exception**: a narrow rule
that says "this exact text is allowed for this rule" or "this rule does not
apply to this tool's content". An admin reviews draft exceptions under
**Settings › App › AI safety**, publishes them, and then publishes them with
the policy (see [How exceptions reach your app](#how-exceptions-reach-your-app)).
An admin can also add an exception by typing the allowed text.

- **Exact and case-sensitive.** An exception for `Alice@Example.com` does not
  cover `alice@example.com`. Heystack first normalises the text the way the
  guard does (look-alike letters, invisible characters and repeated spaces are
  tidied, and leading and trailing spaces removed), but it keeps upper and
  lower case. A missed exception leaves the rule in force, which is the safe
  side.
- **No text is stored.** Typed text is turned into a one-way fingerprint salted
  with your organisation's id, and only the fingerprint is kept and shipped in
  the policy. A fingerprint of a short or guessable value is pseudonymous, not
  anonymous, so read keys never see fingerprints.
- **What an exception can cover:** the secrets, personal data, prompt injection
  and harmful content rules, and your custom rules. Never the model review, the
  input size limit, tool permissions or the spend limit.
- **Expiry.** An exception can expire; an expired exception is left out of the
  next policy version. An app can have at most 200 published exceptions.

Heystack's own checks honour published exceptions now. In-process checks
honour them with **`@heystack/guard` 0.3.0**: guard 0.2.0 keeps acting on a
match an exception would have let through, exactly as before the exception
existed.

## Custom rules

Add your own rules under **Settings › App › AI safety**, at most 50 per app:

| Kind | What it matches | Actions |
|---|---|---|
| Keyword | Up to 100 words or phrases, each up to 128 characters, matched as whole words regardless of case, in the prompt, the answer or both | flag, redact, quarantine, block |
| Pattern | Text that equals, starts with, ends with or contains one value of up to 256 characters | flag, redact, quarantine, block |
| Topic | Up to 20 topic labels (for example "medical advice"), each up to 64 characters, read only by the model review | flag, quarantine, block |

Patterns are deliberately simple: there are **no regular expressions**, so a
rule can never slow your app down. A request that includes one is refused.

Heystack's own checks apply custom rules now. In-process checks apply them with
**`@heystack/guard` 0.3.0**; the console marks them "needs @heystack/guard
0.3.0" until then.

## Explanations

A policy can ask for explanations. Each matching check then says which rule
matched, a category from a fixed list (for example `email_address` or
`aws_access_key`), how many matches there were, where they were in the text,
which exception let a match through, and the match's fingerprint (for drafting
an exception). An explanation never contains the matched text, and read keys
never receive fingerprints. Explanations from in-process checks are available
with **`@heystack/guard` 0.3.0**.

## How exceptions reach your app

Exceptions, custom rules, watch-only mode, explanations and the spend limit
rule are part of the policy itself. When you change them, the console builds a
new draft policy version from the latest one, adds the published, unexpired
exceptions and the enabled custom rules, and you publish it the usual way
(check the release, then publish). A policy that uses none of these features is
left exactly as it was.

Apps on `@heystack/guard` 0.2.0 keep receiving a version of the same policy
they understand, so publishing never breaks them. Because an older process
cannot run the new features, the console offers watch-only mode, exceptions,
custom rules and explanations for an app only once **every process that
reported to Heystack in the last 24 hours runs `@heystack/guard` 0.3.0**, and
says which older version is still reporting when it does not. An app whose
processes have not reported in the last 24 hours is shown as unknown, not as
ready.

## What we can see without a policy

Apps with no safety policy (and no guard installed) still get a security
picture from the AI activity Heystack already receives. **AI & Safety ›
Safety** shows how often each of these happened over the last 7 or 30 days,
with one example to open:

| Pattern | What it means | Needs prompt text |
|---|---|---|
| Secrets in prompts or answers | An API key, token or password shape | Yes |
| Personal data in prompts or answers | Email addresses, phone numbers, card numbers and similar | Yes |
| Prompt injection patterns | Text that tries to override the model's instructions | Yes |
| Many AI calls by one user in an hour | More than 120 calls by one user within a short burst | No |
| Very large inputs | More than 32,000 input tokens in one call | No |
| AI calls stuck in a loop | One request making more than 25 AI calls | No |

The three content patterns use the same detectors as the guard, over the first
16 KB of each prompt and answer. They run only when content scanning is
switched on for Heystack and your organisation's AI processing switch allows
it, and only on text your app sends (an app whose AI content capture is off
gets the three content-free patterns only). The page says whether content
scanning is on. Until Heystack switches on counting these patterns, every one of them
reads **Not checked** (never a count of zero) and no one is listed.

The page also lists the users who triggered these patterns most (up to 50),
with their AI cost. Names are shown only where your app's privacy settings
allow it; read keys never see names. Posture counts are readable by every
member; repository security findings stay admin-only.

These are observations, not protection: nothing is blocked until you add a
policy.

## OWASP LLM Top 10 scorecard

**AI & Safety › Safety** also scores the app against the
[OWASP Top 10 for LLM Applications (2025)](https://genai.owasp.org/llm-top-10/).
Each item is **covered**, **partly covered**, **not covered** or **unknown**,
and shows the evidence it was scored from: the app's published policy and its
mode, whether a guard process has reported in the last 24 hours, the patterns
above, whether AI content is captured, and your AI spend budgets.

- An item Heystack has no signal for is **unknown**, never covered. Supply
  chain, data and model poisoning, and vector and embedding weaknesses are
  always unknown today, because Heystack does not see them.
- Patterns seen in telemetry can make an item partly covered at most: seeing a
  problem is not stopping it.
- Covered needs a policy rule that is on, in enforce mode, with a guard process
  that has reported recently. Watch-only mode keeps an item at partly covered.
- Improper output handling, system prompt leakage and misinformation are at
  most partly covered, because Heystack cannot see how your app uses an answer.

## Where problems show up

Runtime problems appear in Issues under the Security source: one person tripping rules again and again (repeat offender), a sudden rise in blocked prompts (block spike), and a rule that starts matching for the first time, at least 5 times in the window and never before (new kind of risky prompt). A burst that begins right after you publish a new policy version is not called new, because the new policy explains it.

These signals cannot be marked resolved or ignored by hand: each one leaves Issues when it stops, so a closed signal always means the behaviour really stopped. You can still assign one or snooze it. A security decision you choose to track (from the decision page, with write access) becomes an issue of its own (subtype tracked), visible to everyone on the team, and it closes only when an operator's journey verification has been recorded against the policy that is active now. If you publish or roll back any policy in that environment afterwards (any app or profile, not only the one it was verified against), the earlier verification no longer counts and every tracked issue in that environment opens again until it is verified again.

If the app has a connected GitHub repository and App Care is on, organization admins also see the repository's open dependency, code scanning and secret scanning findings there, refreshed daily. Findings are visible to admins only. A finding closes only when a complete scan no longer lists it; if scans stop or fail, the finding's own page marks its state as unknown (the list keeps showing it as open, without that marker). A finding that disappears from GitHub's open list is shown as "GitHub no longer lists this as open", not as confirmed fixed, because it may have been dismissed there.

## Credentials and privacy

Security runtime keys begin with `hg_live_`. They are separate from telemetry
ingest keys and API/read credentials, stored hashed, and restricted to one app,
environment, and profile set. Admins create and revoke them under
**Settings › App › AI safety › Runtime keys**, next to the policy they fetch.
The full key is shown once.

Signing in to Heystack itself is handled by Heystack's own sign-in service
(`auth.heystack.dev`; it replaces Clerk, and both are accepted while the move
completes). Console sessions and MCP connections receive short-lived signed
tokens that the API checks locally against the service's published keys. Your
role is read from your workspace membership on every request, never from the
token, and removing someone from a workspace revokes their personal access
tokens. See [API authentication](https://heystack.dev/docs/api#authentication).

A Google or GitHub sign-in joins an existing Heystack account only when Google
or GitHub confirms it has verified that email address, and only when the
Heystack account's own address was verified too. Changing your sign-in email
takes two confirmations: a link to your current address, then a link to the
new one; the new address is used only after it has been opened. You can't
delete your account while you're the only member of a workspace (delete the
workspace first, so its data and keys don't outlive everyone who could manage
them) or its only admin while others remain (make someone else an admin first).

Prompt and completion text in your app's telemetry is separate from security
decisions. `@heystack/otel` doesn't send it unless you turn that on; as a second
fence, an admin can set **Prompt and completion text** to drop under
**Settings › App › Data & privacy**, and Heystack removes it as data arrives,
before anything is stored (model names, token counts and timings are kept).
**Visitor address and location** works the same way for IP addresses and the
location worked out from them. See [the console guide](https://heystack.dev/docs/console#settings).

Decision records contain the decision and correlation metadata, rule results,
policy version and exact effective checksum, latency, review phase, repeat count, and recommended account
action. Content capture is off by default.

You review decisions in the console under **AI & Safety › Safety**: a summary
(enforced blocks are counted separately from shadow-mode matches), a filterable
list, a page for each decision and a plain-language view of the active policy.
See [the console guide](https://heystack.dev/docs/console#safety-decisions-and-policy).

### What a read key never sees about people

A read key (`hs_read_…`) sees **ids only**:

- No names, emails, avatars, plans or account names, whatever the app's name setting. `GET /api/profiles` refuses a read
  key (`403 read_key_not_allowed`), and people pages answer it without the `profiles` map.
- No traits an app sent with `identify()` or `group()` (`heystack.traits.*`, `heystack.account.traits.*`), no
  profile attributes (`heystack.user.*`, `user.*`, `enduser.*` other than the ids), and no feedback comments
  (`heystack.feedback.comment`, the score comment on AI scores). These keys are removed from every row a read key reads.
- The people store itself is not reachable from `POST /api/query/sql`.

### The names boundary

- **Names** (display name, avatar, plan, account name) reach your team only when the app's "Show people's names" setting
  is on. It is off by default and only an organisation admin can change it.
- **Emails** reach organisation admins only (an `org:admin` holding the `admin` scope). Members, read-only tokens and
  read-only viewers never see an email, even with names on.
- **SDK traits** are stored only when the app's "Accept traits sent by the SDK" setting is on (default off), and only
  the traits the app allows (`identity.allowed_traits`, by default name, email and plan); Heystack drops the others again
  when they arrive, whatever the SDK sent. They are stored only in the person's profile, so the names boundary above
  applies to them: the raw `identify` record keeps no trait. With the setting off, `identify()` still links the device to
  the person, but every trait is dropped before it is stored.

### Erasing a person

An organisation admin can erase one person from an app (Settings › App › Privacy, `DELETE /api/apps/{id}/users/{userId}`
or the `heystack_erase_user` MCP tool). Heystack:

- keeps only a one-way fingerprint of the user id, never the id itself, so it can recognise new data about them;
- hides the person everywhere at once: people lists, the person page, visits, accounts, name search and name lookups;
- drops new data naming them as it arrives: traces, logs, metrics, session replays (nothing reaches storage), identify
  calls and links, AI calls routed to the app through an AI gateway app, and people-data imports (a Stripe customer
  matched to them, or carrying their email, is no longer imported). Security decisions are still recorded, without
  their user id;
- removes their stored profile (names, email, plan) from every source, including the people data connectors;
- deletes any export file made for them and closes its download.

Data already stored is not rewritten: activity keeps their id, without a name, outside the people views (for example in
Explore or a trace) until it ages out with normal retention (30 days; security records 90 days). If the list of erased people for an app grows past 20,000, Heystack drops every new record
that names any person in that app until the list is reviewed (it fails closed, never open).

### Exporting a person's data

An organisation admin can export everything Heystack holds about one person in an app as a JSON Lines file: their merged
profile from each source, their linked devices, up to 5,000 product events from the last 30 days and a summary of
the last 7 days of activity. Two exports per organisation per day; each file is kept for 7 days and then deleted. An
erased person cannot be exported, and erasing a person deletes their earlier export files.

### People data connectors

Connecting Clerk, Stripe or Supabase ([People data](https://heystack.dev/docs/connectors)) adds no subprocessor: Heystack calls the
provider's API with your own read key and keeps the data in Heystack. Keys and webhook secrets are encrypted at rest
(AES-GCM, bound to the organisation, app and connection) and are never returned by the API. Each connection has its own
webhook address (a random token, stored hashed) and its own signing secret; signatures are checked before the body is
parsed, and webhook bodies are never logged or stored. Calls go only to `api.clerk.com`, `api.stripe.com` and
`<ref>.supabase.co` (public addresses only). Heystack stores no amounts, card details or addresses. Email matching uses
app-scoped hashes, not addresses. Names stay hidden until an admin confirms the connection (per-app opt-in); emails are
shown to admins only; read keys never see either. Each app holds at most 200,000 imported profiles across all its
connections and the bulk profile API.

### What autocapture may collect (SDK 0.20.0, off by default)

Autocapture is off for every app until an admin switches it on. When on, it records which element was used, never what
was typed or shown: no element text, no input values, no page HTML, and only the attributes `data-hs-name`, `id`,
`name`, `role` and `type` (an admin can narrow this list, never widen it). Password fields and anything inside a
`data-hs-block` or `data-hs-mask` region produce no event. URLs are redacted, fragments are never sent, and a query
parameter is kept only when the admin allowed it by name; credentials-like names (`token`, `code`, `password`,
`session`, …) are never kept. Ingest enforces all of this again on arrival and drops values that look like an email
address, a phone number, a long number or an opaque token.

Kill switches in Settings › App › Data stop a capability in every SDK at its next config refresh and stay in force on
devices that were offline.

### AI processing switch

Heystack's own AI features run on models hosted by our infrastructure provider (see the
[subprocessor list](https://heystack.dev/subprocessors)); your data is never sent to a third-party
AI provider. An admin can turn them off for the whole organisation in **Settings › Organisation ›
Privacy & AI processing**. While it's off, explaining a request, AI-written answers in Ask, an
issue's written story and suggested fix, and a repair Heystack writes in your repository are
refused (`403 ai_processing_disabled`), and automatic investigations and incident summaries return
their evidence without an AI-written summary. It doesn't change the model review in your safety
rules, which runs only for the rules you set up to use it, or what a coding agent you connect asks
for (plain-English search, investigation summaries).

### What a shared investigation contains

Where public links are offered and the organisation allows them, anyone who can edit an
investigation can share a read-only link that expires within 1–30 days and can be revoked at once.
The link opens a frozen copy taken when it was created: title, question, summary, possible causes
and steps. It holds only what a read key could see, so visitor addresses and locations, end-user
profile fields and AI prompt and response text are left out, and so are member ids, app and issue
ids, repository details and links into the console. Opening it never queries your data, isn't
indexed by search engines, and stops working when the organisation turns public links off. See
[the API reference](https://heystack.dev/docs/api#sharing-an-investigation).

## Runtime endpoints

The language-neutral contract is available in the Heystack security OpenAPI
specification. The runtime exposes:

- `GET https://guard.heystack.dev/v1/policy` for a signed effective policy;
- `POST https://guard.heystack.dev/v1/evaluate` for remote deterministic
  evaluation on non-latency-sensitive paths; and
- `POST https://guard.heystack.dev/v1/review` for optional concurrent model
  review and repeat-violation counting (limited per runtime key; `429` when
  exceeded); and
- `GET https://guard.heystack.dev/v1/spend` for the app's spend state from
  enforced AI budgets (`ok`, `warn` or `exceeded`), about a minute behind.

A guard that sends `X-Heystack-Guard: <version>; contract=5` receives the full
policy (watch-only mode, explanations, exceptions, custom rules and the spend
limit); any other caller receives a projection it can enforce safely. See
[the API reference](https://heystack.dev/docs/api#guard-runtime-contract-5).

For live LLM paths, fetch policy ahead of the turn and run deterministic checks
locally. Do not await `/v1/review` before starting the provider.

## What remains your application's responsibility

Your application owns the exact request boundary, source-trust labels, provider
abort controller, already-delivered bytes, billing/refunds, and any account
mutation. A Heystack `flag` or `restrict` result is an idempotent recommendation;
your product applies it under its own support and recovery rules. Existing voice
consent or authorization records remain the authority for voice rights.


## Verified runtime policy contract

Policy bundles are verified with a public key and scoped to organization, app,
environment and feature profile. Applications load a signed policy and refresh it
outside the model request path. Local checks reject unverified or expired
snapshots. Policy rollback advances the activation generation while restoring an
older configuration. A loaded policy is not by itself proof of active protection;
verify a real turn as described above.

The runtime contract separates completed review results from audit
storage availability. `audit_status: scheduled` means an audit write is queued for
background delivery, not that it is persisted. An unavailable repeat counter
cannot justify an account restriction or hide the content verdict. Review results
alone do not prove a block or interruption was applied by your application.

The SDK's synchronous `prepareLocal` is a boundary gate, and the SDK creates
explicit application receipts. Use only the gate's returned content, which applies
required redaction; a deny, quarantine or approval requirement stops that boundary.
Receipt creation happens after the application observes the action and records
whether nothing, part, all, or an unknown amount was already delivered. Persist
critical receipts in the application's durable action transaction and retry
through an outbox. The outbox is part of your application; Heystack does not
provide one.

The receipt API (`submitReceipt` and `submitReceipts`, which post to
`/v1/receipts` and `/v1/receipts/batch`) accepts reports from an
application-owned durable outbox. A successful submit acknowledges queue
acceptance, not a confirmed analytics read. Retries preserve receipt identity and
payload; a conflicting report remains visible evidence instead of overwriting the
earlier claim. Receipt ingestion does not execute billing or account actions.
Heystack keeps a scoped, deduplicated read model of receipts and shows them in the
console, which distinguishes failed reads from missing evidence and marks
conflicts and identity mismatches without claiming successful prevention. Reports
remain application assertions.

## Investigating in the console

Overview prioritizes up to three next steps from the latest 100 review events in
24 hours across all environments. Unavailable evidence comes first, followed by
failed reviews and requested restrictions. An empty sample is not proof of
protection, and a requested restriction is not confirmation that the app blocked
or redacted delivery.

Selecting a review priority opens Activity with that decision's environment and
release, clearing conflicting review filters. An unambiguous decision with an
explicit environment opens its evidence directly. Links without an environment
leave selection to you. If the review is unavailable, check its scope and time
window; retention and late reports can change the results. App receipts and the
correlated trace are separate evidence of what the application reported.

### Execution evidence helpers

The SDK includes local metadata validation and receipt reconciliation through
`parseExecutionReport`, `executionReceiptSetDigest` and
`assessExecutionReceipts`. Run reconciliation outside inference. Unfinished
executions stay unknown; missing, duplicate or mismatched evidence stays
incomplete. An exact nonempty receipt set is recorded evidence, not a protection
claim. The application still owns durable storage, authenticated reporting and
verification of the actual boundary action. These local helpers do not populate console coverage rates.

For stored lifecycle evidence, `executionReportDigest` fingerprints a report and
`reconcileExecutionReports` verifies its stored fingerprint, explicit scope and
matching start/terminal pair. It tolerates exact retries and arrival order, while
preserving conflicts, missing starts and corrupt evidence. A reconciled terminal
still needs receipt reconciliation; it is not a completed protection check.

Not available yet: a console view of execution coverage across a deployment.

Call `guard.submitExecution(report, options)` from a durable background outbox to
submit start/terminal metadata to `POST /v1/executions`. The endpoint requires a
runtime key scoped to the tenant, app, environment and profile. Maximum request
size is 8 KiB; reports use their original start time within the 90-day retention
window. Status 202 confirms queue acceptance only. Preserve the exact report on
failure and retry outside inference; do not wait for export before provider work.
Analytics read-back, sender health and actual boundary verification remain
separate requirements. See the runtime OpenAPI contract for all validation limits.

For a known turn, `GET /api/security/executions` reads scoped lifecycle and receipt
evidence using control-plane read authorization. Supply app, environment and turn;
the default window is seven days. Missing reports remain unknown. Missing starts,
conflicts, corruption or capped results remain incomplete. Recorded means the
reported receipt set is present within that window, not that every application
path is protected. Late reports and retention can change the result; failed reads
return an error.

In a receipt investigation, choose **Check turn evidence** to inspect that turn's
start, terminal report and receipt completeness. This is available only when the
receipt matches the selected decision without conflicts. The panel explains
missing or conflicting reports and shows expected, validated, dropped and invalid
receipt counts. Use manual refresh for delayed reports or retry after a failed
read. Scope and time window stay visible in the details. Recorded evidence is not
proof of protection or playback, and a deployment-wide coverage view is not available yet.
