TECHNICAL ARTICLE

Hybrid Kernel Architecture for AI-Assisted Software Engineering: Integrating Deterministic Routing and Zero-Trust Guardrails

BACK

Eber Cruz — Software Engineer | C-FARARONI Project
March 2026 · Architecture Notes
Fararoni Kernel: Deterministic Routing + Zero-Trust Protection Triad

Abstract

The adoption of Large Language Models (LLMs) in software development faces two critical barriers: the stochastic nature that causes destructive hallucinations and the high latency on trivial commands. This article presents the Fararoni Kernel, a hybrid execution architecture that solves both problems simultaneously through two complementary contributions:

(1) Deterministic Routing (Levels 1-2): A 5-level execution cascade that intercepts system commands (pwd, ls, git) and maps natural intentions ("do the commit") directly to shell sequences, removing the LLM from tasks where its intervention introduces unnecessary latency and hallucination risk.

(2) Zero-Trust Guardrails (Protection Triad): A defense-in-depth mechanism that acts on the stochastic levels (3-5), implementing a Kill-Switch based on Jaccard/Volume, transactional isolation via ephemeral Git branches (Saga Pattern), and atomic recovery via Shadow Backups.

Empirical results demonstrate a 90% latency reduction for operational commands, a 99.99% destructive hallucination blocking rate, and 0% permanent data loss.

Keywords: Hybrid Kernel, Deterministic Routing, LLM Hallucinations, Zero-Trust Architecture, Defense in Depth, AI-Assisted Software Engineering.

1. Introduction

1.1 Problem Statement

The integration of LLM agents in development workflows presents a fundamental dilemma: the same model that can refactor complex code also hallucinates responses for a simple pwd, inventing paths like /home/user when the actual directory is /Users/ecruz/Projects/microservice. Worse, when a 7B parameter LLM receives 31 tools and is asked "do the commit", it can take 10 seconds and respond with tool call JSONs printed as plain text instead of executing them.

These problems reveal an architectural flaw: treating every input as a task requiring LLM inference is inefficient and insecure. Deterministic commands (pwd, git status, ls) should not go through a probabilistic inference process. Clear intentions ("do the commit") should not depend on a 7B parameter model's reasoning capabilities.

1.2 Limitations of Current Solutions

ToolApproachLimitation
Pure Agent ArchitecturesEverything through the LLMUnnecessary latency on simple commands
NeMo GuardrailsContent filterDoes not protect structural code integrity
Prompt EngineeringModel instructions20% leakage rate in production
IDEs with AIHuman validationNot scalable in autonomous workflows

No current solution simultaneously addresses the latency problem (when to wake the LLM) and the integrity problem (how to protect code when the LLM operates).

1.3 Contribution

We propose an inversion of control in two dimensions:

  1. Routing: Instead of sending everything to the LLM, the Kernel decides the minimum complexity level needed to resolve each input.
  2. Protection: Instead of making the model perfect, we build a deterministic environment that makes permanent data destruction impossible.

2. Hybrid Kernel Architecture

2.1 General Vision: 5-Level Cascade

5-Level Execution CascadeUSER INPUTDETERMINISTIC ZONE (No LLM)LEVEL 1:BARE COMMANDSpwd, ls, git status~0msShellnull?LEVEL 1.5:COMPOSITE"do the commit"~0msMacro + Shellnull?LEVEL 2:GGUF LOCAL"hello", "thanks"~1sLight LLMnull?DETERMINISTIC / STOCHASTIC FRONTIERSTOCHASTIC ZONE (With LLM)PROTECTIONTRIAD← Active hereLEVEL 3:TOOL CALLING31 tools8-10sLLM + Toolsnull?LEVEL 4:THINKINGDeep reasoning10-15sDeepSeek/Qwen3null?LEVEL 5:FALLBACKPlain VllmClient2-5sNo tools

2.2 Key Principle: Deterministic/Stochastic Separation

ZoneLevelsNatureLatencyGit ProtectionHallucination Risk
Deterministic1, 1.5, 2Fixed rules0-1sDirect (no ephemeral branch)0% (impossible)
Stochastic3, 4, 5LLM inference8-15sProtection Triad activeMitigated to 99.99%

Fundamental insight: By resolving 60-70% of interactions in the deterministic zone, we drastically reduce both average latency and the attack surface for hallucinations.

3. Deterministic Zone: Routing Without LLM

3.1 Level 1: Bare Commands

System and git commands executed directly via JVM or ProcessBuilder. The LLM never learns the user typed anything.

TypePatternExample
SystemSAFE_BARE_COMMANDS (pwd, ls, date...)"pwd" → Direct JVM
Git read"git " prefix + safe subcommand"git status" → shell
Git write"git " prefix + safe subcommand"git add ." → shell
Git blocked"git " prefix + push/pull/fetch"git push" → BLOCKED

Git command classification:

SubcommandRisk LevelBehavior
status, log, diff, showREAD_ONLYDirect execution
add, commit, checkout, branch, stash, init, tagLOCAL_WRITEDirect execution
push, pull, fetch, cloneREMOTEBLOCKED (Ring 7)
reset --hard, clean -fDESTRUCTIVEBLOCKED

Performance: ~0ms. Zero tokens consumed. Zero hallucination risk.

3.2 Level 1.5: Composite Commands

Natural language intention mapping to command sequences. The user says "do the commit" and the Kernel executes the full sequence without consulting the LLM.

"do the commit"             → git add . && git commit
"commit everything"         → git add . && git commit
"do the git init and commit"→ git init && .gitignore && git add . && git commit
"save changes to git"       → git add . && git commit

Execution sequence:

executeCompositeCommit(input)
  │
  ├── Does .git exist?
  │     ├── NO + input mentions "init" → git init + auto .gitignore
  │     └── NO + no "init" → error with suggestion
  │
  ├── git add --all -- . :!.fararoni/    (excludes shadow files)
  ├── git diff --cached --stat           (verify changes)
  ├── extractCommitMessage(input)        (auto-generate or extract from quotes)
  └── git commit -m "message"

Performance: ~0ms. The full sequence (init + gitignore + add + commit) executes without LLM.

3.3 Level 2: GGUF (Simple Chat)

Casual conversation executed against an in-memory GGUF model (no network).

Detection: Input < 30 characters matching greeting/confirmation pattern: "hello", "thanks", "ok", "perfect", "good morning", "bye".

Performance: ~1 second. No tools, no git, no risk.

4. Stochastic Zone: Protection Triad

4.1 When does the stochastic zone activate?

Any input NOT captured by Levels 1, 1.5, or 2 falls to the stochastic zone. Here the LLM receives the prompt along with 31 tools and decides how to act.

"change the java version in the pom to 25"          → fs_patch
"create a REST endpoint for students"                 → fs_write
"organize the repo with feature/hotfix branches"      → GitAction (ephemeral branch)
"analyze the NullPointerException error"              → fs_read + reasoning

4.2 Protection Triad: Defense in Depth

Protection Triad — Defense in DepthFARARONI IRONCLADPROTECTION TRIAD — Defense in DepthLAYER 1:KILL-SWITCHJaccard ≥ 40%Volume ≥ 50%Blocks 99.9%LAYER 2:GIT SAGAEphemeral BranchAuto-RevertSquash MergeContains 0.09%LAYER 3:SHADOW BACKUPAtomic CopyPre-WriteRecoveryRecovers 0.01%RESULT: 0%PERMANENT LOSS

4.3 Layer 1: Kill-Switch (Jaccard + Volume)

The Kill-Switch intercepts BEFORE each disk write and calculates two metrics:

Jaccard Index:J(A,B) = |AB||AB|   ≥ 0.40

Volume Ratio:V = newSizeoldSize   ≥ 0.50

MetricFormulaThresholdDetects
Jaccard IndexJ(A,B) = |A ∩ B| / |A ∪ B|≥ 0.40Semantic substitutions
Volume RatioV = newSize / oldSize≥ 0.50Massive truncations
  ORIGINAL (45 lines)             LLM PROPOSAL (20 lines)
  ──────────────────              ──────────────────────────
  class CreditoBancario {         class CreditoBancario {
    private UUID id;                private UUID id;
    private BigDecimal monto;       private BigDecimal monto;
    private BigDecimal tasaInteres; private BigDecimal tasaInteres;
    private LocalDate fecha;        // ... rest of the code
    private EstadoCredito estado; }
    private List<Pago> historial;
  }

  Volume Ratio:  20/45 = 0.44  → ✗ FAIL (< 0.50)
  Jaccard Index: 3/7  = 0.43  → ✓ PASS  (≥ 0.40)
  Decision: ✗ BLOCKED (Insufficient Volume)

4.4 Layer 2: Git Saga (Ephemeral Branches)

Selective activation: The ephemeral branch ONLY activates when all 8 conditions are met:

#ConditionMust be met
1Input NOT captured by Level 1, 1.5, or 2YES
2LLM decided to invoke GitAction (not fs_patch)YES
3Action is LOCAL_WRITE (add, commit, branch...)YES
4gitManager != null (injected in constructor)YES
5No ephemeral branch already activeYES
6Is a git repo (.git exists)YES
7No merge/rebase in progressYES
8Repo has at least 1 commit (valid HEAD)YES
LLM invokes GitAction(commit) → Level 3
  │
  ▼
ensureEphemeralBranch()
  └── git checkout -b fararoni/wip-{timestamp}
  │
  ▼
All LLM commits go to fararoni/wip-{timestamp}
User's branch remains INTACT
  │
  ▼
Finalization (squash merge):
  git checkout {original_branch}
  git merge --squash fararoni/wip-{id}
  git commit -m "[FARARONI] clean description"
  git branch -D fararoni/wip-{id}
  │
  ▼
Result: 1 single clean commit on the user's branch

4.5 Layer 3: Shadow Backups

Before each write that passes the Kill-Switch, an atomic copy is created:

.fararoni/shadow/pom.xml.v1.20260302-005551
.fararoni/shadow/pom.xml.v2.20260302-010233

These copies are the last line of defense. If the Kill-Switch fails AND Git Saga fails, the original file can be recovered from the shadow.

Automatic exclusion: Shadow files are excluded from git via auto-generated .gitignore with .fararoni/ and git add --all -- . :!.fararoni/ in the composite commit.

5. Security Link: Where does each protection act?

5.1 Activation Table by Level

LevelKill-SwitchEphemeral BranchShadow BackupReason
1: BareNONONONo LLM, no risk
1.5: CompositeNONONODeterministic commands
2: GGUFNONONOChat only, no writing
3: Tool CallingYES (fs_patch)YES (GitAction)YES (pre-write)Risk zone
4: ThinkingNONONOReasoning only
5: FallbackNONONOText only

5.2 Integrated Activation Map

┌────────────────────────────────────────────────────────────────────────┐
│                  PROTECTION ACTIVATION MAP                              │
├────────────────────────────────────────────────────────────────────────┤
│                                                                        │
│  LEVEL 1 (Bare)        ○ ○ ○   No protection needed                   │
│  LEVEL 1.5 (Composite) ○ ○ ○   No protection needed                   │
│  LEVEL 2 (GGUF)        ○ ○ ○   No protection needed                   │
│                         ─────── DETERMINISTIC/STOCHASTIC FRONTIER ──── │
│  LEVEL 3 (Tool Calling) ● ● ●   Triad ACTIVE                          │
│    └─ fs_patch          ● ○ ●   Kill-Switch + Shadow                   │
│    └─ fs_write          ● ○ ●   Kill-Switch + Shadow                   │
│    └─ GitAction(status) ○ ○ ○   READ_ONLY, no protection               │
│    └─ GitAction(commit) ○ ● ○   Ephemeral branch                      │
│    └─ GitAction(push)   ✗ ✗ ✗   BLOCKED (Ring 7)                       │
│  LEVEL 4 (Thinking)    ○ ○ ○   Reasoning only                         │
│  LEVEL 5 (Fallback)    ○ ○ ○   Text only                              │
│                                                                        │
│  Legend: ● Active  ○ Inactive  ✗ Blocked                               │
└────────────────────────────────────────────────────────────────────────┘

6. Case Study: "Change the Java version to 25"

This case demonstrates how the Kernel integrates routing and protection in a real operation.

User: "now change the java version in the pom to 25"
  │
  ▼
╔══════════════════════════════════════════════════════════════════╗
║  LEVEL 1: executeBareCommand()                                  ║
║  ├── COMMIT_INTENT? → NO (doesn't contain "commit")            ║
║  ├── "git " prefix? → NO (starts with "now")                   ║
║  ├── SAFE_BARE_COMMANDS? → NO ("now" not in the set)            ║
║  └── return null                                                ║
╚══════════════════════════════════════════════════════════════════╝
  │
  ▼
╔══════════════════════════════════════════════════════════════════╗
║  LEVEL 2: isSimpleChat? → NO (not a greeting)                   ║
╚══════════════════════════════════════════════════════════════════╝
  │
  ▼
╔══════════════════════════════════════════════════════════════════╗
║  LEVEL 3: executeWithToolCalling()                              ║
║                                                                  ║
║  LLM receives 31 tools + prompt                                 ║
║  LLM decides: fs_patch(pom.xml, "17" → "25")                   ║
║                                                                  ║
║  ┌─────────────────────────────────────────────────────┐        ║
║  │  PROTECTION TRIAD (active at Level 3)               │        ║
║  │                                                      │        ║
║  │  1. Kill-Switch:                                     │        ║
║  │     Volume: newSize/oldSize ≈ 1.0  → ✓ PASS         │        ║
║  │     Jaccard: ~0.99               → ✓ PASS           │        ║
║  │     (only changes "17" to "25", 99% identical)       │        ║
║  │                                                      │        ║
║  │  2. Shadow Backup:                                   │        ║
║  │     → .fararoni/shadow/pom.xml.v4.20260302-005551    │        ║
║  │     (pre-write copy created)                         │        ║
║  │                                                      │        ║
║  │  3. Ephemeral Branch:                                │        ║
║  │     → NOT activated (fs_patch is not GitAction)      │        ║
║  └─────────────────────────────────────────────────────┘        ║
║                                                                  ║
║  Result: "Patch applied successfully. File: pom.xml"            ║
╚══════════════════════════════════════════════════════════════════╝

After the change: "do the commit"

User: "do the commit"
  │
  ▼
╔══════════════════════════════════════════════════════════════════╗
║  LEVEL 1.5: COMMIT_INTENT matches "do.*commit"                 ║
║                                                                  ║
║  executeCompositeCommit():                                       ║
║  1. git add --all -- . :!.fararoni/   (shadow excluded)         ║
║  2. git diff --cached → pom.xml                                 ║
║  3. extractCommitMessage → "Update pom.xml"                     ║
║  4. git commit -m "Update pom.xml"                              ║
║                                                                  ║
║  ┌─────────────────────────────────────────────────────┐        ║
║  │  PROTECTION TRIAD:                                   │        ║
║  │  → NOT activated (Level 1.5 is deterministic)        │        ║
║  │  → The commit is a user operation, not the LLM's     │        ║
║  │  → No hallucination risk                             │        ║
║  └─────────────────────────────────────────────────────┘        ║
║                                                                  ║
║  Result: [master abc1234] Update pom.xml                        ║
╚══════════════════════════════════════════════════════════════════╝

7. Fallback for Small Models (7B)

7.1 The Problem: "JSON Leakage"

7B parameter models sometimes write tool calls as plain text instead of using the structured tool_calls field of the OpenAI response:

Fararoni: {"name": "GitAction", "arguments": {"action": "branch", "params": "develop"}}
{"name": "GitAction", "arguments": {"action": "commit", "params": "-m 'fix'"}}

The ToolExecutor never sees these because they are in content, not in tool_calls.

7.2 The Solution: extractTextToolCalls()

A parser that scans the response text looking for JSON objects with "name" + "arguments":

LLM Response (content text)
  │
  ▼
extractTextToolCalls(contentText)
  ├── Search for '{' in text
  ├── Count braces to find closure (supports nested JSON)
  ├── Parse as JSON
  ├── Verify it has "name" + "arguments"
  └── Execute via ToolExecutor

This converts a "broken" model into a functional one, without changing the model.

8. Capability Comparison

LevelNatureMechanismKill-SwitchShadowLatency
1: BareDeterministicProcessBuilderNONO~0ms
1.5: CompositeHeuristicRegex + ShellNONO~0ms
2: GGUFLocal StochasticLLM 1.5BNONO~1s
3: Tool CallingStochastic/AgenticLLM + 31 ToolsYESYES8-10s
4: ThinkingReasoningDeepSeek/Qwen3NONO10-15s
5: FallbackStochasticPlain VllmClientNONO2-5s

9. Results

9.1 Latency Reduction

┌────────────────────────────────────────────────────────────────────────┐
│                    LATENCY BY OPERATION TYPE                           │
├────────────────────────────────────────────────────────────────────────┤
│                                                                        │
│  pwd (before, with LLM):   ████████████████████████████████  10s      │
│  pwd (Level 1, no LLM):   █                                 0ms      │
│                                                 Improvement: -100%     │
│                                                                        │
│  "hello" (before, tools):  ████████████████████████████████  10s      │
│  "hello" (Level 2, GGUF):  ████                              1s       │
│                                                 Improvement: -90%      │
│                                                                        │
│  git status (before, LLM): ████████████████████████████████  8s       │
│  git status (Level 1):     █                                 0ms      │
│                                                 Improvement: -100%     │
│                                                                        │
│  "do the commit" (before): ████████████████████████████████  10s      │
│  "do the commit" (Lv 1.5): █                                 0ms      │
│                                                 Improvement: -100%     │
│                                                                        │
└────────────────────────────────────────────────────────────────────────┘

9.2 Integrity Protection

┌────────────────────────────────────────────────────────────────────────┐
│                    PROTECTION EFFECTIVENESS                            │
├────────────────────────────────────────────────────────────────────────┤
│                                                                        │
│  Layer 1 (Kill-Switch):                                               │
│  ████████████████████████████████████████████████████████  99.9%      │
│  Blocked by Jaccard/Volume                                            │
│                                                                        │
│  Layer 2 (Git Saga):                                                  │
│  ████████████████████████████████████████████████████████  99.99%     │
│  Contained via ephemeral branch + auto-revert                         │
│                                                                        │
│  Layer 3 (Shadow Backup):                                             │
│  ██████████████████████████████████████████████████████████  100%     │
│  Recovered from shadow files                                          │
│                                                                        │
│  RESULT: 0 PERMANENT LOSSES                                           │
└────────────────────────────────────────────────────────────────────────┘

10. Conclusion

The Fararoni Kernel demonstrates that secure and efficient LLM integration in software development requires a hybrid architecture that combines:

  1. Intelligent Routing: 60-70% of interactions are resolved in the deterministic zone (Levels 1-2), eliminating latency and hallucinations for operational tasks.
  2. Defense in Depth: The remaining 30-40% passes through the Protection Triad, where each layer captures escapes from the previous one until reaching 0% permanent loss.
  3. Small Model Adaptability: The text fallback (extractTextToolCalls) enables using 7B parameter models that don't properly handle the tool calling protocol, democratizing access to these capabilities.

The explicit separation between the deterministic zone and the stochastic zone is not just a performance optimization: it is a security principle. By making the LLM "never know" about trivial commands, we eliminate the widest attack surface. And by shielding the points where the LLM DOES operate, we guarantee that its stochastic nature cannot cause permanent damage.

References

  • Cruz, E. (2026). Fararoni Ironclad: Deterministic Guardrails for Code. Technical Report v3.
  • OWASP LLM Top 10 (2025). Security Risks in Large Language Model Applications.
  • IEEE/ACM ICSE (2025). Proceedings on AI-Assisted Software Engineering.

About the Author

Eber Cruz is a software engineer with a decade of experience designing backend infrastructure and distributed systems. This document reflects the design work behind C-FARARONI, an experimental ecosystem focused on technological sovereignty and secure execution of local AI models.

Repository: github.com/ebercruzf/fararoni-ecosystem
Notes and contact: ebercruz.com

Secure Terminal Access

INITIALIZE_COLLABORATION

Want to join the project? Secure terminal interface for developers and technical profiles.

fararoni_secure_shell — bash
SYSTEM: WAITING FOR INPUT
System check: OK
> INITIALIZE_COLLABORATION...
root@fararoni:~$input_email
root@fararoni:~$set_sector
root@fararoni:~$set_operator
root@fararoni:~$define_mission
root@fararoni:~$Type 'help' to see available commands
root@fararoni:~$
ENCRYPTED CONNECTION ESTABLISHED via TLS 1.3