# Trust audit

URL: /docs/agents/audit
Markdown: /docs/agents/audit.md

> Inventory trust assumptions and explicit refinement conversions with sakura audit.

`sakura audit` is available in the source-built CLI. Run it from a project directory:

```sh
sakura audit src
sakura audit --json src
```

It lists user-package `@trust` expressions (including reason and resolved sink), `@total` declarations, `@external` declarations, `@resource` types and explicit refined-type `T.from` calls. The human report groups sites by file. Std sites are excluded here; the [build manifest](/docs/agents/build-manifest) includes the std trusted base.

The following program checks and runs; its audit contains one `total`, one `from` and one `trust` site:

```sakura
@total
fn identity(n: Int) -> Int { n }

type Positive = Int where it > 0

pub fn main() -> Unit ! {Console} {
  let n = Positive.from(identity(1))
  let raw = Untrusted.of(n)
  Console.print("{Untrusted.trust(raw, @trust("locally constructed positive value"))}")
}
```

JSON output is JSON Lines: each site has `schema_version: "1.0"`, `kind: "audit"`, `site`, `symbol_id`, `span` and `reason` (nullable). `trust` and `from` records also identify the resolved `sink`. A final `summary` has the snapshot hash, site count and counts by site kind. Spans identify the source URI, content hash and byte range.

An audit is an inventory, not a successful type check or a security certification. It exits 0 regardless of the sites found; loading and usage errors can still fail. Run `sakura check` separately.

## Literal conversions [#literal-conversions]

A literal whose refinement succeeds at compile time needs no startup conversion and does not appear in the report. A literal the checker cannot decide keeps a startup check, listed as a `from` record with `reason: "literal"` at the literal and the refined type's `from` as its `sink` (design §17.78, §17.87). See [contracts](/docs/tour/contracts#literal-refinements-at-compile-time).
