Shadow — Live Compiler
The Shadow Compiler runs cargo check in the background and provides live diagnostics to the LLM. It enables the LLM to check compilation status and auto-fix issues without manual intervention.
How It Works
Project root detected with Cargo.toml
→ ShadowCheckPlugin spawns background thread
→ Runs: cargo check --message-format=json
→ Parses JSON output into structured diagnostics
→ Stores in DiagnosticStore (thread-safe)
→ Broadcasts DiagnosticUpdated event
→ Re-checks on file changes (debounced)Diagnostic Types
Each diagnostic includes:
- File path — Source file containing the error
- Line/column — Exact location
- Severity — Error or Warning
- Code — Rust error code (e.g.,
E0425,unused_variables) - Message — Human-readable description
- Suggestions — Compiler-suggested fixes with applicability level
Suggestion Applicability
| Level | Meaning | Auto-apply? |
|---|---|---|
MachineApplicable | Safe to apply automatically | Yes |
MaybeIncorrect | Might not be right | Ask user first |
HasPlaceholders | Requires manual input | No |
Unspecified | Unknown | No |
MCP Integration
| Tool | Description |
|---|---|
diagnostics | Get current errors/warnings, optionally filtered by file |
quickfix | Apply a MachineApplicable fix by file and error code |
Usage Flow
- LLM writes code
- Shadow compiler detects change, re-checks
- LLM calls
diagnosticsto see errors - LLM calls
quickfixfor auto-fixable issues - Repeat until clean
json
// Step 1: Check for errors
{"method": "tools/call", "params": {"name": "diagnostics", "arguments": {}}}
// Step 2: Fix an error
{"method": "tools/call", "params": {"name": "quickfix", "arguments": {"file": "src/main.rs", "error_code": "unused_variables"}}}Security Considerations (D39)
Warning: The Shadow Compiler executes
cargo checkas a child process with the full privileges of the current user. Cargo's check phase compiles and runsbuild.rsbuild scripts, which can contain arbitrary code (network I/O, file system writes, environment variable reads, etc.).
Risks
| Risk | Description |
|---|---|
Malicious build.rs | An untrusted project can execute arbitrary code when the Shadow Compiler runs cargo check in the background. |
| Supply chain | A compromised dependency's build.rs runs automatically. |
| Data exfiltration | A build.rs can read ~/.ssh, ~/.aws, environment variables, and send them over the network. |
Mitigations
- Only open trusted projects. The same risk applies to any
cargo build/cargo checkinvocation — this is a general Cargo security property, not specific to Synapseed. - Review
build.rsfiles in new projects and dependencies before opening them. - DNA opt-out: Disable background compilation in
.synapseed/dna.yaml:yamlhci: shadow_check: false - Environment hardening: Never run in shells with production credentials in environment variables.
- Future work: Sandbox
cargo checkviabubblewrap(Linux) or similar isolation on supported platforms.
For the full threat model and review checklist, see Build Script Security.