UtkarshSingh-09/RudraKernel

0

stars

99

commits

Python

primary language

Apr 26, 2026

updated

README

🛡️ RudraKernel — LLM Reliability Infrastructure

"Train for the wrong. Deploy for the real."

OpenEnv India 2026 Environment Agents Rewards Frontend Backend Python License


RudraKernel is a multi-agent RL environment for sleeper-agent detection and epistemic-failure resistance in LLM systems. It provides OpenEnv-compatible env APIs, composable ground-truth rewards (R1–R9), deterministic replay, and a Gradio analytics console for before/after evidence.


📑 Table of Contents



🔴 The Problem — Epistemic Cascade Failure

What breaks when agents trust each other?

Modern AI systems increasingly rely on multi-agent collaboration: agents share observations, vote on diagnoses, and collectively decide on actions. This creates a critical vulnerability:

A single compromised agent that has built trust over time can inject false information at the worst possible moment — and the entire network believes it.

We call this an Epistemic Cascade Failure: one bad belief propagates through trust edges, corrupts coalition decisions, and pushes the system to act on a lie.

Real-world analogs:

  • Clinical: a trusted node misclassifies severity and pushes unsafe escalation.
  • Infrastructure: a high-reputation bot suppresses real incident response.
  • Finance: a trusted signaler injects false market causality.

Core SIEGE question: Can an LLM learn to challenge a high-trust liar when social consensus is misleading?


🟢 The Solution — Epistemic Immune System

RudraKernel models a multi-agent network as an immune system:

BiologySIEGE
Pathogen enters bodySleeper agent enters coalition
Mimics healthy behaviorBuilds trust during cooperative phase
Immune detectionDefender spots claim-evidence inconsistency
Antibody responsechallenge action reduces trust / blocks spread
Immune memoryReputation carries across episodes
Incident Template → 8 Agents Emit Claims → Sleeper Builds Trust
→ Triggered Adversarial Flip → Defender Diagnoses/Challenges
→ R1–R9 Reward Decomposition → GRPO Update → Replay + Metrics

Design goals:

  • No LLM-judge dependence for reward scoring.
  • Explicit anti-exploit tests for each reward component.
  • Deterministic replay for auditability and demo stability.

🏗️ System Architecture

graph TB
    subgraph Frontend[Frontend — Gradio Console]
        WR[Incident Command / War Room]
        BA[Before-After]
        AR[Training Curve / Arms Race]
    end

    subgraph API[Backend — FastAPI]
        APP[/siege_env.server.app/]
        ENV[SIEGEEnvironment]
    end

    subgraph Core[Core Engine]
        AG[NPC Population + Pathogen Strategies]
        TN[Trust Network + Reputation]
        MECH[Mechanics: cascade/asymmetry/whisper/red-herring/severity]
        RW[Reward Aggregator R1-R9]
        RP[Replay Logger + Player]
        LG[League Opponent Pool]
    end

    subgraph Train[Training + Eval]
        T1[grpo_train.py]
        T2[grpo_train_unsloth.py]
        AB[Ablation Configs]
        HO[Heldout Split]
    end

    WR --> APP
    BA --> APP
    AR --> APP
    APP --> ENV
    ENV --> AG
    ENV --> TN
    ENV --> MECH
    ENV --> RW
    ENV --> RP
    ENV --> LG
    T1 --> ENV
    T2 --> ENV
    AB --> T2
    HO --> T2

🔄 Episode Flow — How SIEGE Works

sequenceDiagram
    participant Env as SIEGEEnvironment
    participant NPC as NPC Agents
    participant Slp as Sleeper Agent
    participant Def as Defender LLM
    participant R as Reward Aggregator (R1-R9)

    Env->>Env: reset() from incident template
    Env->>NPC: Generate claims + trust context
    Slp->>Def: Cooperative phase (trust gain)
    Env->>Env: Trigger signal appears
    Slp->>Def: Adversarial claim injection
    Def->>Env: diagnose/challenge/ratify/escalate/whisper/postmortem
    Env->>R: Compute grounded reward components
    R-->>Env: weighted reward + component trace
    Env-->>Def: next observation, done, info

Observation surface (high level)

  • Incident dashboard and evolving evidence signals.
  • Agent claims with trust/reputation context.
  • Coalition status and per-step severity.
  • Whisper channels and red-herring distractions.
  • Replay/provenance metadata hooks.

Action surface (MCP tools)

  • diagnose
  • challenge
  • ratify
  • escalate
  • whisper
  • postmortem

💰 The 9-Component Reward System (R1–R9)

All components are computed from explicit environment state and outcomes.

#ComponentWeightIntent
1R1 Resolution30%Correct root cause and decision quality
2R2 Deception Resistance25%Resist sleeper misinformation
3R3 Detection20%Catch adversarial claims with low false positives
4R4 Trust Calibration10%Align trust with reliability
5R5 Confidence7%Confidence-accuracy calibration
6R6 Temporal Efficiency4%Time-sensitive decision quality
7R7 Postmortem2%Causal and actionable retrospective quality
8R8 Severity-Speed1%Faster response under higher severity
9R9 Correlation1%Multi-signal consistency and anti-red-herring behavior

🦠 Failure Mode Taxonomy

#Failure ModeDescriptionMeasured By
1Epistemic CascadeWrong belief spreads via trust networkR₀ proxy / spread metrics
2Sleeper ActivationCooperative-to-adversarial role flipDetection timing
3Self-CascadeAgent reinforces own wrong claimSelf-cascade index
4Belief MutationClaim morphs while propagatingMutation/provenance traces

Epistemic metrics tracked in replay/eval outputs include:

  • Belief spread rate (R₀-style)
  • Belief half-life
  • Belief entropy
  • Self-cascade index
  • Composite resilience indicators

📊 Training Pipeline & Results

Training modes in repository

ModeScriptPurpose
Lightweight GRPO scaffoldRudraKernel-src/training/grpo_train.pyfast local/CI demo runs
Full Unsloth/TRL GRPORudraKernel-src/training/grpo_train_unsloth.pyGPU-based fine-tuning

Core configuration surface

  • Base configs: RudraKernel-src/training/configs/
  • Ablation configs: ablate_curriculum.yaml, ablate_trust_poisoning.yaml, ablate_whisper.yaml
  • Heldout utility: RudraKernel-src/training/heldout_split.py

Artifact outputs

  • Checkpoints/metrics: RudraKernel-src/artifacts/training/
  • Plot pipeline: RudraKernel-src/scripts/generate_step23_plots.py (writes to RudraKernel-src/docs/plots/)
  • Demo notebook: RudraKernel-src/training/SIEGE_GRPO_Demo.ipynb

🧪 Comprehensive Test Suite

Test layout is organized by step gates + unit + integration + e2e + perf.

SuiteLocation
Master suiteRudraKernel-src/tests/master_suite.py
Step gate testsRudraKernel-src/tests/step_tests/
Unit testsRudraKernel-src/tests/unit/
Integration testsRudraKernel-src/tests/integration/
E2E and perfRudraKernel-src/tests/e2e/, RudraKernel-src/tests/perf/

Common commands:

cd RudraKernel-src

# Full suite
make test-all

# Per-step gate
make test-step STEP=24

# Lint/type
make lint

# Format
make format

🛠️ Tech Stack

LayerTechnology
RuntimePython 3.10+, FastAPI, Uvicorn
Env ContractOpenEnv (reset/step/state)
Data ModelsPydantic v2
RL TrainingTRL + Unsloth + LoRA
FrontendGradio
EvaluationPytest + deterministic replay
QualityRuff, Mypy, pre-commit
Packagingpyproject.toml + editable install

🚀 Quick Start

1) Clone and install

git clone https://github.com/UtkarshSingh-09/RudraKernel.git
cd RudraKernel/RudraKernel-src
python3 -m venv .venv
source .venv/bin/activate
pip install -e .
pip install -e ".[dev]"

2) Run environment API

python -m uvicorn siege_env.server.app:app --host 0.0.0.0 --port 8000 --reload

Health check:

curl http://localhost:8000/health

3) Run frontend

python frontend/app.py

4) Run training (lightweight)

python -m training.grpo_train --episodes 50 --output-dir artifacts/training

🧭 Runbook (Local)

Environment loop smoke

curl http://localhost:8000/env/reset
curl -X POST http://localhost:8000/env/step \
  -H "Content-Type: application/json" \
  -d '{"action": {"tool_name": "diagnose", "args": {"root_cause": "coordinated_misinformation_campaign", "confidence": 0.8}}}'

Training service endpoints (if enabled)

curl -X POST http://localhost:8000/train/start
curl http://localhost:8000/train/status
curl "http://localhost:8000/train/logs?lines=100"
curl http://localhost:8000/train/result

Replay/player tools

python -m siege_env.replay.player --help
python -m siege_env.replay.logger --help

🔌 API Endpoints (OpenEnv Contract)

From siege_env/server/app.py:

MethodEndpointPurpose
GET/healthliveness
GET/env/resetinitialize episode and observation
POST/env/stepapply one action and advance environment
GET/env/stateinspect internal state snapshot
POST/train/startstart background training job
GET/train/statustraining process status
GET/train/logstail training log
GET/train/resultread latest metrics

OpenEnv manifest:

name: siege_env
version: 0.1.0
runtime:
  framework: fastapi
  entrypoint: siege_env.server.app:app
  healthcheck: /health

📁 Project Structure

RudraKernel/
├── README.md
├── IMPLEMENTATION_PLAN.md
├── openenv.yaml
└── RudraKernel-src/
    ├── siege_env/
    │   ├── server/
    │   ├── models/
    │   ├── trust/
    │   ├── rewards/
    │   ├── mechanics/
    │   ├── league/
    │   ├── replay/
    │   ├── incidents/
    │   └── curriculum/
    ├── training/
    ├── frontend/
    ├── tests/
    ├── artifacts/
    ├── docs/
    └── scripts/

🎬 Demo Storyboard (60-Second Proof)

  1. Open Gradio dashboard (frontend/app.py).
  2. Show replay-linked metrics and baseline-vs-trained scorecard.
  3. Walk through one sleeper-trigger episode log.
  4. Highlight R1–R9 decomposition and trust dynamics.
  5. Show deterministic replay + artifact-backed plots.
  6. Close with heldout/ablation hooks and training reproducibility.

📚 References

  • Anthropic alignment/sleeper-agent research (2024 lineage)
  • OpenEnv framework docs/spec
  • TRL GRPO documentation
  • Unsloth optimization stack
  • Incident-response literature for trust and cascading failure systems

Project docs:

  • RudraKernel-src/docs/ARCHITECTURE.md
  • RudraKernel-src/docs/REWARD_HACKING_AUDIT.md
  • RudraKernel-src/docs/ABLATION_RESULTS.md
  • RudraKernel-src/training/README.md

👥 Team

  • Utkarsh Singh — Environment architecture, training system, evaluation tracks
  • Ankit Choubey — Frontend analytics, UX storytelling, integration support

🧠 Submission Note

This repository is organized for OpenEnv hackathon evaluation:

  • environment contract + API,
  • reproducible training entrypoints,
  • step-gated tests,
  • replay/evidence-friendly demo UI.

For judge flow, start at RudraKernel-src/frontend/app.py and RudraKernel-src/tests/master_suite.py.

Contributors

UtkarshSingh-09

86 commits

ankit-choubey

13 commits

UtkarshSingh-09/RudraKernel

0

stars

99

commits

Python

primary language

Apr 26, 2026

updated

README

🛡️ RudraKernel — LLM Reliability Infrastructure

"Train for the wrong. Deploy for the real."

OpenEnv India 2026 Environment Agents Rewards Frontend Backend Python License


RudraKernel is a multi-agent RL environment for sleeper-agent detection and epistemic-failure resistance in LLM systems. It provides OpenEnv-compatible env APIs, composable ground-truth rewards (R1–R9), deterministic replay, and a Gradio analytics console for before/after evidence.


📑 Table of Contents



🔴 The Problem — Epistemic Cascade Failure

What breaks when agents trust each other?

Modern AI systems increasingly rely on multi-agent collaboration: agents share observations, vote on diagnoses, and collectively decide on actions. This creates a critical vulnerability:

A single compromised agent that has built trust over time can inject false information at the worst possible moment — and the entire network believes it.

We call this an Epistemic Cascade Failure: one bad belief propagates through trust edges, corrupts coalition decisions, and pushes the system to act on a lie.

Real-world analogs:

  • Clinical: a trusted node misclassifies severity and pushes unsafe escalation.
  • Infrastructure: a high-reputation bot suppresses real incident response.
  • Finance: a trusted signaler injects false market causality.

Core SIEGE question: Can an LLM learn to challenge a high-trust liar when social consensus is misleading?


🟢 The Solution — Epistemic Immune System

RudraKernel models a multi-agent network as an immune system:

BiologySIEGE
Pathogen enters bodySleeper agent enters coalition
Mimics healthy behaviorBuilds trust during cooperative phase
Immune detectionDefender spots claim-evidence inconsistency
Antibody responsechallenge action reduces trust / blocks spread
Immune memoryReputation carries across episodes
Incident Template → 8 Agents Emit Claims → Sleeper Builds Trust
→ Triggered Adversarial Flip → Defender Diagnoses/Challenges
→ R1–R9 Reward Decomposition → GRPO Update → Replay + Metrics

Design goals:

  • No LLM-judge dependence for reward scoring.
  • Explicit anti-exploit tests for each reward component.
  • Deterministic replay for auditability and demo stability.

🏗️ System Architecture

graph TB
    subgraph Frontend[Frontend — Gradio Console]
        WR[Incident Command / War Room]
        BA[Before-After]
        AR[Training Curve / Arms Race]
    end

    subgraph API[Backend — FastAPI]
        APP[/siege_env.server.app/]
        ENV[SIEGEEnvironment]
    end

    subgraph Core[Core Engine]
        AG[NPC Population + Pathogen Strategies]
        TN[Trust Network + Reputation]
        MECH[Mechanics: cascade/asymmetry/whisper/red-herring/severity]
        RW[Reward Aggregator R1-R9]
        RP[Replay Logger + Player]
        LG[League Opponent Pool]
    end

    subgraph Train[Training + Eval]
        T1[grpo_train.py]
        T2[grpo_train_unsloth.py]
        AB[Ablation Configs]
        HO[Heldout Split]
    end

    WR --> APP
    BA --> APP
    AR --> APP
    APP --> ENV
    ENV --> AG
    ENV --> TN
    ENV --> MECH
    ENV --> RW
    ENV --> RP
    ENV --> LG
    T1 --> ENV
    T2 --> ENV
    AB --> T2
    HO --> T2

🔄 Episode Flow — How SIEGE Works

sequenceDiagram
    participant Env as SIEGEEnvironment
    participant NPC as NPC Agents
    participant Slp as Sleeper Agent
    participant Def as Defender LLM
    participant R as Reward Aggregator (R1-R9)

    Env->>Env: reset() from incident template
    Env->>NPC: Generate claims + trust context
    Slp->>Def: Cooperative phase (trust gain)
    Env->>Env: Trigger signal appears
    Slp->>Def: Adversarial claim injection
    Def->>Env: diagnose/challenge/ratify/escalate/whisper/postmortem
    Env->>R: Compute grounded reward components
    R-->>Env: weighted reward + component trace
    Env-->>Def: next observation, done, info

Observation surface (high level)

  • Incident dashboard and evolving evidence signals.
  • Agent claims with trust/reputation context.
  • Coalition status and per-step severity.
  • Whisper channels and red-herring distractions.
  • Replay/provenance metadata hooks.

Action surface (MCP tools)

  • diagnose
  • challenge
  • ratify
  • escalate
  • whisper
  • postmortem

💰 The 9-Component Reward System (R1–R9)

All components are computed from explicit environment state and outcomes.

#ComponentWeightIntent
1R1 Resolution30%Correct root cause and decision quality
2R2 Deception Resistance25%Resist sleeper misinformation
3R3 Detection20%Catch adversarial claims with low false positives
4R4 Trust Calibration10%Align trust with reliability
5R5 Confidence7%Confidence-accuracy calibration
6R6 Temporal Efficiency4%Time-sensitive decision quality
7R7 Postmortem2%Causal and actionable retrospective quality
8R8 Severity-Speed1%Faster response under higher severity
9R9 Correlation1%Multi-signal consistency and anti-red-herring behavior

🦠 Failure Mode Taxonomy

#Failure ModeDescriptionMeasured By
1Epistemic CascadeWrong belief spreads via trust networkR₀ proxy / spread metrics
2Sleeper ActivationCooperative-to-adversarial role flipDetection timing
3Self-CascadeAgent reinforces own wrong claimSelf-cascade index
4Belief MutationClaim morphs while propagatingMutation/provenance traces

Epistemic metrics tracked in replay/eval outputs include:

  • Belief spread rate (R₀-style)
  • Belief half-life
  • Belief entropy
  • Self-cascade index
  • Composite resilience indicators

📊 Training Pipeline & Results

Training modes in repository

ModeScriptPurpose
Lightweight GRPO scaffoldRudraKernel-src/training/grpo_train.pyfast local/CI demo runs
Full Unsloth/TRL GRPORudraKernel-src/training/grpo_train_unsloth.pyGPU-based fine-tuning

Core configuration surface

  • Base configs: RudraKernel-src/training/configs/
  • Ablation configs: ablate_curriculum.yaml, ablate_trust_poisoning.yaml, ablate_whisper.yaml
  • Heldout utility: RudraKernel-src/training/heldout_split.py

Artifact outputs

  • Checkpoints/metrics: RudraKernel-src/artifacts/training/
  • Plot pipeline: RudraKernel-src/scripts/generate_step23_plots.py (writes to RudraKernel-src/docs/plots/)
  • Demo notebook: RudraKernel-src/training/SIEGE_GRPO_Demo.ipynb

🧪 Comprehensive Test Suite

Test layout is organized by step gates + unit + integration + e2e + perf.

SuiteLocation
Master suiteRudraKernel-src/tests/master_suite.py
Step gate testsRudraKernel-src/tests/step_tests/
Unit testsRudraKernel-src/tests/unit/
Integration testsRudraKernel-src/tests/integration/
E2E and perfRudraKernel-src/tests/e2e/, RudraKernel-src/tests/perf/

Common commands:

cd RudraKernel-src

# Full suite
make test-all

# Per-step gate
make test-step STEP=24

# Lint/type
make lint

# Format
make format

🛠️ Tech Stack

LayerTechnology
RuntimePython 3.10+, FastAPI, Uvicorn
Env ContractOpenEnv (reset/step/state)
Data ModelsPydantic v2
RL TrainingTRL + Unsloth + LoRA
FrontendGradio
EvaluationPytest + deterministic replay
QualityRuff, Mypy, pre-commit
Packagingpyproject.toml + editable install

🚀 Quick Start

1) Clone and install

git clone https://github.com/UtkarshSingh-09/RudraKernel.git
cd RudraKernel/RudraKernel-src
python3 -m venv .venv
source .venv/bin/activate
pip install -e .
pip install -e ".[dev]"

2) Run environment API

python -m uvicorn siege_env.server.app:app --host 0.0.0.0 --port 8000 --reload

Health check:

curl http://localhost:8000/health

3) Run frontend

python frontend/app.py

4) Run training (lightweight)

python -m training.grpo_train --episodes 50 --output-dir artifacts/training

🧭 Runbook (Local)

Environment loop smoke

curl http://localhost:8000/env/reset
curl -X POST http://localhost:8000/env/step \
  -H "Content-Type: application/json" \
  -d '{"action": {"tool_name": "diagnose", "args": {"root_cause": "coordinated_misinformation_campaign", "confidence": 0.8}}}'

Training service endpoints (if enabled)

curl -X POST http://localhost:8000/train/start
curl http://localhost:8000/train/status
curl "http://localhost:8000/train/logs?lines=100"
curl http://localhost:8000/train/result

Replay/player tools

python -m siege_env.replay.player --help
python -m siege_env.replay.logger --help

🔌 API Endpoints (OpenEnv Contract)

From siege_env/server/app.py:

MethodEndpointPurpose
GET/healthliveness
GET/env/resetinitialize episode and observation
POST/env/stepapply one action and advance environment
GET/env/stateinspect internal state snapshot
POST/train/startstart background training job
GET/train/statustraining process status
GET/train/logstail training log
GET/train/resultread latest metrics

OpenEnv manifest:

name: siege_env
version: 0.1.0
runtime:
  framework: fastapi
  entrypoint: siege_env.server.app:app
  healthcheck: /health

📁 Project Structure

RudraKernel/
├── README.md
├── IMPLEMENTATION_PLAN.md
├── openenv.yaml
└── RudraKernel-src/
    ├── siege_env/
    │   ├── server/
    │   ├── models/
    │   ├── trust/
    │   ├── rewards/
    │   ├── mechanics/
    │   ├── league/
    │   ├── replay/
    │   ├── incidents/
    │   └── curriculum/
    ├── training/
    ├── frontend/
    ├── tests/
    ├── artifacts/
    ├── docs/
    └── scripts/

🎬 Demo Storyboard (60-Second Proof)

  1. Open Gradio dashboard (frontend/app.py).
  2. Show replay-linked metrics and baseline-vs-trained scorecard.
  3. Walk through one sleeper-trigger episode log.
  4. Highlight R1–R9 decomposition and trust dynamics.
  5. Show deterministic replay + artifact-backed plots.
  6. Close with heldout/ablation hooks and training reproducibility.

📚 References

  • Anthropic alignment/sleeper-agent research (2024 lineage)
  • OpenEnv framework docs/spec
  • TRL GRPO documentation
  • Unsloth optimization stack
  • Incident-response literature for trust and cascading failure systems

Project docs:

  • RudraKernel-src/docs/ARCHITECTURE.md
  • RudraKernel-src/docs/REWARD_HACKING_AUDIT.md
  • RudraKernel-src/docs/ABLATION_RESULTS.md
  • RudraKernel-src/training/README.md

👥 Team

  • Utkarsh Singh — Environment architecture, training system, evaluation tracks
  • Ankit Choubey — Frontend analytics, UX storytelling, integration support

🧠 Submission Note

This repository is organized for OpenEnv hackathon evaluation:

  • environment contract + API,
  • reproducible training entrypoints,
  • step-gated tests,
  • replay/evidence-friendly demo UI.

For judge flow, start at RudraKernel-src/frontend/app.py and RudraKernel-src/tests/master_suite.py.

Contributors

UtkarshSingh-09

86 commits

ankit-choubey

13 commits

Languages

Python

73.9%

Jupyter Notebook

18.4%

CSS

6.3%

Shell

1.1%