How jarambler/entropyguard works
EntropyGuard is a research detector for indirect prompt injection: it probes a Transformer’s early attention over trusted instructions and untrusted data, selects informative heads, then classifies carrier-delta features. The main workflow is offline head selection and classifier training via run_pipeline.py, followed by single-input detection or cross-dataset evaluation. The README also documents an OpenClaw pre-tool-call integration design, but this tree contains no plugin implementation. Arrows follow the sampled pipeline references and README; unsampled implementation details are not inferred.
Main entry points: run_pipeline.py Train pipeline · eval_cross_dataset.py Cross-dataset evaluation · trainer.py Classifier training · detect.py Detect input
Components 23
Data preparation
- Dataset builder
src/data/dataset.py - External datasets
src/data/external_datasets.py
Model probing
- Model and attention
src/models/model_loader.py - Model registry
src/models/registry.py - Regional features
src/entropy/entropy_compute.py
Head selection and detection
- Train pipeline
run_pipeline.py - Detect input
scripts/detect.py - Carrier-delta features
src/head_selection/features.py - CI head selection
src/head_selection/selector.py - Selection artifacts
src/head_selection/artifacts.py - Classifier training
src/classifier/trainer.py - Selected-head logistic
src/classifier/selected_head_logistic.py - Adaptive margin
src/classifier/adaptive_margin.py - Signed risk
src/classifier/signed_risk.py - Threshold utilities
src/classifier/thresholds.py
Evaluation and integration
- Metric evaluation
src/evaluation/evaluator.py - Cross-dataset evaluation
scripts/eval_cross_dataset.py - Result visualization
src/utils/plotting.py - OpenClaw hook design
Other components
- Researcher
- Workspace files
- OpenClaw agent
- EntropyGuard service
Connections 35
- Researcher → Train pipeline: runs training
README.md - Train pipeline → Dataset builder: prepares samples
run_pipeline.py - Train pipeline → Model and attention: loads model
run_pipeline.py - Model and attention → Model registry: reads registry
src/models/model_loader.py - Train pipeline → Regional features: computes attention features
run_pipeline.py - Train pipeline → CI head selection: selects heads
run_pipeline.py - CI head selection → Regional features: uses regional features
src/head_selection/selector.py - Train pipeline → Selection artifacts: saves selection
run_pipeline.py - Train pipeline → Carrier-delta features: builds classifier features
run_pipeline.py - Carrier-delta features → Regional features: uses regional measures
src/head_selection/features.py - Train pipeline → Classifier training: trains classifier
run_pipeline.py - Classifier training → Selected-head logistic: selects classifier
src/classifier/trainer.py - Classifier training → Adaptive margin: supports classifier
src/classifier/trainer.py - Classifier training → Signed risk: supports classifier
src/classifier/trainer.py - Adaptive margin → Threshold utilities: chooses thresholds
src/classifier/adaptive_margin.py - Selected-head logistic → Threshold utilities: uses threshold utilities
src/classifier/selected_head_logistic.py - Detect input → Dataset builder: formats input
scripts/detect.py - Detect input → Model and attention: loads model
scripts/detect.py - Detect input → Regional features: computes features
scripts/detect.py - Detect input → Classifier training: loads classifier
scripts/detect.py - Researcher → Detect input: submits input
README.md - Cross-dataset evaluation → External datasets: loads benchmarks
scripts/eval_cross_dataset.py - Cross-dataset evaluation → Model and attention: loads model
scripts/eval_cross_dataset.py - Cross-dataset evaluation → Regional features: computes features
scripts/eval_cross_dataset.py - Cross-dataset evaluation → Dataset builder: formats samples
scripts/eval_cross_dataset.py - Cross-dataset evaluation → Classifier training: evaluates classifier
scripts/eval_cross_dataset.py - Classifier training → Metric evaluation: computes metrics
src/classifier/trainer.py - Researcher → Cross-dataset evaluation: runs evaluation
README.md - Researcher → Result visualization: requests figures
README.md - OpenClaw agent → Workspace files: references files
README.md - OpenClaw hook design → Workspace files: extracts content
README.md - OpenClaw hook design → EntropyGuard service: sends detection request
README.md - EntropyGuard service → Detect input: uses detector design
- OpenClaw hook design → OpenClaw agent: blocks tool call
README.md - External datasets → Cross-dataset evaluation: provides datasets
scripts/eval_cross_dataset.py