Skip to content

revert: remove experimental auto review - #5649

Merged
7Sageer merged 2 commits into
mainfrom
revert/auto-review-4655
Nov 27, 2026
Merged

7Sageer merged 2 commits into
mainfrom
revert/auto-review-4655

Conversation

@7Sageer

@7Sageer 7Sageer commented Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator

Requirement or Bug

回退 #4655(14affd12d5)引入的实验特性 Auto Review。该特性默认关闭,尚未进入正式版(仅出现在 canary 构建中)。回退后权限判断恢复为单一静态策略链,Bash 与 MCP 调用不再发送给独立模型复核。

Bug Reproduction Steps

N/A

Root Cause

N/A

Code Changes

核心思路:基于最新 main(87058b9085)对 14affd12d5 执行 revert。未被后续提交触碰的文件逐字节恢复到 #4655 之前;之后被其他提交改过的重叠文件只摘除 Auto Review 片段,保留后续演进。

flowchart TD
    A["工具调用进入权限门"] --> B["PermissionPolicy.evaluate(context) 按当前模式求值"]
    B --> C{"静态策略结果"}
    C -- "ask" --> D["沿用两阶段审批询问用户"]
    C -- "approve" --> E["直接放行"]
    C -- "deny" --> F["返回否决结果"]
Loading

删除 features/autoReview/ 整个目录及 useAutoReviewHint;权限门移除 registerReviewer 钩子,恢复原有的两阶段 permitting 处理(以及 #4655 删除前同样无生产调用方的 authorize() 接口);PermissionPolicy.evaluate 恢复只按当前模式求值,非交互宿主恢复在构造期跳过危险命令策略。KAP、SDK、TUI、Desktop/Web、VS Code、ACP、vis 与双语文档中的 auto_review / approval_detail 字段、事件与展示同步移除,并重新生成 config-manifest.toml、state-manifest.d.ts、wire-manifest.d.ts 与 KAP schema。

关键决策

决策 选择 没选 理由
resolveMaxOutputTokens 保留在 provider-catalog/model/completion-budget.ts 随 #4655 一并删除 #5541 已让主循环、压缩和提示预测复用它
scripted-generate.ts 的错误分支 保留 isError2(error) 恢复 !(error instanceof ChatProviderError) ChatProviderError 继承 Error2,旧判断会让 mock provider 错误无法直接抛出
kap-server/src/protocol/interaction.ts 保留共享的 approvalInteractionRequestSchema(删除 approval_detail) 恢复两段内联 z.object 避免把旧重复带回代码库,生成的 OpenAPI 契约完全一致
GenericTool.vue 的 empty-text 提取为 emptyText computed(与 BrowserToolDetails.vue 一致) 保持模板内联三元表达式 规避 jscpd 对 .vue <template #body> 倒置行号产生的空串指纹碰撞,渲染行为不变
后续重构过的文件(loopService.ts、openapi.json、app-components、externalHooks 测试) 保留新结构,仅移除 Auto Review 片段 整体恢复到 #4655 之前 避免误回退 #5478(压缩失败记录)、#5541(provider-catalog)、#5549(去自包 barrel 导入)、#5537(审批反馈样式)、#5621(OpenAPI $ref)
lint 棘轮基线 保持 main 不变,修掉回退带回的 .sort() 和未使用导入 调高 oxlint-ratchet.json 遵守不抬高棘轮基线的约束

阅读指南:packages/agent-core-v2/src/agent/permissionGate/ 与 permissionPolicy/(恢复静态策略链与构造期危险命令开关)→ packages/kap-server/src/protocol/(协议字段移除)。其余为 features/autoReview/ 整体删除、各端字段/事件透传与展示代码的对应删除,以及重新生成的 manifest / schema,可略读。

Behavior Changes and Affected Users

Behavior Before After Who relies on the old behavior Escape hatch
默认配置(未开启实验) 不发复核请求、不写快照,按静态策略审批 不变 所有未开启 Auto Review 的用户 —
开启实验时 yolo / auto(含 kimi -p)下的 Bash 与 MCP 调用 先交独立模型复核;deny/失败在 yolo 转人工、auto 返回工具错误 不再复核,直接按 #4655 之前的静态权限策略执行或询问 canary 中通过 KIMI_CODE_EXPERIMENTAL_AUTO_REVIEW=1、KIMI_CODE_EXPERIMENTAL_FLAG=1 或 [experimental] auto_review = true 开启实验的 TUI、print、headless、Tower、SDK 用户 无(实验特性整体移除,请维护者确认)
[auto_review] 配置节、[experimental] auto_review、KIMI_CODE_EXPERIMENTAL_AUTO_REVIEW 生效并校验模型、effort、timeout_ms 不再识别;残留的 [auto_review] 节按未知配置节产生 warning 诊断并忽略,不阻断启动 配置了上述键的 canary 用户 从配置与环境变量中移除这些键
KAP tool_call.auto_review 字段、approval_detail 字段与 auto_review.* WS 事件 实验开启时下发 不再下发;均为可选字段/增量事件,HOST_API_LEVEL 保持 1 消费这两个字段的 KAP 外部 Agent、机器人与自定义界面,以及 @moonshot-ai/klient 调用方 无
工具卡片与审批弹窗的复核提示 复核满 3 秒显示 Reviewing…,复核拒绝/失败时在审批卡片显示标题与理由 不再显示 canary 中开启实验的 TUI、desktop/web、VS Code、ACP(如 Zed)用户 无
canary 写入的含 auto_review.* wire 记录与 autoReview.* 状态的会话 回放复核状态与祖先授权快照 跳过未知记录与状态 key,会话对话历史仍可正常恢复 恢复 canary 会话的用户 无需操作
遥测事件 auto_review_decision 复核结束时上报 不再产生 分析该事件的遥测查询 —
[secondary_model].default_effort 校验 与 Auto Review 共用校验函数 恢复内联校验,校验规则与报错文案同 #4655 之前 配置 [secondary_model] 的用户(无行为变化) —
SDK 导出(@moonshot-ai/kimi-code-sdk、@moonshot-ai/agent-core-v2) 导出 Auto Review 事件类型、ApprovalReviewDetail、formatApprovalReviewTitle 移除上述导出 在 canary 版本中使用这些类型的 SDK 调用方 移除对这些类型的引用

受影响模块与测试覆盖:

  • 权限门与静态策略链:permissionGate.test.ts、permissionPolicyService.test.ts、toolExecutor.test.ts、externalHooks/integration.test.ts(默认路径与危险命令/非交互分支)。
  • 配置与状态:configManifest.test.ts、stateManifest.test.ts、subagent/configSection 与 forkParity.test.ts([secondary_model] 校验与 manifest 同步)。
  • KAP / SDK / ACP:apiSurface.test.ts(schema 与 HOST_CONTRACT 摘要已更新,apiLevel 保持 1)、sessions.test.ts、conversation.test.ts、klient/test、node-sdk/test、acp-server/test。
  • TUI / Desktop / 场景:approval-panel.test.ts、kimi-tui-message-flow.test.ts、transcript-projection.test.ts、app-components/test/genericTool.test.ts、app-core/test、tests/scenarios。

验证结论:在 Linux(Node 24,16 vCPU)跑通整仓 pnpm lint(0 errors / 0 warnings,棘轮无新增)、整仓 pnpm typecheck,以及受影响的 473 个测试文件、8662 个用例(含上述全部模块)。未验证:Windows、macOS 桌面端专项。

验证明细与两项需维护者知悉的环境/工具问题
  1. 沙盒中 4 个未触碰的测试文件超时(已证实为基线既有问题,未在本 PR 修改):

    • packages/app-components/test/composerMenuViewportClamp.test.ts
    • packages/app-client/test/actionToastDismiss.test.ts
    • packages/app-client/test/exportToastFacade.test.ts
    • packages/app-client/test/session-observation-integration.test.ts
      在同一 Linux 环境中对未改动的 main 运行这 4 个文件,出现完全相同的 5s/10s 超时,与本次 revert 无关。本次改动涉及的所有测试文件均通过。
  2. check:duplication 的 jscpd 空串指纹碰撞及规避方式(已通过,无需豁免):
    纯 revert 状态下 pnpm run check:duplication origin/main 会把未改动的 GoalTool.vue:19 与 GrepTool.vue:57(60 tokens)误报为新增重复。根因是 [email protected] 的基线指纹算法缺陷(baseline.rs / shared.rs):

    • .vue 内嵌 HTML 扫描对 <template #body> 起始处记录的 start.line > end.line(如 19 -> 16、48 -> 33),extract_lines 用 saturating_sub 计算出长度 0,导致这类克隆的文本切片全为空串,指纹全部退化为同一个 snippet_pair_hash("", "")。
    • main 基线中有 2 个此类空指纹(BackgroundTaskTool<->CronTool、GoalTool<->GrepTool)。回退移除 GenericTool.vue 中的 reviewHint 分支后,GenericTool<->WaitForTool 成为第 3 个空指纹克隆,超出 mark_new 的 multiplicity 计数。
      本 PR 未改动 GoalTool.vue、GrepTool.vue、WaitForTool.vue 等无关组件,而是将 GenericTool.vue 的 :empty-text 三元表达式提取为 emptyText computed(+3/-1 行,与 BrowserToolDetails.vue 写法一致,渲染行为完全不变),消除与 WaitForTool.vue 的 61-token 空指纹对齐,check:duplication 已验证 0 退出通过。jscpd 的 .vue 行号倒置问题可后续单独修复。

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue (external PRs: issue must have a maintainer's /approve).
  • I have added tests that prove my feature works.
  • The behavior-change table above is complete, and every removed behavior or flipped default is named in the changeset and either has an escape hatch or was explicitly approved by a maintainer in this PR.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

@changeset-bot

changeset-bot Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: cd2ae91

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 8 packages
Name Type
@moonshot-ai/kimi-code Patch
@moonshot-ai/agent-core-v2 Patch
kimi-code-app Patch
@moonshot-ai/kap-server Patch
@moonshot-ai/klient Patch
@moonshot-ai/kimi-code-sdk Patch
@moonshot-ai/acp-server Patch
kimi-code Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-27T10:02:22.330437Z cd2ae91 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@7Hanrui

7Hanrui commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

Reviewed commit: 7d85de1790

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@7Sageer
7Sageer force-pushed the revert/auto-review-4655 branch from 7d85de1 to 682737a Compare November 27, 2026 09:49
@7Hanrui

7Hanrui commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

@codex review

@pkg-pr-new

pkg-pr-new Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@cd2ae91
npx https://pkg.pr.new/@moonshot-ai/kimi-code@cd2ae91

commit: cd2ae91

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: 682737a204

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@7Hanrui

7Hanrui commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

Reviewed commit: cd2ae91ed0

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@7Sageer
7Sageer merged commit da8bdbb into main Nov 27, 2026
24 checks passed
@7Sageer
7Sageer deleted the revert/auto-review-4655 branch November 27, 2026 10:07
7723qqq pushed a commit to 7723qqq/kimi-code that referenced this pull request Dec 2, 2026
`bun scripts/upstream-ledger.mjs --refresh` at upstream/main 4eb2919
added 126 rows, so every open upstream commit and every PR it references
now has a ledger row: 0/596, down from 125 at 8bf8ba3 and 126 at the
fetched tip. The refresh only reads `upstream/main ^ main`, so the three
release-2.6.2 commits named by the mission (MoonshotAI#4875/MoonshotAI#4905/MoonshotAI#4922) gained
rows with the refresh's row shape.

Settled with live probes in this tree:

- ported: MoonshotAI#5533 (docs 2.8.1 changelog), MoonshotAI#4875 (registry search_url and
  feedback_url plus the feedback service), MoonshotAI#4905 (Kimi upload status
  validation in packages/core), MoonshotAI#4922 (swarm task events in
  sessionTaskFeed), MoonshotAI#5438 (unload only declared dynamic tools), MoonshotAI#5592
  (dynamic tool replacement order), MoonshotAI#5595 (append-log known length),
  MoonshotAI#5573 (skill roots for every work dir), MoonshotAI#5576 (date reminder cwd
  comparison), MoonshotAI#5618 (session titles for skill openers), MoonshotAI#5638 (frozen
  loop tool baseline), MoonshotAI#5626 (legacy turn-input origins)
- partial: MoonshotAI#5505 (processLiveness source and consumers present; the
  upstream unit test file was never carried), MoonshotAI#5571 (program-resume and
  OSC 7577 present; the upstream test helper was never carried), MoonshotAI#5532
  (gitService half present; fsService still leaks the environment lease
  at fsService.ts:1133 and :1267), MoonshotAI#5557 (app-client icon registry kept;
  the move to app-ui was never carried)
- not-applicable: MoonshotAI#4655 (upstream reverted auto review in MoonshotAI#5649), MoonshotAI#5333
  (PLAYBOOK:111 deliberate flat experimental flags)

M39's "likely present" list was checked, not trusted: MoonshotAI#5438 is present
(upstream test passes), MoonshotAI#5487 is not (nativeStartSettleMs/leg.nativeSettled
absent), MoonshotAI#5635 is not (ToolsSettled absent), MoonshotAI#5429 needs a visual probe.
The remaining 194 pending rows stay open with their reasons; no feature
was ported and no upstream-drift allowlist entry was added.

Verification: verify -> 332 closed rows, 332 carry every file of their
PR; 317 probes pass, 2 foreign-runner skips, 0 fail; a second verify is
byte-identical (ledger sha256 cbf53638...). Probe tests 29 pass; bun run
lint and node scripts/checks/ratchet.mjs green.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants