Expand description
ToolInvocation extraction from a PeeledCommand (R295-F1).
Extracts a structured ToolInvocation once the peeled command’s
basename is matched against a registered ToolLookup. The schema
(global-flag specs, max subcommand depth) lives in ToolSchemaInfo,
which the full policy types in agent_tools::tool_schema embed.
Dependency direction is intentionally one-way:
bash-ast(this crate) defines extraction + the lookup trait.agent-toolsdefines policy (ApprovalTier,ToolSchema) and implementsToolLookupon itsToolRegistry. No circular deps arise.
@arch:see(.yah/docs/working/W086-git-subcommand-gate.md)
@yah:ticket(R295-F7, “bash-ast: arg provenance + path scope + pipe-edge facts”)
@yah:assignee(agent:miravel)
@yah:at(2026-05-25T23:42:54Z)
@yah:status(review)
@yah:parent(R295)
@yah:next(“Add pure fns over the existing tree: arg_provenance(&CommandArgument) -> Provenance (Literal from Word; Variable from SimpleExpansion/Expansion; CommandSub from CommandSubstitution; ProcessSub from ProcessSubstitution; Glob when a Word contains unquoted */?/[) and path_scope(literal, camp_root) -> PathScope (WithinCamp/OutsideCamp/System/Unresolvable via canonicalization against camp root). See addendum table in the design doc.”)
@yah:next(“Add a pipe-edge stamping helper: when walking a Pipeline, expose each stage’s upstream/downstream tool basename so the floor walker can populate CommandFact.pipe_into/pipe_from.”)
@yah:verify(“cargo test -p bash-ast # provenance per node-kind + path_scope buckets (within/outside/system/unresolvable) + glob detection”)
@arch:see(.yah/docs/working/W086-git-subcommand-gate.md)
@yah:handoff(“Shipped. bash-ast/src/tool_invocation.rs grew three public families:\n(1) Provenance enum (Literal/Glob/Variable/ProcessSub/CommandSub) with Ord-derived severity order; arg_provenance(&CommandArgument)->Provenance pure fn; arg_fact(&CommandArgument, &Path)->ArgFact combines provenance + path_scope.\n(2) PathScope enum (WithinCamp/Unresolvable/OutsideCamp/System); path_scope(literal, camp_root) pure fn — no disk I/O, static ..-escape analysis via escapes_camp().\n(3) pipeline_stage_basenames(&Pipeline)->Vec<Option
Structs§
- ArgFact
- Per-argument provenance and path scope derived from the raw AST node.
- Tool
Invocation - Structured representation of a single tool invocation extracted from a
PeeledCommand. All string fields borrow from the sourcePeeledCommandto avoid heap allocation in the hot approval-gate path. - Tool
Schema Info - Minimal schema info needed for
tool_invocation_of.
Enums§
- Global
Flag Spec - Describes how a single global flag (one that appears between the tool name and the subcommand chain) should be consumed during extraction.
- Path
Scope - How far a literal-provenance argument reaches relative to
camp_root. - Provenance
- How statically bounded a command argument’s value is.
Traits§
- Tool
Lookup - Abstraction over a tool-schema registry.
tool_invocation_ofcalls this to resolve the basename of the peeled primary to a schema.
Functions§
- arg_
fact - Build an
ArgFactfor a single command argument. - arg_
provenance - Classify the provenance of a
CommandArgumentfrom the parse tree. - arg_
raw_ text - path_
scope - Classify a literal argument string by how far it can reach relative to
camp_root. Pure — no disk I/O; uses static path analysis only. - pipeline_
stage_ basenames - For each stage of
pipeline, resolve the lowercased tool basename after peeling wrappers.Nonefor stages that are not simple commands or that cannot be peeled (subshells, control flow, …). - tool_
invocation_ of - Extract a
ToolInvocationfrompeeled, looking the primary up inregistry. ReturnsNonewhen the primary’s basename is not registered.