Signal engine wired into the permission firewall for real-time risk classification.
Signal Engine
The Signal Engine (@arcana/ml) is Arcana's local intelligence layer. It runs before, during, and after LLM calls to classify intent, score risk, pack context, and reject generic responses — all without sending data to the cloud.
What It Does
The signal engine provides three phases of intelligence:
Before the LLM
- Intent classification — What is the user trying to do?
- Risk scoring — How dangerous is this request?
- Sandboxing requirements — Does this need isolation?
- Model routing — Which model is best for this task?
- Token budget planning — How much context can we afford?
- Context packing — Include what matters, summarize bulky context, drop irrelevant
- Machine resource posture — Memory-only, no-write, recycle-temp, or approval-required
During Tool Use
- Tool-risk scoring — Score write/network/secret-adjacent tool calls
- Mutation detection — Detect file edits, package installs, config changes
- Disk materialization avoidance — Prevent unnecessary file creation
After Execution
- Response quality gates — Reject generic, vague, or unhelpful responses
- Expectation contracts — Verify the response meets the user's intent
- Audit signals — Structured data for governance and proof
- Machine stewardship — Cleanup, recycling, resource planning
Anti-Generic Response Pipeline
Arcana doesn't ship generic model filler. The pipeline ensures specificity:
- Preflight — Infer an expectation contract from the user's request
- Context pack — Include what matters, summarize bulky context, drop irrelevant
- LLM call — Provide the contract as a prompt addendum (no intent rewriting)
- Postflight — Score for genericity, specificity, actionability, constraint fit
- Revise — If the response fails but the request is clear, revise silently
- Ask — Only when ambiguity blocks correctness or high-impact approval needed
Machine Stewardship
Arcana is careful with your machine:
- Memory-only state — Transient analysis stays in memory
- No unnecessary files — Avoid generating files unless the operation requires it
- Recyclable storage — Temporary artifacts with TTLs
- LRU recycling — Least-recently-used temporary artifacts recycled before new allocation
- No silent persistence — Never persist embeddings, prompt logs, model outputs, or user data without explicit approval
Resource Posture
The machine advisor returns a posture for each operation:
| Posture | Meaning |
|---|---|
memory_only | Keep everything in memory, no disk writes |
no_write | Read-only operation, no writes allowed |
recycle_temp | Use temporary storage with TTL, recycle when full |
approval_required | Must get user approval before writing |
Evaluations
The signal engine includes deterministic JSON fixtures for regression testing:
# Run signal engine evaluations
bun --cwd packages/ml run eval
Fixtures cover: expectation contracts, response quality, token budgeting, SQL optimization, and machine stewardship.
Configuration
Enable the signal engine with an environment variable:
# Enable ML runtime
ARCANA_ML_RUNTIME=1 arcana run "explain this codebase"