Skip to main content

Crate trusty_code

Crate trusty_code 

Source
Expand description

trusty-code — per-project Claude-Code-compatible MPM orchestration harness.

§Why

Each Claude-Code project needs a harness that is already wired to its own .claude configuration: agents, skills, MCP connections, CLAUDE.md, and permissions. trusty-code fills that role as an original, purpose-built coding harness. It is the Claude-Code-native orchestration entry point — driven by API, CLI, or TUI — that runs the PM main-loop, enforces the mandatory workflow, and delegates authority to typed sub-agents according to MPM protocols. Its non-coding sibling, trusty-agents, is a separately-installable general-purpose orchestration platform for personal-productivity workflows; the two share architectural DNA but trusty-code is not extracted from it. Tracked under epic #2052.

§Design constraints

  • Claude-Code compatible — reads .claude/ config, agents, skills, MCP descriptors, CLAUDE.md, and permission grants exactly as Claude Code does.
  • API / CLI / TUI driven — no hooks support (hooks are a Claude Code shell-level feature; tcode operates above that layer via its event bus).
  • Per-agent model routing — each agent may specify its own model, independently choosing between AWS Bedrock models and OpenRouter models.
  • Single-instance per project — one tcode serve process per .claude/ root; multiple CLI or TUI clients may attach to it.
  • No unwrap() in library code — all fallible paths use ? with thiserror-derived error types (once errors exist to derive); application entry points use anyhow::Result.

§What

Phase 1 public surface (leaf/protocol modules, per #640):

  • events — process-global broadcast event bus.
  • ipc — NDJSON IPC protocol for PM ↔ sub-agent communication.
  • perf — per-phase latency + token/cost instrumentation.
  • intent — pure-Rust heuristic intent classifier.
  • progress — real-time phase progress reporter.
  • build_info — monotonic build counter + version banner.

Phase 2 public surface (tools layer, per #641):

  • tools — ToolExecutor / AgentRunner / SearchProvider traits, ToolRegistry dispatcher, DelegateToAgentTool, ToolResult.
  • rbac — ServiceTier, UserIdentity, access-control helpers.

Phase 3 public surface (agents + LLM layer, per #642):

  • agents — AgentConfig TOML schema, discover_agents, load_all_agents.
  • identity — CallerIdentity, RecallCeiling for memory scoping.
  • logging — tracing init helpers (init_tracing, init_tracing_for_test).

§Test

cargo test -p trusty-code — all modules carry their own unit tests.

Modules§

agent_loop
Multi-turn agent loop driving an LLM through tool calls to completion.
agents
Agent configuration loading.
build_info
Build and version tracking.
catchup
DOC-28 catch-up context injection for the PM prompt (#1762, PR2).
cli_client
Thin JSON-RPC client the tcode CLI binary drives against its own spawned tcode serve --stdio child (#2060, vision spec §4.4 “CLI as Thin Client” / Axiom 3 “API-First”).
events
Process-wide broadcast event bus for real-time UI streaming.
identity
Caller identity hierarchy for memory scoping.
intent
Pure-Rust heuristic intent classifier for PM fast-pathing.
ipc
NDJSON IPC protocol for PM ↔ sub-agent communication.
jsonrpc
JSON-RPC 2.0 core: wire types (re-exported from trusty_common::mcp) plus the tcode-specific Router/RpcError extensibility seam.
llm
Native OpenRouter LLM client.
logging
Tracing and logging initialisation.
mode
Harness mode selection: daily-driver (default, token-efficiency consumption point) vs parity (full-schema benchmark mode) — #2059, vision spec §5.9.
perf
Per-phase latency + token/cost instrumentation.
progress
Real-time phase progress reporter to stderr.
project_context
Project-context ingestion — load CLAUDE.md for prompt injection (#1033).
prompt
System-prompt assembly layer implementing the parity spec.
provider
Provider abstraction and per-agent model routing.
rbac
Role-based access control for tool execution.
run_task
tcode run-task end-to-end execution layer (#1034, #1035).
runner
In-process agent runner — the runtime execution layer (per #1029).
serve
tcode serve daemon: STDIO + HTTP JSON-RPC transports + proof-of-life methods.
session
Daemon-owned session model + attach/detach protocol (#2054, Axiom 4).
skills
Progressive-disclosure skill discovery for .claude/skills/ (#2069, vision spec §5.3, Resolved Decision #7).
task
Daemon-owned task execution: task.run + background agent-loop orchestration (#2056, M1 control-plane cut line).
tools
Tool system: traits, registry, and the delegate tool.

Constants§

VERSION
Version string, re-exported so integration tests can assert it without hard-coding the constant.