Skip to content

AuditRecord

Defined in: audit.ts:17

One audit entry: who did what, as which identity, with what result. Recorded by auditLog() to whichever Repository<T> the deployment configures as the sink — audit records are themselves a normal Mantle-shaped record, not a bespoke storage concept.

[key: string]: unknown

Index signature so AuditRecord satisfies Repository<T extends Record<string, unknown>> (e.g. MemoryRepository).

optional agentId?: string

Defined in: audit.ts:21

Set only when the call was authorized via an agent token (HookContext.agent, see @mantlejs/auth).


optional agentScope?: CapabilityScope

Defined in: audit.ts:23

The agent token’s capability scope. Present only alongside agentId.


optional delegatingUserId?: string

Defined in: audit.ts:25

The user who minted the agent token. Present only alongside agentId.


optional mcp?: Record<string, unknown>

Defined in: audit.ts:39

ctx.params.mcp — origin metadata for an MCP-originated call. Under @mantlejs/mcp-code’s code mode this is { mode: "code", executionId, scriptHash, script? }, so every service call one agent script made shares an executionId (“what did this script do” is one find()).


method: string

Defined in: audit.ts:27


optional params?: Record<string, unknown>

Defined in: audit.ts:33

The caller’s query — ctx.params.query (filters, pagination, sort, select). Deliberately never ctx.params.headers or the raw ctx.params.user object: those may carry bearer tokens or other sensitive claims, and identity already has its own field (principal).


path: string

Defined in: audit.ts:26


optional principal?: unknown

Defined in: audit.ts:19

ctx.params.user — undefined for an unauthenticated or internal call.


resultSummary: string

Defined in: audit.ts:42

A short, non-exhaustive description of the outcome — never the full result payload.


status: "success" | "error"

Defined in: audit.ts:40


timestamp: string

Defined in: audit.ts:44

ISO 8601 timestamp of when the entry was recorded.