# `orchestrator.registry.api.audit`
<!-- generated by `orchestrator understand`; the PKG is source of truth, edits here are advisory -->

[← Episteme](../README.md) · [Architecture](../architecture.md)

**Source:** [`src/orchestrator/registry/api/audit.py`](../../src/orchestrator/registry/api/audit.py)

3 types · 9 functions · python

## Changing this safely

**No test module imports this.**

**Most depended-upon here** — a change to these reaches the most code (call graph, ≤4 hops):

- [`_iso`](../../src/orchestrator/registry/api/audit.py#L58) — reaches **5** symbols · **no test path visible**
- [`_budget_cap_usd`](../../src/orchestrator/registry/api/audit.py#L51) — reaches **3** symbols · **no test path visible**
- [`AuditRow`](../../src/orchestrator/registry/api/audit.py#L65) — reaches **2** symbols · **no test path visible**
- [`_fetch_run`](../../src/orchestrator/registry/api/audit.py#L126) — reaches **2** symbols · **no test path visible**
- [`_governance`](../../src/orchestrator/registry/api/audit.py#L147) — reaches **2** symbols · **no test path visible**
- [`AuditPage`](../../src/orchestrator/registry/api/audit.py#L77) — reaches **1** symbol · **no test path visible**
- [`GovernanceResponse`](../../src/orchestrator/registry/api/audit.py#L194) — reaches **1** symbol · **no test path visible**
- [`_derive_state`](../../src/orchestrator/registry/api/audit.py#L139) — reaches **1** symbol · **no test path visible**

_9 of the symbols other code depends on here have no test path the graph can see — worth a second look before changing them. Absence of a path is not proof of absence of a test: calls through an attribute chain (`obj.method()`) are skipped rather than guessed at, so indirect coverage is invisible._

## Documented in

`docs/specs/build-documents/SSPN-49-plan.md#3-pkg-understanding-and-where-it-misleads`

## Types

### `AuditPage`

[`src/orchestrator/registry/api/audit.py:77`](../../src/orchestrator/registry/api/audit.py#L77)

- **Extends** (1): `pydantic.BaseModel`
- **Called by** (1): [`query_audit`](../../src/orchestrator/registry/api/audit.py#L96)
- **Fields**: `items`, `model_config`

### `AuditRow`

[`src/orchestrator/registry/api/audit.py:65`](../../src/orchestrator/registry/api/audit.py#L65)

- **Extends** (1): `pydantic.BaseModel`
- **Called by** (1): [`_to_row`](../../src/orchestrator/registry/api/audit.py#L83)
- **Fields**: `action`, `actor`, `after`, `model_config`, `resource_id`, `resource_type`, `timestamp`, `trace_id`

### `GovernanceResponse`

[`src/orchestrator/registry/api/audit.py:194`](../../src/orchestrator/registry/api/audit.py#L194)

- **Extends** (1): `pydantic.BaseModel`
- **Called by** (1): [`run_governance`](../../src/orchestrator/registry/api/audit.py#L205)
- **Fields**: `approvals`, `model_config`, `note`, `policy`, `run_id`, `spend`

## Functions

### `_budget_cap_usd`

[`src/orchestrator/registry/api/audit.py:51`](../../src/orchestrator/registry/api/audit.py#L51)

- **Called by** (1): [`_governance`](../../src/orchestrator/registry/api/audit.py#L147)
- **Calls** (1): `getenv`

### `_derive_state`

[`src/orchestrator/registry/api/audit.py:139`](../../src/orchestrator/registry/api/audit.py#L139)

- **Called by** (1): [`export_run`](../../src/orchestrator/registry/api/audit.py#L216)

### `_fetch_run`

[`src/orchestrator/registry/api/audit.py:126`](../../src/orchestrator/registry/api/audit.py#L126)

- **Called by** (2): [`export_run`](../../src/orchestrator/registry/api/audit.py#L216), [`run_governance`](../../src/orchestrator/registry/api/audit.py#L205)
- **Calls** (2): `sqlalchemy.or_`, `sqlalchemy.select`

### `_governance`

[`src/orchestrator/registry/api/audit.py:147`](../../src/orchestrator/registry/api/audit.py#L147)

- **Called by** (2): [`export_run`](../../src/orchestrator/registry/api/audit.py#L216), [`run_governance`](../../src/orchestrator/registry/api/audit.py#L205)
- **Calls** (3): [`_budget_cap_usd`](../../src/orchestrator/registry/api/audit.py#L51), [`_iso`](../../src/orchestrator/registry/api/audit.py#L58), `suppress`

### `_iso`

[`src/orchestrator/registry/api/audit.py:58`](../../src/orchestrator/registry/api/audit.py#L58)

- **Called by** (3): [`_governance`](../../src/orchestrator/registry/api/audit.py#L147), [`_to_row`](../../src/orchestrator/registry/api/audit.py#L83), [`export_run`](../../src/orchestrator/registry/api/audit.py#L216)

### `_to_row`

[`src/orchestrator/registry/api/audit.py:83`](../../src/orchestrator/registry/api/audit.py#L83)

- **Called by** (1): [`query_audit`](../../src/orchestrator/registry/api/audit.py#L96)
- **Calls** (2): [`AuditRow`](../../src/orchestrator/registry/api/audit.py#L65), [`_iso`](../../src/orchestrator/registry/api/audit.py#L58)

### `export_run`

[`src/orchestrator/registry/api/audit.py:216`](../../src/orchestrator/registry/api/audit.py#L216)

- **Calls** (7): [`_derive_state`](../../src/orchestrator/registry/api/audit.py#L139), [`_fetch_run`](../../src/orchestrator/registry/api/audit.py#L126), [`_governance`](../../src/orchestrator/registry/api/audit.py#L147), [`_iso`](../../src/orchestrator/registry/api/audit.py#L58), `dumps`, `fastapi.HTTPException`, `fastapi.Response`

### `query_audit`

[`src/orchestrator/registry/api/audit.py:96`](../../src/orchestrator/registry/api/audit.py#L96)

- **Calls** (4): [`AuditPage`](../../src/orchestrator/registry/api/audit.py#L77), [`_to_row`](../../src/orchestrator/registry/api/audit.py#L83), `sqlalchemy.or_`, `sqlalchemy.select`

### `run_governance`

[`src/orchestrator/registry/api/audit.py:205`](../../src/orchestrator/registry/api/audit.py#L205)

- **Calls** (4): [`GovernanceResponse`](../../src/orchestrator/registry/api/audit.py#L194), [`_fetch_run`](../../src/orchestrator/registry/api/audit.py#L126), [`_governance`](../../src/orchestrator/registry/api/audit.py#L147), `fastapi.HTTPException`

## Imports

`__future__.annotations`, `contextlib`, `fastapi.APIRouter`, `fastapi.HTTPException`, `fastapi.Response`, `fastapi.status`, `json`, [`orchestrator.registry.api.deps`](../../src/orchestrator/registry/api/deps.py#L1), [`orchestrator.registry.db.models`](../../src/orchestrator/registry/db/models.py#L1), `os`, `pydantic.BaseModel`, `pydantic.ConfigDict`, `sqlalchemy.or_`, `sqlalchemy.select`, `typing.Any`

## Imported by

[`orchestrator.registry.api.app`](../../src/orchestrator/registry/api/app.py#L1)
