dsh-repro-audit 0.0.0-stage → 0.1.0

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.
Files changed (61) hide show
  1. package/CHANGELOG.md +63 -0
  2. package/LICENSE +201 -0
  3. package/README-zh.md +124 -0
  4. package/README.md +129 -2
  5. package/cordis.patch.yml +18 -0
  6. package/lib/config.d.ts +37 -0
  7. package/lib/config.d.ts.map +1 -0
  8. package/lib/config.js +44 -0
  9. package/lib/config.js.map +1 -0
  10. package/lib/index.d.ts +37 -0
  11. package/lib/index.d.ts.map +1 -0
  12. package/lib/index.js +46 -0
  13. package/lib/index.js.map +1 -0
  14. package/lib/manifest.d.ts +104 -0
  15. package/lib/manifest.d.ts.map +1 -0
  16. package/lib/manifest.js +248 -0
  17. package/lib/manifest.js.map +1 -0
  18. package/lib/report.d.ts +14 -0
  19. package/lib/report.d.ts.map +1 -0
  20. package/lib/report.js +95 -0
  21. package/lib/report.js.map +1 -0
  22. package/lib/runtime.d.ts +62 -0
  23. package/lib/runtime.d.ts.map +1 -0
  24. package/lib/runtime.js +226 -0
  25. package/lib/runtime.js.map +1 -0
  26. package/lib/scan.d.ts +70 -0
  27. package/lib/scan.d.ts.map +1 -0
  28. package/lib/scan.js +275 -0
  29. package/lib/scan.js.map +1 -0
  30. package/lib/tools/repro-card.d.ts +10 -0
  31. package/lib/tools/repro-card.d.ts.map +1 -0
  32. package/lib/tools/repro-card.js +80 -0
  33. package/lib/tools/repro-card.js.map +1 -0
  34. package/lib/tools/repro-check.d.ts +12 -0
  35. package/lib/tools/repro-check.d.ts.map +1 -0
  36. package/lib/tools/repro-check.js +62 -0
  37. package/lib/tools/repro-check.js.map +1 -0
  38. package/lib/tools/repro-manifest.d.ts +12 -0
  39. package/lib/tools/repro-manifest.d.ts.map +1 -0
  40. package/lib/tools/repro-manifest.js +66 -0
  41. package/lib/tools/repro-manifest.js.map +1 -0
  42. package/lib/tools/shared.d.ts +20 -0
  43. package/lib/tools/shared.d.ts.map +1 -0
  44. package/lib/tools/shared.js +14 -0
  45. package/lib/tools/shared.js.map +1 -0
  46. package/lib/version.d.ts +7 -0
  47. package/lib/version.d.ts.map +1 -0
  48. package/lib/version.js +7 -0
  49. package/lib/version.js.map +1 -0
  50. package/package.json +80 -4
  51. package/src/config.ts +69 -0
  52. package/src/index.ts +56 -0
  53. package/src/manifest.ts +322 -0
  54. package/src/report.ts +98 -0
  55. package/src/runtime.ts +235 -0
  56. package/src/scan.ts +317 -0
  57. package/src/tools/repro-card.ts +82 -0
  58. package/src/tools/repro-check.ts +61 -0
  59. package/src/tools/repro-manifest.ts +65 -0
  60. package/src/tools/shared.ts +14 -0
  61. package/src/version.ts +7 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,63 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project are documented here. The format follows
4
+ [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project
5
+ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+ ## [Unreleased]
8
+
9
+ ### Fixed
10
+
11
+ - `repro_check` resolves a saved manifest through `realpath` and rejects a
12
+ symlink that escapes the workspace (`PATH_ESCAPE`).
13
+ - Malformed saved manifests (invalid JSON, `null`, or missing required arrays)
14
+ return `INVALID_MANIFEST` instead of throwing a `SyntaxError`/`TypeError`.
15
+ - `repro_card` validates its manifest/drift inputs (including `null` and each
16
+ drift finding's expected/actual fields) and returns `INVALID_MANIFEST`/
17
+ `INVALID_INPUT` rather than crashing on malformed JSON.
18
+ - The symlink-skipping test now creates a real symlink and asserts that it is
19
+ skipped (the previous assertion was unconditional `|| true`).
20
+ - `package.json`, `jsconfig.json` and `tsconfig*.json` are no longer classified
21
+ as input data; a Node project therefore no longer suppresses the `no_data`
22
+ gap with its build configuration.
23
+ - The `no_seed` gap now recognizes lowercase `.r` (and `.Rmd`/`.qmd`) scripts;
24
+ it previously matched only `.py` and uppercase `.R`.
25
+ - Exclude the configured record store from the scan when it is inside the
26
+ project (the default `.repro-audit/` is also in the skip list); previously a
27
+ second manifest/drift check hashed its own records as added data.
28
+ - Disable repository-local fsmonitor hooks for the read-only `git` calls: a
29
+ repository can configure `core.fsmonitor` to an executable, which `git status`
30
+ would run. `GIT_OPTIONAL_LOCKS=0` also keeps `git status` from refreshing the
31
+ index. A regression test asserts the hook is not executed.
32
+ - Strip inherited `GIT_*` variables before spawning git, so `GIT_DIR`/
33
+ `GIT_WORK_TREE` from the host cannot redirect the evidence to another
34
+ repository; covered by a regression test.
35
+
36
+ ### Changed
37
+
38
+ - Test count is now 24; the README and evaluation notes list the new failure
39
+ branches.
40
+
41
+ ## [0.1.0] - 2026-11-08
42
+
43
+ First release: reproducibility evidence and drift detection.
44
+
45
+ ### Added
46
+
47
+ - `repro_manifest`: bounded, read-only scan recording git commit/dirty state,
48
+ lockfiles, environment pins, data/figure/notebook hashes, seed literals and
49
+ runnable commands, plus gap severities and a reproducibility level.
50
+ - `repro_check`: re-scan and compare — changed, missing and added artifacts —
51
+ with the level downgraded when recorded evidence no longer matches.
52
+ - `repro_card`: Markdown report card + SARIF 2.1.0.
53
+ - REP v1 integration: the manifest's artifacts are written as a valid
54
+ `ResearchRecord` with `Artifact` rows (code/env/data/seed/command/figure/
55
+ notebook) and the manifest itself alongside it.
56
+ - Path containment, symlink skipping, file/depth/hash caps; `git` only via
57
+ fixed read-only arguments with a timeout.
58
+ - 17 tests; manual scenario matrix in the README.
59
+
60
+ ### Notes
61
+
62
+ - Metadata-level audit only: a manifest proves bytes existed, not that the
63
+ analysis is correct or that its command reproduces the figures.
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README-zh.md ADDED
@@ -0,0 +1,124 @@
1
+ # dsh-repro-audit
2
+
3
+ **别人能复现这项分析吗 —— 以及从你记录至今,有没有东西发生漂移?**
4
+
5
+ *有界、只读的扫描:记录 commit、lockfile、环境、数据哈希、图表、seed 与运行命令;对照这份记录做漂移检查;生成可直接交给评审的报告卡。*
6
+
7
+ [![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](LICENSE)
8
+ [![Node](https://img.shields.io/badge/node-%5E22.19%20%7C%7C%20%3E%3D24.9-brightgreen.svg)]()
9
+
10
+ [English](README.md) · 简体中文
11
+
12
+ ---
13
+
14
+ ## 它做什么
15
+
16
+ - **`repro_manifest`** 扫描工作区中的一个项目并记录:git commit + 工作区脏状态、依赖 lockfile、环境版本固定(`.nvmrc`、`.python-version`、`pyproject.toml`、Dockerfile……)、输入数据哈希、图表哈希、notebook、显式随机种子(`random_state`、`np.random.seed`、`set.seed`、`torch.manual_seed`……)以及可运行命令(package.json scripts、Makefile targets、`run`/`reproduce`/`analysis` 入口脚本)。
17
+ - **`repro_check`** 重新扫描并对比:**发生变化**或**消失**的产物都会成为一项发现 —— 因此清单生成后被修改过的数据文件也能被抓住。
18
+ - **`repro_card`** 把证据渲染为 Markdown + SARIF 2.1.0,逐项列出缺口、严重级别和具体建议。
19
+
20
+ 级别:`reproducible`(没有 error/warning 级缺口)、`partial`(只有 warning)、`not_reproducible`(存在任何 error 级缺口或漂移)、`unknown`(保留)。
21
+
22
+ ## 它不做什么
23
+
24
+ - **不执行代码。** 绝不运行项目代码;唯一的子进程是 `git rev-parse` 和 `git status`,带超时且不经 shell。
25
+ - **不上传、不构建。** 它不抓取数据、不安装依赖,也不复现图表。
26
+ - **不声称结论为真。** 清单只能证明这些字节曾经存在,不能证明分析正确或完整。
27
+ - **没有 UI。** 只输出 JSON、Markdown 与 SARIF。
28
+
29
+ ## 缺口代码
30
+
31
+ | 代码 | 严重级别 | 含义 |
32
+ |---|---|---|
33
+ | `no_git_commit` | error | 不是 git 仓库,或没有任何 commit |
34
+ | `no_lockfile` | error | 未记录依赖 lockfile |
35
+ | `no_run_command` | error | 未找到入口 |
36
+ | `dirty_worktree` | warning | 存在未提交的改动;commit 无法描述这些文件 |
37
+ | `no_seed` | warning | 存在脚本,但未找到 seed 字面量 |
38
+ | `no_data` | warning | 项目中无输入数据文件 |
39
+ | `no_environment` | warning | 未固定运行时/环境 |
40
+ | `unhashed_data` | warning | 某个数据文件超出哈希上限 |
41
+ | `no_figures` | info | 没有图表/表格产物 |
42
+ | `scan_truncated` | warning | 达到文件数上限 |
43
+
44
+ error 级缺口会把级别降为 `not_reproducible`;warning 会把级别降为 `partial`。
45
+
46
+ ## 工具
47
+
48
+ ### `repro_manifest`
49
+
50
+ `{ path? }` → `{ ok, manifest, recordPath }`。该记录是一条合法的 REP `ResearchRecord`,其 `artifacts` 是代码/环境/数据/seed/命令/图表/notebook 证据。
51
+
52
+ ### `repro_check`
53
+
54
+ `{ manifest | manifestPath, path? }` → `{ ok, drift }`。`manifestPath` 相对于工作区;`path` 是要重新扫描的项目(默认是工作区根目录)。
55
+
56
+ ### `repro_card`
57
+
58
+ `{ manifest, drift? }` → `{ ok, markdown, sarif }`。
59
+
60
+ ### 错误码
61
+
62
+ `INVALID_INPUT` · `NOT_FOUND` · `PATH_ESCAPE` · `NOT_A_DIRECTORY` · `INVALID_MANIFEST` · `STORE_ERROR`
63
+
64
+ ## 兼容性与安装
65
+
66
+ | | |
67
+ |---|---|
68
+ | DeepSeek Harness | **`dsh-v0.2.1-rc.5`**(2026-11-08 实测);peer `>=0.2.1-0 <0.3.0 \|\| >=0.2.2-0 <0.3.0` |
69
+ | Node | `^22.19.0 \|\| >=24.9.0`(实测 `24.22.1`),仅 ESM |
70
+ | Peer 依赖 | `@perrylink/dsh-research-core ^0.1.0`、`@deepseek-ai/cordis ^4.0.5-alpha.1`、`@deepseek-ai/dsh-tools`、`@deepseek-ai/schemastery ^3.18.5-alpha.1` |
71
+ | 运行时依赖 | **零** |
72
+
73
+ ```sh
74
+ dsh plugin --profile <name> add @perrylink/dsh-research-core dsh-repro-audit
75
+ dsh --profile <name> --dump-config | grep dsh-repro-audit
76
+ ```
77
+
78
+ ## 配置
79
+
80
+ | 键 | 默认值 | 含义 |
81
+ |---|---|---|
82
+ | `enabled` | `true` | `false` 时不挂载任何内容 |
83
+ | `root` | `.repro-audit` | 清单与记录的根目录 |
84
+ | `workspaceRoot` | `process.cwd()` | 项目路径必须解析到该目录内 |
85
+ | `maxFiles` | `2000` | 每次扫描访问的文件数(超限会报告) |
86
+ | `maxDepth` | `6` | 目录深度 |
87
+ | `maxFileBytes` | `8388608` | 单文件哈希上限(更大的数据只记录为未哈希 + 缺口) |
88
+
89
+ 忽略的目录:`.git`、`node_modules`、`.venv`、`dist`、`build`、`target`、`__pycache__`、`coverage`、`.next`、各缓存目录、`.repro-audit`,以及配置的存储根目录(当其位于项目内时)。
90
+
91
+ ## 安全边界
92
+
93
+ - 项目只读;记录写入 `root` 下。若存储目录位于被扫描的树内(默认的 `.repro-audit/`),该目录会被排除,因此清单不会把自己生成的记录也纳入。
94
+ - 项目内的符号链接会被报告并跳过,绝不跟随。
95
+ - 哈希上限用于防止内存暴涨;达到文件数上限时会报告,而不是静默忽略。
96
+ - `git` 以固定的只读参数运行,5 秒超时,并启用 `windowsHide`;不经 shell。仓库本地的 fsmonitor hook 被禁用(`-c core.fsmonitor=false`),`GIT_OPTIONAL_LOCKS=0` 阻止 `git status` 刷新/写入索引;继承来的 `GIT_*` 变量会被清除,因此 `git -C <root>` 无法被重定向到另一个仓库。
97
+
98
+ ## 评测
99
+
100
+ **24 个测试**:扫描(lockfile/数据/图表/seed/命令/运行时、跳过 `node_modules`、符号链接跳过但报告、项目配置不计为数据、小写 `.r` 脚本、文件数上限、排除自身存储、不执行 fsmonitor hook、忽略继承的 `GIT_*`)、清单级别(干净 → reproducible、无 seed → partial、无 git → not_reproducible、有未提交改动 → partial、空项目的缺口集合)、漂移(数据变化 + 图表缺失、干净重查)、运行时(合法 REP 记录、内联清单、带项目路径的已保存清单、拒绝格式错误的已保存清单并报 `INVALID_MANIFEST`、拒绝符号链接清单逃逸、路径逃逸)、tools(schema、manifest→check→card 端到端、失败分支、格式错误的 card 输入)、包契约。
101
+
102
+ 人工样例矩阵(不声称基准测试结果 —— 产物集合基于规则,而非学习得到):
103
+
104
+ | 场景 | 预期 | 覆盖 |
105
+ |---|---|---|
106
+ | 完整项目、干净工作树 | `reproducible`,0 个缺口 | 测试 |
107
+ | 无 seed | `partial`,`no_seed` | 测试 |
108
+ | 无 git | `not_reproducible`,`no_git_commit` | 测试 |
109
+ | 有未提交改动 | `partial`,`dirty_worktree` | 测试 |
110
+ | 清单生成后数据被修改 | 漂移 `changed`,`not_reproducible` | 测试 |
111
+ | 图表被删除 | 漂移 `missing` | 测试 |
112
+ | 刚记录的清单 | 漂移为空 | 测试 |
113
+
114
+ ## 已知限制(v0.1)
115
+
116
+ - 只到元数据层面:不验证记录的命令是否真的能复现图表。
117
+ - seed 通过字面量模式发现;经由配置文件或环境变量注入的 seed 会被漏掉。
118
+ - 图表只做哈希,未与生成它的脚本关联(尚无溯源图)。
119
+ - 大型数据文件只记录为“未哈希”(并记一个缺口),而不是流式处理。
120
+ - 不识别 `.gitignore`:已被忽略但实际存在的文件,只要属于数据/图表/相应扩展名,仍会被哈希。
121
+
122
+ ## 许可
123
+
124
+ Apache-2.0。运行时不含第三方代码。
package/README.md CHANGED
@@ -1,3 +1,130 @@
1
- # Temporary Holding Version
1
+ # dsh-repro-audit
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ **Would someone else be able to reproduce this analysis — and has anything drifted since you recorded it?**
4
+
5
+ *A bounded, read-only scan that records the commit, lockfiles, environment, data hashes, figures, seeds and run commands; a drift check against that record; and a report card you can hand to a reviewer.*
6
+
7
+ [![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](LICENSE)
8
+ [![Node](https://img.shields.io/badge/node-%5E22.19%20%7C%7C%20%3E%3D24.9-brightgreen.svg)]()
9
+
10
+ English · [简体中文](README-zh.md)
11
+
12
+ ---
13
+
14
+ ## What it does
15
+
16
+ - **`repro_manifest`** scans a workspace project and records: git commit + dirty state, dependency lockfiles, environment pins (`.nvmrc`, `.python-version`, `pyproject.toml`, Dockerfile…), input-data hashes, figure hashes, notebooks, explicit random seeds (`random_state`, `np.random.seed`, `set.seed`, `torch.manual_seed`…) and runnable commands (package.json scripts, Makefile targets, `run`/`reproduce`/`analysis` entry scripts).
17
+ - **`repro_check`** re-scans and compares: an artifact that **changed** or **disappeared** is a finding — so a data file edited after the manifest is caught.
18
+ - **`repro_card`** renders the evidence as Markdown + SARIF 2.1.0, with every gap, its severity and a concrete suggestion.
19
+
20
+ Levels: `reproducible` (no error/warning gap), `partial` (warnings only), `not_reproducible` (any error gap or drift), `unknown` (reserved).
21
+
22
+ ## What it does not do
23
+
24
+ - **No execution.** Project code is never run; the only subprocesses are `git rev-parse` and `git status`, with a timeout and no shell.
25
+ - **No upload, no build.** It does not fetch data, install dependencies, or reproduce figures.
26
+ - **No truth claim.** A manifest proves these bytes existed; it does not prove the analysis is correct or complete.
27
+ - **No UI.** JSON + Markdown + SARIF only.
28
+
29
+ ## Gap codes
30
+
31
+ | Code | Severity | Meaning |
32
+ |---|---|---|
33
+ | `no_git_commit` | error | not a git repo, or no commit |
34
+ | `no_lockfile` | error | no dependency lockfile recorded |
35
+ | `no_run_command` | error | no entry point found |
36
+ | `dirty_worktree` | warning | uncommitted changes; the commit does not describe the files |
37
+ | `no_seed` | warning | scripts exist but no seed literal was found |
38
+ | `no_data` | warning | no input data file in the project |
39
+ | `no_environment` | warning | no runtime/environment pin |
40
+ | `unhashed_data` | warning | a data file exceeded the hash cap |
41
+ | `no_figures` | info | no figure/table output |
42
+ | `scan_truncated` | warning | the file cap was reached |
43
+
44
+ Error gaps make the level `not_reproducible`; warnings make it `partial`.
45
+
46
+ ## Tools
47
+
48
+ ### `repro_manifest`
49
+
50
+ `{ path? }` → `{ ok, manifest, recordPath }`. The record is a valid REP `ResearchRecord` whose `artifacts` are the code/env/data/seed/command/figure/notebook evidence.
51
+
52
+ ### `repro_check`
53
+
54
+ `{ manifest | manifestPath, path? }` → `{ ok, drift }`. `manifestPath` is workspace-relative; `path` is the project to re-scan (defaults to the workspace root).
55
+
56
+ ### `repro_card`
57
+
58
+ `{ manifest, drift? }` → `{ ok, markdown, sarif }`.
59
+
60
+ ### Error codes
61
+
62
+ `INVALID_INPUT` · `NOT_FOUND` · `PATH_ESCAPE` · `NOT_A_DIRECTORY` · `INVALID_MANIFEST` · `STORE_ERROR`
63
+
64
+ ## Compatibility & install
65
+
66
+ | | |
67
+ |---|---|
68
+ | DeepSeek Harness | **`dsh-v0.2.1-rc.5`** (verified 2026-11-08); peer `>=0.2.1-0 <0.3.0 \|\| >=0.2.2-0 <0.3.0` |
69
+ | Node | `^22.19.0 \|\| >=24.9.0` (tested `24.22.1`), ESM only |
70
+ | Peers | `@perrylink/dsh-research-core ^0.1.0`, `@deepseek-ai/cordis ^4.0.5-alpha.1`, `@deepseek-ai/dsh-tools`, `@deepseek-ai/schemastery ^3.18.5-alpha.1` |
71
+ | Runtime dependencies | **zero** |
72
+
73
+ ```sh
74
+ dsh plugin --profile <name> add @perrylink/dsh-research-core dsh-repro-audit
75
+ dsh --profile <name> --dump-config | grep dsh-repro-audit
76
+ ```
77
+
78
+ ## Configuration
79
+
80
+ | Key | Default | Meaning |
81
+ |---|---|---|
82
+ | `enabled` | `true` | `false` mounts nothing |
83
+ | `root` | `.repro-audit` | manifest + record root |
84
+ | `workspaceRoot` | `process.cwd()` | project paths must resolve inside it |
85
+ | `maxFiles` | `2000` | files visited per scan (over-limit reported) |
86
+ | `maxDepth` | `6` | directory depth |
87
+ | `maxFileBytes` | `8388608` | per-file hash cap (larger data is recorded unhashed + gap) |
88
+
89
+ Ignored directories: `.git`, `node_modules`, `.venv`, `dist`, `build`, `target`, `__pycache__`, `coverage`, `.next`, caches, `.repro-audit`, plus the configured store root when it is inside the project.
90
+
91
+ ## Security boundaries
92
+
93
+ - The project is read-only; records go under `root`. A store that lives inside
94
+ the scanned tree (the default `.repro-audit/`) is excluded from the scan, so
95
+ the manifest cannot include its own records.
96
+ - Symlinks inside the project are reported and skipped, never followed.
97
+ - Hash caps prevent memory blow-ups; the file cap is reported, not ignored.
98
+ - `git` runs with fixed read-only arguments, a 5 s timeout and `windowsHide`; no shell.
99
+ Repository-local fsmonitor hooks are disabled (`-c core.fsmonitor=false`) and
100
+ `GIT_OPTIONAL_LOCKS=0` keeps `git status` from refreshing/writing the index;
101
+ inherited `GIT_*` variables are stripped so `git -C <root>` cannot be
102
+ redirected to another repository.
103
+
104
+ ## Evaluation
105
+
106
+ **24 tests**: scanning (lockfiles/data/figures/seeds/commands/runtimes, `node_modules` skipped, symlinks skipped but reported, project config not counted as data, lowercase `.r` scripts, file cap, own store excluded, fsmonitor hook not executed, inherited GIT_* ignored), manifest levels (clean → reproducible, no seed → partial, no git → not_reproducible, dirty → partial, empty project gap set), drift (changed data + missing figure, clean re-check), runtime (valid REP record, inline manifest, saved manifest with project path, malformed saved manifests rejected with `INVALID_MANIFEST`, symlinked manifest escape rejected, path escape), tools (schemas, manifest→check→card end-to-end, failure branch, malformed card input), package contract.
107
+
108
+ Manual sample matrix (no benchmark claimed — the artifact set is rule-based, not learned):
109
+
110
+ | Scenario | Expected | Covered |
111
+ |---|---|---|
112
+ | complete project, clean tree | `reproducible`, 0 gaps | test |
113
+ | no seed | `partial`, `no_seed` | test |
114
+ | no git | `not_reproducible`, `no_git_commit` | test |
115
+ | uncommitted change | `partial`, `dirty_worktree` | test |
116
+ | data edited after manifest | drift `changed`, `not_reproducible` | test |
117
+ | figure deleted | drift `missing` | test |
118
+ | just-recorded manifest | drift empty | test |
119
+
120
+ ## Known limitations (v0.1)
121
+
122
+ - Metadata-level only: it does not verify that the recorded command actually reproduces the figures.
123
+ - Seeds are found by literal patterns; seeds injected via config files or environment variables are missed.
124
+ - Figures are hashed but not linked to the script that produced them (no provenance graph yet).
125
+ - Large data files are recorded unhashed (with a gap) rather than streamed.
126
+ - No `.gitignore` awareness: ignored-but-present files are still hashed if they are data/figure/extensions.
127
+
128
+ ## License
129
+
130
+ Apache-2.0. No third-party runtime code.
@@ -0,0 +1,18 @@
1
+ # dsh-repro-audit bundle patch: mount the reproducibility tools.
2
+ #
3
+ # Every key below is a Config field (Schemastery schema); invalid values fail the
4
+ # profile load loudly. The scan is read-only and bounded; the only subprocesses
5
+ # are git rev-parse / git status.
6
+ - insert:
7
+ - id: dsh-repro-audit
8
+ name: dsh-repro-audit
9
+ config:
10
+ enabled: true
11
+ root: .repro-audit
12
+ # Maximum files visited per scan (over-limit is reported, not ignored).
13
+ maxFiles: 2000
14
+ # Maximum directory depth.
15
+ maxDepth: 6
16
+ # Maximum bytes hashed per file; larger data files are recorded unhashed
17
+ # and reported as a gap instead of being silently skipped.
18
+ maxFileBytes: 8388608
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Config schema and resolution for `dsh-repro-audit`.
3
+ * @module dsh-repro-audit/config
4
+ */
5
+ import z from '@deepseek-ai/schemastery';
6
+ /** Raw plugin config. */
7
+ export interface Config {
8
+ enabled?: boolean;
9
+ /** Store/record root. */
10
+ root?: string;
11
+ /** Workspace root that project paths must stay inside. */
12
+ workspaceRoot?: string;
13
+ /** Maximum files visited per scan. */
14
+ maxFiles?: number;
15
+ /** Maximum directory depth. */
16
+ maxDepth?: number;
17
+ /** Maximum bytes hashed per file. */
18
+ maxFileBytes?: number;
19
+ }
20
+ /** Fully resolved config. */
21
+ export interface ResolvedConfig {
22
+ readonly enabled: boolean;
23
+ readonly root: string;
24
+ readonly workspaceRoot: string;
25
+ readonly maxFiles: number;
26
+ readonly maxDepth: number;
27
+ readonly maxFileBytes: number;
28
+ }
29
+ /** Schemastery schema. */
30
+ export declare const Config: z<Config>;
31
+ /**
32
+ * Validate raw values and fill explicit defaults.
33
+ * @param config - raw plugin config.
34
+ * @returns the fully resolved config.
35
+ */
36
+ export declare function resolveConfig(config?: Config): ResolvedConfig;
37
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,CAAC,MAAM,0BAA0B,CAAA;AAExC,yBAAyB;AACzB,MAAM,WAAW,MAAM;IACrB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,yBAAyB;IACzB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,0DAA0D;IAC1D,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,sCAAsC;IACtC,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,+BAA+B;IAC/B,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,qCAAqC;IACrC,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB;AAED,6BAA6B;AAC7B,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAA;IAC9B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;CAC9B;AAED,0BAA0B;AAC1B,eAAO,MAAM,MAAM,EAAE,CAAC,CAAC,MAAM,CAO3B,CAAA;AAOF;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,MAAM,GAAE,MAAW,GAAG,cAAc,CAejE"}
package/lib/config.js ADDED
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Config schema and resolution for `dsh-repro-audit`.
3
+ * @module dsh-repro-audit/config
4
+ */
5
+ import path from 'node:path';
6
+ import z from '@deepseek-ai/schemastery';
7
+ /** Schemastery schema. */
8
+ export const Config = z.object({
9
+ enabled: z.boolean().default(true),
10
+ root: z.string().default('.repro-audit'),
11
+ workspaceRoot: z.string(),
12
+ maxFiles: z.number().default(2000),
13
+ maxDepth: z.number().default(6),
14
+ maxFileBytes: z.number().default(8 * 1024 * 1024),
15
+ });
16
+ /** Throw unless the value is a positive safe integer. */
17
+ function assertPositiveInt(name, value) {
18
+ if (!Number.isSafeInteger(value) || value <= 0)
19
+ throw new TypeError(`${name} must be a positive safe integer, got ${String(value)}`);
20
+ }
21
+ /**
22
+ * Validate raw values and fill explicit defaults.
23
+ * @param config - raw plugin config.
24
+ * @returns the fully resolved config.
25
+ */
26
+ export function resolveConfig(config = {}) {
27
+ const root = config.root ?? '.repro-audit';
28
+ if (typeof root !== 'string' || root.trim() === '')
29
+ throw new TypeError('root must be a non-empty path');
30
+ const maxFiles = config.maxFiles ?? 2000;
31
+ const maxDepth = config.maxDepth ?? 6;
32
+ const maxFileBytes = config.maxFileBytes ?? 8 * 1024 * 1024;
33
+ for (const [name, value] of Object.entries({ maxFiles, maxDepth, maxFileBytes }))
34
+ assertPositiveInt(name, value);
35
+ return {
36
+ enabled: config.enabled ?? true,
37
+ root: path.resolve(root),
38
+ workspaceRoot: path.resolve(config.workspaceRoot ?? process.cwd()),
39
+ maxFiles,
40
+ maxDepth,
41
+ maxFileBytes,
42
+ };
43
+ }
44
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,CAAC,MAAM,0BAA0B,CAAA;AA2BxC,0BAA0B;AAC1B,MAAM,CAAC,MAAM,MAAM,GAAc,CAAC,CAAC,MAAM,CAAC;IACxC,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC;IAClC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,cAAc,CAAC;IACxC,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE;IACzB,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC;IAClC,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IAC/B,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;CAClD,CAAC,CAAA;AAEF,yDAAyD;AACzD,SAAS,iBAAiB,CAAC,IAAY,EAAE,KAAa;IACpD,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC;QAAE,MAAM,IAAI,SAAS,CAAC,GAAG,IAAI,yCAAyC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;AACtI,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,SAAiB,EAAE;IAC/C,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,IAAI,cAAc,CAAA;IAC1C,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE;QAAE,MAAM,IAAI,SAAS,CAAC,+BAA+B,CAAC,CAAA;IACxG,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,IAAI,IAAI,CAAA;IACxC,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,IAAI,CAAC,CAAA;IACrC,MAAM,YAAY,GAAG,MAAM,CAAC,YAAY,IAAI,CAAC,GAAG,IAAI,GAAG,IAAI,CAAA;IAC3D,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,YAAY,EAAE,CAAC;QAAE,iBAAiB,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;IAChH,OAAO;QACL,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,IAAI;QAC/B,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;QACxB,aAAa,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,aAAa,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;QAClE,QAAQ;QACR,QAAQ;QACR,YAAY;KACb,CAAA;AACH,CAAC"}