---
title: Signal Engine
url: https://arcana.otnelhq.com/docs/signal-engine
---

New in v0.4.0 

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:

1. **Preflight** — Infer an expectation contract from the user's request
2. **Context pack** — Include what matters, summarize bulky context, drop irrelevant
3. **LLM call** — Provide the contract as a prompt addendum (no intent rewriting)
4. **Postflight** — Score for genericity, specificity, actionability, constraint fit
5. **Revise** — If the response fails but the request is clear, revise silently
6. **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:

```bash
# 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:

```bash
# Enable ML runtime
ARCANA_ML_RUNTIME=1 arcana run "explain this codebase"
```

## Related

- [Permissions](/docs/permissions) — Permission firewall and benign auto-allow
- [File Edit Guard](/docs/file-edit-guard) — Line-level mutation analysis
- [Session Compaction](/docs/session-compaction) — Context packing and token budgeting
