Repository navigation
refactor: move the Google files to the upstream layout - #367
Merged
eric8810 merged 10 commits intoOct 27, 2026
Merged
Conversation
Split src/google/ into one file per @ai-sdk/google 4.0.87 source file (RFC-0046 §4.2), with transcription/ as upstream. Function bodies only change paths and visibility; the crate-root and google-root exports are unchanged, and the sub-modules that were public are listed in the CHANGELOG. The old tests/google_*_test.rs programs and the inline utils test move into src/google/tests/ with equal test names and counts. The files tests use a wiremock server of their own: the abort case drops the client mid-request, and a request landing after the test ended reached the next test that took the pooled server once all tests share one binary. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0116HPMoqaLfFr1TyqDq1hrW
34 of 57 tasks
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0116HPMoqaLfFr1TyqDq1hrW
eric8810
approved these changes
Oct 25, 2026
eric8810
left a comment
Contributor
There was a problem hiding this comment.
Google layout refactor:584→584 tests,move-only,公开 re-export 保留;仅需修正 audit 文档里指向已删除 google_files_test.rs 的链接。Approve。
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0116HPMoqaLfFr1TyqDq1hrW
Contributor
Author
Generated by Claude Code |
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0116HPMoqaLfFr1TyqDq1hrW
…sts' into refactor/move-the-google-files-to-the-upstream-layout Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0116HPMoqaLfFr1TyqDq1hrW
…sts' into refactor/move-the-google-files-to-the-upstream-layout Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0116HPMoqaLfFr1TyqDq1hrW
…sts' into refactor/move-the-google-files-to-the-upstream-layout Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0116HPMoqaLfFr1TyqDq1hrW
…sts' into refactor/move-the-google-files-to-the-upstream-layout Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0116HPMoqaLfFr1TyqDq1hrW
…sts' into refactor/move-the-google-files-to-the-upstream-layout Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0116HPMoqaLfFr1TyqDq1hrW
eric8810
approved these changes
Oct 27, 2026
eric8810
left a comment
Contributor
There was a problem hiding this comment.
Verified the post-approval commits on this head: only additive tests/docs or tightened boundary checks; no weakening or behavior regression. Re-approving the current head.
…sts' into refactor/move-the-google-files-to-the-upstream-layout Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0116HPMoqaLfFr1TyqDq1hrW
eric8810
changed the base branch from
test/port-the-upstream-google-tests
to
master
October 27, 2026 04:37
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
把
src/google/按@ai-sdk/google一个文件对一个文件重排(RFC-0046 §4.2),照上游建transcription/子目录。九个老测试程序和utils.rs里的内联测试并进厂商测试目录src/google/tests/(RFC-0046 §5)。函数体只改了路径和可见性。crate 根和google模块根的再导出不变;google下有公开模块路径变了,列在“公开路径”一节。测试数量和函数名前后一致;tests/files.rs的 mock 服务器改成不走 wiremock 的池(见“共享进程状态”)。叠在测试 PR #363 上。实施进度在 #328 跟踪。已经测试分支
b49a3ba3合上 masterb69137eb,冲突按 master 的改动搬到新位置解决(convert.rs的改动落到language_model.rs、language_model_options.rs,speech、transcription 的改动落到各自的模型和 options 文件以及get_realtime_base_url.rs,老测试程序里的错误模式改成结构体变体);测试数前后仍相等(584 个:lib 569 个加留在tests/的 15 个,名字多重集相同)。一、体系现状(概览,测试 PR #363 头
54e6fd31)上游同一条路:
createGoogle(google-provider.ts)建GoogleLanguageModel(google-language-model.ts,getArgs、doGenerate、doStream和流的解析都在这个文件)、GoogleEmbeddingModel、GoogleImageModel、GoogleVideoModel、GoogleSpeechModel、transcription/下的GoogleTranscriptionModel、GoogleFiles;提示词转换、工具准备、能力表、schema 清理、finish reason、usage、错误、API 类型、选项 schema、JSON 累加器各在自己的文件。aimux 把这些放在 11 个文件里:mod.rs(provider、设置、错误处理、模型列表)、model.rs、convert.rs(提示词转换、工具、能力表、schema 清理、getArgs、选项校验、finish reason、usage、sources)、types.rs(API 类型和错误信封)、utils.rs(get_model_path、is_supported_file_url、GoogleJsonAccumulator)、embedding.rs、image.rs、video.rs、speech.rs、transcription.rs、files.rs,加上 aimux 自己的options.rs。测试:#363 的新用例在
src/google/tests/(google::下 439 个,含utils.rs的 1 个内联测试);老用例在九个独立测试程序里:tests/google_embedding_test.rs(7)、tests/google_evaluation_test.rs(7)、tests/google_factory_test.rs(6)、tests/google_files_test.rs(17)、tests/google_image_test.rs(20)、tests/google_speech_test.rs(40)、tests/google_transcription_test.rs(16)、tests/google_upstream_e2e_test.rs(13)、tests/google_video_test.rs(4)。二、本 PR 改动(细节)
mod.rs的模块文档、mod、pub usemod.rs(只有模块声明和导出)index.ts、internal/index.tsmod.rs的常量、EXTERNAL_URL_MEDIA_TYPES、supported_urls、GoogleProviderSettings、create_google、google、GoogleProvider和Provider/ProviderDiscovery实现、list_models_onceprovider.rsgoogle-provider.ts(list_models_once是 aimux 的模型发现,跟 provider 放一起)mod.rs的google_stream_error、google_failed_response_handler;types.rs的GoogleErrorEnvelope、GoogleErrorerror.rsgoogle-error.tstypes.rs其余api_types.rsgoogle-api-types.ts(RFC-0046 §4.2:zod 响应 schema 放在 api_types)model.rs;convert.rs的build_vertex_request_body、build_request_body_with_warnings*、validate_call_options*、validate_file_part、resolve_thinking、code_execution_tool_name、extract_sourceslanguage_model.rsgoogle-language-model.ts(getArgs、extractSources都在这个文件)convert.rs里validate_call_options_for_namespace的 providerOptions 校验(原 :1430 起)language_model_options.rs的validate_provider_optionsgoogle-language-model-options.ts(上游 zod schema 的手写校验)convert.rs的提示词转换、contains_schema_referenceconvert_to_messages.rsconvert-to-google-generative-ai-messages.tsconvert.rs的GooglePromptprompt.rsgoogle-generative-ai-prompt.tsconvert.rs的prepare_tools、prepare_all_tools、build_function_declarationprepare_tools.rsgoogle-prepare-tools.tsconvert.rs的GoogleModelCapabilities、get_google_model_capabilitiesmodel_capabilities.rsgoogle-model-capabilities.tsconvert.rs的sanitize_response_json_schemasanitize_response_json_schema.rssanitize-response-json-schema.tsconvert.rs的parse_finish_reasonmap_finish_reason.rsmap-google-generative-ai-finish-reason.tsconvert.rs的convert_usageconvert_usage.rsconvert-google-generative-ai-usage.tsutils.rs的get_model_path/is_supported_file_url/GoogleJsonAccumulatorget_model_path.rs/supported_file_url.rs/json_accumulator.rsget-model-path.ts/google-supported-file-url.ts/google-json-accumulator.tsembedding.rs、video.rsembedding_model.rs、video_model.rs(原样)google-embedding-model.ts、google-video-model.ts(它们的*-options.ts/*-settings.ts在 aimux 里没有单独的内容,留在模型文件里)image.rs的GoogleImageSettings/ 其余image_settings.rs/image_model.rsgoogle-image-settings.ts/google-image-model.tsspeech.rs的选项结构和parse_options/GoogleSpeechInput、google_speech_input/ 响应结构 / 其余speech_model_options.rs/speech_input.rs/speech_api.rs/speech_model.rsgoogle-speech-model-options.ts/google-speech-input.ts/google-speech-api.ts/google-speech-model.tstranscription.rs的live_web_socket_urlget_realtime_base_url.rs(cfg(feature = "realtime"))get-realtime-base-url.tstranscription.rs的TranscriptionOptions、parse_offset_seconds/ 其余transcription/transcription_model_options.rs/transcription/transcription_model.rstranscription/google-transcription-model-options.ts/transcription/google-transcription-model.tsfiles.rsgoogle-files.tsoptions.rsgoogle::embedding、google::image、google::speech、google::video不再公开;GoogleEmbeddingModel、GoogleImageModel、GoogleImageSettings、GoogleSpeechModel、GoogleVideoModel仍可从google::和 crate 根拿到。google::convert、google::types、google::utils不再公开:convert_to_google_messages、build_request_body、build_request_body_with_warnings、prepare_tools、prepare_all_tools、get_google_model_capabilities、sanitize_response_json_schema、parse_finish_reason、convert_usage、extract_sources、响应类型、get_model_path、is_supported_file_url、GoogleJsonAccumulator变成 crate 内部,没有公开的替代。speech::google_speech_input同样变成 crate 内部。convert::convert_to_google_messages、convert::build_request_body删掉了(模块不公开后它们是死代码;文档合到convert_to_google_messages_for_namespace、build_request_body_with_warnings上)。只有测试用的get_model_path、is_supported_file_url现在是#[cfg(test)] pub(super)(aimux 的请求路径不调用上游的getModelPath);ProcessResult.current_json只有测试读,按 xai 的先例加了cfg_attr(not(test), allow(dead_code, reason = …))。google::files、google::transcription照旧公开,google::transcription::GoogleTranscriptionModel照旧。google::convert::build_vertex_request_body由mod.rs的pub(crate) use language_model as convert;接住,google_failed_response_handler由pub(crate) use error::google_failed_response_handler;导出,default_providers.rs的API_KEY_ENV_VAR/DEFAULT_BASE_URL和 Vertex 的list_models_once由pub(crate) use provider::{…}导出,google::options::*不动,Vertex 转写用的TranscriptionOptions、parse_offset_seconds、live_stream、validate_live_input_audio_format由transcription/mod.rs的pub(crate) use导出。src/vertex/一个文件都没改,Vertex 自己的搬移 PR 因此不会和这里在 import 上冲突。pub(super):matches_prefix_boundary、speech_api.rs和speech_model_options.rs的结构体及字段、parse_options、live_web_socket_url、interactions_config、validate_provider_options;language_model模块改为pub(crate)(给convert别名用),其余新模块私有。transcription_model.rs里的super::改成crate::google::(多了一层目录)。older_*模块里:tests/google_embedding_test.rs→tests/embedding_model.rs的older_embedding;google_evaluation_test.rs→tests/evaluation.rs的older_evaluation;google_factory_test.rs→tests/provider.rs的older_factory;google_files_test.rs→tests/files.rs的older_files;google_image_test.rs→tests/image_model.rs的older_image;google_transcription_test.rs→tests/transcription/transcription_model.rs的older_transcription;google_upstream_e2e_test.rs→tests/language_model.rs的older_upstream_e2e;google_video_test.rs→tests/video_model.rs的older_video。google_speech_test.rs按它的上游来源拆:getGoogleSpeechInput那节 7 个进tests/speech_input.rs的older_speech_input,其余 33 个进tests/speech_model.rs的older_speech。utils.rs的内联测试进tests/json_accumulator.rs的older_utils。mock_fetch改用crate::test_support::mock_fetch,aimux_providers::改成crate::。test: port the upstream Google tests #363 测试里的convert::、types::、utils::、speech::import 改到新路径。断言都没改。tests/的:tests/google_pse_test.rs(另一个厂商)、tests/google_vertex_image_test.rs(Vertex 的)和其余跨厂商的测试程序。layout.toml的[google]29 个rust字段改到新路径,两条 reason 里的google/convert.rs、google/transcription.rs改成google/prepare_tools.rs、google/transcription/transcription_model.rs。scripts/check_provider_boundaries.sh不用改,照样通过。共享进程状态:老测试原来各是单独的测试程序,现在和 #363 的用例同在 lib 的一个测试程序里。
older_files/older_image的用例在received_requests里多看到一个 1 字节的上传请求。原因是 test: port the upstream Google tests #363 的tests/files.rs的should_reject_promptly_when_aborted_during_the_polling_delay在请求途中丢掉客户端,create_mock_files用的是 wiremock 池里的服务器(MockServer::start()),晚到的请求落在已经还回池、又被下一个用例拿走的服务器上。修法是改那个泄漏的 setup:create_mock_files(tests/files.rs:142)改用MockServer::builder().start(),自己一个不进池的服务器,加了注释说明。改后 32 线程连跑 100 次(60 + 40)没有再出现。用例本身没改,没加#[serial]。GOOGLE_GENERATIVE_AI_API_KEY,Google 也没有 base URL 的环境变量,没有相互影响。没有全局计数器,没有换进程默认 transport 的用例;fixture 路径按CARGO_MANIFEST_DIR算,位置不影响。CHANGELOG
CHANGELOG Unreleased 的 Breaking 末尾加了一条,列出本家变了的公开子模块路径和替代入口(RFC-0046 §4.5 第 2 条):
验证
cargo test -p aimux-providers --lib加原来九个--test:前后都是 710 个测试(前 lib 580 + 130,后 lib 710),函数名多重集相同;google::下 439 → 569。改了create_mock_files之后 lib 测试程序默认线程连跑 20 次、32 线程连跑 100 次,710 个全过。cargo +1.99 clippy -p aimux-providers --lib --tests -- -D warnings、cargo +1.99 check -p aimux-providers --lib --tests --all-features、RUSTDOCFLAGS="-D warnings" cargo +1.99 doc -p aimux-providers --no-deps、cargo fmt --all -- --check、scripts/check_provider_boundaries.sh、cargo +1.99 check --workspace、cargo test -p aimux-providers(2817 过,5 ignored)通过。--no-default-features下有一条LIVE_WEB_SOCKET_PATH is never used的警告,test: port the upstream Google tests #363 上就有,没动。Type of change
Checklist
https://claude.ai/code/session_0116HPMoqaLfFr1TyqDq1hrW
Generated by Claude Code