Skip to content

test: freeze the paused E2E dirs and the engine harness model helpers - #5385

Merged
RealKai42 merged 3 commits into
mainfrom
test/route-new-tests-to-e2e
Nov 25, 2026
Merged

RealKai42 merged 3 commits into
mainfrom
test/route-new-tests-to-e2e

Conversation

@RealKai42

@RealKai42 RealKai42 commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator

Requirement or Bug

#5386 已经把 tests/AGENTS.md 和 testkit 文档改成指向 tests/e2e。但说明文件拦不住改动:往已经停止自动运行的旧目录(apps/desktop/e2e/、apps/desktop/test/e2e/、apps/kimi-code/test/e2e/tui/)加用例,pnpm lint 照样通过,开放的 PR 里已经有这样的新用例。另外,引擎 harness 的 createMockProvider 一类函数不在旧假模型的冻结检查里,新测试直接调它们也能通过。

这个 PR 加两条 lint 检查,把这两件事拦住:新的用户可见用例只能写进 tests/e2e,新测试只能用 testkit 的假模型。

Bug Reproduction Steps

N/A

Root Cause

N/A

Code Changes

核心思路:两条检查都只冻结现状、只减不增。已有用例照常迁移和删除,新增会让 pnpm lint 失败,并在报错里指出该写到哪。

文件 改了什么
scripts/checks/legacy-e2e.mjs(新) 按文件冻结三个旧目录里的用例数,基线 66 个文件、101 条。用例按 test、it、testWithProvider 以及它们的 import ... as 和 .extend() 别名数,包括 .skip、.runIf(...) 这类修饰,不数 test.step、test.describe
scripts/checks/test-doubles.mjs 新规则 engine-mock-provider:数测试里对 createMockProvider、withMockProvider、fetchBackedProvider、createScriptedGenerate 的直接调用,基线记下现状(13 个文件、93 次);desktop-stub-model 的提示从旧 Desktop 夹具改成 tests/e2e
scripts/checks/ratchet.mjs 两个按文件计数的检查共用的三个函数:trackedFiles(列出受管文件)、runCountCheck(参数校验、比对或改写基线、输出)、reportChanges(把变化分成新增和减少)。test-doubles.mjs 改用它们,输出逐字不变
package.json、scripts/checks/registry.json 把 legacy-e2e.mjs 接进 pnpm lint,并在 guards 的接线表里登记
tests/AGENTS.md 在 #5386 的文字上补两句:旧目录那条规则后面写明由 legacy-e2e.mjs 检查;「什么时候用 testkit」写明假模型只用 testkit,列出 test-doubles.mjs 能识别的旧写法,以及 createMockProviderRequester 这个例外
AGENTS.md 跨层故障的例子从 klient 一致性测试、pi-tui 虚拟终端,改成 tests/scenarios(KAP)和 tests/e2e(用户看得到的行为)

关键决策:

决策 选择 没选 理由
怎么冻结旧目录 按文件冻结用例数,只减不增 禁止改动这三个目录 迁移和删除还要改这些文件,旧夹具也可能要跟着动
createMockProviderRequester 算不算旧假模型 不算,loop core 这类只需要一个 requester 的单元测试可以继续用 一起冻结 它只在 requester 这一层放替身,返回的是 requester,接不进 agent;用它的都是 test/agent/loop/core/、toolAdapter、machineTools 这类单元测试。驱动 agent 的写法(createMockProvider 等)照样冻结
搬动或改名旧用例时 沿用 test-doubles.mjs 的退路:--update --allow-increase,并在 PR 里写明 维护一张例外表 两个检查用同一套基线机制,评审看基线 diff 就够了

Behavior Changes and Affected Users

Behavior Before After Who relies on the old behavior Escape hatch
往 apps/desktop/e2e/、apps/desktop/test/e2e/、apps/kimi-code/test/e2e/tui/ 加用例 pnpm lint 通过 pnpm lint 失败,提示写进 tests/e2e 正在往这些目录加用例的开放 PR 只是搬动或改名时,node scripts/checks/legacy-e2e.mjs --update --allow-increase,并在 PR 里写明
测试里新增对 createMockProvider、withMockProvider、fetchBackedProvider、createScriptedGenerate 的调用 pnpm lint 通过 pnpm lint 失败,提示改用 testkit 正在新增这类调用的开放 PR node scripts/checks/test-doubles.mjs --update --allow-increase,并在 PR 里写明
根 AGENTS.md 里跨层故障的例子 klient 一致性测试、pi-tui 虚拟终端 tests/scenarios、tests/e2e 每个会话都会读根 AGENTS.md 的 agent —

产品代码没有改动。已有用例和已有调用都记进了基线,所以现有测试不会因为这个 PR 失败。

测试覆盖:

  • scripts/checks/legacy-e2e.test.mjs:哪些文件算旧目录;别名和修饰的计数;新增用例的报错指向 tests/e2e;减少用例时要求降基线。
  • scripts/checks/test-doubles.test.mjs:新增三条,覆盖 engine-mock-provider 的计数(只数调用,不数 import 和类型引用)、createMockProviderRequester 不计数、desktop-stub-model 的新提示。改动前的检查上,计数和新提示两条会失败。
  • scripts/checks/ratchet.test.mjs:新增三条,覆盖 runCountCheck 的参数校验、失败、改写基线,trackedFiles 对已跟踪、未跟踪、忽略文件和路径范围的处理,以及 reportChanges。
验证
  • pnpm lint:通过。
  • node --test 'scripts/checks/*.test.mjs':98 条通过。
  • pnpm run check:duplication <main>:没有新增重复。
  • test-doubles.mjs 的报告输出:用 main 上的旧实现和新实现对同一组变化各跑一遍,结果逐字相同。

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.

tests/AGENTS.md and the testkit docs still sent new cases to the Desktop
and TUI E2E directories that stopped running automatically, and tests
could call the engine harness provider helpers without the test-doubles
check noticing.

- Point tests/AGENTS.md, the testkit docs and the root AGENTS.md at
  tests/e2e and tests/scenarios, and state that fake models come from
  the testkit.
- Add legacy-e2e.mjs to pnpm lint: it freezes the test cases in the
  three paused directories per file.
- Add the engine-mock-provider rule to test-doubles.mjs; requester-level
  loop-core unit tests may keep createMockProviderRequester.
- Share the file listing, baseline handling and report split of both
  count checks through ratchet.mjs.
@changeset-bot

changeset-bot Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 5034bc7

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 25, 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-25T07:23:24.530416Z 5034bc7 New commits
🔒 Security Review ✅ Completed 2026-11-25T05:30:34.550871Z 5347466 PR opened
ℹ️ 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.

@pkg-pr-new

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

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

commit: 8e583c5

#5386 rewrote tests/AGENTS.md and the testkit docs on main. Keep its
text for tests/AGENTS.md, docs/model.md and docs/fixtures.md, and add
only the two sentences that name legacy-e2e.mjs and test-doubles.mjs.
Drop this branch's testkit README link change, since #5386 kept the
model.md heading it points to.
@RealKai42 RealKai42 changed the title test: route new tests to tests/e2e and freeze the paused E2E directories test: freeze the paused E2E dirs and the engine harness model helpers Nov 25, 2026
@RealKai42

Copy link
Copy Markdown
Collaborator Author

@codex

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

Reviewed commit: 8e583c54a0

ℹ️ 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".

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

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

)

The e2e-turn, skills and lifecycle tests scripted the model through
test/_helpers/scriptedProvider.ts, which imported the agent-core-v2 test
harness, skipped protocol encoding and never failed on a script that
did not match the requests.

- Start a testkit fake model per test, point the fake model config at
  it, and verify the script after each test. Delete scriptedProvider.ts.
- Raise the fake model context window from 8192 to 262144. With real
  usage estimates the engine compacted after the first tool step and
  sent a request no script covered; the old helper reported near-zero
  usage and answered that request with a silent error.
- Check the streamed tool-call cards against the ACP contract (empty
  pending card, cumulative arguments, started, completed) instead of
  the old helper's split point.
- Let an unscripted request hang in the cancel-during-launch test, and
  drop the decoy reply from the unknown slash command test.
- Lower the test-doubles baseline for acp-server.
@RealKai42
RealKai42 merged commit 9c9b354 into main Nov 25, 2026
15 checks passed
@RealKai42
RealKai42 deleted the test/route-new-tests-to-e2e branch November 25, 2026 07:20
7723qqq pushed a commit to 7723qqq/kimi-code that referenced this pull request Nov 25, 2026
Port the testkit half of MoonshotAI#5380: UNIT_TEST_SWITCHES names the defaults that
exist only to speed unit tests, TEST_ENV_DEFAULTS spreads them, and the
fixtures test pins that setting each name to undefined restores product
defaults while telemetry isolation stays on.

Ledger: MoonshotAI#5373, MoonshotAI#5389, MoonshotAI#5431 and MoonshotAI#5423 are not-applicable because the
tests/e2e Playwright suite and its workflow do not exist here. MoonshotAI#5380 is
partial (testkit half landed), and MoonshotAI#5385 is partial: its ACP fake-model
migration remains for the testkit wave while the legacy-e2e freeze does
not apply.
7723qqq pushed a commit to 7723qqq/kimi-code that referenced this pull request Nov 25, 2026
Port the applicable part of MoonshotAI#5385: the skills and lifecycle suites boot a
testkit fake model, verify its script and close it per test; the fake model
config helper gains baseUrl and maxContextSize options so the old e2e-turn
suite keeps its 8192 window while these suites use 262144.

Verified: skills 12 pass, lifecycle 29 pass, acp-server typecheck clean.
The e2e-turn suite remains on scriptedProvider because it also migrates to
the ToolUpdated event; its parked-approval and terminal cases fail at HEAD
with the original helper.
7723qqq pushed a commit to 7723qqq/kimi-code that referenced this pull request Nov 26, 2026
Record the attempted testkit fake-model migration for MoonshotAI#5404/MoonshotAI#5385: the plan-review cases pass, but ToolUpdated field propagation, /usage context size, /compact scripting and the two terminal reverse-RPC cases need a dedicated test-engine update, so the suite stays on scriptedProvider.
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.

1 participant