确定性写入门禁:范围策略在落盘前拒绝越权写入,残留规则扫描所写文本,每个决定落入带内容哈希的 JSONL 台账;可复用仓库的 agent-pr-gate.yaml 让 CI 与会话共用同一策略。
安装
# npm 包(预构建)
dsh plugin --profile web add dsh-pr-gate
# GitHub 源码(首次需按提示配置 allowBuilds 构建授权后重试)
dsh plugin --profile web add github:zhengqiuyang/dsh-pr-gate
装任何插件都等于在你的机器上跑第三方代码,权限和你本人一样大——能读你的文件、用你的凭据、访问网络,工具审批管不到它。GitHub 来源的插件还会在安装时执行构建脚本——pnpm 默认拦截,所以安装可能停在 ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED 或 ERR_PNPM_IGNORED_BUILDS;dsh 会打印出需要添加的确切键名,把它加进该 profile 的 pnpm-workspace.yaml 的 allowBuilds 下,重跑一次即可装上。放行构建本身就是一次信任判断:请只安装可信来源,并尽量锁定 commit(github:owner/repo#sha)。
README
该插件的 README 只有英文版本。
dsh-pr-gate
Deterministic write gate — scope policy + residue scan at the moment of the write
dsh plugin --profile default add dsh-pr-gate
If this helps you, please give it a star — it helps others find it.
Part of the DSH trust layer — ten deterministic checks, no LLM in the trust path.
Deterministic write gate for DeepSeek Harness (dsh) — the CI gate moved to the moment of the write.
Every file the agent writes (write / edit / str_replace_editor) passes
the same scope policy and residue rules that
agent-pr-gate applies to PRs
in CI — deny-before-write in tools/pre-execute, residue scan of the written
text in tools/post-execute, and a durable content-hashed JSONL ledger of
every decision. Zero LLM calls in the trust path: the parts of the gate that
must NOT be an LLM live here.
Why now (checked 2026-10-12)
The review/guard lane in the dsh ecosystem is entirely LLM-shaped:
answer-reviewer plugins re-read turns with a second model, dsh-gungnir
verifies goal completion from exit codes, and the closest action-guard
(cc-safety-net, 1.6k★ in the Claude ecosystem) blocks destructive commands.
Nobody gates what the agent writes deterministically — scope policy,
residue markers, or a durable record the CI can consume. That slot is empty,
and this plugin is the agent-pr-gate
engine living inside the runtime instead of waiting for the PR.
What it does
| Stage | Hook | Deterministic action |
|---|---|---|
| Before the write | tools/pre-execute |
Scope policy: deny globs always win; a non-empty allow list means "only these". Denied writes never touch the disk |
| After the write | tools/post-execute |
Residue scan of the written text: injection text aimed at reviewers, skipped tests, debug markers. warn (default) logs + ledgers; block also fails the write with corrective feedback |
| Always | JSONL ledger | One line per decision — tool, path, action, sha256 of content, matched pattern, residue kinds. agent-pr-gate CI can consume it as the session-side record |
One policy, two enforcement points
Point policyFile at your repo's agent-pr-gate.yaml and the live session
enforces the same allow/deny the CI gate enforces on PRs — all policy entries
are unioned. Inline allow/deny config works without a file.
Install
dsh plugin --profile default add dsh-pr-gate
From npm — no build step, no allowBuilds authorization; git installs are equally prebuilt (lib/ ships in the repo).
Configure
- id: dsh-pr-gate
name: dsh-pr-gate
config:
tools: [write, edit, str_replace_editor]
allow: [src/**, docs/**] # non-empty = only these
deny: ["**/*.pem", .github/workflows/**]
policyFile: "" # or e.g. agent-pr-gate.yaml
residueMode: warn # warn | block
ledgerPath: .dsh-pr-gate/session.jsonl
Compatibility
- DSH: verified against the 0.2.x line (source snapshot 0.2.1-alpha.2); installs on any profile via
dsh plugin add(prebuiltlib/, no build approval). - Node: >= 20 (CI matrix: Node 20/22/24 on Ubuntu and Windows).
- Disposable-profile evidence (2026-10-19):
dsh plugin --profile <fresh> add github:zhengqiuyang/dsh-pr-gate→ installed in 30s; boot shows[dsh-pr-gate] active: …;dsh plugin --profile <fresh> remove dsh-pr-gate→ dependencies cleared, bundles restored.
Develop
npm install
npm test # syncs the vendored agent-pr-gate core, builds, runs unit tests
The scope glob semantics and residue rules are vendored from the sibling
agent-pr-gate checkout (npm run sync; CI runs sync --check).
Roadmap
bashcommand write-heuristics (redirect/shell-write detection, warn-only)- Ledger → GitHub check-run bridge (session attestations surfaced in CI)
- Per-policy selection by agent preset, matching the CI gate's policy classes
- Claims-vs-diff at turn end (the agent's final summary vs. the session ledger)
Kill criteria
If dsh ships first-party deterministic write gating, or reviewer plugins converge on deterministic enforcement (they are all LLM-based today), this freezes at its last working version with a postmortem here. The engine stays owned by agent-pr-gate either way.
Known limitations
- Paths are judged by their resolved target relative to the workspace root — traversal like
src/../.github/workflows/x.ymlis normalized before matching (fixed in this release). Symlinks are NOT followed by the pure matcher (documented limitation), and there is an inherent TOCTOU window between check and write; the host's own permissions remain the hard boundary. - Named file tools only.
shellwrites, custom tools, and unknown argument shapes are not gated. - Residue scan is post-write.
residueMode: blockfails the tool result but does not roll back a file already on disk; default iswarn. - Empty policy = open. With no allow/deny entries, every write passes (ledger still records
written).
链接
同类插件
kenryu42/cc-safety-net★ 2132
执行前守卫,在工具调用运行前拦截破坏性 Git 与文件系统命令,以及对 SSH 密钥、.env 等机密文件的访问。
ADWMC/helm-d#helmd★ 1611
DeepSeek Harness 的安全分析插件:33 个工具覆盖六大安全域、证据/报告与工具集,并提供案件生命周期、路由和工具账本;按会话绑定的案件工作区支持证据链、E 编号校验与可复现结论(repro_cmd);内置 362 篇按需参考、三档可热切换人设,以及带案件状态恢复的破甲 / Case / 拦截 / 关于四页工作台。
SeaOf0/dsh-redteam-model★ 935
面向授权安全研究的 DSH 合集:九个工作模式(redteam 总控、渗透测试、代码审计、二进制分析、攻防评估、免杀对抗、应急溯源、云安全攻防、CTF 解题)与十五个运行时插件,设置页管理台支持一键部署、安装、更新与卸载。
toby-bridges/api-relay-audit★ 934
从 DeepSeek Harness 对 AI API 中转站和 LLM 代理运行本地安全审计,生成 Markdown 报告,覆盖提示词注入、模型替换信号、工具调用改写、错误泄漏、流完整性和按 profile 启用的 Web3 风险。
howmp/dsh-pentest★ 624
面向 DeepSeek Harness 的授权渗透模式:以探索链路记录目标、线索、资产与漏洞,并在 Web 中可视化展示。
Jueze-2019/dsh-redteam-mode#packages/redteam-bundle★ 317
红队作战模式:只发一个靶标单位名称,主会话指挥五个执行角色(信息收集/资产梳理/漏洞发现/漏洞利用/内网渗透),并发可配置;开工前做技能与资源预检;得分按四阶段(信息收集/互联网/边界/内网),上限、权限取高、同服务去重由服务端判定;发现落本机 SQLite 事实库。右侧常驻控制台 9 个页面,含资产测绘、智能体、会话隧道、漏洞战果、得分目标、报告、POC 知识库与技能库。v0.15.2 增加 HTTP 证据/动作记录自动留痕、批量落库、范围校验、隧道内网探测、数据证明、清理台账与 T0–T3 资产准入,防止打偏靶标。59 个 redteam_* 工具,随 npm 包 38 个随包技能。
社区评论
评论公开保存在 GitHub Discussions。加载评论会连接 GitHub 和 Giscus;发表内容需要 GitHub 账号。