dsh-molbio-tools 0.28.0 → 0.28.2
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.
- package/CHANGELOG.md +98 -0
- package/README.md +8 -6
- package/batch.mjs +53 -21
- package/benchmark/README.md +6 -0
- package/benchmark/harness.mjs +11 -3
- package/benchmark/profile.mjs +2 -2
- package/benchmark/run.mjs +3 -1
- package/benchmark/sequences.mjs +16 -0
- package/benchmark/tasks/01-core.json +1 -1
- package/benchmark/tasks/02-primers.json +1 -5
- package/benchmark/tasks/04-cloning.json +2 -2
- package/benchmark/tasks/09-formats.json +1 -1
- package/benchmark/tasks/10-v28.json +1 -1
- package/benchmark/verifications.mjs +3 -9
- package/build/check.mjs +463 -0
- package/build/client-bundle.mjs +1 -1
- package/build/panel-core.mjs +15 -3
- package/build/release-notes.mjs +82 -52
- package/build/release-preflight.mjs +1 -1
- package/docs/audit-2026-12.md +314 -0
- package/docs/change-process.md +305 -0
- package/docs/history.md +2 -0
- package/docs/maintainer.md +7 -2
- package/docs/roadmap.md +1 -1
- package/docs/rules.md +36 -6
- package/docs/store-evidence.md +17 -7
- package/docs/workflow.md +17 -5
- package/genbank.mjs +65 -14
- package/host.mjs +1 -1
- package/index.mjs +239 -140
- package/lib/client.js +89 -17
- package/package.json +11 -7
- package/pcr.mjs +29 -7
- package/phylo.mjs +0 -6
- package/seqio.mjs +5 -0
- package/taqman.mjs +4 -0
- package/test/client.mjs +6 -0
- package/test/contract.mjs +1 -1
- package/test/prompt.mjs +149 -0
- package/test/release.mjs +15 -8
- package/test/smoke.mjs +129 -4
- package/view.mjs +13 -1
package/build/release-notes.mjs
CHANGED
|
@@ -1,80 +1,110 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* dsh-molbio-tools/build/release-notes.mjs
|
|
3
3
|
*
|
|
4
|
-
* Turn
|
|
4
|
+
* Turn one CHANGELOG section into the body of a GitHub Release.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* A
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* therefore the CHANGELOG's own text, and the only things added are the facts
|
|
13
|
-
* this script can read from the manifests: which versions went to npm.
|
|
6
|
+
* WHAT A RELEASE SAYS, AND WHAT IT DOES NOT
|
|
7
|
+
* -----------------------------------------
|
|
8
|
+
* A release page answers one question for a user: "what do I get if I upgrade?"
|
|
9
|
+
* That is **new tools** and **fixed behaviour**, nothing else. The CHANGELOG is
|
|
10
|
+
* the opposite kind of document — it records the whole change, including internal
|
|
11
|
+
* work (benchmarks, CI, docs, measurements) that a user does not act on.
|
|
14
12
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
13
|
+
* So the notes are a CONVENTION inside the version section, not a copy of it:
|
|
14
|
+
* `### 新增工具` and `### 修复` are the only headings this script reads, and only
|
|
15
|
+
* their top-level `- ` bullets are published. Everything else in that section
|
|
16
|
+
* stays in the CHANGELOG. No npm install block, no version table, no "full entry"
|
|
17
|
+
* link — the release page already shows the version, and install instructions
|
|
18
|
+
* belong to the README.
|
|
19
|
+
*
|
|
20
|
+
* A version with neither heading is REFUSED rather than published with empty
|
|
21
|
+
* notes: an empty Release is indistinguishable from a mistaken one. The format is
|
|
22
|
+
* enforced by `build/check.mjs` (every run) and driven with mutated sections in
|
|
23
|
+
* `test/release.mjs` (rules.md §9).
|
|
19
24
|
*
|
|
20
25
|
* USAGE
|
|
21
26
|
* -----
|
|
22
|
-
* node build/release-notes.mjs --tag v0.
|
|
23
|
-
* node build/release-notes.mjs --tag v0.
|
|
27
|
+
* node build/release-notes.mjs --tag v0.28.2 --out release-notes.md
|
|
28
|
+
* node build/release-notes.mjs --tag v0.28.2 # print to stdout
|
|
24
29
|
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
* text belongs to a version.
|
|
30
|
+
* Section extraction lives in `build/release-preflight.mjs` (`changelogSection`),
|
|
31
|
+
* so the gate and the notes never disagree about which text belongs to a version.
|
|
28
32
|
*/
|
|
29
33
|
|
|
30
34
|
import { readFileSync, writeFileSync } from 'node:fs';
|
|
31
35
|
import { join, resolve } from 'node:path';
|
|
32
36
|
import { fileURLToPath } from 'node:url';
|
|
33
37
|
|
|
34
|
-
import {
|
|
38
|
+
import { changelogSection, tagVersion } from './release-preflight.mjs';
|
|
39
|
+
|
|
40
|
+
/** The only headings that reach a release, in the order they are emitted. */
|
|
41
|
+
const NOTE_SECTIONS = [
|
|
42
|
+
{ key: 'new', heading: '新增工具', title: '新增工具' },
|
|
43
|
+
{ key: 'fix', heading: '修复', title: '修复' },
|
|
44
|
+
];
|
|
35
45
|
|
|
36
46
|
/**
|
|
37
|
-
* The
|
|
47
|
+
* The bullets that belong in a GitHub Release.
|
|
48
|
+
*
|
|
49
|
+
* Top-level `- ` lines only: a continuation line or a nested bullet is detail
|
|
50
|
+
* for the CHANGELOG, not for the release page.
|
|
38
51
|
*
|
|
39
|
-
* @param {string}
|
|
40
|
-
* @
|
|
52
|
+
* @param {string} body - one version's CHANGELOG body.
|
|
53
|
+
* @returns {{new: string[], fix: string[]}}
|
|
54
|
+
*/
|
|
55
|
+
export function extractReleaseBullets(body) {
|
|
56
|
+
const collected = { new: [], fix: [] };
|
|
57
|
+
const sectionOf = new Map(NOTE_SECTIONS.map((entry) => [entry.heading, entry.key]));
|
|
58
|
+
let current;
|
|
59
|
+
for (const line of String(body).split('\n')) {
|
|
60
|
+
const heading = /^###\s+(.+?)\s*$/.exec(line);
|
|
61
|
+
if (heading !== null) {
|
|
62
|
+
current = sectionOf.get(heading[1].trim());
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
if (current === undefined || !line.startsWith('- ')) continue;
|
|
66
|
+
const text = line.slice(2).trim();
|
|
67
|
+
if (text !== '') collected[current].push(text);
|
|
68
|
+
}
|
|
69
|
+
return collected;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Render the release body from bullets.
|
|
74
|
+
* @param {{new?: string[], fix?: string[]}} bullets
|
|
41
75
|
* @returns {string} markdown
|
|
76
|
+
* @throws when there is nothing to announce (a release with no notes is a bug)
|
|
42
77
|
*/
|
|
43
|
-
export function
|
|
78
|
+
export function renderNotes(bullets) {
|
|
79
|
+
const blocks = [];
|
|
80
|
+
for (const entry of NOTE_SECTIONS) {
|
|
81
|
+
const items = bullets[entry.key] ?? [];
|
|
82
|
+
if (items.length === 0) continue;
|
|
83
|
+
blocks.push([`## ${entry.title}`, '', ...items.map((item) => `- ${item}`)].join('\n'));
|
|
84
|
+
}
|
|
85
|
+
if (blocks.length === 0) {
|
|
86
|
+
throw new Error('no release-note bullets: add a "### 新增工具" or "### 修复" heading with "- " bullets to the CHANGELOG entry (docs/change-process.md §5)');
|
|
87
|
+
}
|
|
88
|
+
return blocks.join('\n\n');
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* The GitHub Release body for one tag.
|
|
93
|
+
*
|
|
94
|
+
* @param {string} tag - the release tag (`v0.28.2`).
|
|
95
|
+
* @param {{root?: string, changelog?: string}} [options] `changelog` overrides the file (tests).
|
|
96
|
+
* @returns {string} markdown
|
|
97
|
+
*/
|
|
98
|
+
export function releaseNotes(tag, { root = resolve(fileURLToPath(import.meta.url), '..', '..'), changelog } = {}) {
|
|
44
99
|
const parsed = tagVersion(tag);
|
|
45
100
|
if (parsed.error !== undefined) throw new Error(parsed.error);
|
|
46
101
|
const { version } = parsed;
|
|
47
|
-
|
|
48
|
-
const section = changelogSection(
|
|
102
|
+
const text = changelog ?? readFileSync(join(root, 'CHANGELOG.md'), 'utf8');
|
|
103
|
+
const section = changelogSection(text, version);
|
|
49
104
|
if (!section.found) {
|
|
50
105
|
throw new Error(`CHANGELOG.md has no "## ${version}" section, so this release has no notes (write one before tagging)`);
|
|
51
106
|
}
|
|
52
|
-
|
|
53
|
-
throw new Error(`the CHANGELOG section for ${version} is only ${section.body.length} characters; expand it before tagging`);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
const published = PUBLISHED_PACKAGES.map((entry) => {
|
|
57
|
-
const manifest = JSON.parse(readFileSync(join(root, entry.directory, 'package.json'), 'utf8'));
|
|
58
|
-
return { name: entry.name, version: manifest.version, directory: entry.directory };
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
const lines = [
|
|
62
|
-
section.body,
|
|
63
|
-
'',
|
|
64
|
-
'---',
|
|
65
|
-
'',
|
|
66
|
-
'**npm entries published by this release**',
|
|
67
|
-
'',
|
|
68
|
-
...published.map(
|
|
69
|
-
(entry) =>
|
|
70
|
-
`- \`${entry.name}@${entry.version}\`${entry.directory === '.' ? '' : ' *(the panel package; its version line is independent of the root package)*'} — \`npm install -g ${entry.name}\``,
|
|
71
|
-
),
|
|
72
|
-
'',
|
|
73
|
-
'**Install in the harness** — `dsh plugin --profile <profile> add dsh-molbio-tools`; the tools load only in the **Molecular Biology Lab** mode. See [README.md](README.md) for the panel-only package and the manual install path.',
|
|
74
|
-
'',
|
|
75
|
-
`**Full entry** — [CHANGELOG.md](https://github.com/lovy2004/dsh-molbio-tools/blob/${tag}/CHANGELOG.md).`,
|
|
76
|
-
];
|
|
77
|
-
return lines.join('\n');
|
|
107
|
+
return renderNotes(extractReleaseBullets(section.body));
|
|
78
108
|
}
|
|
79
109
|
|
|
80
110
|
function main() {
|
|
@@ -103,4 +133,4 @@ function main() {
|
|
|
103
133
|
|
|
104
134
|
if (process.argv[1] !== undefined && resolve(process.argv[1]) === resolve(fileURLToPath(import.meta.url))) {
|
|
105
135
|
main();
|
|
106
|
-
}
|
|
136
|
+
}
|
|
@@ -41,7 +41,7 @@ import { gunzipSync } from 'node:zlib';
|
|
|
41
41
|
* The two npm entries this repository publishes, in publish order.
|
|
42
42
|
*
|
|
43
43
|
* THEY DO NOT SHARE A VERSION LINE, and that is deliberate rather than an
|
|
44
|
-
* oversight to be "fixed" here. The root package carries the
|
|
44
|
+
* oversight to be "fixed" here. The root package carries the 72 tools and moves
|
|
45
45
|
* with every toolset release; `dsh-molbio-panel` carries only the browser panel
|
|
46
46
|
* and moves when the panel's own artifact moves. The tag names the ROOT version
|
|
47
47
|
* (`v0.19.0`), and each entry is checked against its own declared version —
|
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
# 审计与整理报告(2026-12-04,针对 0.28.1 工作树)
|
|
2
|
+
|
|
3
|
+
本文件记录一次对 `dsh-molbio-tools` 的全面审计:**做了什么检查、修了什么、
|
|
4
|
+
哪些是环境问题、哪些有意不修**。它不是变更日志——用户可见的变化仍进
|
|
5
|
+
[CHANGELOG](../CHANGELOG.md);这里的读者是要接手维护的人。
|
|
6
|
+
|
|
7
|
+
维护纪律见 [rules.md](rules.md),操作流程见 [workflow.md](workflow.md),
|
|
8
|
+
历史教训见 [history.md](history.md)。
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## 1. 结论摘要
|
|
13
|
+
|
|
14
|
+
- **10 个正确性或崩溃缺陷已修复**:GenBank 折行坐标(静默截断)、两处 `RangeError`(`parseLocation`、
|
|
15
|
+
batch 的 ORF 汇总)、glob 灾难性回溯、PCR 三个(环状重复位点、全长产物截断、产物组合爆炸)、
|
|
16
|
+
FASTA 的 `;` 注释行、TaqMan 推荐含 `N` 探针、未声明参数被静默忽略。其中 3 个是崩溃/挂起,
|
|
17
|
+
4 个是静默的错误数值。
|
|
18
|
+
- **2 个安全边界已收紧**:auto-view 只把白名单扩展名交给操作系统;论文标题链接只放行
|
|
19
|
+
`http(s)://`。前者原本可以借 `output_path: "x.cmd"` 让 `Invoke-Item` 执行任意内容。
|
|
20
|
+
- **“拼错却成功”这一类被根除**:未声明的参数以前被忽略,拼错 `attach_imag` 会照常成功并走默认值;
|
|
21
|
+
现在报错并列出合法参数名。同一改动顺带暴露了两处测试/基准里的“假调用”。
|
|
22
|
+
- **文档与元数据 9 处不一致已对齐**(`64/64`→`72/72`、`65 题`→`73 题`、`0.28.0`→`0.28.1`、
|
|
23
|
+
白名单规则与 `contract.mjs` 相反、兼容性声明覆盖了无法挂载的旧版本等)。
|
|
24
|
+
- **测试全绿**(审计当时有 3 个环境项因本机 harness 落后而失败;2026-12-04 晚升级基线后
|
|
25
|
+
已全部转绿,见第 2 节顶部注记),`bench --offline` 73 题全过,客户端产物与源码一致。
|
|
26
|
+
|
|
27
|
+
改动规模:29 个文件(28 个修改 + 本报告),`git diff` 约 +620/−185 行,含两处打包产物重建。
|
|
28
|
+
新增 20 余条断言,覆盖第 4 节列出的 10 类行为;每条都对应一个**修复前会失败**的行为。
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
> **2026-12-04 晚的更新。** 本机全局 DSH 已升到基线 **0.2.3-alpha.2**,`contract`、`preset-health`、
|
|
33
|
+
> `drift-probe` 现在全绿,`node build/check.mjs --strict` 退出 0。下面第 2 节保留的是**升级前**的环境证据,
|
|
34
|
+
> 它记录的问题类型(基线不一致 → 假红)仍然成立,只是本机已不再是那种状态。
|
|
35
|
+
|
|
36
|
+
## 2. 升级前的环境与基线不一致(历史记录)
|
|
37
|
+
|
|
38
|
+
本机全局安装的 DSH 是 **0.2.2-rc.3**,而本包基线(`preset/molbio-lab/agent.cordis.yml` 头部、
|
|
39
|
+
两份清单、CI pin)是 **0.2.3-alpha.2**。这导致 `npm test` 有 3 项失败,**都不是仓库缺陷**:
|
|
40
|
+
|
|
41
|
+
| 套件 | 失败内容 | 判定依据 |
|
|
42
|
+
| --- | --- | --- |
|
|
43
|
+
| `test/contract.mjs` | 1/17:`selectSessionDirectory` 不在已安装的 sidebar bundle 里 | 该函数 0.2.3 才引入;0.27.1 的 history 已记录这次适配 |
|
|
44
|
+
| `test/preset-health.mjs` | `extra row "tool-cordis" (not in shipped standard)` | `dsh-tool-cordis` 包在 0.2.2-rc.3 里**存在**(版本号 0.2.2-rc.3),只是未被上游 `standard` 引用;挂载本身不受影响 |
|
|
45
|
+
| `test/drift-probe.mjs` | 1 项(依赖 preset-health 的对比) | 同上 |
|
|
46
|
+
|
|
47
|
+
复现命令:`node -e "console.log(require('C:/Users/<you>/AppData/Roaming/npm/node_modules/@deepseek-ai/dsh/package.json').version)"`。
|
|
48
|
+
把本机全局 harness 升到 0.2.3-alpha.2 后这三项即转绿;CI 已 pin 该版本。
|
|
49
|
+
|
|
50
|
+
两个额外的环境限制,影响的是**怎么跑**而不是**跑什么**:
|
|
51
|
+
|
|
52
|
+
1. `node test/release.mjs` 直接运行会失败:`detectNpmVersion()` 在拿不到子进程时回退到
|
|
53
|
+
`npm --version`,本会话的沙箱拒绝 spawn(`EPERM`),且没有 `npm_config_user_agent` 兜底。
|
|
54
|
+
用 `npm run test:release`(npm 派生进程会设置该变量)即可通过。这是测试对启动方式的隐含要求,
|
|
55
|
+
已在 `workflow.md` 的单套件命令旁注记。
|
|
56
|
+
2. npm 缓存目录 `%LOCALAPPDATA%\npm-cache` 被沙箱拒绝(`EPERM`),因此无法在本机安装基线 harness,
|
|
57
|
+
也就无法在本次审计里把上述 3 项跑到绿。报告按“未验证”处理,不当作通过。
|
|
58
|
+
|
|
59
|
+
> **提交注意**:OPS 编辑工具会保留 mtime,而 git 的 stat 缓存对“大小相同、mtime 相同”的文件
|
|
60
|
+
> 不会重新哈希。本次有 6 个文件的改动(`host.mjs`、`docs/maintainer.md`、`test/contract.mjs`、
|
|
61
|
+
> `build/client-bundle.mjs`、`build/release-preflight.mjs`、`packages/molbio-panel/README.md`)
|
|
62
|
+
> 一度在 `git status` 里不可见,`touch` 之后才出现。**提交前请以 `git add -A` 后
|
|
63
|
+
> `git diff --cached --stat` 为准**,不要只信 `git status`。
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## 3. 已修复的缺陷
|
|
68
|
+
|
|
69
|
+
每条都给“症状 → 证据 → 修法 → 回归断言”。行号会漂移,函数名不会。
|
|
70
|
+
|
|
71
|
+
### 3.1 正确性(会给出错误数值)
|
|
72
|
+
|
|
73
|
+
**A. GenBank 折行 `location` 被静默截断**(`genbank.mjs`,`parseGenBank`)
|
|
74
|
+
|
|
75
|
+
- 症状:`join(10..20,30..40,` + 续行 `50..60,70..80)` 解析成 `10..40`,`location` 只剩半截。
|
|
76
|
+
- 根因:21 空格续行只被当成“引号限定符的续行”,且要求 `currentQualifier !== undefined`;
|
|
77
|
+
而真实的 NCBI 记录里长 `join()` 必然折行,所以图谱、批量表、特征计数全部落在错误坐标上。
|
|
78
|
+
- 修法:新增“location 未闭合(括号深度 > 0)”状态,把续行拼回 location 再重新解析;
|
|
79
|
+
新 feature 到来时复位限定符状态;无法落位的 feature 仍然计入 `skippedFeatures`(不再提前计数)。
|
|
80
|
+
- 回归:`test/smoke.mjs` 的 GenBank 段新增折行 `join(1..10,50..60,70..80,90..100)` → `1..100`,
|
|
81
|
+
并断言 `/label` 仍挂在该 feature 上。
|
|
82
|
+
|
|
83
|
+
**B. `parseLocation` 用 `Math.min(...numbers)` 展开大数组**(`genbank.mjs`)
|
|
84
|
+
|
|
85
|
+
- 症状:一条 13 万段的 `join()` 直接 `RangeError: Maximum call stack size exceeded`。
|
|
86
|
+
- 修法:改成单次循环求 min/max。
|
|
87
|
+
- 回归:13 万段 `join()` → `start=1, end=130001`。
|
|
88
|
+
|
|
89
|
+
**C. batch 的“最长 ORF”同样用 spread**(`batch.mjs`,`analyzeSequenceFile`)
|
|
90
|
+
|
|
91
|
+
- 症状:1 Mb 基因组、`orf_min_aa: 1` 时约 16.6 万个 ORF,`Math.max(...lengths)` 抛 `RangeError`;
|
|
92
|
+
该异常被工具层吞成一行 `error`,用户看到的是一张“这张表有问题”的结果,而不是“文件太大”。
|
|
93
|
+
- 修法:循环求最大值。顺手删掉 `maxOrfBases: 2_000_000`——`normalizeSequence` 的上限是 1 Mb,
|
|
94
|
+
这个阈值永远不可能触发,是一段读起来像保护、实际是死代码的配置。
|
|
95
|
+
- 回归:1 Mb 序列仍能扫描,`error` 为空。
|
|
96
|
+
|
|
97
|
+
**D. FASTA 的 `;` 注释行被并入序列**(`seqio.mjs`,`parseFasta`)
|
|
98
|
+
|
|
99
|
+
- 症状:`>a\nACGT\n; a comment line\nTTTT` 得到 21 bp 的“序列”,长度与 GC% 一起错,且无警告。
|
|
100
|
+
- 修法:跳过以 `;` 开头的行(FASTA 的注释约定)。
|
|
101
|
+
- 回归:同一 fixture → `ACGTTTTT`。
|
|
102
|
+
|
|
103
|
+
**E. TaqMan 会推荐含 `N` 的探针**(`taqman.mjs`,`probeCandidates`)
|
|
104
|
+
|
|
105
|
+
- 症状:模板探针区出现 `N` 时,候选仍被接受并给出“合理”的 Tm(NN 模型把该步按 0 处理)。
|
|
106
|
+
这种探针无法订购,Tm 也无意义。
|
|
107
|
+
- 修法:候选窗口必须是纯 `ACGT`。
|
|
108
|
+
- 状态:**无独立回归用例**(现有 TaqMan fixture 不含 N);由代码不变式兜底,见第 6 节待办。
|
|
109
|
+
|
|
110
|
+
### 3.2 崩溃与资源耗尽
|
|
111
|
+
|
|
112
|
+
**F. PCR 环状模板多扫一个起点**(`pcr.mjs`,`findBindingSites`)
|
|
113
|
+
|
|
114
|
+
- 症状:60 bp 环状模板报出两个位点 `start=1` 与 `start=61`,同一个位点被画成两条一样的条带。
|
|
115
|
+
- 根因:`limit = circular ? length : length - probe.length` 配 `start <= limit`;环状只有 `length` 个起点。
|
|
116
|
+
- 修法:`windows = circular ? length : length - probe.length + 1`,`start < windows`。
|
|
117
|
+
|
|
118
|
+
**G. PCR 全长产物序列被截断**(`pcr.mjs`,`sliceSequence`)
|
|
119
|
+
|
|
120
|
+
- 症状:43 bp 环状模板、产物 size=43,返回的 `sequence` 只有 33 bp。
|
|
121
|
+
- 根因:平铺到 `length` 而不是 `start + length`,起点非 0 时少一截。
|
|
122
|
+
- 修法:`while (out.length < start + length) out += sequence`。
|
|
123
|
+
|
|
124
|
+
**H. PCR 产物笛卡尔积无上限**(`pcr.mjs`,`simulatePair`)
|
|
125
|
+
|
|
126
|
+
- 症状:poly-A 模板 1200 bp + 8-mer 引物 → 约 71 万对、全量入数组后才 `slice(max_products)`;
|
|
127
|
+
5 kb 模板 1250 万对象,1 Mb 直接 OOM。
|
|
128
|
+
- 修法:新增 `max_pair_evaluations: 200_000`,超出即停止并置 `truncated: true`(不再静默采样)。
|
|
129
|
+
- 回归:1200 bp poly-A → 57 ms 返回,`truncated: true`,`amplicon_count <= 200`。
|
|
130
|
+
|
|
131
|
+
**I. batch 的 glob 匹配可被灾难性回溯打成挂起**(`batch.mjs`)
|
|
132
|
+
|
|
133
|
+
- 症状:`*a*a*a*a*a*a*a*a*a*a*b` 对 28 个字符的文件名耗时约 1.4 s,每多一个 `*` 指数增长。
|
|
134
|
+
- 根因:把 glob 翻译成 `.*` 再交给正则引擎。
|
|
135
|
+
- 修法:换成两指针线性匹配 `globMatches(pattern, name)`(单回溯点,O(pattern×name)),
|
|
136
|
+
语义仍是 `*` = 任意串、`?` = 单字符、大小写不敏感。
|
|
137
|
+
- 回归:同一 pattern 立即返回 `false`,并断言耗时 < 100 ms;`*.fa`/`sub/*.fa`/`?` 行为不变。
|
|
138
|
+
|
|
139
|
+
### 3.3 安全边界
|
|
140
|
+
|
|
141
|
+
**J. auto-view 会把任意扩展名交给操作系统**(`view.mjs`、`index.mjs` 的 `writeSvgFile`)
|
|
142
|
+
|
|
143
|
+
- 症状:`output_path: "x.cmd"` → 把 SVG 文本写进 `.cmd` → `Invoke-Item` **执行**它。
|
|
144
|
+
写入本身在沙箱内,但“写一个批处理再让系统打开”是逃出工具沙箱的一条路。
|
|
145
|
+
- 修法:`openDefaultViewer` 只接受 `VIEWABLE_EXTENSIONS`(`.svg/.html/.htm/.xhtml`),
|
|
146
|
+
其余直接返回 `false`,一个进程都不起。
|
|
147
|
+
- 回归:`.cmd`/`.ps1` 返回 `false` 且 opener 调用次数为 0;`.svg` 仍正常。
|
|
148
|
+
|
|
149
|
+
**K. 论文标题链接接受任意 scheme**(`build/panel-core.mjs`,`paperLink`)
|
|
150
|
+
|
|
151
|
+
- 症状:`paper.url` 原样进 `<a href>`;它来自工具参数与 web 结果,`javascript:` 会在点击时执行。
|
|
152
|
+
- 修法:只放行 `http(s)://`;PMID 分支要求纯数字。
|
|
153
|
+
- 回归:`test/client.mjs` 断言 `javascript:` / `file://` → `undefined`,`https` 保留,非数字 PMID 不生成链接。
|
|
154
|
+
|
|
155
|
+
### 3.4 参数校验(“拼错却成功”)
|
|
156
|
+
|
|
157
|
+
**L. 未声明的参数被静默忽略**(`index.mjs`,`define`/`validateArgsAgainstSchema`)
|
|
158
|
+
|
|
159
|
+
- 症状:72 个工具没有任何一个声明 `additionalProperties: false`,于是校验器里“未知参数”的分支
|
|
160
|
+
**不可达**。模型把 `attach_image` 拼成 `attach_imag`、`auto_view` 拼成 `auto_vew`,调用照常成功、
|
|
161
|
+
悄悄走默认值——这是唯一一种“看起来正确的错误”。
|
|
162
|
+
- 修法:`define()` 给所有工具补 `additionalProperties: false`;未知参数报错并**列出合法参数名**;
|
|
163
|
+
嵌套对象的 `additionalProperties: false` 也真正生效;enum 校验不再只对字符串生效
|
|
164
|
+
(`strand: {enum: [1,-1]}` 以前接受 7)。
|
|
165
|
+
- 附带收益:这台守卫当场抓出两处“假调用”——`test/smoke.mjs` 曾给 `molbio_fastq_qc` 传内部设置
|
|
166
|
+
`adapter_scan_reads`(不是工具参数),`benchmark/verifications.mjs` 曾给 `molbio_extract_region` 传
|
|
167
|
+
`vector`(schema 里的名字是 `sequence`)。两处都已改为真实参数,基准题注记同步重写。
|
|
168
|
+
- 回归:拼错参数报 `unknown argument "window_size" (valid: ...)`;`strand: 7` 报 `must be one of 1, -1`。
|
|
169
|
+
|
|
170
|
+
### 3.5 文档与元数据
|
|
171
|
+
|
|
172
|
+
| 位置 | 原值 | 现值 | 依据 |
|
|
173
|
+
| --- | --- | --- | --- |
|
|
174
|
+
| `docs/rules.md` §6 | 64/64 工具覆盖 | 72/72 | `benchmark-coverage` 实测 72/72 |
|
|
175
|
+
| `docs/workflow.md` 发版表 | `bench:full` 65 题 | 73 题 | `benchmark/tasks/*.json` 共 73 题 |
|
|
176
|
+
| `docs/workflow.md` §3 | 49 条 tool 断言 | 210 条(不写死的说法) | 解析 73 个任务得到 210 |
|
|
177
|
+
| `docs/maintainer.md` 基线 | 版本 0.28.0 | 0.28.1 | `package.json` |
|
|
178
|
+
| `docs/rules.md` §4 | 白名单“必须覆盖 `lib/`、`packages/`” | 根包覆盖 `lib/`/`build/`/`preset/` 且**必须排除** `packages/` | `contract.mjs` 断言根 tarball 不得含第二个清单 |
|
|
179
|
+
| `docs/rules.md` §10 | 提示段 5,708 | 5,813 | `test/prompt.mjs` 实测(本次改动后为 5,917) |
|
|
180
|
+
| `docs/history.md` | 最新 0.28.0 | 补 0.28.1 行 | `CHANGELOG` / tag |
|
|
181
|
+
| `docs/roadmap.md` | “当前状态(0.28.0)” | “功能线 0.28,最新补丁 0.28.1” | 同上 |
|
|
182
|
+
| `packages/molbio-panel/README.md` | 64 个工具 | 72 | 实际注册数 |
|
|
183
|
+
| `host.mjs`、`build/client-bundle.mjs`、`build/release-preflight.mjs`、`test/contract.mjs` 注释 | 64/65 | 72 | 同上 |
|
|
184
|
+
| `.github/workflows/release.yml` 注释 | Node 来自 0.2.2-rc.5 | 0.2.3-alpha.2 | 同文件 pin |
|
|
185
|
+
|
|
186
|
+
两处 0.28.0 的 `(v12)` 版本标记(在输出 schema 的 property description 里,可能随工具定义发给模型)
|
|
187
|
+
已删除——`rules.md` §10 规定模型可见文本不写版本号。
|
|
188
|
+
|
|
189
|
+
### 3.6 兼容性声明
|
|
190
|
+
|
|
191
|
+
`package.json` 原本把 0.2.1-rc.2 至 0.2.2-rc.5 全部标为 `compatible`,`engines.dsh` 下限写
|
|
192
|
+
`>=0.2.1-rc.2`。但 0.25.1 起 preset 带 `tool-office` 行,而本仓库自己的
|
|
193
|
+
[store-evidence.md](store-evidence.md) 已记录该包在 **0.2.2-rc.1 不存在**(`MODULE_NOT_FOUND`);
|
|
194
|
+
0.2.1-rc.x 从未用当前行清单验证过。本次:
|
|
195
|
+
|
|
196
|
+
- `engines.dsh` → `>=0.2.2-rc.2 <0.3.0-0`;
|
|
197
|
+
- 0.2.1-rc.2/rc.3/rc.5、0.2.2-rc.1 → `unknown`;0.2.2-rc.2/rc.3/rc.5 与 0.2.3-alpha.2 保持 `compatible`
|
|
198
|
+
(`dsh-tool-cordis` / `dsh-tool-office` 在 0.2.2-rc.3 的安装里均存在,已核对版本号);
|
|
199
|
+
- `store-evidence.md` 的声明块与说明同步更新,并补 0.2.3-alpha.2 一行。
|
|
200
|
+
|
|
201
|
+
**面板包 `packages/molbio-panel` 的声明没有改**:它没有工具行,只挂一个惰性宿主行,
|
|
202
|
+
而且面板对 `workingDirectory` projection 有旧版回退,确实兼容更老的版本。两条发布线的兼容范围
|
|
203
|
+
本来就不同,这是有意的。
|
|
204
|
+
|
|
205
|
+
### 3.7 顺手的整理
|
|
206
|
+
|
|
207
|
+
- `index.mjs` 里同一段 `sandboxPolicy` 解析复制了 **17 次**,收敛为 `resolveSandboxPolicy(ctx, exec)`。
|
|
208
|
+
这原本是“`resolve()` 加一个参数就要改 17 处、漏一处就是一次越界写”的结构。
|
|
209
|
+
- `phylo.mjs` 里唯一一处 `console.log`(只在 `MOLBIO_PROBE_RADIAL=1` 时输出的调试块)已删除;
|
|
210
|
+
库函数不应往宿主 stdout 写东西。
|
|
211
|
+
- `attach_image` 在 clone/Golden Gate/qPCR 三个工具上“只给开关、没给路径”时原本静默无图;
|
|
212
|
+
现在补 `image_note` 说明需要 `map_path`/`plot_path`。`molbio_signal_peptide` 的 render 补上了
|
|
213
|
+
`imageNote(value)`,失败原因不再只存在于字段里。
|
|
214
|
+
- 网络/环境类错误(PubMed 不可达、部署没有 web fetch)原本也叫 `MolbioInputError`,与
|
|
215
|
+
“改参数重试”的提示冲突;错误文案与提示段第 7 条现在区分“参数错”与“服务/网络错”。
|
|
216
|
+
|
|
217
|
+
---
|
|
218
|
+
|
|
219
|
+
## 4. 验证记录
|
|
220
|
+
|
|
221
|
+
本机(Node 26.12.1,Windows)。命令均在包根目录执行,`MOLBIO_AUTO_VIEW=0`。
|
|
222
|
+
|
|
223
|
+
| 套件 | 结果 |
|
|
224
|
+
| --- | --- |
|
|
225
|
+
| `node test/smoke.mjs` | PASS — 72 个工具、输出 schema 全通过;新增 8 组断言 |
|
|
226
|
+
| `node test/svgpng.mjs` / `svgio` / `charts` / `structure` | PASS(23 / 26 项等) |
|
|
227
|
+
| `node test/client.mjs` / `panel-render` / `map-card` / `client-mount` | PASS |
|
|
228
|
+
| `node test/prompt.mjs` | PASS — 5,917 字符(预算 6,000)、72/72 覆盖、5 个突变全被抓 |
|
|
229
|
+
| `node test/contract.mjs` | 16/17 — 1 项为环境(`selectSessionDirectory`) |
|
|
230
|
+
| 全矩阵(14 套件 + 三条构建检查) | 14 PASS;4 FAIL 全部是环境项:contract / release(spawn)/ drift-probe / preset-health |
|
|
231
|
+
| `node test/release.mjs`(经 `npm run`) | PASS 13 项 |
|
|
232
|
+
| `node test/benchmark-profile` / `-score` / `-coverage` / `-changed` | PASS(72/72 覆盖、73 题) |
|
|
233
|
+
| `node benchmark/run.mjs --offline` | PASS — 73 题对真实工具输出重算 |
|
|
234
|
+
| `node build/client-bundle.mjs --check` | PASS — 两个产物与源码一致(503.0 KB) |
|
|
235
|
+
| `node build/preset-patch.mjs --check` | PASS |
|
|
236
|
+
| `node test/preset-health.mjs` / `drift-probe.mjs` | FAIL — 环境(0.2.2-rc.3 vs 0.2.3-alpha.2) |
|
|
237
|
+
|
|
238
|
+
每个新增断言都对应修复前的真实行为(用一次性探针逐条复现过):
|
|
239
|
+
|
|
240
|
+
| 断言 | 修复前 |
|
|
241
|
+
| --- | --- |
|
|
242
|
+
| 折行 `join` → 1..100 | 得到 1..60 |
|
|
243
|
+
| 13 万段 `join` | `RangeError` |
|
|
244
|
+
| 1 Mb ORF 扫描 | `RangeError`(变成 error 行) |
|
|
245
|
+
| glob 线性 | 1.4 s 且指数增长 |
|
|
246
|
+
| `.cmd` 不交给 opener | `Invoke-Item` 被执行 |
|
|
247
|
+
| `javascript:` 链接 | 原样进 `href` |
|
|
248
|
+
| 环状模板位点数 = 1 | 2(start 61 越界) |
|
|
249
|
+
| 全长产物 43 bp | 33 bp |
|
|
250
|
+
| 拼错参数报错 | 静默成功 |
|
|
251
|
+
| `;` 注释行 | 进入序列 |
|
|
252
|
+
|
|
253
|
+
---
|
|
254
|
+
|
|
255
|
+
## 5. 已核实为“有意设计”,不要按“问题”去改
|
|
256
|
+
|
|
257
|
+
- **`digest()` 只扫正链**:`lib.mjs` 的注释明说它是简化版,完整切点集是 `enzymeCuts()`/`enzymeCatalog()`。
|
|
258
|
+
两个工具因此对 IIS 酶给出不同计数(`restriction_sites` vs `enzyme_lookup`)——这是**已知分歧**,
|
|
259
|
+
不是隐藏 bug;统一它需要同时改 4 个工具输出与基准期望,见第 6 节。
|
|
260
|
+
- **根包 `files` 不含 `packages/`**:面板是独立 npm 条目,根 tarball 里出现两个 `dsh` 清单更糟。
|
|
261
|
+
`contract.mjs` 明确断言这一点。
|
|
262
|
+
- **CHANGELOG 与 plan 文档里的 64/65/66**:各版本当时的事实,不要全局替换。
|
|
263
|
+
- **`benchmark/reports/` 不在 git 里**:测量产物,`.gitignore` 有意排除;CHANGELOG 有注明。
|
|
264
|
+
- **客户端产物里同时有工具与面板的浏览器半**:两条发布渠道共用一个 bundle,只有注册 id 不同;
|
|
265
|
+
“panel only” 指的是宿主半不注册工具,不是体积更小。
|
|
266
|
+
|
|
267
|
+
---
|
|
268
|
+
|
|
269
|
+
## 6. 未修复的发现(按优先级)
|
|
270
|
+
|
|
271
|
+
以下都是本次审计确认过的真实问题,但改动会波及基准期望或属于产品决策,留给下一次专题。
|
|
272
|
+
|
|
273
|
+
**P1**
|
|
274
|
+
|
|
275
|
+
1. **`digest()` 与 `enzymeCuts()` 的分歧变成用户可见矛盾**:`molbio_restriction_sites` 对 IIS 酶
|
|
276
|
+
(BsaI 等)少报反向位点。建议让 `restriction_sites`/`double_digest`/`batch` 改用 `enzymeCuts`,
|
|
277
|
+
同步 4 个基准任务的期望值。
|
|
278
|
+
2. **`methylationSites` 是 O(位点×酶×全长)**:10 kb 约 12 s,1 Mb 外推数十小时,输出无上限;
|
|
279
|
+
`analyzeMethylation` 还把 `methylationSites` 算了两次。建议每酶只扫一遍起点再判重叠。
|
|
280
|
+
3. **`designPrimers` 没有模板上限**:约 0.23 ms/bp,1 Mb 模板约 4 分钟。建议加 50 kb 级别的预算
|
|
281
|
+
(`normalizeSequence` 的 1 Mb 是硬上限,不是预算)。
|
|
282
|
+
4. **TaqMan 反向探针的 `distance_from_primer_3prime` 可能为负**(待确认):正向路径有断言,
|
|
283
|
+
反向回退路径没有回归用例。先在 `test/smoke.mjs` 造一条反向 assay 再改几何。
|
|
284
|
+
5. **multiplex 与 design 的 3' 末端错配规则不一致**:design 把末端错配排除在“可延伸”之外,
|
|
285
|
+
multiplex 计入错配数,`count`/建议偏大。建议抽公共 helper。
|
|
286
|
+
6. **`gcPercentOf` 两份实现、精度不同**(1 位 vs 2 位):同一序列在不同工具里一个 42.9、一个 42.86。
|
|
287
|
+
建议收敛到 `lib.mjs` 的 `gcPercent(seq, digits)`。
|
|
288
|
+
|
|
289
|
+
**P2**
|
|
290
|
+
|
|
291
|
+
7. 重复实现:`escapeXml` 5 份(`svgio` 已导出,其余 4 处可零成本改为 import)、
|
|
292
|
+
`safeSelfAny/End/HairpinTm` 2 份(multiplex/taqman)、`hamming` 3 份、`buildKmerIndex` 2 份。
|
|
293
|
+
统一时注意:`escapeXml` 在 `logo.mjs` 的版本漏了 `'`,严格说不改输出字节。
|
|
294
|
+
8. `lib.mjs` 有 6 个导出无人 import(`BASE_ORDER`、`IUPAC_EXPAND`、`METHYLATION_SITES`、
|
|
295
|
+
`ANY_BUFFER_ENZYMES`、`ENZYME_BUFFERS`、`enzymeBuffers`),属“多余 export”而非死代码;
|
|
296
|
+
`align-post.showAlignedSlice`、`font-metrics.capHeight`、`sequence-ops` 的两个别名是真正无人引用。
|
|
297
|
+
9. `view.mjs` 的 `$BROWSER` 被当成单个可执行文件:`BROWSER="firefox --new-window"` 会静默失败。
|
|
298
|
+
10. `phylo.mjs` 的 `buildTree` 在 `unaligned: true` 时忽略 `method: 'nj'`(只走 UPGMA,目前仅供测试)。
|
|
299
|
+
11. `crispr.mjs` 的 `designGrnas` 不筛歧义碱基(工具层的 `crisprTarget` 已拒绝),属 defense-in-depth 缺口。
|
|
300
|
+
12. TaqMan 的 ACGT 守卫缺独立回归用例(第 3.1-E 条)。建议在 `test/smoke.mjs` 的 TaqMan 段
|
|
301
|
+
用一个探针区带 N 的模板断言“没有任何 assay 的 probe 含 N”。
|
|
302
|
+
|
|
303
|
+
---
|
|
304
|
+
|
|
305
|
+
## 7. 发布前 checklist
|
|
306
|
+
|
|
307
|
+
本次改动**没有**动版本号,也**没有**写 CHANGELOG —— 版本决策留给维护者。发布时至少:
|
|
308
|
+
|
|
309
|
+
1. `package.json` 升到 0.28.2(或按 semver 判断:参数校验变严属于行为变更,建议 minor 而非 patch);
|
|
310
|
+
2. 在 `CHANGELOG.md` 顶部加一节,`docs/history.md` 补一行;
|
|
311
|
+
3. `node build/client-bundle.mjs` 后确认 `--check` 为 up to date(本次已重建,503.0 KB);
|
|
312
|
+
4. `npm test`(在基线 0.2.3-alpha.2 上跑,否则第 2 节的三项会红);
|
|
313
|
+
5. `node --run bench:offline`(已验证 73 题绿);
|
|
314
|
+
6. `git add -A && git diff --cached --stat` 核对 29 个文件——不要只信 `git status`(见第 2 节)。
|