# sashankh/dsh-taintguard architecture

> Architecture diagram of the GitHub repository sashankh/dsh-taintguard, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sashankh/dsh-taintguard
- Repository: https://github.com/sashankh/dsh-taintguard

## Overview

dsh-taintguard is a DeepSeek Harness plugin that limits indirect prompt-injection impact. Harness tool results enter its post-execution listener, where configured source matching and content scanning can mark an agent tainted; optionally, the result is reframed as quoted third-party data. Later privileged calls are gated according to mode, while outbound arguments to egress tools are independently scanned for credentials and canaries on every call. The diagram follows the sampled runtime implementation and README; no separate storage service is involved, and the agent taint is in-memory. Evidence for the main runtime links is in src/index.ts; mode behavior is also documented in README.md.

Main entry points: [`src/index.ts`](https://github.com/sashankh/dsh-taintguard/blob/main/src/index.ts) (Guard Listeners), [`src/detect.ts`](https://github.com/sashankh/dsh-taintguard/blob/main/src/detect.ts) (Credential Scanner), [`src/text.ts`](https://github.com/sashankh/dsh-taintguard/blob/main/src/text.ts) (Text Utilities)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_integration["Harness Integration"]
  node_harness["DeepSeek Harness"]
  node_tool_io["Tool Calls"]
  node_plugin["Guard Listeners<br/>[index.ts]"]
end

subgraph group_detection["Scanning"]
  node_text["Text Utilities<br/>[text.ts]"]
  node_injection["Injection Scanner<br/>[detect.ts]"]
  node_secrets["Credential Scanner<br/>[detect.ts]"]
end

subgraph group_enforcement["Guard Decisions"]
  node_taint["Agent Taint<br/>[index.ts]"]
  node_gate["Sink Gate<br/>[index.ts]"]
  node_annotation["Result Framing<br/>[index.ts]"]
end

node_operator(("Operator"))

node_operator -->|"configures mode"| node_harness
node_harness -.->|"dispatches calls"| node_tool_io
node_tool_io -->|"emits tool hooks"| node_plugin
node_plugin -->|"extracts and matches"| node_text
node_plugin -->|"scans results"| node_injection
node_plugin -->|"scans egress arguments"| node_secrets
node_plugin -->|"records first source"| node_taint
node_taint -->|"informs sink checks"| node_gate
node_plugin -->|"checks privileged calls"| node_gate
node_gate -->|"returns ask or deny"| node_harness
node_plugin -->|"frames tainted results"| node_annotation
node_annotation -->|"returns quoted content"| node_harness
node_harness -->|"routes approval"| node_operator
node_secrets -->|"denies credential egress"| node_gate

click node_plugin "https://github.com/sashankh/dsh-taintguard/blob/main/src/index.ts"
click node_text "https://github.com/sashankh/dsh-taintguard/blob/main/src/text.ts"
click node_injection "https://github.com/sashankh/dsh-taintguard/blob/main/src/detect.ts"
click node_secrets "https://github.com/sashankh/dsh-taintguard/blob/main/src/detect.ts"
click node_taint "https://github.com/sashankh/dsh-taintguard/blob/main/src/index.ts"
click node_gate "https://github.com/sashankh/dsh-taintguard/blob/main/src/index.ts"
click node_annotation "https://github.com/sashankh/dsh-taintguard/blob/main/src/index.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_harness,node_tool_io,node_plugin toneBlue
class node_text,node_injection,node_secrets toneAmber
class node_taint,node_gate,node_annotation toneMint
class node_operator toneIndigo
```

## Components

### Harness Integration

- **DeepSeek Harness**
- **Tool Calls**
- [Guard Listeners](https://github.com/sashankh/dsh-taintguard/blob/main/src/index.ts): `src/index.ts`

### Scanning

- [Text Utilities](https://github.com/sashankh/dsh-taintguard/blob/main/src/text.ts): `src/text.ts`
- [Injection Scanner](https://github.com/sashankh/dsh-taintguard/blob/main/src/detect.ts): `src/detect.ts`
- [Credential Scanner](https://github.com/sashankh/dsh-taintguard/blob/main/src/detect.ts): `src/detect.ts`

### Guard Decisions

- [Agent Taint](https://github.com/sashankh/dsh-taintguard/blob/main/src/index.ts): `src/index.ts`
- [Sink Gate](https://github.com/sashankh/dsh-taintguard/blob/main/src/index.ts): `src/index.ts`
- [Result Framing](https://github.com/sashankh/dsh-taintguard/blob/main/src/index.ts): `src/index.ts`

### Other components

- **Operator**

## Connections

- Operator → DeepSeek Harness: configures mode (evidence: `README.md`)
- DeepSeek Harness → Tool Calls: dispatches calls
- Tool Calls → Guard Listeners: emits tool hooks (evidence: `src/index.ts`)
- Guard Listeners → Text Utilities: extracts and matches (evidence: `src/index.ts`)
- Guard Listeners → Injection Scanner: scans results (evidence: `src/index.ts`)
- Guard Listeners → Credential Scanner: scans egress arguments (evidence: `src/index.ts`)
- Guard Listeners → Agent Taint: records first source (evidence: `src/index.ts`)
- Agent Taint → Sink Gate: informs sink checks (evidence: `src/index.ts`)
- Guard Listeners → Sink Gate: checks privileged calls (evidence: `src/index.ts`)
- Sink Gate → DeepSeek Harness: returns ask or deny (evidence: `src/index.ts`)
- Guard Listeners → Result Framing: frames tainted results (evidence: `src/index.ts`)
- Result Framing → DeepSeek Harness: returns quoted content (evidence: `src/index.ts`)
- DeepSeek Harness → Operator: routes approval (evidence: `README.md`)
- Credential Scanner → Sink Gate: denies credential egress (evidence: `src/index.ts`)
