Community plugin

kovey / dsh-standards-gate

Code-standards gate for DeepSeek Harness: measure a target repository against its declared structural standards (file/function size, nesting, branch size, parameter count, exported surface, module dependency direction) and turn the result into a deterministic gate with a baseline ratchet.

  • TypeScript
  • Apache-2.0
  • 0 stars
  • Nov 25, 2026

About this plugin

Written by the registry from verified metadata, not from the README.

dsh-standards-gate is a DSH plugin published from the packages/dsh-standards-gate package in the kovey/dsh-engineering-suite repository.

  • Listing statusManifest verified
  • Manifest checkedNov 25, 2026
  • Packagedsh-standards-gate
  • Package pathpackages/dsh-standards-gate
  • Package version0.9.0
  • Source commite24fb0b
  • Repository createdSep 17, 2026

Capabilities and topics

dshdeepseek-harnesspluginstandards
From the repository README

README

Everything below this line is the repository's own document, cached here. This site did not write or review it.

Cached versionView on GitHub

dsh-standards-gate

结构规范门禁:把"代码规范"从文档变成目标仓库里的确定性门禁。

其他门禁分别回答"能不能跑"(dsh-quality-gate)、"做的是不是对的"(dsh-spec-gate/dsh-test-design-gate)、 "能不能证明"(dsh-evidence-gate);这个插件回答**"还可维护吗"**:

维度判定
文件行数、函数行数、嵌套深度、if/else 块行数、参数个数、导出面大小确定性度量(dsh-eng-core 的 measureWorkspace)
模块依赖方向(分层规则)、循环依赖同上(导入图)
高内聚、命名、抽象是否多余不判——交给 reviewer 角色的 rubric 评审(见 KNOWN-LIMITS)

三个工具

工具作用
standards_check按仓库自己声明的阈值度量,产出违规清单,并把裁决写进 mission 的门禁记录(source: dsh-standards-gate)。基线已接受的存量违规不算失败,新增违规失败。
standards_bootstrap存量项目接入:measure 给出分布(各语言的文件行数/函数行数/嵌套的 p90 与最差文件)、推荐的目标阈值(文件 400/300、函数 80/60、嵌套 4、分支 20、参数 5)以及"按目标阈值今天会有多少违规",freeze 经人工批准后写入仓库。不推荐按 p90 定阈值——真机上 p90 文件长度是 588 行,那等于没有门禁;正确做法是目标阈值 + 把存量冻结进基线。
standards_status只读:当前阈值、依赖方向规则、基线(接受了多少项、何时冻结、为什么)、本次 mission 的变化(变胖/变瘦的文件、新增/消除的违规)、最近一次门禁裁决。

第四层:判断(standards_review)

数字解释不了的部分——职责是否单一、命名是否达意、抽象是否多余、错误路径是否完整、拆分是否真的更好—— 交给 standards_review:它按可疑度挑出最值得看的几个文件,派一个只读子代理(allow: [read, glob, grep]、 剔除 orchestrate、maxDepth: 1)带着 rubric 去读代码,结论落盘到 mission 目录并标注:

⚠️ 这是意见,不是门禁裁决:它不改变任何门禁状态,也不构成交付依据。

rubric 明确要求"允许结论是没问题"(不要为了产出而编造问题)、每条结论带 文件:行号、区分事实(门禁给的数字) 与方法(评审的判断)。role-guard 的内置 reviewer 角色也指向同一份 rubric。

棘轮:为什么第一次就能用

阈值一旦宣布,存量仓库必然全线飘红 → 要么永远堵着,要么被关掉。所以:

<repo>/.dsh/standards.json           阈值、分层规则、豁免(仓库所有)
<repo>/.dsh/standards-baseline.json  已接受的违规(棘轮)
  • 门禁对新增(added)与恶化(worsened:同一个 key 比当初接受时更大)失败,并报告已消除的项(fixed);
  • 已消除的 key 会自动从基线删除(只收紧、不需要批准):否则"删掉文件让门禁变绿、之后再放回来"就能靠旧批准通过;
  • 收紧靠重构(fixed 变多);放宽只有一条路:standards_check({ accept: true, note: "原因" }), 它会要求人工审批(requireApprovalForBaseline,默认开);
  • .dsh/** 在 dsh-spec-gate 的信任根里 → 模型自己写不了阈值和基线。 审计历史里"Agent 可写 mission.json 自我审批"那类漏洞,在这里是同类防护。

配置

profile(宿主上限)与 <repo>/.dsh/standards-gate.json(项目只能细化下列键):

- id: standards-gate
  config:
    enabled: true
    standardsFile: .dsh/standards.json      # 仓库所有
    baselineFile: .dsh/standards-baseline.json
    enforce: gate                            # gate=PASS/BLOCK | warn=最多 WARN(只报告不阻断)| off=不写记录
    maxFiles: 4000
    maxFileBytes: 262144
    requireApprovalForBaseline: true         # 不得由项目级配置关闭
    reviewProvider: spawn                    # 结构评审用的只读子代理
    reviewTargets: 4                         # 一次评审挑几个最可疑的文件
    reviewTimeoutMs: 600000
    reviewMaxDepth: 1
    prompt: { enabled: true, order: 665 }

项目级可覆盖:enforce、standardsFile、baselineFile、maxFiles、maxFileBytes。

规范文件长什么样

{
  "languages": {
    "go": { "maxFileLines": 400, "maxFunctionLines": 80, "maxDepth": 4, "maxIfBlockLines": 20, "maxParams": 5, "maxExports": 20 },
    "ts": { "maxFileLines": 300, "maxFunctionLines": 60, "maxDepth": 4 }
  },
  "layers": [
    { "path": "internal/domain", "mayImport": [] },
    { "path": "internal/app", "mayImport": ["internal/domain"] },
    { "path": "cmd", "mayImport": ["internal/app", "internal/domain"] }
  ],
  "forbidCycles": true,
  "exempt": ["**/*_test.go", "**/*.test.ts", "**/testdata/**", "**/vendor/**"]
}

影子模式:先把规则测一遍,再决定要不要拦

新规则直接上 enforce 往往第一天就红了,于是没人敢开。所以一条规则可以先观察:

{
  "languages": { "go": { "maxFileLines": 400, "maxDepth": 4 } },
  "rules": { "maxDepth": "observe" }
}
  • 规则照常测量一次,它的"本会 PASS/WARN/BLOCK"记进门禁记录的 observations(按规则 id 排序), 报告里单列一段 影子(observe):本会拦下 N 条 …,并给出一行"把 mode 改成 enforce"的下一步; 影子行永远显示 [影子 would=…],不会伪装成 PASS/FAIL/BLOCK;
  • 它不参与裁决:observe 规则再多也不会让门禁失败;enforce(默认,或删掉 mode)照旧失败;
  • 棘轮不动:这是本插件与其他门禁最大的不同。observe 期间的测量不会写进基线—— accept 只接受 enforce 规则的违规(影子违规即使勾了 accept 也一项都不写), 自动收紧(删除已消除的 key)也只删除 enforce 规则的条目。 否则"先测量"就变成了"先豁免",切回 enforce 时明天的裁决已经被今天的观察买走了;
  • 测量本身不会丢:门禁记录的 observations、度量明细(standards/ 下的 JSON)与报告影子段落都保留实测数字, 但这些是只读产物——门禁从不回读上一次测量,所以保留它们不会移动棘轮;
  • mode 写在 rules 里(与阈值同一个仓库文件、同一个信任根):拼错的规则名、拼错的 mode 都是配置问题, 按 enforce 处理并在报告里点名——未知值绝不会被静默当成 observe。

standards_status 会显示哪些规则在 observe,以及最近一条门禁记录里的影子结果(旧记录没有 observations 字段时按"没有观察"读取,不是错误)。

门禁记录与交付

每次 standards_check(enforce: gate)都会写一条 GateRecord(source: dsh-standards-gate, 含 scope 与工作区指纹),所以交付侧可以像要求质量门禁那样要求它:最新一条 standards 门禁必须是 PASS, 且不早于最新代码改动。enforce: warn 只报告;off 连记录都不写。

与套件其他插件的分工

插件关系
dsh-spec-gate保护 .dsh/**(阈值与基线模型改不了);规格里可以写"本 mission 不得新增 standards 违规"这类可判定的 AC
dsh-quality-gate需要时把规范检查当普通命令;更强的是让本插件自己写门禁记录
dsh-evidence-gate交付不变式可以要求最新 standards 门禁 PASS
dsh-orchestratorquality-verify 阶段的离开门禁可扩展为"质量门禁 + 规范门禁"
dsh-audit-trail每次门禁的度量明细(含文件尺寸)落在 mission 目录;standards_status 比较首末两次测量,直接给出"这次让哪个文件变胖/变瘦、哪些违规新增/消除"
dsh-role-guard机械判不了的(内聚、命名、抽象)交给 reviewer 角色的 rubric

诚实的边界

行数与嵌套是启发式:一个 300 行的内聚文件可能优于三个 100 行的碎片;门禁表、角色表、大 switch 这类"表格型代码"刻意长,应当写进 exempt 或按目录放宽。机械层是下限,评审是上限,两者不能互相替代。 更多见 docs/KNOWN-LIMITS.md。

Badge

Listed here? Link back with this badge — paste the snippet into your repository README.

Listed on DSH Plugin badge
[![Listed on DSH Plugin](https://dsh-plugin.com/badges/listed.svg)](https://dsh-plugin.com/plugins/kovey/dsh-engineering-suite/packages/dsh-standards-gate)
dsh-standards-gate — DSH Plugin