Skip to main content

Module dogwood

Module dogwood 

Source
Expand description

Dogwood policy authorization of tool calls.

DogwoodAuthorization evaluates a Dogwood .dw policy set before each tool call and records each allowed call’s result afterwards, so temporal rules (when temporal { formerly within 1h Action::"search"::response{} }) can correlate across calls. A call maps to the principal, Action::"<tool name>" (qualified by the schema’s namespace when it has one), Resource::"agent", and input (the tool arguments) in both the Cedar context and the temporal record. It runs dogwood-language, the engine behind Dogwood’s WebAssembly build, so decisions and messages match the other Strands SDKs.

use strands::Agent;
use strands::testing::MockModel;
use strands::types::ToolSpec;
use strands::vended_interventions::dogwood::{DogwoodAuthorization, DogwoodAuthorizationConfig};

let search = ToolSpec::new("search", "Search for information");
let dogwood = DogwoodAuthorization::new(DogwoodAuthorizationConfig {
    policies: r#"permit(principal, action == Action::"search", resource);"#.into(),
    tools: Some(vec![search]),
    ..Default::default()
})?;
let agent = Agent::builder()
    .model(MockModel::new())
    .interventions([dogwood])
    .printer(false)
    .build()?;

Structs§

ContextEnricher
Adds fields to the session group of the Cedar request context, read by a policy as context.session.<field>. The fields reach when { .. } conditions only: the default event schema declares a tool’s input fields and nothing else, so a temporal predicate cannot read them.
ContextEnricherInput
What a ContextEnricher gets.
DogwoodAuthorization
Authorizes each tool call against a Dogwood policy set (DogwoodAuthorization).
DogwoodAuthorizationConfig
Settings of a DogwoodAuthorization (DogwoodAuthorizationConfig).
DogwoodAuthorizationConfigBuilder
Use builder syntax to set the inputs and finish with build().
EntityInput
An entity supplied to every decision: its identity plus the attributes and direct parents a policy reads (EntityInput).
EntityRef
A Dogwood entity reference (EntityRef).
PrincipalResolver
Resolves the principal from the invocation state; None denies (fail-closed).