Documentation
¶
Overview ¶
Package paths implements attack-path enumeration and shortest-path search over the AgentGraph graph model.
Index ¶
Constants ¶
const DefaultMaxDepth = 10
DefaultMaxDepth is the default maximum attack-path depth (PRD section 38).
const DefaultMaxPaths = 1000
DefaultMaxPaths caps enumerated paths to protect against graph explosion.
Variables ¶
This section is empty.
Functions ¶
func Describe ¶
Describe renders a path in the arrow notation used throughout the PRD, e.g. "finance-agent -USES-> github-mcp -CAN_WRITE-> payments-repository".
func IsTerminal ¶
IsTerminal reports whether a node is a valid attack-path target.
Types ¶
type Options ¶
type Options struct {
// MaxDepth is the maximum number of edges in a path.
MaxDepth int
// MinConfidence excludes edges below this confidence (0-1).
MinConfidence float64
// MaxPaths caps the number of returned paths (0 = DefaultMaxPaths).
MaxPaths int
// TargetID restricts results to paths ending at this node ID.
TargetID string
// TargetSubstring matches target node ID or name (case-insensitive).
TargetSubstring string
// CrownJewelsOnly restricts results to paths ending at crown jewels.
CrownJewelsOnly bool
// EdgeTypes is an optional allowlist of edge types.
EdgeTypes map[graph.EdgeType]bool
}
Options controls path enumeration constraints.
type Path ¶
type Path struct {
ID string
Source *graph.Node
Target *graph.Node
Steps []Step // target is Steps[len-1].Node
// Confidence is the product of all edge confidences.
Confidence float64
}
Path is a single attack path from a source node to a target node.
func Enumerate ¶
Enumerate finds all attack paths from source subject to the options. Paths are simple (no repeated nodes), which prevents meaningless loops such as Agent -> Tool -> Agent -> Tool. Results are deterministically ordered and assigned IDs of the form PATH-0001.
func EnumerateAll ¶
EnumerateAll enumerates paths from every AI agent in the graph. IDs are assigned across the combined, deterministically sorted result. When any single agent's enumeration hits the MaxPaths cap, its partial results are kept and enumeration continues with the remaining agents; the returned error is a *TruncatedError in that case.
func Shortest ¶
Shortest returns the shortest path (fewest hops) from source to a target matching the spec, using breadth-first search. Target resolution: if targetSpec exactly matches a node ID, that node is used; otherwise the spec is matched case-insensitively as a substring of node ID or name. Returns nil if no target matches or no path exists.
func ShortestToPredicate ¶
ShortestToPredicate returns the shortest path from source to any node for which match returns true.
type TruncatedError ¶
type TruncatedError struct{ Found int }
TruncatedError is returned when enumeration hits the MaxPaths cap. Partial results are returned alongside it.
func (*TruncatedError) Error ¶
func (e *TruncatedError) Error() string