dsh-request-doctor 0.14.6 → 0.15.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,7 +2,7 @@
2
2
 
3
3
  **产品名称**:request-doctor(请求急救员)
4
4
  **产品标识**:request-doctor
5
- **版本**:0.14.6
5
+ **版本**:0.15.1
6
6
 
7
7
  ---
8
8
 
@@ -1,7 +1,7 @@
1
1
  # 软件设计说明
2
2
 
3
3
  **产品名称**:request-doctor(请求急救员)
4
- **版本**:0.14.6
4
+ **版本**:0.15.1
5
5
  **编制依据**:GB/T 8567-2006《计算机软件文档编制规范》6.2
6
6
 
7
7
  ---
@@ -1,7 +1,7 @@
1
1
  # 软件测试报告
2
2
 
3
3
  **产品名称**:request-doctor(请求急救员)
4
- **版本**:0.14.6
4
+ **版本**:0.15.1
5
5
  **编制依据**:GB/T 8567-2006《计算机软件文档编制规范》6.6;GB/T 8566-2007 验证与确认过程
6
6
 
7
7
  ---
@@ -62,6 +62,8 @@
62
62
  | `test/client-half.test.mjs` | 11 | 客户端半:模块身份、注入声明、apply 注册、组件能渲染 |
63
63
  | `test/diagnostics.test.mjs` | 3 | 快照可选写入:不配置不写盘、突发合并、坏路径不致命 |
64
64
  | `test/restart-notice.test.mjs` | 3 |
65
+ | `test/skip-log.test.mjs` | 4 | 未修复失败按类别归并:同类别计数、按频次排序、留最后一条 |
66
+ | `test/give-up-advice.test.mjs` | 5 | 不重试的类别各有可照做的建议,未知类别不编造 |
65
67
  | `test/allow-route.test.mjs` | 4 | 授权路由:路径声明、坏请求体 400、空 spec 200 失败、正常放行 |
66
68
  | `test/install-remote.test.mjs` | 2 | 远程安装的前置拒绝:非注册表名、缺 profile,均不触网 |
67
69
  | `test/install-branches.test.mjs` | 4 | 安装分支:已存在就地修、非注册表名、缺 profile、授权被拒 |
@@ -70,7 +72,7 @@
70
72
  | `test/panel-blocked.test.mjs` | 7 | 冲突判定:审计兼容却被拒装、清单形状解析、给 allow 动作 |
71
73
  | `test/panel-briefs.test.mjs` | 6 | 界面摘要:按名索引、只送可见行、缺数据不抛、不污染诊断 |
72
74
  | `test/verdict-report.test.mjs` | 29 | why 与 list:判定、理由、环境摘要、自动扫描、分组、缺口、按形态给建议 | 缺导出判为需要重启;其它失败不误判;多次累积不覆盖 |
73
- | **合计** | **232** | **全部通过** |
75
+ | **合计** | **241** | **全部通过** |
74
76
 
75
77
  执行结果:
76
78
 
@@ -224,7 +226,7 @@
224
226
 
225
227
  ### 7.2 分文件执行结果
226
228
 
227
- 37 个测试文件逐个单独执行,每个都有用例且全部通过,不存在因导入失败而静默跳过的文件。用例数分布:compat.test.mjs 17、plugin.test.mjs 15、compat-env.test.mjs 14、classify.test.mjs 13,其余按职能分散,合计 232。
229
+ 39 个测试文件逐个单独执行,每个都有用例且全部通过,不存在因导入失败而静默跳过的文件。用例数分布:compat.test.mjs 17、plugin.test.mjs 15、compat-env.test.mjs 14、classify.test.mjs 13,其余按职能分散,合计 241。
228
230
  ## 8 覆盖率实测
229
231
 
230
232
  用 Node 自带的 `--experimental-test-coverage` 跑一遍,作为「分支有没有被真的走一遍」的证据。这不替代对断言质量的判断,只说明哪些代码从未被执行。
@@ -1,7 +1,7 @@
1
1
  # 软件安装部署说明
2
2
 
3
3
  **产品名称**:request-doctor(请求急救员)
4
- **版本**:0.14.6
4
+ **版本**:0.15.1
5
5
  **编制依据**:GB/T 8567-2006《计算机软件文档编制规范》6.7
6
6
 
7
7
  ---
@@ -1,7 +1,7 @@
1
1
  # 软件用户手册
2
2
 
3
3
  **产品名称**:request-doctor(请求急救员)
4
- **版本**:0.14.6
4
+ **版本**:0.15.1
5
5
  **编制依据**:GB/T 8567-2006《计算机软件文档编制规范》6.5
6
6
 
7
7
  ---
@@ -1,7 +1,7 @@
1
1
  # 软件质量度量报告
2
2
 
3
3
  **产品名称**:request-doctor(请求急救员)
4
- **版本**:0.14.6
4
+ **版本**:0.15.1
5
5
  **度量标准**:GB/T 45717-2025《信息技术 软件测量 软件质量测量 自动化的源代码质量测度》
6
6
  **度量工具**:`tools/quality-measure.mjs`(本仓库自带,可复现)
7
7
 
@@ -1,20 +1,20 @@
1
1
  {
2
2
  "standard": "GB/T 45717-2025 信息技术 软件测量 软件质量测量 自动化的源代码质量测度",
3
- "generatedAt": "2026-10-29T16:44:26.413Z",
3
+ "generatedAt": "2026-10-29T16:51:53.560Z",
4
4
  "scope": {
5
- "files": 36,
6
- "totalLines": 5412,
7
- "sourceLines": 3906,
8
- "commentLines": 1001
5
+ "files": 38,
6
+ "totalLines": 5472,
7
+ "sourceLines": 3946,
8
+ "commentLines": 1013
9
9
  },
10
10
  "measures": {
11
- "commentDensity": 25.63,
12
- "duplicationPercent": 4.96,
13
- "functionCount": 415,
11
+ "commentDensity": 25.67,
12
+ "duplicationPercent": 4.98,
13
+ "functionCount": 421,
14
14
  "maxComplexity": 10,
15
15
  "maxFunctionLines": 57,
16
16
  "maxFileLines": 500,
17
- "averageComplexity": 3.83
17
+ "averageComplexity": 3.81
18
18
  },
19
19
  "limits": {
20
20
  "maxComplexity": 10,
@@ -3,6 +3,7 @@
3
3
  // 管三件事:各项修复计数、最近若干条事件、可选的快照文件。单独拎出来是因为组合根要
4
4
  // 关心的是"怎么修",不该顺带管状态怎么记。
5
5
  import { writeFileSync } from 'node:fs';
6
+ import { createSkipLog } from './skip-log.js';
6
7
 
7
8
  // 最近事件留多少条给 /doctor 看
8
9
  const MAX_LOG = 30;
@@ -21,6 +22,7 @@ export function createDiagnostics(input) {
21
22
  last: [],
22
23
  };
23
24
  const diagnostics = { versionScan: null };
25
+ const skipped = createSkipLog();
24
26
  let pending;
25
27
 
26
28
  const snapshot = () => ({
@@ -73,5 +75,5 @@ export function createDiagnostics(input) {
73
75
  writeNow();
74
76
  };
75
77
 
76
- return { record, scheduleWrite, writeNow, flush, scanError, stats, diagnostics, snapshot };
78
+ return { record, scheduleWrite, writeNow, flush, scanError, stats, skipped: () => skipped.read(), diagnostics, snapshot };
77
79
  }
@@ -0,0 +1,18 @@
1
+ // 不重试的失败怎么向用户交代。
2
+ //
3
+ // TLS 证书、本机权限、配额、内容策略这些重试一百次也不会变,所以不重试是对的。
4
+ // 但「不重试」不等于「不解释」:用户需要知道这次是谁的问题、接下来自己能做什么。
5
+
6
+ const ADVICE = {
7
+ tls: '证书校验没过。换掉中间代理的自签证书,或让系统信任该根证书;重试不会有帮助。',
8
+ 'local-blocked': '本机权限、路径或磁盘空间不足。先把缺的权限或空间补上,重试才有意义。',
9
+ quota: '额度或频率到上限了。等额度恢复再发请求;这不是插件或网络的问题。',
10
+ policy: '内容被服务方的策略拦下了。改写提问再发;重试会得到同样的结果。',
11
+ image: '图片需要走转存才能发送。换一张图,或让客户端先完成转存。',
12
+ };
13
+
14
+ // @param {string} kind - 分类结果里的 kind。
15
+ // @returns {string|undefined} 一句话建议;没有对应建议时返回 undefined。
16
+ export function adviceFor(kind) {
17
+ return ADVICE[kind];
18
+ }
@@ -10,6 +10,7 @@
10
10
  // - 无进展:压缩/修历史连续两轮都没让问题前进,就不再无限重试。
11
11
  import { classifyModelFailure, computeDelay } from './classify.js';
12
12
  import { cancellableSleep } from './sleep.js';
13
+ import { adviceFor } from './give-up-advice.js';
13
14
 
14
15
  // 每个策略分到的预算倍数。鉴权类的重试更贵(要换凭据),给的次数更少。
15
16
  const STRATEGY_BUDGET = { auth: 'auth', 'history-repair': 'history', compact: 'normal' };
@@ -152,7 +153,7 @@ export function createModelRepair(input) {
152
153
  if (payload.signal?.aborted || lifetime.signal.aborted) return downstream;
153
154
 
154
155
  const decision = classifyModelFailure(payload.failure);
155
- if (!decision.clientCaused || decision.strategy === 'skip') return downstream;
156
+ if (!decision.clientCaused || decision.strategy === 'skip') return skipOut(decision, downstream, record);
156
157
 
157
158
  const key = `${payload.turn}:${payload.step}:${payload.provider}:${decision.kind}`;
158
159
  // 同一处只放一个重试进去。并发的那几个直接让下游收场,避免重试互相叠加。
@@ -165,7 +166,17 @@ export function createModelRepair(input) {
165
166
  }
166
167
  }
167
168
 
168
- // 依次过三关:本地修复成不成、还有没有进展、预算还剩不剩。
169
+
170
+ // 不重试的失败也要留痕:用户得知道这次是谁的问题、接下来能做什么。
171
+ function skipOut(decision, downstream, record) {
172
+ if (decision.strategy === 'skip') {
173
+ const note = adviceFor(decision.kind) ?? '这类失败重试也不会变,跳过修复';
174
+ record('skip', decision.kind + ': ' + note);
175
+ }
176
+ return downstream;
177
+ }
178
+
179
+ // 依次过三关:本地修复成不成、还有没有进展、预算还剩不剩。
169
180
  async function attempt(key, payload, decision, downstream) {
170
181
  if (!(await prepare(decision, payload))) {
171
182
  stats.modelSkips += 1;
@@ -0,0 +1,27 @@
1
+ // 本次会话里没救回来的失败。
2
+ //
3
+ // 日志是流式的,翻起来费事。这里按类别归并,只留每类最后一条与出现次数,
4
+ // 让「刚才那次为什么没救回来」能一眼看到。
5
+
6
+ const MAX_KINDS = 12;
7
+
8
+ // 可读的汇总对象:add 记账,read 取回按次数排序的列表。
9
+ export function createSkipLog() {
10
+ const entries = new Map();
11
+ return {
12
+ add(detail) {
13
+ const kind = String(detail).split(':')[0].trim();
14
+ const previous = entries.get(kind);
15
+ entries.set(kind, {
16
+ kind,
17
+ note: String(detail),
18
+ count: (previous?.count ?? 0) + 1,
19
+ at: new Date().toISOString(),
20
+ });
21
+ while (entries.size > MAX_KINDS) entries.delete(entries.keys().next().value);
22
+ },
23
+ read() {
24
+ return [...entries.values()].sort((a, b) => b.count - a.count);
25
+ },
26
+ };
27
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-request-doctor",
3
- "version": "0.14.6",
3
+ "version": "0.15.1",
4
4
  "description": "自动修复客户端引起的请求失败,并让版本不匹配的 DSH 插件能装上、能跑起来。",
5
5
  "keywords": [
6
6
  "dsh-plugin",