Shared implementation for the built-in LLM-driven red-team plugins.
use Tribunal.RedTeam.Plugin.Base injects id/0, severity/0, and a full
generate/1 pipeline: required-option validation, the plugin and attacker
telemetry spans, the attacker call, attack extraction, and per-case emission.
The using module supplies only the parts that differ between plugins:
meta_prompt/1— build the attacker meta-prompt from the call opts (:purpose,:count, and any plugin-specific keys like:policy).expected/1— build theexpectedclause carried into each generated case (the assertion the judge runs against the target's response).goal_description/0— the schema description for each attack'sgoal.
Options
:id— required. The plugin id atom.:severity— required.:low,:medium, or:high.:required— required option keys, validated before generation. Defaults to[:purpose].:default_count— attacks per call when:countis absent. Defaults to 5.
Example
defmodule MyApp.RedTeam.Plugins.Custom do
use Tribunal.RedTeam.Plugin.Base, id: :custom, severity: :medium
@impl true
def meta_prompt(opts), do: "Attack #{opts[:purpose]} ..."
@impl true
def expected(opts), do: %{custom: %{purpose: opts[:purpose]}}
@impl true
def goal_description, do: "One sentence on what the attack elicits."
end
Summary
Types
@type opts() :: keyword()