toolpath
Core types, builders, and query operations for Toolpath provenance documents.
Toolpath records who changed what, why, what they tried that didn't work, and how to verify all of it. Think "git blame, but for everything that happens to code — including the stuff git doesn't see."
Three objects model this: a Step is one atomic change by one actor. A Path is a DAG of steps (like a PR) — abandoned branches become implicit dead ends. A Graph collects related paths (like a release) and is the single root type of every Toolpath document.
Overview
This crate provides the type system and query API for Toolpath. It contains:
- Types:
Graph,Path,Step,ArtifactChange, and all supporting structures - Builders: Convenient constructors and builder methods for constructing documents
- Serde: Full serialization/deserialization
- Query: Graph traversal and filtering operations on step DAGs
This is the gravity well of the workspace. All other crates depend on toolpath; it depends on nothing except serde and serde_json.
Types
Graph -- the root type of every Toolpath document
graph: GraphIdentity { id }
paths: Vec<PathOrRef> -- inline Path or $ref
meta?: GraphMeta
Path
path: PathIdentity { id, base?, head }
steps: Vec<Step>
meta?: PathMeta
Step
step: StepIdentity { id, parents, actor, timestamp }
change: HashMap<String, ArtifactChange>
meta?: StepMeta
Building documents
use ;
// Build a step
let step = new
.with_parent
.with_raw_change
.with_intent
.with_vcs_source;
// Build a path
let path = new;
// Branch from another path's step
let base = toolpath;
Query operations
The query module provides graph traversal and filtering over step slices:
use ;
let s1 = new
.with_raw_change;
let s2 = new
.with_parent
.with_raw_change;
let steps = vec!;
let ancestors = ancestors;
let dead_ends = dead_ends;
let human_steps = filter_by_actor;
let main_rs = filter_by_artifact;
let all_files = all_artifacts;
let all_actors = all_actors;
let index = step_index;
Serialization
A Toolpath document is a JSON-serialized Graph at the root. Single-step or
single-path provenance becomes a single-path graph:
use ;
let step = new
.with_raw_change;
let path = Path ;
let graph = from_path;
let json = graph.to_json_pretty.unwrap;
assert!;
let parsed = from_json.unwrap;
assert_eq!;
Part of Toolpath
This crate is the core of the Toolpath workspace. See also:
toolpath-git-- derive from git historytoolpath-claude-- derive from Claude conversationstoolpath-dot-- Graphviz DOT renderingpath-cli-- unified CLI (cargo install path-cli)- RFC -- full format specification
- FAQ -- design rationale