Compliance report API
The compliance report API exports a per-tenant governance metric set as a CSV file. It aggregates data the gateway already stores — request log, control-plane audit log, and per-request billing/residency legs — into a fixed set of mechanical counts over a time window. It is the reporting surface for the KI-Governance metric layer.
The figures are neutral mechanical counts. This endpoint makes no legal or certification claim; the metric labels describe what was counted, not a compliance verdict.
Base URL: https://<your-gateway-host>/admin/v1
GET /compliance/report
Machine access: a token scoped exactly
["admin_read"]may call this route withAuthorization: Bearer(details).
Returns the metric set for one tenant as a CSV attachment (Content-Type: text/csv; charset=utf-8, Content-Disposition: attachment; filename="compliance-report.csv").
Required role: admin, tenant_admin, or ki_manager.
The metric section is a pure tenant aggregate — it contains no per-user or natural-person identifiers. The live report additionally carries an agent-version register (agent id, name, purpose text, purpose status); that is tenant configuration, not user data. A ki_manager reads their own tenant's report (unlike the per-user analytics endpoints, no group-scoping applies).
curl 'https://<your-gateway-host>/admin/v1/compliance/report?from=1767225600&to=1798761600' \
-o compliance-report.csv
Tenant scope
Tenant scope is decided server-side; the client value never widens it.
| Caller | Scope |
|---|---|
admin |
Must target one tenant with ?tenant_id=<id>. |
tenant_admin / ki_manager |
Always their own tenant. A ?tenant_id naming another tenant is ignored (pinned to the caller's own). |
This endpoint is inherently per-tenant: there is no global/all-tenant variant. An admin who omits ?tenant_id is rejected 400 { "error": "tenant_id required", "code": "tenant_id_required" } (the query never runs). A non-admin whose account carries no tenant is refused 403 { "error": "forbidden" }.
Query parameters
A query string carrying more than 100 parameters is refused 400 { "error": "too many query parameters", "code": "too_many_params" } (a bound cut off by the cap must not read as absent).
| Parameter | Accepted | Rejected |
|---|---|---|
tenant_id |
A single tenant id string (admin only; ignored for other roles). |
A repeated (?tenant_id=a&tenant_id=b) or valueless (?tenant_id) parameter → 400 { "error": "tenant_id must be a single value", "code": "bad_param" }; for an admin, a value that is not one canonical tenant UUID → 400 { "error": "tenant_id must be a tenant id", "code": "bad_param" }. |
from, to |
Both absent (the default window applies), or a pair of unix-second integers written in plain digits (at most 15) with from < to. A window that ends in the future is a valid query. |
Every rejection is 400 with "code": "bad_param": a bound that is empty (from=), repeated, valueless, negative, fractional, in exponent form (1e3) or otherwise not plain digits; a lone from or to → { "error": "from and to must be given together" } (it used to be ignored, silently reporting the wrong period); from >= to → { "error": "from must be < to" }. |
Default window: the last 30 days. Maximum window: the span is clamped to 366 days (a wider request keeps its to and moves from forward to the cap) so a single synchronous request cannot scan an unbounded range.
Bad input is rejected at the boundary before any database work; a storage failure (a failed read) returns 503 { "error": "temporarily unavailable; retry later" } (retry; never a partial CSV, never the database's own text).
Read source
The metrics are read from MySQL by default. With the setting request_log_read_source_compliance set to "clickhouse", they are read from ClickHouse when the coverage check agrees with MySQL, and from MySQL otherwise. With the area on, an empty settled window (no traffic yet in the guard window, for example a new tenant or a window younger than the 5 minute settle grace) is also answered by MySQL and labelled mysql_fallback, the same as the other ClickHouse-backed areas.
- The response carries the header
X-Read-Source:mysql,clickhouseormysql_fallback. The header is listed inAccess-Control-Expose-Headers(next toContent-Disposition) so the cross-origin SPA can read it. - A store error is never rendered as zeros: a failed read is
503(see above), never a report of empty figures. - The buckets are byte-exact between the two stores, so switching the source changes no figure. For that reason the switch did not change
definitions_version: the definitions did not change, only where the rows are read from. - The anonymisation check compares the personal aggregates (detectors fired) of both stores; any difference is answered by MySQL.
- The monthly snapshot job always reads MySQL.
CSV shape
A long-format metric,value table: a header row, six self-describing context rows, one row per metric, twelve crosswalk rows, then the agent-version register.
metric,value
tenant_id,acme
period_from,2026-06-18T00:00:00Z
period_to,2026-07-18T00:00:00Z
generated_at,2026-07-18T09:41:07Z
definitions_version,3
residency_basis,approximate
requests_total,48213
requests_redacted,192
requests_detector_hit,204
requests_blocked,57
blocked_rate_limit,4
blocked_budget_quota,2
blocked_pii_gate,9
blocked_ip_allowlist,1
blocked_plan_model,3
blocked_guardrail,38
auth_failures,11
residency_eu,47010
residency_non_eu,20
residency_unknown,6
residency_no_dispatch,120
crosswalk.blocked_guardrail.owasp,"LLM01, LLM02, LLM05, LLM06"
crosswalk.blocked_guardrail.atlas,"AML.T0048, AML.T0051, AML.T0053, AML.T0054, AML.T0057"
crosswalk.blocked_pii_gate.owasp,LLM02
crosswalk.blocked_pii_gate.atlas,AML.T0057
…
crosswalk.blocked_plan_model.owasp,—
crosswalk.blocked_plan_model.atlas,—
agent_versions_truncated,false
…
period_from / period_to are the ISO-8601 UTC window bounds; generated_at is the report instant. definitions_version names the version of the metric definitions the counts were computed with (see Definitions versions). CSV cells are RFC-4180 framed (CRLF) and formula-injection-armored.
residency_basis qualifies the four residency_* rows below:
| Value | Meaning |
|---|---|
authoritative |
Every request in the window carried a resolved dispatch-time residency zone (residency_unknown is 0) and the whole period is at/after dispatch-time residency recording went live. The residency breakdown is complete dispatch evidence. |
approximate |
Some requests carry an unresolved zone, or the period starts before dispatch-time residency recording was complete (legs recorded earlier have no zone and fold to residency_no_dispatch, not unknown, so a clean-looking unknown=0 alone does not prove coverage). The residency breakdown is a best-effort approximation, not authoritative evidence. |
The go-live instant is an operator setting configured by Myra for your deployment. Until it is declared, every report is approximate — the gateway never presents residency figures as authoritative that it cannot vouch for.
Agent-version register
The live report (this endpoint) appends one register section after the metric rows: for every agent version created up to the end of the period, the agent's stated purpose and whether it is confirmed. Each version contributes three rows, keyed by agent id and version number:
agent_versions_truncated,false
agent_version.<agent_id>.v1.name,Contract summariser
agent_version.<agent_id>.v1.purpose,Summarise supplier contracts for the legal team
agent_version.<agent_id>.v1.purpose_status,confirmed
purpose_status |
Meaning |
|---|---|
confirmed |
The purpose was confirmed by a person. |
unconfirmed |
A purpose is recorded but not confirmed. |
unrecorded |
The version predates purpose recording (no value stored); the purpose cell is empty. |
unreadable |
The stored status is not one the gateway recognises; it is never presented as confirmed. |
Rules:
- Window. The metric rows cover
from <= ts < to. The register is a point-in-time listing: it includes versions withcreated_at <= floor(to)(unix seconds, inclusive period end) and has no lower bound, because a version created before the period still describes the agent in force. - Current agents only. Versions are deleted with their agent, so the register reflects agents that currently exist.
- Truncation. At most the first 2000 versions are listed, ordered by agent id then version. Truncation keeps the first 2000 rows in that order, so whole later agents are dropped, not just their later versions.
agent_versions_truncatedistruewhen more than 2000 versions exist in the window; narrow the period or read the remainder through the agents API. - Stored snapshots stay metric-only. Reports downloaded from the stored-report endpoints carry the frozen metrics and no register.
- Escaping. Names and purposes are free text and are RFC-4180 framed and formula-injection-armored like every other cell.
- Visibility. Readable by the same roles as the rest of the report (
admin,tenant_admin,ki_manager), scoped to the resolved tenant.
Metric definitions
All counts are scoped to the resolved tenant and the [period_from, period_to) window.
Request activity (from the request log):
| Metric | Definition |
|---|---|
requests_total |
All logged requests. |
requests_redacted |
Requests where PII redaction was applied (scrub_applied). This is an independent signal, not disjoint from requests_blocked (a request can be redacted and then blocked), and it differs from the dashboard's exclusive "scrubbed" bucket (which excludes blocked requests). |
requests_detector_hit |
Requests where at least one guardrail detector fired (non-empty detector list). |
requests_blocked |
Requests blocked before completion. |
Blocked-reason breakdown — these six buckets partition requests_blocked (they sum to it exactly):
| Metric | Definition |
|---|---|
blocked_rate_limit |
Blocked by a rate limit. |
blocked_budget_quota |
Blocked by a budget / quota / subscription limit or a missing entitlement — including a free trial's wallet credit running out, an expired trial, a member's personal budget or a team's budget used up, the allowance for Myra-managed models, the demo prompt allowance, and a Myra-hosted model requested without the EU-Gov add-on. |
blocked_pii_gate |
Blocked by the mandatory PII-residency gate (protection required / unmaskable media), or refused because a PII masking detector (custom_pii, pii_protector, presidio) or the PII scan of stored content or tool labels could not run (the request log marks it meta.pii_guardrail_failure; the same requests are PII_BLOCK in your SIEM). A PII detector that ran and returned a block verdict is counted under blocked_guardrail, not here. A refusal whose reason is a rate limit, IP allowlist, budget or model block keeps that bucket. |
blocked_ip_allowlist |
Blocked by the IP allowlist. |
blocked_plan_model |
Blocked because the model is outside the plan's allowlist. |
blocked_guardrail |
Every other block — guardrail/detector verdicts (including PII detectors that ran), the outage refusal of a detector that is not a PII masking detector, and the workspace's own policy blocks (a model restricted by role, by the local-model rule or by a tenant-wide model block, a disabled gateway, a sub-processor objection, media that cannot be scanned for classified markings, a non-local model refused in a Local only project or on a spoken turn — local_model_required, a Local only turn that could not be kept inside Myra infrastructure — local_only_egress; both also for a refused conversation summary or raw file upload of such a project). Computed as the residual so the six buckets always sum to requests_blocked. |
OWASP-LLM / MITRE-ATLAS crosswalk
The report also carries a static crosswalk mapping each blocked-reason category to the
OWASP Top 10 for LLM Applications
and MITRE ATLAS technique IDs. It is a reference/taxonomy layer — no
new detection — for governance and SIEM correlation. In the CSV it appears as
crosswalk.<category>.owasp / crosswalk.<category>.atlas rows; in the Markdown/PDF export as an
"OWASP-LLM / MITRE-ATLAS crosswalk" table. The exported cells carry the ids only (e.g.
LLM02 / AML.T0057 for the PII gate); the table below is the legend that names them. The
crosswalk is a reference table: every download — the live report and a stored monthly snapshot
alike — renders it from the current taxonomy at download time; it is not part of a snapshot's frozen
metrics.
| Blocked reason | OWASP-LLM Top 10 | MITRE ATLAS |
|---|---|---|
| Guardrail / detector verdict | LLM01 (Prompt Injection), LLM02 (Sensitive Information Disclosure), LLM05 (Improper Output Handling), LLM06 (Excessive Agency) | AML.T0048, AML.T0051, AML.T0053, AML.T0054, AML.T0057 |
| PII gate | LLM02 (Sensitive Information Disclosure) | AML.T0057 |
| Rate limit | LLM10 (Unbounded Consumption) | AML.T0034 |
| Budget / quota | LLM10 (Unbounded Consumption) | AML.T0034 |
| IP allowlist | — (operational access control, no LLM threat class) | — |
| Plan model allowlist | — (operational entitlement, no LLM threat class) | — |
For metrics computed with definitions version 2 or later, a category's tags are the union of the threat classes of the refusals it can contain; a category may also contain refusals that carry no threat class at all — the EU-Gov entitlement refusal in Budget / quota, a refusal because a PII masking detector could not run in PII gate (no detection happened, so it is not tagged), the workspace's own policy blocks (role / local-model restriction, sub-processor objection) in Guardrail / detector verdict. Those requests are not tagged individually (below), so a category's blocked count can exceed the number of tagged events of its classes. Conversely, an individual blocked request's own tags (below) can also include the class of another signal it carried — for example egress exfiltration (AML.T0024) on a blocked tool-loop turn — which its category's row does not list.
The SIEM feed classifies the EU-Gov entitlement refusal as a model block (MODEL_BLOCKED), not
as a quota event: matching Budget / quota against QUOTA_EXCEEDED SIEM events therefore leaves
the EU-Gov refusals as the difference.
Per-request tagging. Beyond the aggregate report, each request carrying a classified signal
carries the same taxonomy on its request-log entry (meta.threat_taxonomy = { owasp: […],
atlas: […] }) and on the SIEM CEF record (extension fields flexString1 = owasp_llm, flexString2 = atlas; the
JSON SIEM formats carry it under meta.threat_taxonomy). The per-request map is derived from the
reliable verdict signals (PII-gate reasons, resource limits, egress-exfil kind, the content-
safety S-code list, and indirect prompt-injection detected over tool/RAG/MCP results → LLM01 /
AML.T0051) plus a best-effort match on default-named detectors; a renamed detector is
left untagged rather than mis-tagged. Categories with no LLM threat class (IP allowlist, plan
allowlist, control-unavailable) are intentionally not tagged.
Security events (from the control-plane audit log):
| Metric | Definition |
|---|---|
auth_failures |
Tenant-attributable authentication / authorization / SSO failures (status ≥ 400): failed or blocked OTP attempts, denied access (403), and failed/replayed SSO/SAML logins. Successful logins are excluded. Failures that cannot be attributed to a tenant (e.g. an OTP attempt for an unknown account) are not counted. |
Data residency (from the per-request dispatch legs, folded worst-case per request):
Each request is classified by the worst residency zone across its dispatch legs: any non-EU leg ⇒ non_eu; otherwise any unprovable leg ⇒ unknown; otherwise any EU-vouched leg ⇒ eu; a request whose legs carry no zone ⇒ no_dispatch.
| Metric | Definition |
|---|---|
residency_eu |
Requests whose model dispatch was positively EU-vouched at dispatch time. A mechanical dispatch fact — not a legal EU-residency certification. |
residency_non_eu |
Requests with at least one positively non-EU dispatch leg. |
residency_unknown |
Requests with at least one leg whose residency was unprovable at dispatch (e.g. variable-routing providers). |
residency_no_dispatch |
Requests whose legs carry no residency zone: sidecar/guardrail-only legs, or legs recorded before residency logging was enabled. |
The residency counts are over dispatched requests (those with at least one leg), which is generally fewer than requests_total (a request blocked before dispatch, or served from cache, has no dispatch leg).
Definitions versions
Every report carries definitions_version (CSV row; "Definitions version" in the Markdown / PDF
header), and every stored monthly snapshot records the version it was computed with — a snapshot
keeps its own version forever, whatever later releases change. The list endpoint returns it per
snapshot: definitions_version (the number, null for a snapshot generated before versioning) and
definitions_version_label ("3", "unrecorded" or "unreadable" — the same label the downloads
print; display this one).
| Version | Blocked-reason definitions |
|---|---|
1 |
Earlier split: trial-credit, trial-expiry, Myra-managed allowance and EU-Gov entitlement refusals counted under Guardrail / detector verdict. Never recorded as a number. |
2 |
Those refusals count under Budget / quota. A refusal because a PII masking detector could not run counts under Guardrail / detector verdict. |
3 |
A refusal because a PII masking detector (or the PII scan of stored content or tool labels) could not run counts under PII gate (the buckets above). Requests logged before this release carry no such mark and stay where they were. |
unrecorded means the snapshot was generated before versioning, so its definitions cannot be read
from the snapshot itself: usually version 1, but a snapshot generated shortly before versioning reached
that environment can already use version 2 — compare its generated_at with when the release listed in
What's new as "Compliance report: trial, allowance and entitlement
refusals count as budget blocks" reached that environment. unreadable means the stored value is
damaged. Neither is ever shown as a version number.
Scheduled monthly snapshots
The monthly snapshots are the evidence the Myra governance templates point to for monitoring the AI system (EU AI Act Art. 26(5), EU AI Act template) and for the data protection impact assessment (GDPR Art. 35, GDPR template).
GET /compliance/report recomputes its figures live on every call. Two of its inputs decay over time: the control-plane audit log is periodically pruned (so auth_failures for an old window shrinks as rows age out), and a later change to a metric definition would silently rewrite historical numbers. To keep durable, stable governance evidence, the gateway also freezes the metric set once per closed calendar month.
A background job on the maintenance worker snapshots, for each active tenant, the complete metric map for each recently closed UTC calendar month, storing it immutably. Properties:
- Cadence: the month containing "now" is still open, so the job snapshots the prior closed month (and backfills a bounded window of earlier closed months after a first deploy or downtime). A tenant + month pair is snapshotted once — a re-run is a no-op that preserves the original row.
- Every month is recorded, including quiet ones: a month with no activity is snapshotted all-zero (a positive "no incidents" record), so the tenant's compliance history has no gaps. A month that fully predates the tenant's creation is not snapshotted.
- Scope: only active (non-deleted) tenants that have opted in are enumerated. Each snapshot is tenant-isolated.
- Off by default, enabled per tenant in the database: the job ships dark. Enablement is the per-tenant flag
compliance_report_enabled(default0), set viaPATCH /admin/v1/tenants/{id}— platform-admin-only (the snapshot content is DPO-gated governance evidence, not tenant self-service). Enablement is per-tenant only — there is no deployment-wide switch. Snapshot content mirrors the live report exactly (metrics only — the agent-version register is live-report only, see above; same metric definitions, sameresidency_basisrule) as of the moment it was generated — a snapshot is never recomputed, so one stored before a metric definition changed (for example the budget bucket's, which since the release listed in What's new as "Compliance report: trial, allowance and entitlement refusals count as budget blocks" also includes trial-credit, trial-expiry, Myra-managed allowance and EU-Gov entitlement refusals) keeps the earlier split — its recorded definitions version says which split it uses (for anunrecordedsnapshot, see that section). Only the metrics are frozen: the crosswalk table in a snapshot download is rendered from the current taxonomy (see the crosswalk section above), so an older snapshot's guardrail row can list classes its frozen guardrail count was not split by.
GET /compliance/reports
Machine access: a token scoped exactly
["admin_read"]may call this route withAuthorization: Bearer(details).
Lists the calling tenant's stored monthly snapshots, newest period first, as JSON. Metadata only — the frozen metric bytes are fetched per report by the download endpoint below.
Required role and tenant scope: identical to GET /compliance/report (admin must pass ?tenant_id; tenant_admin / ki_manager are pinned to their own tenant; an admin without ?tenant_id is rejected 400). A tenant with no snapshots returns { "reports": [] } (always a JSON array).
{
"reports": [
{ "id": "1f9c…", "period_from_ms": 1748736000000, "period_to_ms": 1751328000000, "generated_at_ms": 1751330000000, "definitions_version": 3, "definitions_version_label": "3" }
]
}
GET /compliance/reports/:id
Machine access: a token scoped exactly
["admin_read"]may call this route withAuthorization: Bearer(details).
Downloads one stored snapshot. The :id is resolved scoped to the caller's tenant, so an unknown id and another tenant's id both return the identical 404 { "error": "not found" } (a foreign id's existence is never confirmed). Each such answer is recorded as one access.denied security event (status 404, no entity; see ids of another tenant), also for a platform admin's miss in the targeted tenant. A caller without the GOVERNANCE_MANAGE permission gets 403, and a database fault gets 503; neither is recorded as a not-found denial.
| Query parameter | Accepted | Rejected |
|---|---|---|
format |
csv (default) or pdf. |
Any other value → 400 { "error": "format must be csv or pdf" }. |
csv— the same long-formatmetric,valueCSV as the live report, rebuilt from the frozen metrics (including the frozenresidency_basisandgenerated_at— the snapshot's frozengenerated_at_ms, not the download time — and the snapshot's own recordeddefinitions_version).pdf— a rendered PDF report (headed tables for requests, blocked-by-reason, security events, and data residency, carrying the residency caveat when the basis isapproximate). The PDF is produced by the shared document-render pipeline and is branded with the report's tenant branding.
Failure modes: a corrupt stored snapshot → the sanitised 500 { "error": "internal error", "request_id": "…" } (permanent); the render pool saturated → 503 { "error": "document rendering is at capacity; please retry shortly" } with Retry-After: 10 (retry shortly); any other render failure → 500 { "error": "PDF generation failed" }.