Path: redb-route/redb.Route.Llm.Abstractions/Tools/LlmToolSafety.cs
Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route
Page: https://redbase.app/src/dev-2026-12-06/redb-route/redb.Route.Llm.Abstractions/Tools/LlmToolSafety.cs
----
namespace redb.Route.Llm.Abstractions.Tools;
///
/// Governance metadata attached to every . These are declarations:
/// some are enforced by the engine, some are reserved for later work. Every property states which,
/// so a reader never has to guess whether a field is a control point.
///
public sealed class LlmToolSafety
{
///
/// Side-effect classification. Defaults to .
/// Enforced — the engine reads it for two decisions. A tool that is not
/// is de-duplicated through the idempotency store (a replay
/// of the same tool_use id returns the stored result instead of running again); a
/// read-only tool is not reserved at all. Only a read-only tool may declare a caching policy.
/// Default matters: "declared nothing" and "declared ReadOnly" are indistinguishable,
/// so a tool with no explicit class is treated as read-only — no replay protection. Set
/// on anything that changes state.
///
public ToolSideEffect SideEffect { get; init; } = ToolSideEffect.ReadOnly;
///
/// Caching policy. Defaults to .
/// Enforced for read-only tools — the engine answers a repeated identical call from a
/// cache and reports the skip to observers. A mutating tool that declares a caching policy is
/// rejected when its route is built.
///
public ToolCachingPolicy Caching { get; init; } = ToolCachingPolicy.None;
///
/// Cost class hint. Defaults to .
/// Reserved — budgets are computed from real provider usage, not from this hint.
///
public ToolCostClass Cost { get; init; } = ToolCostClass.Cheap;
///
/// When true the tool requires an explicit approval decision before execution.
/// Enforced — the engine awaits IApprovalGate before dispatching. Note that
/// the shipped default gate approves automatically; a real control point requires replacing it.
///
public bool RequiresApproval { get; init; }
///
/// Claims required on the calling exchange's principal. Empty = no requirements.
/// Enforced — the engine asks the registered IToolClaimsSource and denies the
/// call when the claims cannot be verified. The default source reads the caller's principal from
/// the exchange (ExchangePrincipal, a property — not a header) and takes its scope /
/// scp values; AddRedbRouteLlm() registers it, so claims work out of the box. A
/// deployment with another vocabulary registers its own source. An unrelated identity header, an
/// anonymous caller and a run with no inbound request all fail the check.
///
public IReadOnlyList RequiredClaims { get; init; } = [];
}