Claw-Code-Parity: Coarse-Grained Executor Wrappers
Claw-Code-Parity is a Rust port of an AI agent harness, organized as a workspace of 8 crates. Unlike ZeroClaw’s per-tool Tool trait, it uses a coarser-grained ToolExecutor trait where a single executor dispatches all tool calls through a central execute() method.
Architecture Difference
This architectural difference is precisely why we chose it as a second case study:
| Aspect | ZeroClaw | Claw-Code-Parity |
|---|---|---|
| Tool abstraction | Tool trait per tool | ToolExecutor trait per executor |
| Dispatch | Each tool has its own execute() | Central execute_tool() with match statement |
| Wrapping granularity | Per-tool: RateLimitedTool<FileReadTool> | Per-executor: RateLimitedExecutor<StaticToolExecutor> |
| Middleware | None (inline guards) | None (inline guards) |
Composable ToolExecutor Wrappers
We implemented three wrappers in rust/crates/runtime/src/wrappers.rs:
RateLimitedExecutor
Sliding-window rate limiting with per-tool independent counters:
#![allow(unused)]
fn main() {
pub struct RateLimitedExecutor<T> {
inner: T,
max_calls: usize,
window: Duration,
history: BTreeMap<String, Vec<Instant>>,
}
impl<T: ToolExecutor> ToolExecutor for RateLimitedExecutor<T> {
fn execute(&mut self, tool_name: &str, input: &str) -> Result<String, ToolError> {
self.prune_expired(tool_name);
if self.count(tool_name) >= self.max_calls {
return Err(ToolError::rate_limited(tool_name));
}
self.record(tool_name);
self.inner.execute(tool_name, input)
}
}
}
PermissionGuardedExecutor
Gates tool access based on permission modes:
#![allow(unused)]
fn main() {
pub struct PermissionGuardedExecutor<T> {
inner: T,
active_mode: PermissionMode,
tool_requirements: BTreeMap<String, PermissionMode>,
}
}
Tools can be assigned minimum permission levels. If the active mode is insufficient, the executor returns a permission error without forwarding to the inner executor.
AuditLoggingExecutor
Records all tool invocations for compliance and debugging:
#![allow(unused)]
fn main() {
pub struct AuditLoggingExecutor<T> {
inner: T,
log: Arc<Mutex<Vec<AuditEntry>>>,
}
pub struct AuditEntry {
pub tool_name: String,
pub timestamp: Instant,
pub success: bool,
pub error_message: Option<String>,
}
}
Composition
The three wrappers compose as nested types (Russian-doll pattern):
#![allow(unused)]
fn main() {
let executor = AuditLoggingExecutor::new(
RateLimitedExecutor::new(
PermissionGuardedExecutor::new(
StaticToolExecutor::new(),
PermissionMode::Default,
tool_requirements,
),
10, // max 10 calls
Duration::from_secs(60), // per 60-second window
),
audit_log.clone(),
);
}
CI: Nightly Build Acceleration
We also contributed a CI workflow for accelerated release builds. The investigation process is instructive.
Hypothesis: cargo-slicer
cargo-slicer stubs unreachable library functions at the MIR level, skipping LLVM codegen for code the final binary never calls. On ZeroClaw (~100 crates), it saves approximately 27% of build time.
Benchmark Results
On this smaller workspace (8 crates), the results were different:
| Configuration | Time | vs Stable |
|---|---|---|
| Stable baseline | 50.2s | – |
| Nightly (no slicer) | 41.4s | -17.5% |
| cargo-slicer syn pre-analysis | 52.5s | +4.6% (slower) |
| cargo-slicer MIR-precise | 49.3s | -1.7% |
Analysis
The RUSTC_WRAPPER dispatch overhead of cargo-slicer exceeds the LLVM codegen savings on small workspaces. The nightly Rust compiler alone provides the meaningful speedup, likely from improved optimization passes and codegen improvements.
Outcome
The CI workflow was simplified to cargo +nightly build --release with the benchmark data documented in the PR description as the decision rationale. The honest reporting of “we tried X, it didn’t help here, here’s what works instead” was well-received.
Crosscutting Concern Analysis
Applying the RE2026 methodology (8 traditional + 6 agent-specific patterns), we found:
| Concern | Scattering Degree | aspect-rs Applicable |
|---|---|---|
| Rate limiting | High (tool dispatch) | Yes |
| Permission checking | High (tool dispatch) | Yes |
| Audit logging | Medium (scattered prints) | Yes |
| Error recovery | Medium (retry patterns) | Yes |
| Token budget tracking | Medium (usage tracking) | Yes |
| Sandbox enforcement | Low (centralized) | Yes |
| Prompt injection defense | Absent | Gap |
11 out of 12 patterns applicable (92%) – matching ZeroClaw’s coverage exactly.
Results
Both PRs have been merged to the fork’s main branch:
- PR #1: Composable
ToolExecutorwrappers with 10 unit tests - PR #2: Nightly CI build workflow with benchmark data
The upstream repository (ultraworkers/claw-code-parity) has PRs disabled, so contributions are demonstrated on the fork (yijunyu/claw-code-parity).