Repository navigation
RFC-0045: 上游测试迁移策略 - #281
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RoxcKU4zBD64Lri3e4Lrq5
15 of 27 tasks
Contributor
Author
|
有几处需要改。
另外,§2 的 409 个文件和 7,784 个用例能否附上统计脚本和统计范围?我用正则数行首的 |
…y script - Markers carry the full describe chain; each describe level is a Rust mod, and cases with identical chains get #2, #3. - A module aligned to a newer upstream than VERSIONS.json (decide at ai@7.0.128) sets `version` on its layout.toml entry. - `tests` is always a table; single-step and telemetry are decided by API name in the ai package, the other categories need a reason. - Drop the test-count check from section 7 (it belongs to RFC-0046). - Fixture list covers all 15 vendor packages, huggingface included. - scripts/aisdk-tests/inventory.mjs counts the cases at the pinned tags: 445 files, 8810 cases; section 2 is recomputed from it. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RoxcKU4zBD64Lri3e4Lrq5
Contributor
Author
|
六条都改了,统计脚本也附上了,见 a18f124。
初稿的 409 个文件、7784 个用例对不上,是因为取了
Generated by Claude Code |
3 tasks done
cunninghamcard-bit
marked this pull request as ready for review
October 20, 2026 03:00
Merged
3 tasks done
Internal-function tests go in foo/tests.rs (`mod tests;`), public-API tests in per-vendor directories under tests/, built as tests/it/main.rs; the shared mock fetch sits in the crate behind a test-only feature. Replaces the foo_test.rs and src/test_support/ wording, matching RFC-0044 and RFC-0046. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RoxcKU4zBD64Lri3e4Lrq5
Public-API tests sit in tests/it/<vendor>/, helpers in src/test_support/ behind the test-support feature; layout.toml is RFC-0046 §4.4 and test placement §5. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RoxcKU4zBD64Lri3e4Lrq5
This was referenced Oct 20, 2026
One Rust file per upstream test file, named after it, holding both the internal-function and the public-API cases, with fixtures and snapshots beside it. No foo/tests.rs directories and no tests/it/ program; the crate-level tests/ keeps only cross-vendor tests. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RoxcKU4zBD64Lri3e4Lrq5
6 of 12 tasks
Test PRs carry only tests and layout.toml and stack on the fix PR, following one PR one direction. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RoxcKU4zBD64Lri3e4Lrq5
eric8810
approved these changes
Oct 20, 2026
eric8810
left a comment
Contributor
There was a problem hiding this comment.
评审:RFC-0045 上游测试迁移策略 —— 批准
策略本身与既有规范体系一致且闭环完整,核验通过的关键点:
- "测试跟着代码走" 与 RFC-0036"设计齐备不等于实现完成"的纪律一致;未实现功能的测试不预迁、随实现 PR 带入——正确。
- 版本纪律:测试源按 VERSIONS.json 锁定 tag 取(发布包不带测试的细节处理正确);
decide@7.0.128的版本例外机制与 #255 已登记的 Decision 行为参照完全一致,且 check.mjs 强制 version ≥ 锁定版本、升级后删字段——闭环。 - 排除类别(自动 single-step/telemetry + 手写 ts-only/registered/sub-feature 各带理由/ref/issue)与对齐文档 Q1/D25/§5/§9.1 的既有决定一一对应,不允许 #[ignore]、修复与测试 PR 分离并叠放——与 ts-rust-port 纪律和当前 PR 波(#282–#291 fix、#295–#309 test)的实际形态吻合。
- 数字内部自洽:445=208+52+40+145,8810 各行可加总,1431=1327+104;core 缺口的 250–350 估算路径(746−26−310−87−多步漏网)可复核。inventory.mjs 按 tag 读 blobless clone 的实现与描述相符,单元测试已接入 CI(ci.yml 改动仅加一行)。
- 完成标准可判定:按文件×用例的全覆盖判定 + CI 校验(标记指向真实用例、唯一性、排除带理由)+ job summary 进度——不是数量清零目标,可执行。
两个观察项(不阻塞):
- 落地顺序:本 RFC 的机制面(layout.toml 的 status/tests/version 字段、§4/§5 的位置规则)依赖 RFC-0046(#294,Draft)与 RFC-0044(#279,Draft)。策略先行合并可接受(批 0 才接线),但请确认 0044/0046 会在批 0 执行前落地,避免 layout.toml 机制悬空。
- 445/8810 及 3000–3500 的统计数字无法在不克隆 vercel/ai 的情况下独立复核;鉴于其仅为估算基数、非门禁,接受声明值。check.mjs 在批 0 上线前的标记纪律属约定执行,已如实声明。
批准。三个 RFC(0044/0045/0046/0047)建议作为一组尽快齐落地。
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RoxcKU4zBD64Lri3e4Lrq5
Contributor
Author
|
谢谢评审。两个观察项的情况:
另外顺手改了两处与现行做法不一致的文字(提交 Generated by Claude Code |
This was referenced Oct 20, 2026
This was referenced Oct 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
新增
rfc/0045-upstream-test-parity.md(Draft)和它第 2 节用到的统计脚本scripts/aisdk-tests/inventory.mjs(附单测,挂在 CI 现有的 Node 脚本步骤里)。按
VERSIONS.json锁定的 18 个包、各自的 git tag 统计,上游有 445 个测试文件、8810 个用例,按用例名能在 aimux 里找到对应的 1475 个。上游很多功能我们没做,也不打算做,所以不能全迁。本文定迁移策略:single-step(对齐文档 Q1、D25)和telemetry在ai包里按 API 名自动判定;ts-only、registered、sub-feature每条手写一行理由。layout.toml,本文在条目上加tests表和可选的version。出处标记写完整describe链,每层describe对应一个 Rustmod。估计要补约 3000 到 3500 个用例,core 的
generate-text和stream-text占 250 到 350 个。测试体系概览(master
5743a40a)CI 怎么跑测试:
其中和上游对照的有两条路,cassette 回放对照的是 aimux 自己录下的历史响应,不是上游。
差分 fixture:先在 Node 里跑真实的
@ai-sdk/*,再在 Rust 里用同一份 JSON 回放比对。目前 29 个,覆盖 openai、openai-compatible、anthropic、google、provider-utils。手搬的上游单测:上游用例和 aimux 测试并排。
体系里目前没有一步把"上游有哪些用例"和"aimux 有哪些测试"对起来,所以上面这些测试全绿,并不说明上游用例覆盖到了哪里。
本 PR 的改动(细节)
本 PR 加 RFC 和统计脚本。RFC 在上面的体系里再加四样东西,下面是它规定的调用路径。
0. 统计上游用例(本 PR 的代码,RFC §2):
1. 选哪些上游用例(RFC §3.1、§3.2):
2. 搬来的测试(RFC §4、§5;位置按 RFC-0046 §5):
完整链也相同的 7 处,标记加
#2、#3,函数名加_2、_3。行为和上游不一致时,每处单独开一个 fix PR(带一个在 master 上失败的测试,登记到 #275 的 provider 偏差清单),测试 PR 叠在上面、只含测试和layout.toml;刻意的差异登记后记进registered。3. CI 校验(RFC §7,新增 job):
4. core 差分(RFC §6,新增):
厂商侧的差分 fixture 照现有
*_factory_test.rs的路径,补到还没有 fixture 的 11 个厂商包:amazon-bedrock、anthropic-aws、azure、cohere、deepseek、google-vertex、groq、huggingface、mistral、open-responses、xai。Type of change
Checklist
rfc/)node --test scripts/fetch-aisdk.test.mjs scripts/aisdk-fixtures/versions.test.mjs scripts/aisdk-tests/inventory.test.mjs本地通过(15 个)Notes for reviewers
telemetry类别由谁取消、差分覆盖能否替代逐条搬、上游快照里的随机值。layout.toml)和 RFC-0044(RFC-0044: crate 拆分与依赖反转 #279)。按本文迁的厂商测试 PR 已经在用这套位置和标记:Mistral test: port the upstream Mistral tests #295、Cohere test: port the upstream Cohere tests #296、DeepSeek test: port the upstream DeepSeek tests #299、Groq test: port the upstream Groq tests #301、Hugging Face test: port the upstream Hugging Face tests #303,每个带自己那家的layout.toml表;迁移中发现的行为差异各自一个 fix PR(fix: Hugging Face MCP calls are not dynamic #305–fix: DeepSeek usage counts must be numbers #309)。🤖 Generated with Claude Code
https://claude.ai/code/session_01RoxcKU4zBD64Lri3e4Lrq5