Files
mnote/.codex/reasonix-tasks/2026-05-21-batch-f-worker-c-ai-command-context.md
T

2.2 KiB
Raw Blame History

Reasonix Worker CAI 写入 CommandContext 守卫

Project root/mnt/Data1T/mnote

你不是唯一 worker。不要回滚、覆盖或清理他人的改动;只修改本任务 ownership 范围内的文件。不要提交 git。

目标

收口 1-6 Gap A7 中最后的 ai.canWrite 消费缺口:

  1. 复核 CommandContext.ai.canWrite 是否已经被 Hermes / AI 写入路径实际消费。
  2. 若未消费,补最小守卫:只读 workspace、无写权限或 AI 写入未授权时,正文/页面写入类 Hermes tool 返回明确拒绝,不进入文件写入。
  3. 补最小 Rust 单测,避免只停留在 core-protocol evaluator 层。
  4. 更新 design/01-tree-first-graph-kernel/process/1-6-next-phase-gap-closure-checklist-v1.md 与必要的 1-5 状态。

Ownership

允许修改:

  • design/01-tree-first-graph-kernel/process/1-6-next-phase-gap-closure-checklist-v1.md
  • design/01-tree-first-graph-kernel/process/1-5-next-phase-sequential-execution-checklist-v1.md
  • rust/crates/core-protocol/src/command.rs
  • rust/crates/mnote-web/src/hermes_tools/doc.rs
  • rust/crates/mnote-web/src/hermes_tools/page.rs
  • 相关同文件测试

禁止修改:

  • GFM parser / web_shell legacy marks
  • tree realtime / websocket 文件
  • OnlyOffice 文件

执行要求

  • 先搜索现有写权限模型,不要凭空新增一套权限真相。
  • 如果已有 AiAccessScope、allowed roots、readonly workspace 或 local access policy helper,应复用。
  • ai.canWrite 是 command context 口径;如果 runtime 现有权限模型名称不同,可以用桥接 helper,但不要把 evaluator 复制到多个地方。
  • 拒绝响应必须可解释,不能 panic,不能静默成功。
  • 不要扩大 AI 功能面,只守卫已有写入路径。

验收命令

cargo test -p core-protocol command_context -- --test-threads=1
cargo test -p mnote-web hermes_tools -- --test-threads=1
git diff --check

如果 hermes_tools 过滤器过大或无匹配,请运行你新增测试的精确过滤命令,并在最终回复说明。

最终回复格式

  • 修改文件列表
  • 是否实现运行时守卫
  • 运行过的命令和结果
  • 未完成项或风险