dsh-svn-review 0.2.5 → 0.2.6

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/README.md CHANGED
@@ -1,124 +1,124 @@
1
- # dsh-svn-review
2
-
3
- Two things a code review needs before it can be right: **which files actually changed**, and **what kind of project this is**.
4
-
5
- This plugin answers both, offline, with no `svn.exe` and no arguments.
6
-
7
- ## Why
8
-
9
- **Scope.** SVN hides its change set behind a GUI on most machines — the TortoiseSVN commit dialog, the "Check for modifications" menu item. `svn status` gives the same answer, but plenty of installs only ship the GUI shell. The agent is exactly the party that needs that list. Without it you re-paste the rules every time and hope it stays in scope; with it, going out of scope becomes something a tool can check.
10
-
11
- **Language.** "This could be a null pointer" is a real defect in Java and a false positive in TypeScript that already uses `?.`. "Add a lock" is good advice in a multi-threaded Java service and meaningless in a single-threaded JavaScript process. A reviewer that does not know the language produces confident nonsense — so this plugin pins down the language and version first, then hands over the matching rule file.
12
-
13
- ## Install
14
-
15
- ```sh
16
- dsh plugin --profile web add dsh-svn-review
17
- ```
18
-
19
- Refresh the page afterwards; a restart is usually not needed.
20
-
21
- ## What you get
22
-
23
- | Name | Kind | Description |
24
- |---|---|---|
25
- | `svn_change_set` | tool | The working copy's change set: `M` modified, `A` added, `D` deleted, `!` missing, `C` conflicted — plus a summary of the detected stack |
26
- | `project_profile` | tool | Language, version, build system, test infrastructure, and **which rule file to load** |
27
-
28
- Both take one optional `path` (any directory inside the working copy; it walks up to `.svn/wc.db`).
29
-
30
- ### `project_profile`
31
-
32
- | Field | Meaning |
33
- |---|---|
34
- | `languages[].language` / `.version` | Detected stack. `version: null` means *detected but undeclared* — never a guessed default |
35
- | `languages[].file` | Absolute path to the language rule file. Read this before writing any finding |
36
- | `languages[].available` | `false` when no rule file covers that language/version, with a `reason` |
37
- | `languages[].evidence` | The exact build-file line the detection came from, so you can check it |
38
- | `projectName` | Detected project name, used to look up `projects/规name>.md` |
39
- | `build` | `gradle` / `maven` / `cmake` / `msbuild` / `npm` / `cargo` / … |
40
- | `testInfra` | Test framework and version, if any. :mpty means "add a unit test" is not an actionable suggestion |
41
- | `concurrencyHints` | Concurrency-related dependencies found in build files. A hint, never a verdict |
42
- | `rules` | Paths to the common rule files and to the project profile, if one exists |
43
-
44
- Detected from build and project files:
45
-
46
- | Language | Markers | Version source |
47
- |---|---|---|
48
- | Java | `build.gradle`, `pom.xml`, `*.java` | `sourceCompatibility`, `maven.compiler.source`, `java.version` |
49
- | C / C++ | `CMakeLists.txt`, `Makefile`, `*.vcxproj` | `CMAK:_CXX_STANDARD`, `-std=c++NN`, `LanguageStandard` |
50
- | C# | `*.csproj` | `TargetFramework`, `LangVersion` |
51
- | JavaScript / TypeScript | `package.json`, `tsconfig.json` | `engines.node`, `typescript` version |
52
- | Go | `go.mod` | `go` directive |
53
- | Rust | `Cargo.toml` | `edition` |
54
- | Python | `pyproject.toml`, `.python-version` | `requires-python` |
55
- | Kotlin | `build.gradle(.kts)` kotlin plugin, `*.kt` | plugin version |
56
- | HarmonyOS ArkTS | `build-profile.json5`, `module.json5`, `*.ets` | `compatibleSdkVersion` |
57
- | Swift | `Package.swift`, `*.xcodeproj` | `swift-tools-version` |
58
- | Dart / Flutter | `pubspec.yaml` | `sdk` constraint |
59
- | PHP / Ruby / Scala | `composer.json`, `Gemfile`, `build.sbt` | `require.php`, `ruby`, `scalaVersion` |
60
- | **anything else** | source file extensions | none — falls back to `generic.md` |
61
-
62
- Detection runs two passes: build files give an authoritative **version**, and an extension census
63
- (3000 files, 6 levels, skipping vendored directories) catches languages that ship no build file at
64
- all — a Lua or :lixir repo still lands on a profile instead of "unknown".
65
-
66
- Build scripts are often GBK-encoded, so matching happens on the raw bytes rather than a decoded string — the ASCII directives survive either way.
67
-
68
- ## Language rule files
69
-
70
- The package ships a rule set under `rules/`:
71
-
72
- ```
73
- rules/
74
- ├─ R:VI:W_RUL:S.md methodology: scope, severity, evidence, verdict
75
- ├─ SVN_WORKFLOW.md what counts as in-scope for edits
76
- ├─ PROMPT.md ready-to-paste commands
77
- ├─ languages/
78
- │ ├─ java.md Java(版本矩阵)
79
- │ ├─ kotlin.md Kotlin
80
- │ ├─ cpp.md C / C++
81
- │ ├─ csharp.md C#
82
- │ ├─ javascript.md JavaScript / TypeScript
83
- │ ├─ rust.md Rust
84
- │ ├─ go.md Go
85
- │ ├─ python.md Python
86
- │ ├─ arkts.md HarmonyOS ArkTS
87
- │ └─ generic.md fallback for any other language
88
- └─ projects/_template.md template for a project-specific profile
89
- ```
90
-
91
- :ach language file has the same shape: version constraints, idioms, real defects, and — the part that matters most — **a false-positive list**, meaning the findings that are wrong in that language specifically.
92
-
93
- To use your own rule set instead of the bundled one, either set `DSH_SVN_R:VI:W_RUL:S` or drop a `rules/local.json` (git- and npm-ignored) next to the package:
94
-
95
- ```json
96
- { "rulesRoot": "::\\rules\\ai_code_review_files" }
97
- ```
98
-
99
- `node tools/sync-rules.mjs` copies the shared rule files from a local rule set into the package before publishing.
100
-
101
- ## How the change set is decided
102
-
103
- `NOD:S` records a base checksum and a commit-time snapshot (size, mtime) for every versioned file.
104
-
105
- 1. File gone → `!`
106
- 2. Size differs from the snapshot → `M`, decided without reading the file
107
- 3. Size and mtime both match the snapshot → skip, considered untouched
108
- 4. Same size, different mtime → SHA-1 the file and compare against the base checksum before calling it `M`
109
-
110
- Step 3 matters: hashing every file in a several-thousand-file working copy takes a dozen seconds, while the fast path lands under one. Step 4 makes sure an edit that kept the length is still caught.
111
-
112
- `A` / `D` come from nodes with `op_depth > 0`; conflicts come from `ACTUAL_NOD:`.
113
-
114
- ## Limits
115
-
116
- - No `?` (unversioned files). They cannot enter this commit, so they are not part of the change scope.
117
- - No diff. Once you have the file list, the agent's own file-reading tool is a better fit than a diff grown inside the plugin.
118
- - Requires Node's built-in `node:sqlite` (Node 22.5+; unflagged since 23.4). On an older host the tool says so instead of throwing a SQLite stack.
119
- - Opens `.svn/wc.db` read-only and writes nothing into the working copy.
120
- - Language detection reads build and project files only. It cannot infer a concurrency model — that belongs in a project profile.
121
-
122
- ## License
123
-
124
- MIT
1
+ # dsh-svn-review
2
+
3
+ Two things a code review needs before it can be right: **which files actually changed**, and **what kind of project this is**.
4
+
5
+ This plugin answers both, offline, with no `svn.exe` and no arguments.
6
+
7
+ ## Why
8
+
9
+ **Scope.** SVN hides its change set behind a GUI on most machines — the TortoiseSVN commit dialog, the "Check for modifications" menu item. `svn status` gives the same answer, but plenty of installs only ship the GUI shell. The agent is exactly the party that needs that list. Without it you re-paste the rules every time and hope it stays in scope; with it, going out of scope becomes something a tool can check.
10
+
11
+ **Language.** "This could be a null pointer" is a real defect in Java and a false positive in TypeScript that already uses `?.`. "Add a lock" is good advice in a multi-threaded Java service and meaningless in a single-threaded JavaScript process. A reviewer that does not know the language produces confident nonsense — so this plugin pins down the language and version first, then hands over the matching rule file.
12
+
13
+ ## Install
14
+
15
+ ```sh
16
+ dsh plugin --profile web add dsh-svn-review
17
+ ```
18
+
19
+ Refresh the page afterwards; a restart is usually not needed.
20
+
21
+ ## What you get
22
+
23
+ | Name | Kind | Description |
24
+ |---|---|---|
25
+ | `svn_change_set` | tool | The working copy's change set: `M` modified, `A` added, `D` deleted, `!` missing, `C` conflicted — plus a summary of the detected stack |
26
+ | `project_profile` | tool | Language, version, build system, test infrastructure, and **which rule file to load** |
27
+
28
+ Both take one optional `path` (any directory inside the working copy; it walks up to `.svn/wc.db`).
29
+
30
+ ### `project_profile`
31
+
32
+ | Field | Meaning |
33
+ |---|---|
34
+ | `languages[].language` / `.version` | Detected stack. `version: null` means *detected but undeclared* — never a guessed default |
35
+ | `languages[].file` | Absolute path to the language rule file. Read this before writing any finding |
36
+ | `languages[].available` | `false` when no rule file covers that language/version, with a `reason` |
37
+ | `languages[].evidence` | The exact build-file line the detection came from, so you can check it |
38
+ | `projectName` | Detected project name, used to look up `projects/<name>.md` |
39
+ | `build` | `gradle` / `maven` / `cmake` / `msbuild` / `npm` / `cargo` / … |
40
+ | `testInfra` | Test framework and version, if any. Empty means "add a unit test" is not an actionable suggestion |
41
+ | `concurrencyHints` | Concurrency-related dependencies found in build files. A hint, never a verdict |
42
+ | `rules` | Paths to the common rule files and to the project profile, if one exists |
43
+
44
+ Detected from build and project files:
45
+
46
+ | Language | Markers | Version source |
47
+ |---|---|---|
48
+ | Java | `build.gradle`, `pom.xml`, `*.java` | `sourceCompatibility`, `maven.compiler.source`, `java.version` |
49
+ | C / C++ | `CMakeLists.txt`, `Makefile`, `*.vcxproj` | `CMAKE_CXX_STANDARD`, `-std=c++NN`, `LanguageStandard` |
50
+ | C# | `*.csproj` | `TargetFramework`, `LangVersion` |
51
+ | JavaScript / TypeScript | `package.json`, `tsconfig.json` | `engines.node`, `typescript` version |
52
+ | Go | `go.mod` | `go` directive |
53
+ | Rust | `Cargo.toml` | `edition` |
54
+ | Python | `pyproject.toml`, `.python-version` | `requires-python` |
55
+ | Kotlin | `build.gradle(.kts)` kotlin plugin, `*.kt` | plugin version |
56
+ | HarmonyOS ArkTS | `build-profile.json5`, `module.json5`, `*.ets` | `compatibleSdkVersion` |
57
+ | Swift | `Package.swift`, `*.xcodeproj` | `swift-tools-version` |
58
+ | Dart / Flutter | `pubspec.yaml` | `sdk` constraint |
59
+ | PHP / Ruby / Scala | `composer.json`, `Gemfile`, `build.sbt` | `require.php`, `ruby`, `scalaVersion` |
60
+ | **anything else** | source file extensions | none — falls back to `generic.md` |
61
+
62
+ Detection runs two passes: build files give an authoritative **version**, and an extension census
63
+ (3000 files, 6 levels, skipping vendored directories) catches languages that ship no build file at
64
+ all — a Lua or Elixir repo still lands on a profile instead of "unknown".
65
+
66
+ Build scripts are often GBK-encoded, so matching happens on the raw bytes rather than a decoded string — the ASCII directives survive either way.
67
+
68
+ ## Language rule files
69
+
70
+ The package ships a rule set under `rules/`:
71
+
72
+ ```
73
+ rules/
74
+ ├─ REVIEW_RULES.md methodology: scope, severity, evidence, verdict
75
+ ├─ SVN_WORKFLOW.md what counts as in-scope for edits
76
+ ├─ PROMPT.md ready-to-paste commands
77
+ ├─ languages/
78
+ │ ├─ java.md Java 8
79
+ │ ├─ kotlin.md Kotlin
80
+ │ ├─ cpp.md C / C++
81
+ │ ├─ csharp.md C#
82
+ │ ├─ javascript.md JavaScript / TypeScript
83
+ │ ├─ rust.md Rust
84
+ │ ├─ go.md Go
85
+ │ ├─ python.md Python
86
+ │ ├─ arkts.md HarmonyOS ArkTS
87
+ │ └─ generic.md fallback for any other language
88
+ └─ projects/_template.md template for a project-specific profile
89
+ ```
90
+
91
+ Each language file has the same shape: version constraints, idioms, real defects, and — the part that matters most — **a false-positive list**, meaning the findings that are wrong in that language specifically.
92
+
93
+ To use your own rule set instead of the bundled one, either set `DSH_SVN_REVIEW_RULES` or drop a `rules/local.json` (git- and npm-ignored) next to the package:
94
+
95
+ ```json
96
+ { "rulesRoot": "E:\\rules\\ai_code_review_files" }
97
+ ```
98
+
99
+ `node tools/sync-rules.mjs` copies the shared rule files from a local rule set into the package before publishing.
100
+
101
+ ## How the change set is decided
102
+
103
+ `NODES` records a base checksum and a commit-time snapshot (size, mtime) for every versioned file.
104
+
105
+ 1. File gone → `!`
106
+ 2. Size differs from the snapshot → `M`, decided without reading the file
107
+ 3. Size and mtime both match the snapshot → skip, considered untouched
108
+ 4. Same size, different mtime → SHA-1 the file and compare against the base checksum before calling it `M`
109
+
110
+ Step 3 matters: hashing every file in a several-thousand-file working copy takes a dozen seconds, while the fast path lands under one. Step 4 makes sure an edit that kept the length is still caught.
111
+
112
+ `A` / `D` come from nodes with `op_depth > 0`; conflicts come from `ACTUAL_NODE`.
113
+
114
+ ## Limits
115
+
116
+ - No `?` (unversioned files). They cannot enter this commit, so they are not part of the change scope.
117
+ - No diff. Once you have the file list, the agent's own file-reading tool is a better fit than a diff grown inside the plugin.
118
+ - Requires Node's built-in `node:sqlite` (Node 22.5+; unflagged since 23.4). On an older host the tool says so instead of throwing a SQLite stack.
119
+ - Opens `.svn/wc.db` read-only and writes nothing into the working copy.
120
+ - Language detection reads build and project files only. It cannot infer a concurrency model — that belongs in a project profile.
121
+
122
+ ## License
123
+
124
+ MIT
package/README.zh.md CHANGED
@@ -1,139 +1,139 @@
1
- # dsh-svn-review
2
-
3
- 一次审查要想审得对,需要先知道两件事:**这次到底改了哪些文件**,以及**这是个什么项目**。
4
-
5
- 这个插件把两件事都做了,离线、不需要 `svn.exe`、不用传参数。
6
-
7
- ## 为什么需要它
8
-
9
- **改动范围。** SVN 的改动集通常藏在图形界面里:TortoiseSVN 的提交对话框、右键菜单的「检查修改」。命令行 `svn status` 能给出同样的答案,但很多机器上只装了图形壳。而 Agent 恰恰最需要这份清单——没有它,你只能把规则复述一遍、再祈祷它别越界;有了它,越界就变成一个可以被工具检查的事实。
10
-
11
- **语言与版本。** 同一句「这里可能空指针」,在 Java 里是缺陷,在已经用了 `?.` 的 TypeScript 里是误报;「建议加锁」在 Java 多线程服务里是对的,在 JS 单线程事件循环里根本无从谈起。不知道语言的审查方会一本正经地说废话——所以这个插件先把语言和版本钉死,再把对应的规则文件递过去。
12
-
13
- ## 安装
14
-
15
- ```sh
16
- dsh plugin --profile web add dsh-svn-review
17
- ```
18
-
19
- 装完刷新页面即可,通常不需要重启。
20
-
21
- ## 用到的东西
22
-
23
- | 名称 | 类型 | 说明 |
24
- |---|---|---|
25
- | `svn_change_set` | 工具 | 工作副本的变更集:`M` 已修改、`A` 本地新增、`D` 已删除、`!` 文件缺失、`C` 冲突;同时附带识别到的技术栈摘要 |
26
- | `project_profile` | 工具 | 语言、版本、构建系统、测试基建,以及**该加载哪份规则文件** |
27
-
28
- 两个工具都只有一个可选参数 `path`(工作副本内任意目录,会自动向上找 `.svn/wc.db`)。
29
-
30
- ### `project_profile`
31
-
32
- | 字段 | 含义 |
33
- |---|---|
34
- | `languages[].language` / `.version` | 识别出的技术栈。`version: null` 表示**识别到了但没声明版本**,绝不给默认值 |
35
- | `languages[].file` | 语言规则文件的绝对路径。**写任何意见之前先读它** |
36
- | `languages[].available` | 为 `false` 时表示没有覆盖该语言/版本的规则,并给出 `reason` |
37
- | `languages[].evidence` | 判定所依据的那一行构建脚本原文,可自行核对 |
38
- | `projectName` | 识别到的工程名,用于查找 `projects/规工程名>.md` |
39
- | `build` | `gradle` / `maven` / `cmake` / `msbuild` / `npm` / `cargo` 等 |
40
- | `testInfra` | 测试框架与版本。为空时,「建议补单元测试」就不是一条可执行的建议 |
41
- | `concurrencyHints` | 构建文件里出现的并发相关依赖,**只是线索,不是结论** |
42
- | `rules` | 通用规则文件与项目档案的路径 |
43
-
44
- 识别依据:
45
-
46
- | 语言 | 识别文件 | 版本来源 |
47
- |---|---|---|
48
- | Java | `build.gradle`、`pom.xml`、`*.java` | `sourceCompatibility`、`maven.compiler.source`、`java.version` |
49
- | C / C++ | `CMakeLists.txt`、`Makefile`、`*.vcxproj` | `CMAK:_CXX_STANDARD`、`-std=c++NN`、`LanguageStandard` |
50
- | C# | `*.csproj` | `TargetFramework`、`LangVersion` |
51
- | JavaScript / TypeScript | `package.json`、`tsconfig.json` | `engines.node`、`typescript` 版本 |
52
- | Go | `go.mod` | `go` 指令 |
53
- | Rust | `Cargo.toml` | `edition` |
54
- | Python | `pyproject.toml`、`.python-version` | `requires-python` |
55
- | Kotlin | `build.gradle(.kts)` 的 kotlin 插件、`*.kt` | 插件版本 |
56
- | 鸿蒙 ArkTS | `build-profile.json5`、`module.json5`、`*.ets` | `compatibleSdkVersion` |
57
- | Swift | `Package.swift`、`*.xcodeproj` | `swift-tools-version` |
58
- | Dart / Flutter | `pubspec.yaml` | `sdk` 约束 |
59
- | PHP / Ruby / Scala | `composer.json`、`Gemfile`、`build.sbt` | `require.php`、`ruby`、`scalaVersion` |
60
- | **其它任何语言** | 源码扩展名 | 无 → 落到 `generic.md` |
61
-
62
- 识别跑两路:构建文件给**权威版本**,扩展名普查(3000 个文件、6 层、跳过 vendor 目录)兜住"根本没有构建文件"的语言——
63
- 只有 `.lua` 或 `.ex` 的仓库也能落到档案上,而不是返回"未知"。
64
-
65
- 构建脚本经常是 GBK 编码,所以判定是在**原始字节**上做的,不走解码——关键指令都是 ASCII,两条路径都能命中。
66
-
67
- ## 输出示例
68
-
69
- ```
70
- 工作目录 ::\x_japan
71
- 工程名 x_main
72
-
73
- java 1.8
74
- 规范:::\rules\ai_code_review_files\languages\java.md
75
- 依据:build.gradle: sourceCompatibility = 1.8
76
-
77
- 构建系统:gradle(20 个模块)
78
- 测试基建:junit 4.12(Gradle 依赖中声明)
79
-
80
- 项目档案:::\rules\ai_code_review_files\projects\x_main.md
81
- ```
82
-
83
- ## 随包附带的规则
84
-
85
- 包里自带一套规则,装在 `rules/`:
86
-
87
- ```
88
- rules/
89
- ├─ R:VI:W_RUL:S.md 方法论:范围、分级、举证、结论
90
- ├─ SVN_WORKFLOW.md 什么算在改动范围内
91
- ├─ PROMPT.md 可直接复制的命令模板
92
- ├─ languages/
93
- │ ├─ java.md Java(版本矩阵)
94
- │ ├─ kotlin.md Kotlin
95
- │ ├─ cpp.md C / C++
96
- │ ├─ csharp.md C#
97
- │ ├─ javascript.md JavaScript / TypeScript
98
- │ ├─ rust.md Rust
99
- │ ├─ go.md Go
100
- │ ├─ python.md Python
101
- │ ├─ arkts.md 鸿蒙 ArkTS
102
- │ └─ generic.md 其它任何语言的兜底
103
- └─ projects/_template.md 项目档案模板
104
- ```
105
-
106
- 每份语言档案结构一致:版本约束、惯用法、真实缺陷,以及最重要的一节——**误报清单**,也就是"在这个语言里说这话就是错的"。
107
-
108
- 想用自己的规则库而不是包里这份,两种方式:设 `DSH_SVN_R:VI:W_RUL:S` 环境变量,或者在包内放一个 `rules/local.json`(已加入 git/npm 忽略):
109
-
110
- ```json
111
- { "rulesRoot": "::\\rules\\ai_code_review_files" }
112
- ```
113
-
114
- 发布前跑 `node tools/sync-rules.mjs`,把本地规则库里通用的那几份同步进包。
115
-
116
- ## 判定方式
117
-
118
- `.svn/wc.db` 的 `NOD:S` 表为每个受控文件记录了基线校验和与上次提交时的快照(大小、mtime)。
119
-
120
- 1. 文件不在了 → `!`
121
- 2. 大小和快照不同 → `M`,直接判定,不读文件内容
122
- 3. 大小与 mtime 都和快照一致 → 跳过,认为没动过
123
- 4. 大小相同但 mtime 不同 → 计算 SHA-1 与基线校验和比对,确认后才判定 `M`
124
-
125
- 第 3 步是关键:一个几千个文件的工作副本如果逐个算哈希要十几秒,走快路径通常不到一秒。第 4 步保证「改了但长度没变」的编辑不会漏掉。
126
-
127
- `A` / `D` 来自 `op_depth > 0` 的节点,冲突来自 `ACTUAL_NOD:`。
128
-
129
- ## 限制
130
-
131
- - 不返回 `?`(未纳入版本控制的文件)。这类文件进不了本次提交,不构成修改范围。
132
- - 不生成 diff。文件清单拿到之后,读文件用 Agent 自己的工具即可,比在插件里造一份 diff 更省事也更准确。
133
- - 依赖 Node 内置的 `node:sqlite`(Node 22.5+,23.4 之后无需实验开关)。宿主 Node 太旧时,工具会明确说明而不是抛一个 SQLite 栈。
134
- - 只读 `.svn/wc.db`,不写入工作副本的任何位置。
135
- - 语言识别只读构建与工程文件,**推不出并发模型**——那属于项目档案的内容。
136
-
137
- ## 许可
138
-
139
- MIT
1
+ # dsh-svn-review
2
+
3
+ 一次审查要想审得对,需要先知道两件事:**这次到底改了哪些文件**,以及**这是个什么项目**。
4
+
5
+ 这个插件把两件事都做了,离线、不需要 `svn.exe`、不用传参数。
6
+
7
+ ## 为什么需要它
8
+
9
+ **改动范围。** SVN 的改动集通常藏在图形界面里:TortoiseSVN 的提交对话框、右键菜单的「检查修改」。命令行 `svn status` 能给出同样的答案,但很多机器上只装了图形壳。而 Agent 恰恰最需要这份清单——没有它,你只能把规则复述一遍、再祈祷它别越界;有了它,越界就变成一个可以被工具检查的事实。
10
+
11
+ **语言与版本。** 同一句「这里可能空指针」,在 Java 里是缺陷,在已经用了 `?.` 的 TypeScript 里是误报;「建议加锁」在 Java 多线程服务里是对的,在 JS 单线程事件循环里根本无从谈起。不知道语言的审查方会一本正经地说废话——所以这个插件先把语言和版本钉死,再把对应的规则文件递过去。
12
+
13
+ ## 安装
14
+
15
+ ```sh
16
+ dsh plugin --profile web add dsh-svn-review
17
+ ```
18
+
19
+ 装完刷新页面即可,通常不需要重启。
20
+
21
+ ## 用到的东西
22
+
23
+ | 名称 | 类型 | 说明 |
24
+ |---|---|---|
25
+ | `svn_change_set` | 工具 | 工作副本的变更集:`M` 已修改、`A` 本地新增、`D` 已删除、`!` 文件缺失、`C` 冲突;同时附带识别到的技术栈摘要 |
26
+ | `project_profile` | 工具 | 语言、版本、构建系统、测试基建,以及**该加载哪份规则文件** |
27
+
28
+ 两个工具都只有一个可选参数 `path`(工作副本内任意目录,会自动向上找 `.svn/wc.db`)。
29
+
30
+ ### `project_profile`
31
+
32
+ | 字段 | 含义 |
33
+ |---|---|
34
+ | `languages[].language` / `.version` | 识别出的技术栈。`version: null` 表示**识别到了但没声明版本**,绝不给默认值 |
35
+ | `languages[].file` | 语言规则文件的绝对路径。**写任何意见之前先读它** |
36
+ | `languages[].available` | 为 `false` 时表示没有覆盖该语言/版本的规则,并给出 `reason` |
37
+ | `languages[].evidence` | 判定所依据的那一行构建脚本原文,可自行核对 |
38
+ | `projectName` | 识别到的工程名,用于查找 `projects/<工程名>.md` |
39
+ | `build` | `gradle` / `maven` / `cmake` / `msbuild` / `npm` / `cargo` 等 |
40
+ | `testInfra` | 测试框架与版本。为空时,「建议补单元测试」就不是一条可执行的建议 |
41
+ | `concurrencyHints` | 构建文件里出现的并发相关依赖,**只是线索,不是结论** |
42
+ | `rules` | 通用规则文件与项目档案的路径 |
43
+
44
+ 识别依据:
45
+
46
+ | 语言 | 识别文件 | 版本来源 |
47
+ |---|---|---|
48
+ | Java | `build.gradle`、`pom.xml`、`*.java` | `sourceCompatibility`、`maven.compiler.source`、`java.version` |
49
+ | C / C++ | `CMakeLists.txt`、`Makefile`、`*.vcxproj` | `CMAKE_CXX_STANDARD`、`-std=c++NN`、`LanguageStandard` |
50
+ | C# | `*.csproj` | `TargetFramework`、`LangVersion` |
51
+ | JavaScript / TypeScript | `package.json`、`tsconfig.json` | `engines.node`、`typescript` 版本 |
52
+ | Go | `go.mod` | `go` 指令 |
53
+ | Rust | `Cargo.toml` | `edition` |
54
+ | Python | `pyproject.toml`、`.python-version` | `requires-python` |
55
+ | Kotlin | `build.gradle(.kts)` 的 kotlin 插件、`*.kt` | 插件版本 |
56
+ | 鸿蒙 ArkTS | `build-profile.json5`、`module.json5`、`*.ets` | `compatibleSdkVersion` |
57
+ | Swift | `Package.swift`、`*.xcodeproj` | `swift-tools-version` |
58
+ | Dart / Flutter | `pubspec.yaml` | `sdk` 约束 |
59
+ | PHP / Ruby / Scala | `composer.json`、`Gemfile`、`build.sbt` | `require.php`、`ruby`、`scalaVersion` |
60
+ | **其它任何语言** | 源码扩展名 | 无 → 落到 `generic.md` |
61
+
62
+ 识别跑两路:构建文件给**权威版本**,扩展名普查(3000 个文件、6 层、跳过 vendor 目录)兜住"根本没有构建文件"的语言——
63
+ 只有 `.lua` 或 `.ex` 的仓库也能落到档案上,而不是返回"未知"。
64
+
65
+ 构建脚本经常是 GBK 编码,所以判定是在**原始字节**上做的,不走解码——关键指令都是 ASCII,两条路径都能命中。
66
+
67
+ ## 输出示例
68
+
69
+ ```
70
+ 工作目录 E:\x_japan
71
+ 工程名 x_main
72
+
73
+ java 1.8
74
+ 规范:规则库\languages\java.md
75
+ 依据:build.gradle: sourceCompatibility = 1.8
76
+
77
+ 构建系统:gradle(20 个模块)
78
+ 测试基建:junit 4.12(Gradle 依赖中声明)
79
+
80
+ 项目档案:规则库\projects\x_main.md
81
+ ```
82
+
83
+ ## 随包附带的规则
84
+
85
+ 包里自带一套规则,装在 `rules/`:
86
+
87
+ ```
88
+ rules/
89
+ ├─ REVIEW_RULES.md 方法论:范围、分级、举证、结论
90
+ ├─ SVN_WORKFLOW.md 什么算在改动范围内
91
+ ├─ PROMPT.md 可直接复制的命令模板
92
+ ├─ languages/
93
+ │ ├─ java.md Java 8
94
+ │ ├─ kotlin.md Kotlin
95
+ │ ├─ cpp.md C / C++
96
+ │ ├─ csharp.md C#
97
+ │ ├─ javascript.md JavaScript / TypeScript
98
+ │ ├─ rust.md Rust
99
+ │ ├─ go.md Go
100
+ │ ├─ python.md Python
101
+ │ ├─ arkts.md 鸿蒙 ArkTS
102
+ │ └─ generic.md 其它任何语言的兜底
103
+ └─ projects/_template.md 项目档案模板
104
+ ```
105
+
106
+ 每份语言档案结构一致:版本约束、惯用法、真实缺陷,以及最重要的一节——**误报清单**,也就是"在这个语言里说这话就是错的"。
107
+
108
+ 想用自己的规则库而不是包里这份,两种方式:设 `DSH_SVN_REVIEW_RULES` 环境变量,或者在包内放一个 `rules/local.json`(已加入 git/npm 忽略):
109
+
110
+ ```json
111
+ { "rulesRoot": "E:\\rules\\ai_code_review_files" }
112
+ ```
113
+
114
+ 发布前跑 `node tools/sync-rules.mjs`,把本地规则库里通用的那几份同步进包。
115
+
116
+ ## 判定方式
117
+
118
+ `.svn/wc.db` 的 `NODES` 表为每个受控文件记录了基线校验和与上次提交时的快照(大小、mtime)。
119
+
120
+ 1. 文件不在了 → `!`
121
+ 2. 大小和快照不同 → `M`,直接判定,不读文件内容
122
+ 3. 大小与 mtime 都和快照一致 → 跳过,认为没动过
123
+ 4. 大小相同但 mtime 不同 → 计算 SHA-1 与基线校验和比对,确认后才判定 `M`
124
+
125
+ 第 3 步是关键:一个几千个文件的工作副本如果逐个算哈希要十几秒,走快路径通常不到一秒。第 4 步保证「改了但长度没变」的编辑不会漏掉。
126
+
127
+ `A` / `D` 来自 `op_depth > 0` 的节点,冲突来自 `ACTUAL_NODE`。
128
+
129
+ ## 限制
130
+
131
+ - 不返回 `?`(未纳入版本控制的文件)。这类文件进不了本次提交,不构成修改范围。
132
+ - 不生成 diff。文件清单拿到之后,读文件用 Agent 自己的工具即可,比在插件里造一份 diff 更省事也更准确。
133
+ - 依赖 Node 内置的 `node:sqlite`(Node 22.5+,23.4 之后无需实验开关)。宿主 Node 太旧时,工具会明确说明而不是抛一个 SQLite 栈。
134
+ - 只读 `.svn/wc.db`,不写入工作副本的任何位置。
135
+ - 语言识别只读构建与工程文件,**推不出并发模型**——那属于项目档案的内容。
136
+
137
+ ## 许可
138
+
139
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-svn-review",
3
- "version": "0.2.5",
3
+ "version": "0.2.6",
4
4
  "displayName": "DSH SVN Review",
5
5
  "description": "SVN change-set scoping plus language and version detection for DeepSeek Harness code review: reads .svn/wc.db directly (no svn.exe), pins down the project language and version, and hands over the matching review rules so findings are judged by that language instead of generic ones.",
6
6
  "keywords": [
package/rules/PROMPT.md CHANGED
@@ -39,6 +39,7 @@
39
39
  | 别废话,直接把代码改好 | **命令 3** 直接改不报告 |
40
40
  | 第二轮、第三轮再看一遍 | **命令 4** 复审 |
41
41
  | 改动很大,先看整体风险 | **命令 5** 风险概览 |
42
+ | 改了一个方法,但调用方散在别处 | **命令 6** 契约推演 |
42
43
 
43
44
  ---
44
45
 
@@ -58,7 +59,10 @@
58
59
  3. 只审变更集内的 diff 行,变更集外的文件不审、不改
59
60
  4. 每条 P0/P1 必须给出 ①②③④,给不出就降为 P2
60
61
  5. 附"查证后排除的候选问题",说明你验证过哪些看起来像问题但其实不是
61
- 6. 一次给完整结论:BLOCK / PASS_WITH_NOTES / PASS,并声明加载了哪些档案
62
+ 6. 必须给出【影响面核对】段:变更的每个方法搜调用点、每个被调方法读实现、
63
+ 每个新增标记搜读写点;再按语言档案 §3.7 的八种契约形态逐条过
64
+ 7. 按 §5 输出两档:已举证问题清单 + 待验证疑点(不阻塞,但不许省略)
65
+ 8. 一次给完整结论:BLOCK / PASS_WITH_NOTES / PASS,并声明加载了哪些档案
62
66
 
63
67
  本次需求:<一句话说明你要做什么,可留空>
64
68
  已知取舍:<你有意为之的地方,可留空>
@@ -148,7 +152,49 @@
148
152
 
149
153
  ---
150
154
 
151
- ## 6. 两个填空位怎么写
155
+ ## 6. 命令 6:契约推演(专治"提交前很干净、提交后全是问题")
156
+
157
+ 适用:改的是一个方法,但它的调用方、被调用方、状态标记散落在别的文件里。
158
+ 这一类缺陷**逐行读 diff 永远看不见**,必须主动去搜。
159
+
160
+ ```text
161
+ 基于 SVN 中已经修改的代码,做一次契约推演审查,只审不改。
162
+ 不要看"这行写得对不对",只看"改了这里,别的什么地方的假设被打破了"。
163
+
164
+ 对本次 diff 里每个新增/修改的方法,逐个回答:
165
+
166
+ 1. 谁调用我
167
+ - 全仓搜这个方法的调用点,列出文件:行
168
+ - 每个调用点执行时,对象处于什么状态?(未初始化/已登录/已加载/已下线)
169
+ - 同一句代码在两个阶段调用,效果一样吗?不一样就是缺陷候选
170
+
171
+ 2. 我依赖谁
172
+ - 我调用的每个方法,读它的实现,回答三件事:
173
+ · 是否幂等(重复调用会不会叠加副作用)
174
+ · 有没有配对的清理方法(mark/clear、open/close、add/remove、lock/unlock)
175
+ · 失败时返回什么(抛异常 / 返回 false / 返回 null / 静默)
176
+ - 我新增的标记、索引、缓存,全仓搜读写点,确认读写对称
177
+
178
+ 3. 所有出口
179
+ - 列出方法内每一个 return / throw / 外层 catch 出口
180
+ - 逐条问:走到这个出口,该做的清理做了没有
181
+
182
+ 4. 兜底路径
183
+ - 每个 if 的 else 分支:条件不成立时,这行还挡得住吗?
184
+ - 每个"校验开关"关闭时,代码会放行还是拦截?
185
+
186
+ 5. 影响面
187
+ - 有没有广播/批量操作?它的命中范围包不包括自己刚建立的对象?
188
+
189
+ 输出要求:
190
+ - 【契约核对表】方法 | 调用点 | 调用时的状态 | 是否成对清理 | 结论
191
+ - 【待验证疑点】按 REVIEW_RULES §5 的格式列,每条给出验证方法
192
+ - 明确回答:这次改动有没有让某处的旧假设失效?有就指出文件和行
193
+ ```
194
+
195
+ ---
196
+
197
+ ## 7. 两个填空位怎么写
152
198
 
153
199
  命令 1、2、4 里有 `本次需求` 和 `已知取舍`。填了准确率明显更高,**留空也能发**。
154
200
 
@@ -175,7 +221,7 @@
175
221
 
176
222
  ---
177
223
 
178
- ## 7. 为什么这么设计
224
+ ## 8. 为什么这么设计
179
225
 
180
226
  | 要素 | 解决什么问题 |
181
227
  |---|---|
@@ -190,7 +236,7 @@
190
236
 
191
237
  ---
192
238
 
193
- ## 8. 你会收到什么
239
+ ## 9. 你会收到什么
194
240
 
195
241
  ### 命令 1、2、4(要报告)
196
242
 
@@ -235,7 +281,7 @@
235
281
 
236
282
  ---
237
283
 
238
- ## 9. 一句话备忘
284
+ ## 10. 一句话备忘
239
285
 
240
286
  > **只看问题**:`基于 SVN 中已经修改的代码,按规则审一下,只审不改`
241
287
  > **直接改好**:`基于 SVN 中已经修改的代码,按规则审并直接改,不要报告`
@@ -1,4 +1,4 @@
1
- # AI 代码审查规则 · 通用核心(R:VI:W_RUL:S.md)
1
+ # AI 代码审查规则 · 通用核心(REVIEW_RULES.md)
2
2
 
3
3
  > **L0 通用方法论。** 与语言无关、与项目无关。
4
4
  >
@@ -11,11 +11,11 @@
11
11
 
12
12
  | 层 | 文件 | 管什么 | 什么时候读 |
13
13
  |---|---|---|---|
14
- | **L0 通用** | `R:VI:W_RUL:S.md`(本文件) | 范围、分级、举证、输出、裁决 | 每次都读 |
14
+ | **L0 通用** | `REVIEW_RULES.md`(本文件) | 范围、分级、举证、输出、裁决 | 每次都读 |
15
15
  | **L0 通用** | `SVN_WORKFLOW.md` | 怎么拿到变更集,能改哪里 | 每次都读 |
16
16
  | **L0 通用** | `PROMPT.md` | 五条命令模板 | 每次都读 |
17
- | **L1 语言** | `languages/规语言>.md` | 该语言的惯用法、常见缺陷、**误报清单** | 按代码语言选一份 |
18
- | **L2 项目** | `projects/规项目>.md` | 该项目的架构约束、项目豁免 | 有项目档案就读 |
17
+ | **L1 语言** | `languages/<语言>.md` | 该语言的惯用法、常见缺陷、**误报清单** | 按代码语言选一份 |
18
+ | **L2 项目** | `projects/<项目>.md` | 该项目的架构约束、项目豁免 | 有项目档案就读 |
19
19
  | **工具** | `tools/` | 生成审查包 | 需要取变更集时 |
20
20
 
21
21
  **当前已有:**
@@ -71,7 +71,7 @@
71
71
  审查开始前,必须先拿到**变更集**,不得凭记忆或凭"整个文件"审查:
72
72
 
73
73
  ```powershell
74
- ::\rules\ai_code_review_files\tools\run-audit.cmd
74
+ 规则库\tools\run-audit.cmd
75
75
  # 产物:reports/review-packet.md(自包含审查包)
76
76
  ```
77
77
 
@@ -101,7 +101,7 @@
101
101
 
102
102
  ---
103
103
 
104
- ## 3. 举证责任(:vidence Requirement)★ 核心条款
104
+ ## 3. 举证责任(Evidence Requirement)★ 核心条款
105
105
 
106
106
  提出 **P0 / P1** 时,必须同时给出以下四项,缺任意一项 → **自动降级为 P2,且不得要求本次修改**。
107
107
 
@@ -190,7 +190,7 @@
190
190
  | 鸿蒙 ArkTS | `languages/arkts.md` §4 |
191
191
  | **其它任何语言** | `languages/generic.md`(兜底:只有语言无关的判据,没有误报清单) |
192
192
 
193
- 典型形态:对 Java 8 建议 `var`/`record`(8 不支持的语法)、对 C++98 建议智能指针、对 JS 建议加锁、对 C# 建议全面 `async` 化 —— 都是**语言层误报**。
193
+ 典型形态:对 Java 8 建议 `var`/`record`、对 C++98 建议智能指针、对 JS 建议加锁、对 C# 建议全面 `async` 化 —— 都是**语言层误报**。
194
194
 
195
195
  ### 4.3 项目专属豁免
196
196
 
@@ -223,17 +223,28 @@
223
223
  ```markdown
224
224
  ## 审查结论
225
225
 
226
- **结论**:BLOCK / PASS_WITH_NOT:S / PASS
226
+ **结论**:BLOCK / PASS_WITH_NOTES / PASS
227
227
  **diff 覆盖率**:已完整检查本次变更的全部 N 个文件(是/否)
228
228
  **加载的档案**:L1 = languages/java.md;L2 = projects/x_main.md
229
- **问题统计**:P0 = 0,P1 = 2,P2 = 3,P3 = 1
229
+ **问题统计**:P0 = 0,P1 = 2,P2 = 3,P3 = 1,待验证 = 2
230
+ **影响面核对**:本次改动涉及 N 个方法、M 个调用点;调用阶段逐个如下……
230
231
 
231
- ### 问题清单
232
+ ### 问题清单(已举证)
232
233
 
233
- | ID | 级别 | 位置 | 问题 | 证据(①②③④) | 建议 | 需本次修改 |
234
- |---|---|---|---|---|---|---|
235
- | R1 | P1 | `src/.../X.java:1823` | 查表结果未判空即取下标 | ①...②...③...④... | 加存在性判断 | 是 |
236
- | R2 | P2 | `src/.../Y.java:210` | 高频路径内拼接大 JSON | ①...②...③... | 观察 | 否 |
234
+ | ID | 级别 | 置信度 | 位置 | 问题 | 证据(①②③④) | 建议 | 需本次修改 |
235
+ |---|---|---|---|---|---|---|---|
236
+ | R1 | P1 | 高 | `src/.../X.java:1823` | 查表结果未判空即取下标 | ①...②...③...④... | 加存在性判断 | 是 |
237
+ | R2 | P2 | 中 | `src/.../Y.java:210` | 高频路径内拼接大 JSON | ①...②...③... | 观察 | 否 |
238
+
239
+ ### 待验证疑点(不阻塞,但必须列出)
240
+
241
+ > 装的是"怀疑有问题但还没证明"的项。**不参与 BLOCK,但不许省略。**
242
+ > 上一版把这一档全部过滤掉了,结果是提交后门禁报的 6 条里有 5 条属于这一档。
243
+ > 宁可多列,让人一眼否掉——漏报是看不见的,误报是看得见的。
244
+
245
+ | ID | 疑点 | 位置 | 触发条件 | 怎么验证 | 可能的后果 |
246
+ |---|---|---|---|---|---|
247
+ | Q1 | 兜底分支未清理顶号标记 | `X.java:57-69` | 重载失败走早退 | 看 `markKicked` 是否有配对 `clearKicked` | 15 秒内漏掉真实下线 |
237
248
 
238
249
  ### 附录:范围外观察(不阻塞、无需修改)
239
250
  - [范围外] `src/.../Z.java:88` ...
@@ -244,12 +255,13 @@
244
255
 
245
256
  ### 硬性约束
246
257
 
247
- 1. **P2 最多 5 条,P3 最多 2 条(且必须合并表述)。** P0/P1 不限。
258
+ 1. **P2 最多 5 条,P3 最多 2 条(且必须合并表述)。** P0/P1 与待验证不设上限。
248
259
  2. 每条意见**只描述一个问题**,禁止夹带重构。
249
- 3. `证据` 列填不满 §3 的四项 → 该条**不得出现在 P0/P1 行**。
250
- 4. 必须回答「diff 覆盖率」。回答"否"时,本轮结论只能是 `PASS_WITH_NOT:S`,不得 BLOCK(未看全就没资格阻断)。
260
+ 3. `证据` 列填不满 §3 的四项 → 该条**不得出现在 P0/P1 行**;但**应降为待验证疑点保留**,不要直接删掉。
261
+ 4. 必须回答「diff 覆盖率」。回答"否"时,本轮结论只能是 `PASS_WITH_NOTES`,不得 BLOCK(未看全就没资格阻断)。
251
262
  5. **必须声明加载了哪些档案。** 没读语言档案却给语言相关意见,视为未举证。
252
- 6. 不得输出"整体建议""架构思考""进一步优化方向"等段落。
263
+ 6. **必须给出「影响面核对」。** 没写这一段,视为契约类检查(语言档案 §3.7)整体没做,报告退回重审。
264
+ 7. 不得输出"整体建议""架构思考""进一步优化方向"等段落。
253
265
 
254
266
  ---
255
267
 
@@ -258,7 +270,7 @@
258
270
  | 结论 | 触发条件 | 开发方动作 |
259
271
  |---|---|---|
260
272
  | `BLOCK` | 存在 ≥1 条通过 §3 举证的 P0/P1 | 修完再提 |
261
- | `PASS_WITH_NOT:S` | 仅有 P2/P3,或 diff 未完整覆盖 | 可提交;P2 自行登记验证 |
273
+ | `PASS_WITH_NOTES` | 仅有 P2/P3,或 diff 未完整覆盖 | 可提交;P2 自行登记验证 |
262
274
  | `PASS` | 无问题 | 提交 |
263
275
 
264
276
  **约束**:
@@ -279,7 +291,7 @@
279
291
  ├─ 认同 → 修改 → 记录到附录 A(结论:已修)
280
292
  ├─ 不认同 → 提交「反证」:
281
293
  │ ① 该路径不存在 / 已被上游拦住(给出代码位置)
282
- │ ② 该状态在本项目中不可达(引用 projects/规项目>.md 章节)
294
+ │ ② 该状态在本项目中不可达(引用 projects/<项目>.md 章节)
283
295
  │ ③ 该风险已被明确接受(给出设计说明 + 理由)
284
296
  │ ④ 该问题不在本次 diff 范围
285
297
  ↓
@@ -319,9 +331,9 @@
319
331
  - [ ] 新增的错误处理,是否真的覆盖了出错的那一行?
320
332
  - [ ] 有没有把"看起来不对"当成"确实不对",改掉了别人的设计?
321
333
 
322
- **语言部分**:见 `languages/规语言>.md` §5 的自检项。
334
+ **语言部分**:见 `languages/<语言>.md` §5 的自检项。
323
335
 
324
- **项目部分**:见 `projects/规项目>.md`(x_main → §13 豁免清单)。
336
+ **项目部分**:见 `projects/<项目>.md`(x_main → §13 豁免清单)。
325
337
 
326
338
  ---
327
339
 
@@ -332,22 +344,22 @@
332
344
  ```text
333
345
  你现在担任代码审查员。按以下分层依据执行审查:
334
346
 
335
- - L0 通用:::\rules\ai_code_review_files\R:VI:W_RUL:S.md
336
- - L0 变更集:::\rules\ai_code_review_files\SVN_WORKFLOW.md
337
- - L1 语言:::\rules\ai_code_review_files\languages\规按扩展名选>.md
338
- - L2 项目:::\rules\ai_code_review_files\projects\规项目名>.md(如有)
347
+ - L0 通用:规则库\REVIEW_RULES.md
348
+ - L0 变更集:规则库\SVN_WORKFLOW.md
349
+ - L1 语言:规则库\languages\<按扩展名选>.md
350
+ - L2 项目:规则库\projects\<项目名>.md(如有)
339
351
 
340
352
  审查对象:reports\review-packet.md(由 tools 生成,包含本次变更集的完整 diff,
341
353
  已确认尚未提交)。
342
354
 
343
355
  强制要求:
344
- 1. 严格按 R:VI:W_RUL:S.md §2 分级、§3 举证、§4 豁免、§5 格式输出。
356
+ 1. 严格按 REVIEW_RULES.md §2 分级、§3 举证、§4 豁免、§5 格式输出。
345
357
  2. 先读 L1 语言档案,再判断"这算不算问题";语言档案标为误报的,一律不提。
346
358
  3. 有 L2 项目档案时一并读;三者冲突时 L2 > L1 > L0。
347
359
  4. 只审变更集内的 diff 行;变更集外的文件既不在审查范围,也不在修改范围。
348
360
  5. 先读附录 A 的裁决记录,已豁免的问题不得再提。
349
361
  6. 每条 P0/P1 必须给出 ①②③④,给不出就降为 P2。
350
- 7. 一次性给完整结论(BLOCK / PASS_WITH_NOT:S / PASS),不要逐条挤牙膏。
362
+ 7. 一次性给完整结论(BLOCK / PASS_WITH_NOTES / PASS),不要逐条挤牙膏。
351
363
  8. 若要我动手修改,只能改变更集内的文件;范围外问题只报告不修改。
352
364
  ```
353
365
 
@@ -377,8 +389,29 @@
377
389
 
378
390
  - **每次裁决后**:把结论追加进附录 A。这是防止返工的**唯一硬保障**。
379
391
  - **新语言接入**:复制一份最接近的语言档案改写,重点是先写**误报清单**(第 4 节),而不是先写缺陷清单——误报才是这套流程真正的成本。
392
+ - **每次漏报后**:把门禁/线上抓到的、本轮没报出来的问题,追加进**附录 C 漏报台账**。
380
393
  - **每月复盘**:统计哪些问题被反复提出但被裁决豁免 → 补进对应层的豁免清单(语言问题进 L1,项目问题进 L2)。
381
- - **误报率指标**:`误报数 / 总意见数`。目标 **规 15%**。超过则收紧 §3 举证门槛(宁少勿滥)。
382
- - **漏报容忍**:宁可漏掉一个 P2,也不要制造十个误报。开发者注意力是最稀缺的资源。
394
+ - **误报率指标**:`误报数 / 总意见数`。目标 **< 15%**。超过则收紧 §3 举证门槛(宁少勿滥)。
395
+ - **漏报率指标**:`门禁发现且本轮未发现 / 门禁发现总数`。**必须一起看**,否则收紧举证门槛会把召回一起收掉。
396
+
397
+ > 精确率与召回率是一枚硬币的两面。只压误报、不度量漏报,结果就是"提交前很干净,提交后全是问题"——
398
+ > 这正是 §5 引入「待验证疑点」的原因:**中等置信度的怀疑不阻塞,但必须说出口。**
399
+
400
+ ---
401
+
402
+ ## 附录 C:漏报台账(追加式,只增不改)
403
+
404
+ > **为什么有这个表**:每一次门禁/线上抓到的漏报,都是一份免费样本。
405
+ > 不记下来,同一类问题就会反复漏。记下来,它是补规则的唯一依据。
406
+
407
+ | 日期 | 漏报形态 | 真实案例位置 | 当初为什么没看出来 | 已补到哪 | 状态 |
408
+ |---|---|---|---|---|---|
409
+ | 2026-11-26 | 开关关闭时兜底放行(`else result = true`) | `UserValidateCmd.java:41-62` | 只看了 if 分支,没问"else 时还挡不挡得住" | java.md §3.7 | 已补 |
410
+ | 2026-11-26 | 广播影响面包含自己刚建的会话 | `PlayerLoginReceiveCmd.java:71-76` | 没有把"谁会被这条广播命中"列出来 | java.md §3.7 | 已补 |
411
+ | 2026-11-26 | 早退路径跳过配对清理(`markKicked` 无 `clearKicked`) | `PlayerLoginReceiveCmd.java:57-69` | 只读了主路径,没穷举所有 `return` | java.md §3.7 + §5 | 已补 |
412
+ | 2026-11-26 | 对象重建后字段没人重新装配(`getKey()` 为空) | `UserValidateCmd.java:58-62` | 没追对象的生命周期 | java.md §3.7 | 已补 |
413
+ | 2026-11-26 | 用过期快照(旧 `idx`)操作新对象 | `UserValidateCmd.java` | 没问"这个变量是哪一刻取的" | java.md §3.7 | 已补 |
414
+ | 2026-11-26 | 索引缺失被 `0` 兜底,`0` 恰好是合法值 | `GatewayLinkedSet.java:107-115` | 没检查哨兵值 | java.md §3.7 | 已补 |
383
415
 
384
- > 自动化代码审查的工程共识是**精确率优先于召回率**:低价值评论会训练开发者忽略所有评论,包括真正致命的那条。
416
+ **用法**:每次门禁报出本轮没发现的问题,加一行。月底看哪一列出现最多——
417
+ 同一个"当初为什么没看出来"出现三次以上,说明该补的是**流程步骤**,不是规则条目。
@@ -1,7 +1,7 @@
1
1
  # SVN 改动范围规则(SVN_WORKFLOW.md)
2
2
 
3
3
  > 本文件规定 **任何 AI / 开发者在本仓库中工作时,如何确定"该改哪些代码"**。
4
- > 配套文件:`R:VI:W_RUL:S.md`(L0 审查方法论)、`languages/规语言>.md`(L1 语言档案)、`projects/x_main.md`(L2 项目档案)。
4
+ > 配套文件:`REVIEW_RULES.md`(L0 审查方法论)、`languages/<语言>.md`(L1 语言档案)、`projects/x_main.md`(L2 项目档案)。
5
5
  >
6
6
  > **一句话总纲:先读 SVN 改动,只在改动涉及的范围内写代码;没有改动的文件,一个字都不许动。**
7
7
 
@@ -65,33 +65,33 @@ TortoiseSVN 只装了图形界面,命令行 `svn.exe` 未安装。因此用脚
65
65
 
66
66
  ```powershell
67
67
  # 一条命令生成审查包
68
- & python ::\rules\ai_code_review_files\tools\precommit_audit.py
68
+ & python 规则库\tools\precommit_audit.py
69
69
  ```
70
70
 
71
71
  或直接双击 / 运行:
72
72
 
73
73
  ```text
74
- ::\rules\ai_code_review_files\tools\run-audit.cmd
74
+ 规则库\tools\run-audit.cmd
75
75
  ```
76
76
 
77
77
  ### 2.1 原理
78
78
 
79
79
  ```text
80
80
  .svn/wc.db (SQLite)
81
- ├─ NOD:S 所有版本化文件 + 校验和 + 原始 mtime/size
81
+ ├─ NODES 所有版本化文件 + 校验和 + 原始 mtime/size
82
82
  │ ├─ op_depth = 0 基线文件
83
83
  │ └─ op_depth > 0 本地新增(已 add) / 删除
84
- └─ ACTUAL_NOD: 属性修改 / 冲突 / changelist
84
+ └─ ACTUAL_NODE 属性修改 / 冲突 / changelist
85
85
 
86
86
  .svn/pristine/ 基线文件内容(按 SHA-1 分目录存放)
87
87
 
88
88
  判定流程:
89
- 1. 对 NOD:S 中每个 op_depth=0 的文件
89
+ 1. 对 NODES 中每个 op_depth=0 的文件
90
90
  2. 先比 mtime + size(快路径,SVN 自己也这么做)
91
- 3. 不一致则算磁盘文件 SHA-1,与 NOD:S.checksum 比对(慢路径)
91
+ 3. 不一致则算磁盘文件 SHA-1,与 NODES.checksum 比对(慢路径)
92
92
  4. 不等 → 已修改(M)
93
93
  5. 文件不存在 → 缺失(!)
94
- 6. 未在 NOD:S 中 → 未纳管(?)
94
+ 6. 未在 NODES 中 → 未纳管(?)
95
95
  7. diff = pristine 内容 vs 磁盘内容
96
96
  ```
97
97
 
@@ -126,9 +126,9 @@ python precommit_audit.py --quiet # 只输出摘要
126
126
  ↓
127
127
  ③ 得到变更集 + review-packet.md
128
128
  ↓
129
- ④ 审查 AI 读 review-packet.md + R:VI:W_RUL:S.md + 对应语言档案 + projects/x_main.md
129
+ ④ 审查 AI 读 review-packet.md + REVIEW_RULES.md + 对应语言档案 + projects/x_main.md
130
130
  ↓
131
- ⑤ 出结论:BLOCK / PASS_WITH_NOT:S / PASS
131
+ ⑤ 出结论:BLOCK / PASS_WITH_NOTES / PASS
132
132
  ↓
133
133
  ⑥ 若有 P0/P1 → 只在变更集范围内修
134
134
  ↓
@@ -161,12 +161,12 @@ python precommit_audit.py --quiet # 只输出摘要
161
161
 
162
162
  | 场景 | 依据 |
163
163
  | -------------------- | ---------------------- |
164
- | 审查只审 diff 变更行 | `R:VI:W_RUL:S.md` §1.1 |
165
- | 审查范围外问题标 `[范围外]`,不阻塞 | `R:VI:W_RUL:S.md` §1.3 |
164
+ | 审查只审 diff 变更行 | `REVIEW_RULES.md` §1.1 |
165
+ | 审查范围外问题标 `[范围外]`,不阻塞 | `REVIEW_RULES.md` §1.3 |
166
166
  | AI 只改变更集内文件 | **本文件 §1.1** |
167
167
  | 修改必须符合架构约束 | `projects/x_main.md` |
168
168
 
169
- **本文件管"改哪里",`R:VI:W_RUL:S.md` 管"怎么评",`languages/规语言>.md` 管"这门语言什么算缺陷",`projects/x_main.md` 管"为什么不能那样改"。**
169
+ **本文件管"改哪里",`REVIEW_RULES.md` 管"怎么评",`languages/<语言>.md` 管"这门语言什么算缺陷",`projects/x_main.md` 管"为什么不能那样改"。**
170
170
 
171
171
  ---
172
172
 
@@ -186,10 +186,10 @@ python precommit_audit.py --quiet # 只输出摘要
186
186
  ## 6. 目录结构
187
187
 
188
188
  ```text
189
- ::\rules\ai_code_review_files\
189
+ 规则库\
190
190
  ├─ PROMPT.md 审查指令模板(复制粘贴用)
191
- ├─ R:VI:W_RUL:S.md 审查规范(分级/举证/豁免/格式)
192
- ├─ languages/规语言>.md 语言档案(惯用法 / 缺陷 / 误报)
191
+ ├─ REVIEW_RULES.md 审查规范(分级/举证/豁免/格式)
192
+ ├─ languages/<语言>.md 语言档案(惯用法 / 缺陷 / 误报)
193
193
  ├─ projects/x_main.md 项目架构约束
194
194
  ├─ SVN_WORKFLOW.md 本文件:改动范围规则
195
195
  ├─ tools\
@@ -121,6 +121,30 @@
121
121
  | `double` 表示金额 | 精度丢失,`0.1+0.2 != 0.3` |
122
122
  | `Math.abs(Integer.MIN_VALUE)` | 仍是负数 |
123
123
 
124
+ ### 3.7 跨文件契约与状态机(最容易漏的一类)
125
+
126
+ > 这一节的模式**不在任何一行代码里**,逐行读 diff 永远看不见。
127
+ > 它们的共同点是:**改对了当前行,但没同步别处的假设**。
128
+ > 每一条都必须主动去搜,不搜就是漏报。
129
+
130
+ | 模式 | 为什么会错 | 怎么查 |
131
+ |---|---|---|
132
+ | **成对调用只做了一半** | `markKicked` 有对应 `clearKicked`,某条路径只 mark 不 clear,标记残留 | 搜同类前缀的配对方法(`mark/clear`、`open/close`、`lock/unlock`、`add/remove`、`register/unregister`、`begin/end`),确认每个出口都成对 |
133
+ | **早退路径跳过收尾** | `catch` 里 `return`、提前 `return`、`continue` 绕过了方法末尾的清理 | 列出方法内**所有** `return` / `throw` / 外层 `catch` 出口,逐条问"收尾执行了吗" |
134
+ | **开关关闭时兜底放行** | `if (check) { 校验 } else { result = true }` —— 关掉校验开关等于全放行 | 找所有"校验失败/跳过时结果是什么"的兜底分支,问:关掉这个开关,这行还挡得住吗 |
135
+ | **广播代替定向** | `broadcast` 影响面包含自己刚建立的对象(新会话、新连接) | 看广播类 API 是否按 id/session 过滤;能定向就不要广播 |
136
+ | **快照过期** | 用操作前算出的 `idx`/指针去操作操作后的对象 | 看关键操作前有没有重新取索引;跨阶段的变量是否仍有效 |
137
+ | **默认值被当成有效值** | 索引缺失返回 `0`、`null` 被 `int` 兜底成 `0`,`0` 恰好是个合法值 | 看 `0` / `-1` / 空串 / 空集合是否被当作"合法但不存在"使用 |
138
+ | **生命周期假设被打破** | 对象重载/跨服/序列化后,某些字段(`key`、`serverName`、缓存)是空的 | 列出对象重建路径,问:重建后哪些字段没人重新装配 |
139
+ | **同一方法被两个阶段调用** | 校验阶段调用时对象还没登记;登录后调用时已登记,同一句代码效果相反 | 对每个调用点,逐个推演"此时对象处于什么状态" |
140
+
141
+ **执行顺序(强制)**:
142
+
143
+ 1. 变更集里**新增或修改的每个方法** → 全仓搜调用点,逐个记下调用阶段
144
+ 2. 每个**被调用**的方法 → 读实现,确认三件事:是否幂等、有没有配对清理、失败时返回什么
145
+ 3. 每个**新增的字段/标记/索引** → 全仓搜读写点,确认读写对称、生命周期一致
146
+ 4. 把上面三步的结论写进报告的【影响面核对】段——**没写就等于没做**
147
+
124
148
  ---
125
149
 
126
150
  ## 4. 误报清单(不得提出的意见)
@@ -182,7 +206,16 @@
182
206
 
183
207
  ## 5. 提交前自检项
184
208
 
185
- 审 Java 改动时,按顺序过一遍(前 3 条按 §1 的档取用):
209
+ 审 Java 改动时,按顺序过一遍。**前 4 条是契约类,最容易漏,必须回答后再往下一行看**;后面按 §1 的档取用。
210
+
211
+ **契约与状态(§3.7,逐条回答,不许跳过)**:
212
+
213
+ - [ ] 我改了哪些方法?全仓搜过调用点了吗?每个调用点当时对象是什么状态?
214
+ - [ ] 这次新增/修改的标记、索引、缓存,有没有配对的清理方法?每个 `return`/`catch` 出口都调了吗?
215
+ - [ ] 校验开关关掉时,这行代码还挡得住吗?
216
+ - [ ] 广播/批量操作会不会波及自己刚建立的对象?
217
+
218
+ **局部模式**:
186
219
 
187
220
  - [ ] 先确认目标版本,再看 diff 里有没有用到该档之外的语法(有就说明版本判断错了,回头查构建文件)
188
221
  - [ ] 目标版本 ≥ 17 时,`record` 是否被当成可变对象用?`sealed` 是否被当成运行时校验?