Workspace Crates¶
Perspt is organized as a 9-crate Rust workspace under the crates/ directory,
plus a meta-crate (perspt) that re-exports all libraries.
![digraph deps {
rankdir=TB;
node [shape=box, style="rounded,filled", fontname="Helvetica", fontsize=10];
cli [label="perspt-cli\n10 commands", fillcolor="#4ECDC4"];
tui [label="perspt-tui\nRatatui UI", fillcolor="#96CEB4"];
agent [label="perspt-agent\nSRBN Engine", fillcolor="#FFEAA7"];
core [label="perspt-core\nLLM + Types", fillcolor="#45B7D1"];
store [label="perspt-store\nDuckDB", fillcolor="#87CEEB"];
policy [label="perspt-policy\nStarlark", fillcolor="#DDA0DD"];
sandbox [label="perspt-sandbox\nIsolation", fillcolor="#F8B739"];
dashboard [label="perspt-dashboard\nWeb UI", fillcolor="#FFB6C1"];
cli -> tui;
cli -> agent;
cli -> core;
cli -> store;
cli -> dashboard;
agent -> core;
agent -> store;
agent -> policy;
agent -> sandbox;
dashboard -> store;
dashboard -> core;
}](../_images/graphviz-4e18b5c75365d7cb5bc07e5a3a38d537b21d1048.png)
Crate Dependencies¶
Crate Summary¶
Crate |
Purpose |
Key Types |
|---|---|---|
perspt-cli |
Binary entry point with 10 subcommands |
|
perspt-core |
LLM provider abstraction, config, types, events, plugins |
|
perspt-agent |
SRBN orchestrator, agents, LSP client, tools, test runner, ledger |
|
perspt-tui |
Ratatui-based terminal UI for chat and agent monitoring |
|
perspt-store |
DuckDB persistence for sessions, energy, LLM logs |
|
perspt-policy |
Starlark-based policy engine and command sanitization |
|
perspt-sandbox |
Sandboxed command execution with resource limits |
|
perspt-dashboard |
Browser-based agent monitoring (Axum + Askama + HTMX) |
|
perspt-cli¶
The CLI crate parses arguments with clap and dispatches to the appropriate
handler. Subcommands: chat, agent, simple-chat, init, config,
ledger, status, abort, resume, logs.
perspt-core¶
Contains all shared types used across the workspace:
Types:
SRBNNode,NodeState,NodeClass,ModelTier,TaskPlan,BehavioralContract,StabilityMonitor,EnergyComponents,AgentContext,TokenBudget,RetryPolicy,OwnershipManifest,PlanningPolicy,FeatureCharter,BudgetEnvelope,RepairFootprint,SessionOutcome,NodeOutcomeEvents:
AgentEventenum with 40+ lifecycle event variants (PSP-5)Plugins: Language plugin registry (Rust, Python, JS, Go) with LSP config, test runner, init commands, and required binaries
Config:
Configstruct with provider, model, and API keyLLM Provider:
GenAIProvider— thread-safe wrapper around thegenaicrate with streaming support and retry logic
perspt-agent¶
The heart of SRBN:
Orchestrator:
SRBNOrchestratormanages the DAG (petgraph), drives the 7-phase control loop, manages LSP clients, and integrates TUI events. Split into submodules:mod.rs,bundle.rs,commit.rs,convergence.rs,init.rs,planning.rs,repair.rs,solo.rs,verification.rsAgents:
Agenttrait with four implementations —ArchitectAgent,ActuatorAgent,VerifierAgent,SpeculatorAgentTools:
AgentTools—read_file,write_file,apply_patch,apply_diff,run_command,search_code,list_files,sed_replace,awk_filter,diff_filesLSP Client: Native LSP client supporting
rust-analyzer,ty,pyright,typescript-language-server,goplsTest Runner:
PythonTestRunner(pytest) with V_log calculationLedger:
MerkleLedgerbacked byperspt-storeContext Retriever:
ripgrep-based code search for context injectionPrompts: Centralized prompt templates in
prompts.rswith constants andrender_*helper functions for all agent tiers
perspt-tui¶
Ratatui components:
ChatApp — Interactive chat with markdown rendering and virtual scrolling
AgentApp — SRBN monitoring with dashboard, task tree, and diff viewer
ReviewModal — Approval UI with grouped diff view and verification gates
LogsViewer — LLM request/response log inspector
Dashboard — Status display with energy breakdown
TaskTree — Node execution tree with state indicators
perspt-store¶
DuckDB-based persistence layer. Tables include sessions, node states, energy records, verification results, LLM request logs, provisional branches, interface seals, artifact bundles, escalation reports, and sheaf validations.
perspt-policy¶
Starlark-based execution policy:
sanitize_command()validates commands before executionvalidate_workspace_bound()ensures file operations stay within the projectvalidate_artifact_mutation()protects root project files from delete/move
perspt-sandbox¶
Sandboxed command execution with resource limits. Used for running build and test commands in controlled environments during provisional branch verification.
perspt-dashboard¶
Browser-based real-time monitoring of agent sessions. Built with Axum 0.8, Askama 0.15 templates, HTMX 2 for partial updates, and Tailwind v4 / DaisyUI 5 for styling. Opens the session store in read-only mode so it never interferes with the running agent. Provides Overview, DAG, Energy, LLM, Sandbox, and Decisions pages plus an SSE stream for live updates.