infrastructure capa

infrastructure-agent

_No description in Cargo.toml._

Tierinfrastructure
Roleunclassified (baselined)
Pathcrates/infrastructure/agent
Edition2021
Targetsinfrastructure_agent
Public items170 across 17 modules
Tests134

What it is for

infrastructure-agent — headless, embeddable agent engine (Agent Engine epic, sprints 1.0 / 1.0.1).

This crate opens with the shared vocabulary both engine paths speak (sprint 1.0.1 T-1.0.1a-1, Gate 1.5 Q1/Q4-C):

front-end or middleware sees is one of these; wire formats never leak.

the delegate engine (an external CLI runs its own loop) implement.

Capabilities

browser_tool (other)

browser_read — read a page through the operator's OWN browser.

Item
fn get_content_command(url_match : & str, timeout_secs : u64) -> serde_json::Value
fn navigate_command(url : & str, timeout_secs : u64) -> serde_json::Value
fn search_url(provider : & str, query : & str) -> Result <String, String>
fn focus_command(url_match : & str, timeout_secs : u64) -> serde_json::Value
fn commands_for(url_match : & str, timeout_secs : u64, follow : bool) -> Vec <serde_json::Value>
fn parse_response(body : & serde_json::Value) -> Result <String, String>

BridgeConfig

browser_read — read a page through the operator's OWN browser.

Item
pub struct BridgeConfig
BridgeConfig :: fn local(api_key : impl Into <String>) -> Self
BridgeConfig :: fn following(mut self, follow : bool) -> Self

BrowserRead

browser_read — read a page through the operator's OWN browser.

Item
pub struct BrowserRead
BrowserRead :: fn new(cfg : BridgeConfig) -> Result <Self, String>
BrowserRead :: fn spec(& self) -> ToolSpec
BrowserRead :: async fn call(& self, args : & serde_json::Value) -> Result <String, String>

FindFiles

Built-in filesystem operations (T-1.0.3).

Item
pub struct FindFiles
FindFiles :: fn new(guard : PathGuardSet, limits : FsLimits) -> Self
FindFiles :: fn spec(& self) -> ToolSpec
FindFiles :: async fn call(& self, args : & serde_json::Value) -> Result <String, String>

FsLimits

Built-in filesystem operations (T-1.0.3).

Item
pub struct FsLimits
FsLimits :: fn default() -> Self
fn read_only_registry(guard : PathGuardSet, limits : FsLimits) -> crate::tools::ToolRegistry

Grep

Built-in filesystem operations (T-1.0.3).

Item
pub struct Grep
Grep :: fn new(guard : PathGuardSet, limits : FsLimits) -> Self
Grep :: fn spec(& self) -> ToolSpec
Grep :: async fn call(& self, args : & serde_json::Value) -> Result <String, String>

ListDir

Built-in filesystem operations (T-1.0.3).

Item
pub struct ListDir
ListDir :: fn new(guard : PathGuardSet, limits : FsLimits) -> Self
ListDir :: fn spec(& self) -> ToolSpec
ListDir :: async fn call(& self, args : & serde_json::Value) -> Result <String, String>

ReadFile

Built-in filesystem operations (T-1.0.3).

Item
pub struct ReadFile
ReadFile :: fn new(guard : PathGuardSet, limits : FsLimits) -> Self
ReadFile :: fn spec(& self) -> ToolSpec
ReadFile :: async fn call(& self, args : & serde_json::Value) -> Result <String, String>

capability_tool (other)

find_capability — "does this already exist?" as a lookup (Gate 0.5).

Item
fn parse_manifest(text : & str) -> Option <(String, String)>

Capability

find_capability — "does this already exist?" as a lookup (Gate 0.5).

Item
pub struct Capability
fn search(crates : & Capability, query : & str, max : usize) -> Vec <Capability>

FindCapability

find_capability — "does this already exist?" as a lookup (Gate 0.5).

Item
pub struct FindCapability
FindCapability :: fn new(guard : & PathGuard, max_results : usize) -> Self
FindCapability :: fn known(& self) -> usize
FindCapability :: fn spec(& self) -> ToolSpec
FindCapability :: async fn call(& self, args : & serde_json::Value) -> Result <String, String>

commands (other)

Slash-command registry (sprint 1.0.1 follow-on).

Item
fn interpret(line : & str, commands : & Commands) -> Invocation

Command

Slash-command registry (sprint 1.0.1 follow-on).

Item
pub const MAX_COMMAND_BYTES: u64
pub struct Command

Commands

Slash-command registry (sprint 1.0.1 follow-on).

Item
pub struct Commands
Commands :: fn load(dirs : & PathBuf) -> Self
Commands :: fn get(& self, name : & str) -> Option <& Command>
Commands :: fn names(& self) -> Vec <& str>
Commands :: fn is_empty(& self) -> bool
Commands :: fn names_in(& self, scope : Scope) -> Vec <& str>
Commands :: fn families(& self) -> BTreeMap <& str, Vec <& Command>>
Commands :: fn default_dirs(home : Option <& Path>, cwd : & Path) -> Vec <PathBuf>

Invocation

Slash-command registry (sprint 1.0.1 follow-on).

Item
pub enum Invocation

Scope

Slash-command registry (sprint 1.0.1 follow-on).

Item
pub enum Scope
fn declared_scope(body : & str) -> Option <Scope>

ClaudeCliConfig

ClaudeCliDelegate — the stream-json session driver (T-1.0.1a-3).

Item
pub struct ClaudeCliConfig
ClaudeCliConfig :: fn for_binary(bin : impl Into <PathBuf>, extra : Vec <String>, max_input_bytes : usize, max_line_bytes : usize, read_timeout : Duration,) -> Self

ClaudeCliDelegate

ClaudeCliDelegate — the stream-json session driver (T-1.0.1a-3).

Item
pub struct ClaudeCliDelegate
ClaudeCliDelegate :: fn fmt(& self, f : & mut std::fmt::Formatter <'_>) -> std::fmt::Result
ClaudeCliDelegate :: fn spawn(cfg : ClaudeCliConfig, sink : Arc <dyn TraceSink>) -> Result <Self, EngineError>
ClaudeCliDelegate :: async fn send_user(& mut self, text : String) -> Result <(), EngineError>
ClaudeCliDelegate :: async fn send_user_with(& mut self, text : String, attachments : Vec <crate::engine::Attachment>,) -> Result <(), EngineError>
ClaudeCliDelegate :: async fn next_event(& mut self) -> Result <Option <EngineEvent>, EngineError>
ClaudeCliDelegate :: async fn respond_permission(& mut self, id : & str, _allow : bool) -> Result <(), EngineError>

DlpInputGuard

Ready-made pipeline plug-ins (sprint 1.0.1 follow-on).

Item
pub struct DlpInputGuard
DlpInputGuard :: fn new(on_finding : OnFinding) -> Self
DlpInputGuard :: fn with_denylist(mut self, terms : Vec <String>) -> Self
DlpInputGuard :: async fn check(& self, text : & str) -> GuardDecision

DlpOutputRoute

Ready-made pipeline plug-ins (sprint 1.0.1 follow-on).

Item
pub struct DlpOutputRoute
DlpOutputRoute :: fn new() -> Self
DlpOutputRoute :: fn with_denylist(mut self, terms : Vec <String>) -> Self
DlpOutputRoute :: fn default() -> Self
DlpOutputRoute :: async fn route(& self, event : EngineEvent) -> RouteDecision

OnFinding

Ready-made pipeline plug-ins (sprint 1.0.1 follow-on).

Item
pub enum OnFinding

Screened

Ready-made pipeline plug-ins (sprint 1.0.1 follow-on).

Item
pub struct Screened
Screened :: fn is_clean(& self) -> bool
fn screen_text(text : & str, denylist : & String) -> Screened

ContextHintGuard

Context hints: keyword-triggered additions to an operator message.

Item
pub struct ContextHintGuard
ContextHintGuard :: fn new() -> Self
ContextHintGuard :: fn with_rule(mut self, rule : HintRule) -> Self
ContextHintGuard :: async fn check(& self, text : & str) -> GuardDecision

HintRule

Context hints: keyword-triggered additions to an operator message.

Item
pub struct HintRule
HintRule :: fn new(keywords : & & str, source : Box <dyn HintSource>) -> Self
HintRule :: fn directive(verbs : & & str, nouns : & & str, window : usize, source : Box <dyn HintSource>,) -> Self

HintSource

Context hints: keyword-triggered additions to an operator message.

Item
pub trait HintSource

Trigger

Context hints: keyword-triggered additions to an operator message.

Item
pub enum Trigger
Trigger :: fn matches(& self, lowered : & str) -> bool

ImageScreen

Screen images BEFORE they leave the machine (operator request, 2026-08-06).

Item
pub struct ImageScreen
ImageScreen :: fn new(engine : std::sync::Arc <dyn OcrEngine>) -> Self
ImageScreen :: fn with_denylist(mut self, terms : Vec <String>) -> Self
ImageScreen :: fn block_low_confidence(mut self, block : bool) -> Self
ImageScreen :: async fn inspect(& self, bytes : & u8, media_type : MediaType, width : u32, height : u32,) -> ImageVerdict

ImageVerdict

Screen images BEFORE they leave the machine (operator request, 2026-08-06).

Item
pub enum ImageVerdict
ImageVerdict :: fn is_clean(& self) -> bool

LoopEngine

LoopEngine — WE run the tool loop (T-1.0.2, sprint 1.0).

Item
pub struct LoopEngine
LoopEngine :: fn new(provider : Arc <dyn AiProvider>, tools : ToolRegistry, limits : LoopLimits, system_prompt : Option <String>, model : Option <String>,) -> Self
LoopEngine :: async fn send_user(& mut self, text : String) -> Result <(), EngineError>
LoopEngine :: async fn next_event(& mut self) -> Result <Option <EngineEvent>, EngineError>
LoopEngine :: async fn respond_permission(& mut self, id : & str, _allow : bool) -> Result <(), EngineError>

LoopLimits

LoopEngine — WE run the tool loop (T-1.0.2, sprint 1.0).

Item
pub struct LoopLimits

EventRoute

The middleware pipeline (sprint 1.0.1 US-1.0.1b).

Item
pub trait EventRoute

GuardDecision

The middleware pipeline (sprint 1.0.1 US-1.0.1b).

Item
pub enum GuardDecision

InputGuard

The middleware pipeline (sprint 1.0.1 US-1.0.1b).

Item
pub trait InputGuard

Pipeline

The middleware pipeline (sprint 1.0.1 US-1.0.1b).

Item
pub struct Pipeline
Pipeline :: fn new() -> Self
Pipeline :: fn with_guard(mut self, guard : Box <dyn InputGuard>) -> Self
Pipeline :: fn with_route(mut self, route : Box <dyn EventRoute>) -> Self
Pipeline :: fn attach <E : Engine>(self : & Arc <Self>, engine : E) -> PipelinedEngine <E>
Pipeline :: fn inputs_guarded(& self) -> u64
Pipeline :: fn events_traversed(& self) -> u64
Pipeline :: fn default() -> Self

PipelinedEngine

The middleware pipeline (sprint 1.0.1 US-1.0.1b).

Item
pub struct PipelinedEngine<E>

PipelinedEngine<E>

The middleware pipeline (sprint 1.0.1 US-1.0.1b).

Item
PipelinedEngine<E> :: fn shares_pipeline_with <O>(& self, other : & PipelinedEngine <O>) -> bool
PipelinedEngine<E> :: async fn send_user_reporting(& mut self, text : String) -> Result <SendOutcome, EngineError>
PipelinedEngine<E> :: async fn send_user(& mut self, text : String) -> Result <(), EngineError>
PipelinedEngine<E> :: async fn send_user_with(& mut self, text : String, attachments : Vec <crate::engine::Attachment>,) -> Result <(), EngineError>
PipelinedEngine<E> :: async fn next_event(& mut self) -> Result <Option <EngineEvent>, EngineError>
PipelinedEngine<E> :: async fn respond_permission(& mut self, id : & str, allow : bool) -> Result <(), EngineError>

RouteDecision

The middleware pipeline (sprint 1.0.1 US-1.0.1b).

Item
pub enum RouteDecision

SendOutcome

The middleware pipeline (sprint 1.0.1 US-1.0.1b).

Item
pub struct SendOutcome

net_tools (other)

Network tools for the LOCAL engine (operator, 2026-08-06).

Item
fn parse_results(html : & str, max : usize) -> Vec <String>
fn readable_text(html : & str) -> String

FetchLimits

Network tools for the LOCAL engine (operator, 2026-08-06).

Item
pub struct FetchLimits
FetchLimits :: fn default() -> Self

FetchUrl

Network tools for the LOCAL engine (operator, 2026-08-06).

Item
pub struct FetchUrl
FetchUrl :: fn new(limits : FetchLimits) -> Result <Self, String>
FetchUrl :: fn spec(& self) -> ToolSpec
FetchUrl :: async fn call(& self, args : & serde_json::Value) -> Result <String, String>

WebSearch

Network tools for the LOCAL engine (operator, 2026-08-06).

Item
pub struct WebSearch
WebSearch :: fn new(limits : FetchLimits, max_results : usize) -> Result <Self, String>
WebSearch :: fn spec(& self) -> ToolSpec
WebSearch :: async fn call(& self, args : & serde_json::Value) -> Result <String, String>

reasoning (other)

Reasoning traces never cross a model boundary (operator, 2026-08-06).

Item
fn strip_reasoning(text : & str) -> String
fn has_reasoning(text : & str) -> bool

ReasoningStripGuard

Reasoning traces never cross a model boundary (operator, 2026-08-06).

Item
pub struct ReasoningStripGuard
ReasoningStripGuard :: async fn check(& self, text : & str) -> GuardDecision

Segment

Reasoning traces never cross a model boundary (operator, 2026-08-06).

Item
pub enum Segment
fn split_reasoning(text : & str) -> Vec <Segment>

Decision

Retention policy for recorded turns.

Item
pub struct Decision
Decision :: fn may_store(& self) -> bool

Match

Retention policy for recorded turns.

Item
pub enum Match

PolicyConfig

Retention policy for recorded turns.

Item
pub struct PolicyConfig
PolicyConfig :: fn starting_point(venting_terms : Vec <String>) -> Self

Retention

Retention policy for recorded turns.

Item
pub enum Retention

RetentionPolicy

Retention policy for recorded turns.

Item
pub struct RetentionPolicy
RetentionPolicy :: fn deny_by_default() -> Self
RetentionPolicy :: fn with_default(default : Retention) -> Self
RetentionPolicy :: fn default_route(mut self, route : Route) -> Self
RetentionPolicy :: fn with_rule(mut self, rule : Rule) -> Self
RetentionPolicy :: fn decide(& self, text : & str, findings : & String) -> Decision
RetentionPolicy :: fn from_config(cfg : & PolicyConfig) -> Self

Route

Retention policy for recorded turns.

Item
pub enum Route

Rule

Retention policy for recorded turns.

Item
pub struct Rule
Rule :: fn new(matcher : Match, retention : Retention, reason : impl Into <String>) -> Self
Rule :: fn routed(mut self, route : Route) -> Self

RuleConfig

Retention policy for recorded turns.

Item
pub struct RuleConfig

StubEngine

Scripted engine for TDD of middleware, front-ends, and the shared test

Item
pub struct StubEngine
StubEngine :: fn new(turns : Vec <Vec <EngineEvent>>) -> Self
StubEngine :: async fn send_user(& mut self, _text : String) -> Result <(), EngineError>
StubEngine :: async fn next_event(& mut self) -> Result <Option <EngineEvent>, EngineError>
StubEngine :: async fn respond_permission(& mut self, id : & str, _allow : bool) -> Result <(), EngineError>

Tool

The tool registry the loop engine dispatches through (T-1.0.2).

Item
pub trait Tool

ToolRegistry

The tool registry the loop engine dispatches through (T-1.0.2).

Item
pub struct ToolRegistry
ToolRegistry :: fn new() -> Self
ToolRegistry :: fn with(mut self, tool : Box <dyn Tool>) -> Self
ToolRegistry :: fn specs(& self) -> Vec <ToolSpec>
ToolRegistry :: fn get(& self, name : & str) -> Option <& dyn Tool>
ToolRegistry :: fn is_empty(& self) -> bool

NoopTrace

The trace sink (Gate 1.5 Q4-C, adopted R2).

Item
pub struct NoopTrace
NoopTrace :: fn record_raw(& self, _line : & u8)

TraceSink

The trace sink (Gate 1.5 Q4-C, adopted R2).

Item
pub trait TraceSink

How to use it

No examples/ target and no doctest in this crate's rustdoc. The tests listed under Verification are the closest executable usage.

Module structure

infrastructure_agent

flowchart TD
  n_infrastructure_agent["infrastructure_agent"]
  n_infrastructure_agent --> n_browser_tool["browser_tool"]
  n_infrastructure_agent --> n_builtin_tools["builtin_tools"]
  n_infrastructure_agent --> n_capability_tool["capability_tool"]
  n_infrastructure_agent --> n_commands["commands"]
  n_infrastructure_agent --> n_delegate["delegate"]
  n_delegate --> n_delegate__claude_cli["claude_cli"]
  n_infrastructure_agent --> n_guards["guards"]
  n_infrastructure_agent --> n_hints["hints"]
  n_infrastructure_agent --> n_image_screen["image_screen"]
  n_infrastructure_agent --> n_loop_engine["loop_engine"]
  n_infrastructure_agent --> n_middleware["middleware"]
  n_infrastructure_agent --> n_net_tools["net_tools"]
  n_infrastructure_agent --> n_reasoning["reasoning"]
  n_infrastructure_agent --> n_retention["retention"]
  n_infrastructure_agent --> n_stub["stub"]
  n_infrastructure_agent --> n_tools["tools"]
  n_infrastructure_agent --> n_trace["trace"]

Public surface

`browser_tool`

ItemWhat it is
pub struct BridgeConfigWhere the bridge lives and what one read may cost.
BridgeConfig :: fn local(api_key : impl Into <String>) -> SelfThe conventional local bridge.
BridgeConfig :: fn following(mut self, follow : bool) -> SelfWatch mode: focus each tab as it is read.
pub struct BrowserReadReads the text of a tab the operator already has open.
BrowserRead :: fn new(cfg : BridgeConfig) -> Result <Self, String>
fn get_content_command(url_match : & str, timeout_secs : u64) -> serde_json::ValueThe command envelope the extension expects.
fn navigate_command(url : & str, timeout_secs : u64) -> serde_json::ValuePoint a tab at a URL
fn search_url(provider : & str, query : & str) -> Result <String, String>Search URL for a provider
fn focus_command(url_match : & str, timeout_secs : u64) -> serde_json::ValueBring a tab to the front
fn commands_for(url_match : & str, timeout_secs : u64, follow : bool) -> Vec <serde_json::Value>The commands one read sends, in order
fn parse_response(body : & serde_json::Value) -> Result <String, String>Pull page text out of the bridge's response envelope
BrowserRead :: fn spec(& self) -> ToolSpec
BrowserRead :: async fn call(& self, args : & serde_json::Value) -> Result <String, String>

`builtin_tools`

ItemWhat it is
pub struct FsLimitsShared limits
FsLimits :: fn default() -> Self
pub struct ListDirlist_dir — immediate entries of one directory.
ListDir :: fn new(guard : PathGuardSet, limits : FsLimits) -> Self
ListDir :: fn spec(& self) -> ToolSpec
ListDir :: async fn call(& self, args : & serde_json::Value) -> Result <String, String>
pub struct FindFilesfind_files — names matching a substring, anywhere under a path.
FindFiles :: fn new(guard : PathGuardSet, limits : FsLimits) -> Self
FindFiles :: fn spec(& self) -> ToolSpec
FindFiles :: async fn call(& self, args : & serde_json::Value) -> Result <String, String>
pub struct ReadFileread_file — file contents, byte-capped without splitting a codepoint.
ReadFile :: fn new(guard : PathGuardSet, limits : FsLimits) -> Self
ReadFile :: fn spec(& self) -> ToolSpec
ReadFile :: async fn call(& self, args : & serde_json::Value) -> Result <String, String>
pub struct Grepgrep — lines containing a substring, as path:line: text.
Grep :: fn new(guard : PathGuardSet, limits : FsLimits) -> Self
Grep :: fn spec(& self) -> ToolSpec
Grep :: async fn call(& self, args : & serde_json::Value) -> Result <String, String>
fn read_only_registry(guard : PathGuardSet, limits : FsLimits) -> crate::tools::ToolRegistryEvery read-only operation, registered.

`capability_tool`

ItemWhat it is
pub struct CapabilityOne thing the workspace already has.
fn parse_manifest(text : & str) -> Option <(String, String)>Parse name and description out of a Cargo.toml
fn search(crates : & Capability, query : & str, max : usize) -> Vec <Capability>Search loaded crates for a query, best first.
pub struct FindCapabilityThe tool
FindCapability :: fn new(guard : & PathGuard, max_results : usize) -> SelfWalk crates/**/Cargo.toml under the guard's root.
FindCapability :: fn known(& self) -> usize
FindCapability :: fn spec(& self) -> ToolSpec
FindCapability :: async fn call(& self, args : & serde_json::Value) -> Result <String, String>

`commands`

ItemWhat it is
pub const MAX_COMMAND_BYTES: u64Cap on one command file
pub enum ScopeWhere a command's turn is allowed to go
fn declared_scope(body : & str) -> Option <Scope>Read a declared scope from the head of a command file
pub struct CommandOne loaded command: its invocation name and the prompt text it expands to.
pub struct CommandsCommands discovered across one or more directories, later directories winning on a name clash (project overrides user).
Commands :: fn load(dirs : & PathBuf) -> SelfLoad every *.md in each directory, in order
Commands :: fn get(& self, name : & str) -> Option <& Command>
Commands :: fn names(& self) -> Vec <& str>
Commands :: fn is_empty(& self) -> bool
Commands :: fn names_in(& self, scope : Scope) -> Vec <& str>Names carrying the given scope, sorted.
Commands :: fn families(& self) -> BTreeMap <& str, Vec <& Command>>Commands grouped by the prefix before their first - — the family the operator already writes them in (search-*, role-*, legal-*)
Commands :: fn default_dirs(home : Option <& Path>, cwd : & Path) -> Vec <PathBuf>The conventional locations: the user's home commands, then the project's (project wins).
pub enum InvocationWhat a typed line means.
fn interpret(line : & str, commands : & Commands) -> InvocationParse a typed line

`delegate::claude_cli`

ItemWhat it is
pub struct ClaudeCliConfigSession configuration
pub struct ClaudeCliDelegateA live headless session
ClaudeCliDelegate :: fn fmt(& self, f : & mut std::fmt::Formatter <'_>) -> std::fmt::Result
ClaudeCliConfig :: fn for_binary(bin : impl Into <PathBuf>, extra : Vec <String>, max_input_bytes : usize, max_line_bytes : usize, read_timeout : Duration,) -> SelfStandard headless-session vector for a real claude binary
ClaudeCliDelegate :: fn spawn(cfg : ClaudeCliConfig, sink : Arc <dyn TraceSink>) -> Result <Self, EngineError>Spawn the child and open the session.
ClaudeCliDelegate :: async fn send_user(& mut self, text : String) -> Result <(), EngineError>
ClaudeCliDelegate :: async fn send_user_with(& mut self, text : String, attachments : Vec <crate::engine::Attachment>,) -> Result <(), EngineError>
ClaudeCliDelegate :: async fn next_event(& mut self) -> Result <Option <EngineEvent>, EngineError>
ClaudeCliDelegate :: async fn respond_permission(& mut self, id : & str, _allow : bool) -> Result <(), EngineError>

`guards`

ItemWhat it is
pub enum OnFindingWhat to do when an outbound operator message carries sensitive values.
pub struct ScreenedWhat a screen found, without deciding what to do about it
Screened :: fn is_clean(& self) -> bool
fn screen_text(text : & str, denylist : & String) -> ScreenedDetect and redact in one pass, returning both so the caller can choose.
pub struct DlpInputGuardScreens operator input before it leaves the machine
DlpInputGuard :: fn new(on_finding : OnFinding) -> Self
DlpInputGuard :: fn with_denylist(mut self, terms : Vec <String>) -> SelfCaller-supplied denylist terms (project code names, client names).
DlpInputGuard :: async fn check(& self, text : & str) -> GuardDecision
pub struct DlpOutputRouteRedacts sensitive values in engine output before it is rendered — the return path of the same screen (a tool may read a secret out of a file).
DlpOutputRoute :: fn new() -> Self
DlpOutputRoute :: fn with_denylist(mut self, terms : Vec <String>) -> Self
DlpOutputRoute :: fn default() -> Self
DlpOutputRoute :: async fn route(& self, event : EngineEvent) -> RouteDecision

`hints`

ItemWhat it is
pub trait HintSourceResolves a hint at send time (may do I/O — e.g
pub enum TriggerHow a rule decides a message is ASKING for the hint.
Trigger :: fn matches(& self, lowered : & str) -> bool
pub struct HintRuleOne trigger and what it contributes.
HintRule :: fn new(keywords : & & str, source : Box <dyn HintSource>) -> SelfKeyword rule (blunt).
HintRule :: fn directive(verbs : & & str, nouns : & & str, window : usize, source : Box <dyn HintSource>,) -> SelfDirective rule: a verb shortly before a noun.
pub struct ContextHintGuardAppends resolved context for any rule whose keywords appear.
ContextHintGuard :: fn new() -> Self
ContextHintGuard :: fn with_rule(mut self, rule : HintRule) -> Self
ContextHintGuard :: async fn check(& self, text : & str) -> GuardDecision

`image_screen`

ItemWhat it is
pub enum ImageVerdictWhat the local screen concluded about one image.
ImageVerdict :: fn is_clean(& self) -> boolThe only verdict that may be attached without operator override.
pub struct ImageScreenLocal OCR + DLP screen for image attachments.
ImageScreen :: fn new(engine : std::sync::Arc <dyn OcrEngine>) -> Self
ImageScreen :: fn with_denylist(mut self, terms : Vec <String>) -> Self
ImageScreen :: fn block_low_confidence(mut self, block : bool) -> Self
ImageScreen :: async fn inspect(& self, bytes : & u8, media_type : MediaType, width : u32, height : u32,) -> ImageVerdictOCR bytes, then screen the recognized text.

`loop_engine`

ItemWhat it is
pub struct LoopLimitsLoop limits
pub struct LoopEngineAn engine that runs the tool loop locally over an AiProvider.
LoopEngine :: fn new(provider : Arc <dyn AiProvider>, tools : ToolRegistry, limits : LoopLimits, system_prompt : Option <String>, model : Option <String>,) -> Self
LoopEngine :: async fn send_user(& mut self, text : String) -> Result <(), EngineError>
LoopEngine :: async fn next_event(& mut self) -> Result <Option <EngineEvent>, EngineError>
LoopEngine :: async fn respond_permission(& mut self, id : & str, _allow : bool) -> Result <(), EngineError>

`middleware`

ItemWhat it is
pub enum GuardDecisionWhat an InputGuard decided about an operator message.
pub trait InputGuardInspect/rewrite/deny operator input before it reaches any engine.
pub enum RouteDecisionWhat an EventRoute decided about an engine event.
pub trait EventRouteTransform, side-route, or suppress every engine event before render.
pub struct PipelineOrdered guard + route chains with traversal instrumentation.
Pipeline :: fn new() -> Self
Pipeline :: fn with_guard(mut self, guard : Box <dyn InputGuard>) -> Self
Pipeline :: fn with_route(mut self, route : Box <dyn EventRoute>) -> Self
Pipeline :: fn attach <E : Engine>(self : & Arc <Self>, engine : E) -> PipelinedEngine <E>Wrap engine so every input and event traverses THIS pipeline.
Pipeline :: fn inputs_guarded(& self) -> u64How many operator messages the guard chain has processed.
Pipeline :: fn events_traversed(& self) -> u64How many engine events the route chain has processed.
Pipeline :: fn default() -> Self
pub struct PipelinedEngine<E>An engine whose I/O flows through a shared Pipeline.
pub struct SendOutcomeWhat the guard chain did to an operator message, for front-ends that show the operator what was actually sent (a silent rewrite is a lie of omission).
PipelinedEngine<E> :: fn shares_pipeline_with <O>(& self, other : & PipelinedEngine <O>) -> boolConstruction-level identity check for the shared-pipeline AC.
PipelinedEngine<E> :: async fn send_user_reporting(& mut self, text : String) -> Result <SendOutcome, EngineError>Like Engine::send_user, but reports what the guards did so the caller can show it
PipelinedEngine<E> :: async fn send_user(& mut self, text : String) -> Result <(), EngineError>
PipelinedEngine<E> :: async fn send_user_with(& mut self, text : String, attachments : Vec <crate::engine::Attachment>,) -> Result <(), EngineError>
PipelinedEngine<E> :: async fn next_event(& mut self) -> Result <Option <EngineEvent>, EngineError>
PipelinedEngine<E> :: async fn respond_permission(& mut self, id : & str, allow : bool) -> Result <(), EngineError>

`net_tools`

ItemWhat it is
pub struct FetchLimitsCaps for one fetch
FetchLimits :: fn default() -> Self
pub struct FetchUrlfetch_url — retrieve a page and hand back its readable text.
FetchUrl :: fn new(limits : FetchLimits) -> Result <Self, String>Build with the hardened egress client (no allowlist relaxation: this is the public-internet client, and loopback stays refused).
FetchUrl :: fn spec(& self) -> ToolSpec
FetchUrl :: async fn call(& self, args : & serde_json::Value) -> Result <String, String>
pub struct WebSearchweb_search — DuckDuckGo's HTML endpoint
WebSearch :: fn new(limits : FetchLimits, max_results : usize) -> Result <Self, String>
WebSearch :: fn spec(& self) -> ToolSpec
WebSearch :: async fn call(& self, args : & serde_json::Value) -> Result <String, String>
fn parse_results(html : & str, max : usize) -> Vec <String>Pull title — url lines out of a DuckDuckGo HTML result page.
fn readable_text(html : & str) -> StringStrip markup down to readable text

`reasoning`

ItemWhat it is
fn strip_reasoning(text : & str) -> StringRemove every reasoning block
fn has_reasoning(text : & str) -> boolTrue when the text carries any reasoning block.
pub enum SegmentA piece of a model's output, labelled by what it is.
fn split_reasoning(text : & str) -> Vec <Segment>Split output into thinking and answer, in order, so a front-end can style them differently instead of showing one undifferentiated wall.
pub struct ReasoningStripGuardStrips reasoning from anything on its way to an engine
ReasoningStripGuard :: async fn check(& self, text : & str) -> GuardDecision

`retention`

ItemWhat it is
pub enum RetentionHow long a turn may be kept.
pub enum MatchWhat a rule looks at.
pub enum RouteWhich engine should answer this turn.
pub struct RuleOne rule: what to look for, where it should go, and how long it may be kept
Rule :: fn new(matcher : Match, retention : Retention, reason : impl Into <String>) -> Self
Rule :: fn routed(mut self, route : Route) -> SelfSend matches to a specific engine.
pub struct DecisionWhat the policy decided, and which rule decided it
Decision :: fn may_store(& self) -> boolTrue when the turn may be written at all.
pub struct RetentionPolicyOrdered rules plus the default for anything unmatched.
RetentionPolicy :: fn deny_by_default() -> SelfA policy that keeps nothing unless a rule says otherwise.
RetentionPolicy :: fn with_default(default : Retention) -> Self
RetentionPolicy :: fn default_route(mut self, route : Route) -> Self
RetentionPolicy :: fn with_rule(mut self, rule : Rule) -> Self
RetentionPolicy :: fn decide(& self, text : & str, findings : & String) -> DecisionFirst matching rule wins; otherwise the stated defaults.
RetentionPolicy :: fn from_config(cfg : & PolicyConfig) -> SelfBuild from a config document — every term and threshold comes from the operator's file, not from this crate
pub struct PolicyConfigThe configurable shape: what a config file deserializes into
pub struct RuleConfig
PolicyConfig :: fn starting_point(venting_terms : Vec <String>) -> SelfThe starting shape an operator's config would express: nothing sensitive is recorded, venting and chatter go to the local model and are not kept, everything else is work and goes remote

`stub`

ItemWhat it is
pub struct StubEngineAn Engine that replays pre-scripted turns and enforces the full contract (turn discipline, permission gating, session end).
StubEngine :: fn new(turns : Vec <Vec <EngineEvent>>) -> Self
StubEngine :: async fn send_user(& mut self, _text : String) -> Result <(), EngineError>
StubEngine :: async fn next_event(& mut self) -> Result <Option <EngineEvent>, EngineError>
StubEngine :: async fn respond_permission(& mut self, id : & str, _allow : bool) -> Result <(), EngineError>

`tools`

ItemWhat it is
pub trait ToolA tool the model may call.
pub struct ToolRegistryName-addressed set of tools.
ToolRegistry :: fn new() -> Self
ToolRegistry :: fn with(mut self, tool : Box <dyn Tool>) -> Self
ToolRegistry :: fn specs(& self) -> Vec <ToolSpec>Specs for every registered tool, in stable name order.
ToolRegistry :: fn get(& self, name : & str) -> Option <& dyn Tool>
ToolRegistry :: fn is_empty(& self) -> bool

`trace`

ItemWhat it is
pub trait TraceSinkReceives raw wire lines for replay/drift forensics
pub struct NoopTraceThe default sink: drops everything (zero cost when tracing is off).
NoopTrace :: fn record_raw(& self, _line : & u8)

Re-exports. Exported here, defined elsewhere.

ExportDefined in
{Attachment,Engine,EngineError,EngineEvent,ToolOutcome}engine::{Attachment,Engine,EngineError,EngineEvent,ToolOutcome}
{ClaudeCliConfig,ClaudeCliDelegate}claude_cli::{ClaudeCliConfig,ClaudeCliDelegate}
{Commands,Invocation}commands::{Commands,Invocation}
{ContextHintGuard,HintRule,HintSource}hints::{ContextHintGuard,HintRule,HintSource}
{EventRoute,GuardDecision,InputGuard,Pipeline,PipelinedEngine,RouteDecision,SendOutcome,}middleware::{EventRoute,GuardDecision,InputGuard,Pipeline,PipelinedEngine,RouteDecision,SendOutcome,}
{FinishReason,ToolCall}infrastructure_ai::{FinishReason,ToolCall}
{LoopEngine,LoopLimits}loop_engine::{LoopEngine,LoopLimits}
{NoopTrace,TraceSink}trace::{NoopTrace,TraceSink}
{Tool,ToolRegistry}tools::{Tool,ToolRegistry}
{split_reasoning,strip_reasoning,ReasoningStripGuard,Segment}reasoning::{split_reasoning,strip_reasoning,ReasoningStripGuard,Segment}

Boundary

Reaches into foundation.

Shares tier infrastructure with 82 other crates: infrastructure-acquire, infrastructure-adapters-google-calendar, infrastructure-adapters-google-gmail, infrastructure-adapters-google-places, infrastructure-adapters-google-trends, infrastructure-adapters-shodan, infrastructure-adapters-yelp, infrastructure-ai, … (82 total).

_What this crate deliberately does NOT own is a judgment. No committed registry records one for it, so none is stated here._

Where it sits

Tier (ontology)infrastructure
Architectural role (taxonomy)unclassified (baselined)
Locationcrates/infrastructure/agent
Vocabulary in force (lexicon)current

Tier flow. Which tiers this crate's own edges cross.

flowchart LR
  n_infrastructure["infrastructure"] --> n_foundation["foundation"]

Dependencies

Runtime, in this workspace.

CrateTierOptionalOnly on
`foundation-bounded-io`foundationyesalways
`infrastructure-ai`infrastructurenoalways
`infrastructure-dlp-detect`infrastructureyesalways
`infrastructure-fetcher`infrastructureyesalways
`infrastructure-ocr-engine`infrastructureyesalways

Runtime, from outside the workspace.

CrateRequirementFeaturesOptionalOnly on
async-trait^0.1noalways
reqwest^0.12jsonyesalways
serde^1derivenoalways
serde_json^1noalways
thiserror^2noalways
tokio^1fullyesalways
url^2yesalways

Development, from outside the workspace.

CrateRequirementFeaturesOptionalOnly on
tokio^1fullnoalways

Build. None.

Depended on by. 3 workspace crates.

Signal flow — what reaches this crate, and what it reaches.

flowchart LR
  n_application_conversation["application-conversation"] -->|uses| SELF
  n_tools_corpus["tools-corpus"] -->|uses| SELF
  n_tools_imp["tools-imp"] -->|uses| SELF
  SELF["infrastructure-agent"]
  SELF -->|runtime| n_foundation_bounded_io["foundation-bounded-io"]
  SELF -->|runtime| n_infrastructure_ai["infrastructure-ai"]
  SELF -->|runtime| n_infrastructure_dlp_detect["infrastructure-dlp-detect"]
  SELF -->|runtime| n_infrastructure_fetcher["infrastructure-fetcher"]
  SELF -->|runtime| n_infrastructure_ocr_engine["infrastructure-ocr-engine"]
  classDef self fill:#1f883d,stroke:#1f883d,color:#fff;
  class SELF self;

Feature flags

FeatureEnablesOn by default
browser-toolnet-tools, dep:reqwestno
claude-clidep:tokio, dep:foundation-bounded-iono
defaultyes
dlpdep:infrastructure-dlp-detectno
fs-toolsdep:foundation-bounded-iono
image-screendlp, dep:infrastructure-ocr-engineno
net-toolsdep:infrastructure-fetcher, dep:url, dep:foundation-bounded-iono
flowchart LR
  n_browser_tool["browser-tool"] --> n_net_tools["net-tools"]
  n_browser_tool["browser-tool"] --> n_dep_reqwest["dep:reqwest"]
  n_claude_cli["claude-cli"] --> n_dep_tokio["dep:tokio"]
  n_claude_cli["claude-cli"] --> n_dep_foundation_bounded_io["dep:foundation-bounded-io"]
  n_default["default"]
  n_dlp["dlp"] --> n_dep_infrastructure_dlp_detect["dep:infrastructure-dlp-detect"]
  n_fs_tools["fs-tools"] --> n_dep_foundation_bounded_io["dep:foundation-bounded-io"]
  n_image_screen["image-screen"] --> n_dlp["dlp"]
  n_image_screen["image-screen"] --> n_dep_infrastructure_ocr_engine["dep:infrastructure-ocr-engine"]
  n_net_tools["net-tools"] --> n_dep_infrastructure_fetcher["dep:infrastructure-fetcher"]
  n_net_tools["net-tools"] --> n_dep_url["dep:url"]
  n_net_tools["net-tools"] --> n_dep_foundation_bounded_io["dep:foundation-bounded-io"]

Targets

KindNameSource
libinfrastructure_agent`src/lib.rs`

Error model

No public error type was detected: no public item declares a type named *Error, and no public signature returns one.

Operational characteristics

PropertyEvidence
async public surfaceyes
async runtimeyes
database accessnone detected
network I/Oyes
unsafe codenone detected
environment variablesnone detected

No unsafe block, unsafe fn, unsafe impl or unsafe trait was found by the parser anywhere in this crate's source.

Configuration

No environment variable is read with a literal name anywhere in this crate. A variable whose key is computed at run time cannot be listed here, and is not claimed to be absent.

3 workspace crates depend on this one: application-conversation, tools-corpus, tools-imp.

Verification

KindCount
Unit tests134
Integration tests0
Examples0
Doctests0

Evidence by module. How often each public module is named by something executable.

ModuleTestsExamplesConsumers
browser_tool802
builtin_tools602
capability_tool405
commands708
delegate::claude_cli203
guards504
hints401
image_screen202
loop_engine202
middleware705
net_tools503
reasoning505
retention805
stub100
tools202
trace201

What the tests establish, by name:

Documentation coverage

MeasureDocumentedTotal
Public items with rustdoc96170
Public modules with a //! block1717
pie showData
    title Public items with rustdoc
    "Documented" : 96
    "No rustdoc detected" : 74

Metrics

MetricValue
Rust source files19
Source lines5448
Code lines4412
Public API items170
Public modules17
Tests134
Examples0
Cargo features7
Direct runtime dependencies12
Workspace reverse dependencies3
pie showData
    title Public API by kind
    "constant" : 1
    "enum" : 11
    "function" : 17
    "method" : 100
    "struct" : 36
    "trait" : 5
pie showData
    title Rust source composition
    "Code" : 4412
    "Blank or comment" : 1036

Generation

Rendered by tools-corpus corpus readme from repository evidence alone, renderer schema 2, lexicon current. No model, network service or database was consulted. Regenerate with tools-corpus corpus readme --write; verify with --check.

Todas las infrastructure · Manual