Skip to content

Commit df9bf24

Browse files
committed
fix: 收敛间接 Git 操作的仓库与暂存判定
发布 v0.14.5;对一层静态 Shell 脚本统一检测、仓库归属与拟暂存预测,未知跨解释器操作保持 UNVERIFIED。
1 parent be619cd commit df9bf24

14 files changed

Lines changed: 379 additions & 50 deletions

File tree

‎.agents/plugins/marketplace.json‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,20 @@
99
"source": {
1010
"source": "url",
1111
"url": "https://github.com/partme-ai/partme-codeguard-plugin.git",
12-
"ref": "v0.14.4"
12+
"ref": "v0.14.5"
1313
},
1414
"policy": {
1515
"installation": "AVAILABLE",
1616
"authentication": "ON_USE"
1717
},
1818
"category": "Developer Tools",
19-
"version": "0.14.4",
19+
"version": "0.14.5",
2020
"description": "Evidence-backed code checks and Git content gates for AI assistants, with Maven/Gradle module impact analysis. Save hooks provide feedback; unverified checks are explicit.",
21-
"icon": "https://cdn.jsdelivr.net/gh/full-stack-plugins/codeguard-plugin@v0.14.4/assets/official-logo.png",
21+
"icon": "https://cdn.jsdelivr.net/gh/full-stack-plugins/codeguard-plugin@v0.14.5/assets/official-logo.png",
2222
"interface": {
2323
"displayName": "代码规范守卫",
2424
"shortDescription": "Trustworthy code checks and Java impact analysis",
25-
"logo": "https://cdn.jsdelivr.net/gh/full-stack-plugins/codeguard-plugin@v0.14.4/assets/official-logo.png"
25+
"logo": "https://cdn.jsdelivr.net/gh/full-stack-plugins/codeguard-plugin@v0.14.5/assets/official-logo.png"
2626
}
2727
}
2828
]

‎.codex-plugin/plugin.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "codeguard",
3-
"version": "0.14.4+codex.20260923",
3+
"version": "0.14.5+codex.20260923",
44
"description": "Evidence-backed code checks and Git content gates for AI assistants, with Maven/Gradle module impact analysis. Save hooks provide feedback; unverified checks are explicit.",
55
"author": {
66
"name": "Full Stack Skills / PartMe.AI",

‎.zcode-plugin/plugin.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"en": "CodeGuard",
66
"zh-CN": "代码规范检查"
77
},
8-
"version": "0.14.4",
8+
"version": "0.14.5",
99
"description": "Evidence-backed code checks and Git content gates for AI assistants, with Maven/Gradle module impact analysis. Save hooks provide feedback; unverified checks are explicit.",
1010
"description_i18n": {
1111
"en": "Evidence-backed code checks and Git content gates for AI assistants, with Maven/Gradle module impact analysis. Save hooks provide feedback; unverified checks are explicit.",

‎README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ A plain commit checks the index, not an unstaged repair. Supported preceding git
7575
Checks materialize temporary Git blobs without stash, checkout or modifying the real index. The exact-content gate does not reuse the soft working-tree cache. Missing ignored dependencies remain UNVERIFIED rather than silently falling back to different source content.
7676

7777
Limits: 20,000 tracked files / 256 MiB Git content / 32 MiB per overlay file. Symlinks, submodules, conflicts and unsupported content need separate validation. Complex shell rewrites, arbitrary Git refspecs, dynamic aliases and concurrent edits are not a fully modeled transaction. A hook is not a replacement for protected-branch CI.
78+
One statically readable layer of bash/sh/zsh `-c` or script execution is included in repository and staging analysis; unmodelled indirect Git operations are blocked as UNVERIFIED. Dynamic scripts and subprocess calls assembled by Python/Node remain outside this static model.
7879

7980
There is no “historical debt” exemption based only on an unchanged diagnostic filename; a modified API can break an unchanged caller.
8081

‎README.zh-CN.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ Maven 使用 verify 并追加 -DskipTests(测试代码仍编译,仅跳过执
7575
检查在临时目录物化 Git blobs,不 stash、不 checkout、不更改真实 index。精确内容门禁不复用软提醒的工作树缓存。快照缺 ignored 依赖时保持 UNVERIFIED,不改查另一份源码。
7676

7777
限制:20,000 个已跟踪文件 / 256 MiB Git 内容 / 每个覆盖文件 32 MiB。符号链接、子模块、冲突及不支持的内容需要独立验证。复杂 shell 写入、任意 Git refspec、动态别名与并发编辑尚未完整建模;钩子不能替代受保护分支 CI。
78+
仓库归属与拟暂存分析覆盖一层静态可读的 bash/sh/zsh `-c` 或脚本执行;无法建模的间接 Git 操作会以 UNVERIFIED 阻断。动态脚本以及 Python/Node 中拼接的 subprocess 调用仍不在此静态模型内。
7879

7980
不再仅凭“报错文件没修改”豁免历史债:变更 API 也会破坏未修改的调用方。
8081

‎docs/current-architecture.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ flowchart TD
2929
`execution` 只记录进程证据,不把非零退出自动认定为代码违规。`verdict`、CVE 与 Dockerfile 报告解析决定 PASS、FAIL 或 UNVERIFIED;入口仅按各自协议呈现和聚合退出码。Git 提交检查使用 index 或预测暂存快照,推送检查使用 HEAD;保存钩子只给反馈。计划、未执行和未验证不能宣传为通过。
3030
Git 命令的仓库定位与拟暂存解析共用入口传入的 cwd;显式 `cd`/`git -C` 无法绑定 Git 工作树时,硬门禁给出目标未验证并阻断,不退回到调用者仓或无关子仓。未给出显式目标且调用目录非仓时仍保留 workspace 子仓兜底。静态命令解析不等于完整 Shell 执行模拟。
3131
一条命令链中的 Git 副作用先绑定为仓库与操作的有序对,再按仓库聚合检查面:纯 push 不读取该仓未提交的 index,同仓 commit→push 则保留已有 HEAD 与拟提交内容的并集。仓库级、内联及链式 `skipGate` 均按目标仓与操作顺序生效;已存在的仓库配置也可被同链先行 `git config --unset` 取消。链式设置跨 `||`、`;` 或换行时无法证明生效,门禁要求拆分命令;写入其它文件的 config 设置也不构成本仓豁免。语法、仓库归属、间接脚本与拟暂存分析共用引号/转义感知切分;参数文本中的控制符不能合成豁免。解析能力仍限于受支持的静态 Shell 形态。
32+
一层 `bash`/`sh`/`zsh` 的 `-c`(含组合短选项)及可读脚本现在携带调用目录与正文进入同一 Git 操作计划;脚本内的 `git add` 可进入拟暂存范围,外层和内层 Git 操作按仓分别检查。识别到无法建模的间接 Git 操作、脚本内 `skipGate` 配置变更或跨解释器的暂存/提交关系时,明确以 Git 意图 UNVERIFIED 阻断,不借用调用者仓的检查结果。动态脚本、任意控制流及 Python/Node 中构造的 subprocess 仍未建模。
3233

3334
## 模块所有权
3435

‎kimi.plugin.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "codeguard",
3-
"version": "0.14.4",
3+
"version": "0.14.5",
44
"description": "Evidence-backed code checks and Git content gates for AI assistants, with Maven/Gradle module impact analysis. Save hooks provide feedback; unverified checks are explicit.",
55
"author": {
66
"name": "Full Stack Skills / PartMe.AI"

‎openspec/changes/refactor-codeguard-architecture/design.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,13 @@ flowchart TD
7878
传入的 cwd,不再分别读取进程全局工作目录。Git 根查询故障也保留阻断结论;这些只覆盖
7979
支持的静态命令形态,不能宣称模拟完整 Shell 控制流。
8080

81+
后续收敛一层 Shell 间接执行:从外层命令链提取解释器调用及其调用目录,静态读取
82+
`bash`/`sh`/`zsh` 的 `-c` 文本或脚本正文。内层 Git 操作携带来源命令与调用目录,
83+
供仓库归属、豁免和拟暂存分析复用;外层与内层操作按目标仓聚合。不把 Python/Node
84+
源码误当 Shell 执行计划:它们若被保守静态扫描命中但无法证明行为,返回明确的 Git
85+
意图未验证,不能用外层仓库检查结果代替。仍只支持一层、静态可读的脚本,不推断任意
86+
控制流、动态脚本生成或解释器在运行时调用的 subprocess。
87+
8188
参考:pre-commit 的 [Language Protocol 与通用执行](https://github.com/pre-commit/pre-commit/blob/main/pre_commit/lang_base.py)、[Python 适配器](https://github.com/pre-commit/pre-commit/blob/main/pre_commit/languages/python.py)。只借鉴边界设计,不复制安装环境逻辑或新增插件生态协议。
8289

8390
### 6. 状态基础设施与已完成事件分开

‎openspec/changes/refactor-codeguard-architecture/specs/execution-kernel/spec.md‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,10 @@ index 或工作树;不支持的动态/交互式形态必须明确未验证,
210210
或换行后的配置状态无法静态证明时,MUST 阻断并提示拆分命令,不得猜测已生效。
211211
命令切分 MUST 区分真实 Shell 分隔符和被引用/转义的字面文本;提交消息、echo 参数
212212
或文件路径中的 `;`、`&&` 不得生成虚假的 Git 操作或豁免设置。
213+
对一层可静态读取的 `bash`/`sh`/`zsh` 内联命令(含 `-lc` 等组合短选项)或脚本,Git 副作用的识别、仓库归属与
214+
拟暂存分析 MUST 使用脚本的实际调用目录和同一份内层命令;外层直接 Git 操作与内层操作
215+
不得互相覆盖。若已识别间接 Git 副作用但不能可靠建立仓库或暂存计划,MUST 报告 Git
216+
意图 UNVERIFIED 并阻断,不得回退扫描无关子仓或以错误仓库的 PASS 放行。
213217

214218
#### Scenario: Two repositories have different staging commands
215219
- **WHEN** 一条命令链对 A 执行 add -A、对 B 只提交已暂存内容
@@ -239,6 +243,26 @@ index 或工作树;不支持的动态/交互式形态必须明确未验证,
239243
- **WHEN** `echo` 的引号参数或 commit 消息包含 `; git config codeguard.skipGate true`
240244
- **THEN** 不产生虚假的 config 设置,随后未豁免的提交仍须检查并阻断违规内容
241245

246+
#### Scenario: Shell wrapper commit uses the invocation repository
247+
- **WHEN** 从 Git 仓执行 `bash -c 'git commit'` 或相对路径脚本,脚本内存在待提交内容
248+
- **THEN** 将内层 commit 绑定到脚本调用目录的 Git 仓,而非报无仓或扫描其子仓
249+
250+
#### Scenario: Script arguments are not interpreter options
251+
- **WHEN** 一个无 Git 副作用的脚本接收名为 `-c` 的普通参数及包含 `git commit` 的文本
252+
- **THEN** 解析器不得把脚本参数当成解释器 `-c` 代码并虚构 Git 副作用
253+
254+
#### Scenario: Inner shell staging remains visible
255+
- **WHEN** 可静态读取的 shell 命令内先 `git add` 敏感文件再提交,或先切换到另一仓再提交
256+
- **THEN** 拟暂存分析包含内层 add 并归属实际目标仓;同链外层 Git 操作仍分别检查
257+
258+
#### Scenario: Staging crosses an interpreter boundary
259+
- **WHEN** 独立的 shell 包装器只执行 `git add`,之后外层或另一个包装器才提交
260+
- **THEN** 无法证明完整拟暂存计划时报告 Git 意图 UNVERIFIED 并阻断;若 add 仅发生于纯 push 之后且无后续提交,不扩张该 push 的检查面
261+
262+
#### Scenario: Unmodelled indirect Git operation cannot borrow another repository
263+
- **WHEN** 非 Shell 解释器脚本静态命中 Git 副作用,但无法可靠推断其执行目录与暂存动作
264+
- **THEN** 返回 Git 意图 UNVERIFIED,不以调用者的其它仓库或兜底子仓的结果替代
265+
242266
#### Scenario: An explicit Git target is not a repository
243267
- **WHEN** 命令从 Git 仓调用,但在 `cd` 到非 Git 目录后运行 `git push`,或使用无效的 `git -C` 目标
244268
- **THEN** 门禁以明确诊断阻断,而不是检查调用者仓或用 workspace 兜底;后续显式 `git -C` 指向有效仓时仍能正确绑定该仓

‎openspec/changes/refactor-codeguard-architecture/tasks.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@
3333
- [x] 5.1 增加自动架构依赖/循环检查并接入 CI,临时源码树注入反向依赖/函数内导入/相对导入环后确实拒绝;本地已验证,远端 CI 待发布阶段。不以文件行数当合格标准。
3434
- [x] 5.2 四个历史 skipped 已全部恢复;Dockerfile CLI 接入统一报告解析与扫描应用,14 项真实进程边界测试通过;基线比较按诊断内容和次数核验并要求基线实际 FAIL,三项误豁免用例先红后绿。完整 433 项单测零跳过、142 项回归零失败。
3535
- [x] 5.3 新增当前架构 Mermaid 与扩展指南;报告版本读取插件 manifest,双语 README 指向当前证据,旧设计标明历史范围;双语标题/链接/版本及本地链接存在性测试通过。发布版本仍需在 5.5 检查。
36-
- [x] 5.4 全量单测/真实 hook 回归/ruff/语言 schema/vendor 离线与在线/本 change strict 和逐条规格追溯通过;第十八批 481 项单测、143 项真实 Hook 回归、57 项/11 规则,证据见 verification.md。仅证明本地契约,不等同三宿主现场验收。
37-
- [ ] 5.5 按仓规升级版本、生成市场元数据、授权的 PR/CI/不可变 tag/Release 闭环;v0.14.3 阶段版本已完成插件/市场双仓合并、PR/main CI、tag/Release,但本 change 后续改动仍需独立发布。宿主安装运行独立记录,未授权不得改宿主。
36+
- [x] 5.4 全量单测/真实 hook 回归/ruff/语言 schema/vendor 离线与在线/本 change strict 和逐条规格追溯通过;第十九批 495 项单测、143 项真实 Hook 回归、57 项/11 规则,证据见 verification.md。仅证明本地契约,不等同三宿主现场验收。
37+
- [ ] 5.5 按仓规升级版本、生成市场元数据、授权的 PR/CI/不可变 tag/Release 闭环;v0.14.4 阶段版本已完成插件/市场双仓合并、PR/main CI、tag/Release,但第十九批新改动仍需独立发布。宿主安装运行独立记录,未授权不得改宿主。
3838
- [ ] 5.6 完成全目标审计,代码/规格/证据一致后同步并归档 change,才可将整体优化标记完成。

0 commit comments

Comments
 (0)