Discipline Guard Policy Interceptor & Safety Filter

Official Core
@deepseek-ai/dsh-discipline-guard · v1.4.0

A bidirectional safety firewall and policy enforcement proxy for DeepSeek Harness. Prevents prompt injection, redacts sensitive PII data, and intercepts dangerous CLI operations in real time.

Safety-GuardPrompt-InjectionPII-MaskingHuman-in-the-Loop
GitHub Stars
102 K+
+12.4% this month
Monthly Downloads
421 K+
Monthly registry pulls
Reach Score
99.4/ 100
Top Tier Ecosystem
Runtime
Cordis v3+
Node 18+ / Bun / Deno

Installation & Integration

CLI one-click launch, package managers, and Cordis integration

bash
manager:
$ pnpm add @deepseek-ai/dsh-discipline-guard

Architecture

Discipline Guard establishes enterprise-grade guardrails for autonomous agents. Granting agents tool-calling permissions to filesystems and APIs exposes organizations to prompt injection attacks, accidental data destruction, and compliance violations. This plugin acts as a bidirectional policy gatekeeper on the Cordis pipeline. Inbound prompts are scanned for adversarial jailbreaks and sanitized of sensitive personal credentials. Outbound tool calls undergo real-time heuristic inspection—intercepting destructive commands (e.g., dropping production tables) with mandatory approval gates.

Architectural Principles & Constraints

01
Strict Type Isolation

Guaranteed by TypeScript compile-time contracts, inter-plugin event bus calls enjoy zero-drift safety.

02
Sub-Millisecond Hot Reload

Supports dynamic runtime mounting and graceful unloading without restarting the primary host process.

03
Deterministic State Machine

Embeds multi-phase execution lifecycle guards, preventing context loss during long-horizon reasoning.

04
Zero Native Build Dependencies

Designed for lightweight cross-platform environments, booting instantly across Node.js, Bun, and Deno.

Core Features

01
Full-Duplex Safety Gate: Inspects both inbound user prompts and outbound tool invocations
02
Curated Dangerous Command Blacklist: Halts destructive commands (`rm -rf`, `mkfs`, `DROP TABLE`)
03
Zero-Leak PII Sanitization: Replaces credentials, tokens, and personal data with synthetic tokens
04
Human-in-the-Loop Approval: Suspends sensitive actions awaiting explicit operator authorization

Core Workflow

01

Inbound Threat Scanning

Analyzes input prompts for adversarial injection, system prompt leaks, and jailbreaks.

02

PII Masking & Sanitization

Detects and redacts credentials, phone numbers, and API tokens before LLM dispatch.

03

Outbound Command Audit

Intercepts tool actions against risk blacklists and protected paths.

04

Interception & Human Review

Blocks prohibited operations or suspends execution until admin approval is received.

Configuration Parameters Reference (YAML / JSON)

ParameterTypeDefaultDescription
strictLevelstringhighSafety enforcement strictness level
maskPIIbooleantrueAutomatically redact PII and credentials
requireHumanApprovalForRootbooleantrueRequire human sign-off on root-level writes

Use Cases

Enterprise Production Agent

Relies on microkernel lifecycle guards and fault-tolerant state machines for continuous reliability.

SWE-bench Benchmark Evaluation

Native integration with SWE-bench workflows, automatically capturing diffs and verification metrics.

Autonomous Code Refactoring

Separates reasoning from tool actions to independently locate and refactor multi-file codebases.

Cross-Tool Workflow Automation

Safely orchestrates events across sandboxes to seamlessly link enterprise developer tooling.

Best Practices

01
Sandbox Permission Guard

Strictly isolate sub-process calls and network scope; deploy within Docker containers in production.

02
Exponential Backoff Retries

Configure adaptive exponential retries with strict timeouts to mitigate upstream model rate limits.

03
Session State Checkpointing

Persist state machine snapshots to survive hardware interruptions and resume instantly without loss.

04
Full Trajectory Audit Logs

Enable full trace logging, aggregating reasoning thought streams and tool I/O into your observability hub.

FAQ

Q1:How to handle timeouts in long-running autonomous tasks?

Increase the timeout parameter inside your YAML configuration and dispatch periodic heartbeat signals across the Cordis event bus. For long-running tool execution and model reasoning, configure persistent session snapshotting so suspended tasks can safely resume their exact context after interruptions, preventing the kernel from recycling active agent sessions prematurely.

Q2:How to capture and stream the model reasoning thought process?

The harness runtime natively provides end-to-end streaming hooks while its state machine automatically intercepts and strips <think> reasoning tags from model responses. Subscribe directly to the onThink event listener to consume live reasoning token streams in real-time, delivering typewriter animation to the user interface while persisting full trajectories for audit compliance.

Q3:How to resolve dependency conflicts across multiple plugins?

Cordis microkernel uses directed acyclic graph topological sorting to dynamically resolve plugin dependencies. When shared services or runtime versions conflict, assign distinct isolated namespaces at the application entrypoint. Leveraging context injection alongside lazy activation ensures dependencies load strictly on-demand when tools are triggered, maintaining system stability and preventing memory bloat.

Q4:How to enforce permissions and sandbox isolation in production?

Combine isolated container sandboxing with fine-grained capability checks to prevent plugins from accessing sensitive files or unauthorized external networks. Enforce explicit runtime system call whitelisting through the microkernel, executing all third-party tool scripts inside isolated ephemeral containers to block arbitrary code execution and eliminate security privilege escalation risks entirely.

Recommended Ecosystem Plugins

Explore related Cordis extensions designed to work synergistically