Files
Agent-System-Dev/policy/tool-adaptation-zcode.md
T
weichen c2da46e4d2 Harden the gate: uninitialized-submodule detection and platform protection registration
Why: precheck missed uninitialized submodules (git submodule status '-'
prefix), and the branch protection configured today plus the second live
probe outcome must be recorded honestly in the matrices.
Evidence: platform negative: direct push to protected main rejected
(pre-receive hook declined, Logging-System probe); second write-guard probe
confirmed session-start config loading (no hook run in the pre-config
session log).
Impact: precheck sub_dirty now counts '-' prefixed entries; A3 registered
enforced at platform layer across 11 repos; zcode matrix pending-live
annotated with the loading-timing proof.
Refs: policy/tool-adaptation-matrix.md; policy/tool-adaptation-zcode.md
2026-09-30 03:47:24 +00:00

34 lines
3.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# zcode 客户端机制实例——能力矩阵
- 适配对象:zcode CLI(工作区级配置)
- 依据:Development-Guidelines 0.1.0-draft.8(c9ab623)standards/tool-adaptation.md + policy/adoption.md
- 状态:verified(脚本级正负例 8/8;客户端实弹拦截待下个会话日志确认,见备注)
- 实例位置:.zcode/config.json(PreToolUse 钩子)、scripts/zcode/write-guard.sh、AGENTS.md(常驻条文 = zcode 的 rules 层)
- 单一权威声明:本实例是上述规范的机制实现,语义以库与项目入口为准
## 能力矩阵
| 要求 | 等级 | 机制(执行时机) | 正例证据 | 负例证据 | 备注 |
|---|---|---|---|---|---|
| A1 启动门禁 | enforced(写路径)+ advisory(检测纪律) | PreToolUse 拦 Edit/Write/ApplyPatch:目标仓在集成分支、detached HEAD、坏分支名时 exit 2 阻断(落笔前,git 钩子只拦提交时) | 脚本套件 P1–P4 放行 | N1 main 拦截、N2 detached 子仓拦截、N3 坏分支名拦截(均 exit 2 带指引) | detached 拦截正是多租户事故形态;检测/verdict 仍靠 precheck 纪律 |
| A2 节点同步 | advisory | 无对应 zcode 事件;走 task-sync 纪律 | Dev PR#1–6 均经 sync | 实战脏树拒绝 | 不虚报 |
| A3 集成分支保护 | enforced(local) 双层 | zcode 写路径(落笔前)+ git pre-commit(提交时);平台分支保护未配置 | 12+ PR 全走平台 | N1 + 套件 hook-main-refused | 平台层配置后升级 |
| A4 提交与任务记录格式 | enforced(local) 主题行 + manual body | git commit-msg 钩子(对 zcode 的 Bash git commit 同样生效) | 本批提交 | 套件 hook-longsubject-refused | body 四段无机器校验 |
| A5 工作区回收 | advisory | task-finish(rm+prune 兜底) | PR#5/#6 后实战回收 | finish-before-merge 拒绝 | |
| A6 秘密边界 | manual | token 自 ~/.secrets/gitea;守卫与配置无凭证 | 全程无明文泄漏 | 无构造负例 | 纪律项 |
| A7 证据落盘 | manual | 完成声明附三段输出 | 各 PR body | 无构造负例 | |
## 降级与失败行为
| 机制 | 依赖缺失时行为 | 对应等级调整 | 解锁路径 |
|---|---|---|---|
| write-guard 输入解析(python3) | 缺 python3 或 stdin 无路径/垃圾 → 放行(fail-open) | A1 写路径降级 manual | 装 python3;提交时仍有 git 钩子兜底,构成第二道 |
| write-guard(bash/git) | 脚本报错非 0/2 → 客户端记为错误事件 | 同上 | 修复后重跑套件 |
| zcode 钩子运行器 | 配置文件钩子须 hooks.enabled=true(已设) | A1 写路径整体失效 | 客户端设置确认运行器激活 |
## 验证记录
- 2026-09-30 脚本级套件 8/8 PASS(N1–N3 拦截、P1–P5 放行与配置合法),执行者 weichen,输出留存任务卡
- 客户端内实弹拦截:pending-live——两次无副作用探针(配置创建当期会话)均未被拦,ZCode 日志无 hook 执行记录,证实钩子配置随会话启动加载;本会话早于配置存在,属预期。下个会话首次写入即自然验证
- 证据复用:A2–A7 行沿用 CLI/git 实例矩阵证据(机制未变)