Skip to content

AtomCode v5.0.9 新子系统深度分析 — Review Deep + 会话恢复 + Headless ​

基于 strings / 运行时行为验证的还原分析 2026-09-09 前置报告:05-version-diff-v4.25.5-to-v5.0.9.md


1. /review 深度模式(deep / deep+verify) ​

1.1 源码模块(v5 新增 6 文件) ​

crates/atomcode-review/src/fanout.rs        ← 维度 fan-out 并发
crates/atomcode-review/src/assemble.rs      ← 跨维度合并去重
crates/atomcode-review/src/confine.rs       ← 范围收敛(仅审查变更文件)
crates/atomcode-review/src/impact_plan.rs   ← 影响面规划(code-graph 引导)
crates/atomcode-review/src/round_budget.rs  ← 轮次预算
crates/atomcode-review/src/config.rs        ← 审查配置

1.2 工具契约(完整还原) ​

Run a rigorous READ-ONLY code review of the current changes and return
prioritized findings (correctness > security > reliability). Resolve only the
requested scope, then invoke this tool without pre-reviewing the diff. Large
scopes return a preflight instead of starting; only echo `confirm_scope` after
the user explicitly accepts that exact scope. Runs a separate reviewer agent
and never modifies files. Choose `depth` by the change's risk and size:
default to `single`; escalate to `deep`/`deep+verify` only for substantive,
risky, or security-sensitive changes, or when the user asks for a thorough/
careful review.

关键契约:

  1. READ-ONLY:审查代理绝不改文件
  2. 不预先自查 diff:直接调用,避免模型 pre-review 偏置
  3. 大范围 → preflight:先返回预检,用户 confirm_scope 后才继续
  4. 优先级:correctness > security > reliability

1.3 参数结构 ​

ScopeArgWorkingTree    ← 范围枚举(internally tagged):base/staged/working-tree 三态
base / staged          ← /review <base> 支持比较基线
Optional repo-relative path filters
Opaque token from a preflight. Pass only after explicit user confirmation.
single / deep / deep+verify    ← depth 参数三档
Review depth

1.4 四维度 fan-out(lens) ​

维度Lens 注入审查视角
correctnessThis review's lens: CORRECTNESS逻辑正确性
securityThis review's lens: SECURITY安全漏洞
performanceThis review's lens: PERFORMANCE性能
tests & contractsThis review's lens: TESTS & CONTRACTS测试覆盖与契约

1.5 影响面规划(impact_plan.rs) ​

## Review impact plan (deterministic, code-graph guided)

No high-risk symbol targets were inferred. Review the changed hunks and only
use deeper code-graph tools if a hunk changes runtime behavior, dependency
resolution, or public contracts.
  • 先用 code-graph 推断高风险符号 → 生成确定性影响面计划
  • 无高风险目标时退回变更 hunk 审查,避免过度深挖
  • 只在 hunk 触及运行时行为/依赖解析/公共契约时才启用 code-graph 工具

1.6 范围收敛(confine.rs) ​

review scope; tools may only access the changed/reviewable files (and their
parent directories)
path is required under review scope confinement; pass a path within the
changed/reviewable files

→ 审查工具的所有访问被限制在变更文件集内(连同父目录),杜绝审查代理越界读取整个仓库。

1.7 verify 阶段(deep+verify) ​

ZVerify the following single candidate finding from a prior review.
  • 每条候选 finding 由独立 reviewer 依据 diff 验证一次
  • 弱模型 reviewer 附加纪律约束(验证提示含指令约束)
  • 剔除误报后组装最终报告

1.8 运行状态机 ​

Deep review: 0 dimensions completed
Deep review: 4 dimensions completed
Deep review complete
Deep review incomplete
every dimension failed (0/
Failed dimensions:

→ 维度数实时上报;维度可独立失败,失败维度单独列出。

1.9 轮次/时长预算 ​

ATOMCODE_REVIEW_MAX_ROUNDS
ATOMCODE_REVIEW_MAX_DURATION_SECS
preflight timed out after 30 seconds
round_budget.rs    ← 轮次预算模块

2. 会话恢复(resume) ​

2.1 双通道 ​

CLI:  atomcode resume <id|name>      ← 无参恢复最近会话
      atomcode -p --resume <id>      ← headless 用法
TUI:  /resume 交互

2.2 恢复状态机 ​

状态错误串
无会话resume failed:
进行中another session resume is still in progress
会话占用session is active in another atomcode process; close it before resuming
准备超时session preparation is taking unusually long (large session or slow disk); please try again

2.3 相关结构体(v5 新增) ​

struct SessionMeta with 17 elements    ← 会话元数据(17 字段)
struct InflightSnapshot with 3 elements ← 进行中快照
struct TurnRecord with 12 elements      ← 回合记录
struct ToolRecord with 4 elements       ← 工具调用记录
struct UsageRecord with 3 elements      ← 用量记录

3. Headless JSONL 结构化输出 ​

3.1 事件流(运行时验证) ​

--output-format jsonl
{"type":"run.started","schema_version":1,"provider":"AtomGit-deepseek-v4-flash","model":"deepseek",...}
{"type":"turn.completed","stop_reason":"ProviderError","exit_code":1,"duration_ms":1478,
 "rounds":0,"tool_calls":0,"total_tokens":0,...,"snapshot_error":null}

事件类型(版本化):

run.started / message.delta / tool.started / usage / turn.completed

3.2 辅助标志 ​

--ephemeral        不创建/恢复/写入会话状态(纯评测)
--no-tools         暴露空工具目录(纯模型评测)
--permission-mode  权限模式
--dangerously-skip-permissions

3.3 与 ACP v2 的关系 ​

JSONL 与 ACP 共用回合/会话内核 —— 一个是本地脚本消费的单向事件流,一个是远程客户端双向控制通道。


4. 逆向方法论备注 ​

  1. internally tagged enum ScopeArgWorkingTree 直接暴露范围三态枚举
  2. 四维度 lens 提示语是模板化注入(This review's lens: <DIMENSION>),可按维度枚举
  3. preflight 令牌机制(Opaque token from a preflight)是"大范围审查 → 用户确认"两阶段流程的核心证据
  4. 运行状态串(Deep review: N dimensions completed)提供状态机完备性校验

本报告由持续分析循环生成 — v5.0.9 Review Deep + 会话恢复 + Headless 深度分析

基于 VitePress 构建 · AtomCode v5.2.3 逆向工程分析文档