Skip to content
Back to skills

Brain

ASecurity

Intelligent routing of tasks between Local (OS) and Remote (Cloud) resources based on complexity, privacy, and cost constraints.

  • 23 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added October 14, 2026
ai-agentsgoreactrailsdebuggingrefactoringapisecurity

Works with

  • cli
  • api

Security analysis

A100/100

Pro scans all 21 files and shows the line behind each finding

Scanned October 14, 2026

npx -y skills add andreibesleaga/GABBE --skill brain --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Brain?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Brain
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/andreibesleaga-brain-b9af8478/badge)](https://www.skillsdirectory.com/skills/andreibesleaga-brain-b9af8478)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: cost-benefit-router
description: Intelligent routing of tasks between Local (OS) and Remote (Cloud) resources based on complexity, privacy, and cost constraints.
triggers: [route task, optimize cost, choose model, local or remote]
tags: [brain]
core: true
context_cost: low
---
# Cost-Benefit Router

## Goal
> **Purpose**: Decide the most efficient execution path for a given task.
> **Philosophy**: "Don't use a cannon to kill a mosquito."

## Logic Flow

### Steps
## 1. Complexity Scoring (0–10 conceptual band)
This 0–10 banding is an illustrative conceptual scale; the actual `gabbe route` CLI scores
**0–100** against a single threshold and returns one `LOCAL`/`REMOTE` verdict. Analyze the prompt/task:
- **0-3 (Low)**: Typos, simple regex, one-line fixes, known boilerplate.
  - *Recommendation*: **LOCAL** (Llama-3-8b, Mistral, Grep/Sed).
- **4-7 (Medium)**: React components, API integration, unit tests, refactoring.
  - *Recommendation*: **HYBRID** (Draft Local -> Polish Remote) or mid-tier Cloud.
- **8-10 (High)**: System architecture, security review, complex debugging, creative writing.
  - *Recommendation*: **REMOTE SOTA** (Claude 3.5 Sonnet, GPT-4o).

### 2. Context Analysis
- **Privacy Critical?** (PII, Credentials, Proprietary Core) -> **FORCE LOCAL**.
- **Context Size?** (>32k tokens) -> **REMOTE** (or Local with RAG).

### 3. Routing Table

| Score | Privacy | Context | Decision | Rationale |
|---|---|---|---|---|
| Low | Any | Low | **LOCAL** | Speed, Free, Good enough. |
| Med | Low | Med | **REMOTE (Mini)** | Fast cloud models (Haiku/Flash). |
| Med | High | Any | **LOCAL (Large)** | Llama-3-70b (if available). |
| High | Low | High | **REMOTE (SOTA)** | Intelligence required via API. |
| High | High | Any | **LOCAL (Max)** | Best available local quantization. |

## Usage

**Input**:
```json
{
  "task": "Fix a typo in README_FULL.md",
  "files": ["README_FULL.md"],
  "user_preference": "auto"
}
```

**Output**:
```json
{
  "route": "LOCAL",
  "model": "mistral-tiny",
  "reason": "Low complexity task, no reasoning required."
}
```

## Self-Adaptive Routing

> **Conceptual framing vs the actual CLI.** The implemented `gabbe route` command returns a
> **one-shot binary decision** (`LOCAL` / `REMOTE`) by scoring complexity on a **0–100** scale
> against a threshold, with a **PII/DLP override that forces `LOCAL`**. The richer behaviors
> described below — the multi-tier ladder, the **self-correction / escalation loop**, the
> per-task **heuristic updates**, and **autonomy-gating** (`ask`/`auto`/`hybrid`) — are
> *conceptual framing for how an agent should route work*, not features the one-shot CLI
> performs. Treat them as guidance for the orchestrator's own loop, and don't claim the router
> "guarantees" the optimal/cheapest path. See `guides/ai/self-evolving-skills.md`.

In GABBE the router is designed to behave self-adaptively end to end: it scores task **complexity**,
layers in **privacy** (a PII/DLP hit forces `LOCAL`, overriding any complexity score), and weighs
**context size** to pick the cheapest path that can still do the job. Conceptually it is gated by
autonomy level (`GABBE_AUTONOMY` = `ask` | `auto` | `hybrid`): `ask` confirms each route,
`auto` routes silently, `hybrid` auto-routes the safe cases and asks on the rest. The framing also
includes **self-correction** — when a `LOCAL` attempt fails, the orchestrator escalates up the tier
ladder to a remote model (re-checking privacy first) and updates its heuristics for next time —
though the bare `gabbe route` CLI returns only the single LOCAL/REMOTE verdict (the loop lives in
the calling agent).

## Self-Correction
If a routed task FAILS (e.g., Local model produces garbage):
1.  Log failure.
2.  **Escalate**: Retry with next tier up (Local -> Remote Mini -> Remote SOTA).
3.  Update heuristics.

## Security & Guardrails

### 1. Skill Security (Cost-Benefit Router)
- **Hard-Coded Privacy Overrides**: The agent must mathematically enforce the "Context Analysis" rule (Step 2). If a regex pattern or Data Loss Prevention (DLP) scanner flags *any* data in the context as highly sensitive (API keys, PII, internal proprietary source code), the router `decision` variable MUST be overwritten to `LOCAL`, regardless of the High Complexity score.
- **Router Tampering**: The logic that determines `Complexity Scoring` and `Routing Table` execution represents the core security boundary preventing exfiltration to the cloud. The agent must ensure the file dictating these rules (`cost-benefit-router.skill.md`) is read-only during execution and requires explicit human approval to modify its heuristics.

### 2. System Integration Security
- **Escalation Data Leakage**: In the "Self-Correction" phase, if a `LOCAL` task fails, the router escalates to `REMOTE SOTA`. If the task originally failed *because* it involved obfuscated proprietary data that the local model couldn't handle, escalating it blindly to the cloud causes an immediate data breach. The agent must completely re-run the Privacy/DLP Context check before any escalation path is approved.
- **Downgrade Attacks (Cost Exhaustion)**: An attacker might submit a massive volume of highly complex tasks disguised as "simple typos" or "routine tasks." If the router misclassifies them, it forces the system to either use expensive `REMOTE SOTA` models incessantly (Cost Exhaustion DoS) or stall out the local GPU (Compute Exhaustion DoS). The router must apply strict Rate Limiting to the intake queue before classification.

### 3. LLM & Agent Guardrails
- **Model Capability Hallucination**: The directing LLM might confidently assert that a small local model (e.g., Llama-3-8b) is perfectly capable of safely refactoring a critical Cryptographic Key Management module because the code is "short." The agent must override this; tasks involving Security, Cryptography, or IAM explicitly warrant `REMOTE SOTA` (or highly verified local experts) regardless of line-count complexity.
- **Vendor Lock-in Bias**: The LLM might develop a pattern of persistently routing medium tasks to a specific Remote provider due to implicit bias in its training data (e.g., constantly selecting GPT-4o over Claude 3.5). The router must be deterministically evaluated based on objective parameters (Token Cost, Latency, API status), totally ignoring the LLM's subjective brand preference.

Files in this skill

  • README.md3.8 KB
  • active-inference.skill.md4.4 KB
  • brain-mode.skill.md8.5 KB
  • cognitive-architectures.skill.md3.3 KB
  • cognitive-testing.skill.md5.2 KB
  • consciousness-loop.skill.md3.8 KB
  • cost-benefit-router.skill.md6.2 KB
  • episodic-consolidation.skill.md3.6 KB
  • epistemology-knowledge.skill.md4 KB
  • global-workspace.skill.md3.8 KB
  • learning-adaptation.skill.md5.2 KB
  • loki-mode.skill.md15.9 KB
  • neuroscience-foundations.skill.md3.8 KB
  • scripts/active_inference_loop.py2.6 KB
  • scripts/cognition_test.py2.2 KB
  • scripts/global_workspace.py2.8 KB
  • self-improvement.skill.md5.7 KB
  • sensory-motor.skill.md4 KB
  • sequential-thinking.skill.md3.9 KB
  • working-memory.skill.md4.2 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.