Repository navigation
Conversation
Split src/bedrock/ into one Rust file per source file of @ai-sdk/amazon-bedrock 5.0.100 (RFC-0046 §4.2): provider.rs (settings, create_amazon_bedrock and the provider), sigv4_fetch.rs (the API key or SigV4 decision, credential loading and the regional base URL), chat_language_model.rs and its options, convert_to_chat_messages.rs, prepare_tools.rs, anthropic_model_support.rs, convert_usage.rs, map_finish_reason.rs, normalize_tool_call_id.rs, error.rs, event_stream_decoder.rs, event_stream_response_handler.rs, api_types.rs, embedding_model.rs and its options, image_model.rs, and reranking/ with the API, options and model files. Function bodies change only in paths and visibility. The bedrock root re-exports are unchanged; the public modules convert, embedding and image are now private, and event_stream is renamed event_stream_decoder. Fold tests/amazon_bedrock_image_test.rs, tests/bedrock_convert_test.rs, tests/bedrock_embedding_test.rs, tests/bedrock_remaining_test.rs, tests/bedrock_upstream_e2e_test.rs and the inline unit tests of event_stream.rs into src/bedrock/tests/ without changing assertions. The cassette replay and the cross-vendor user-agent tests stay in tests/. Eighteen tests now run #[serial]: the wiremock image and embedding tests and one OpenAI-compatible wiremock test use the process default transport, which a moved test swaps, and two provider tests read the endpoint variables that the provider tests set. Point layout.toml at the new paths, and let boundary rules 7 and 7b accept the provider_from_env_* test names and bedrock::sigv4_fetch. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0116HPMoqaLfFr1TyqDq1hrW
The moved provider_default_transport_is_looked_up_per_request points the process default transport at a proxy while other lib tests run; loopback now bypasses it, as the ported sigv4 tests already do, so the image and embedding wiremock tests no longer need #[serial]. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0116HPMoqaLfFr1TyqDq1hrW
This was referenced Oct 20, 2026
RFC-0046 §4.5 item 2: the vendor move PR lists the old public sub-module paths and the replacement entry under Unreleased > Breaking. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0116HPMoqaLfFr1TyqDq1hrW
3 tasks done
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0116HPMoqaLfFr1TyqDq1hrW
The two cases the test branch added to bedrock_remaining_test.rs move next to their neighbours: the prelude checksum case to src/bedrock/tests/chat_language_model_event_stream.rs (with the event_stream_decoder path), the per-request default transport case for the embedding, image and reranking models to src/bedrock/tests/sigv4_fetch.rs, where its proxy skips loopback like the chat case beside it so the wiremock tests in the same binary keep reaching their servers. layout.toml keeps amazon-bedrock-error.ts mapped to bedrock/error.rs, where the move put the error handler. 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 |
…drock-tests' into refactor/move-the-amazon-bedrock-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
…drock-tests' into refactor/move-the-amazon-bedrock-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
…drock-tests' into refactor/move-the-amazon-bedrock-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
…drock-tests' into refactor/move-the-amazon-bedrock-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
…drock-tests' into refactor/move-the-amazon-bedrock-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
…drock-tests' into refactor/move-the-amazon-bedrock-files-to-the-upstream-layout Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0116HPMoqaLfFr1TyqDq1hrW
…drock-tests' into refactor/move-the-amazon-bedrock-files-to-the-upstream-layout Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0116HPMoqaLfFr1TyqDq1hrW
…drock-tests' into refactor/move-the-amazon-bedrock-files-to-the-upstream-layout Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0116HPMoqaLfFr1TyqDq1hrW
…drock-tests' into refactor/move-the-amazon-bedrock-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-amazon-bedrock-tests
to
master
October 27, 2026 13:19
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/bedrock/按@ai-sdk/amazon-bedrock@5.0.100一个文件对一个文件重排(RFC-0046 §4.2),照上游建reranking/子目录。五个老测试程序和event_stream.rs里的单元测试并进厂商测试目录src/bedrock/tests/(RFC-0046 §5)。函数体只改了路径和可见性。crate 根和bedrock模块根的再导出不变;bedrock下有公开模块路径变了,列在“公开路径”一节。测试数量和函数名前后一致;2 个用例加了#[serial],一个搬来的用例的代理设置让本机地址直连(见“共享进程状态”)。叠在测试 PR #358 上。实施进度在 #328 跟踪。已经测试分支
328982c8合上 masterb69137eb,冲突按 master 的改动搬到新位置解决(RFC-0047 的错误结构体改动从convert.rs、model.rs、embedding.rs、image.rs、reranking.rs、event_stream.rs、mod.rs搬到对应的新文件,老测试程序bedrock_remaining_test.rs和bedrock_upstream_e2e_test.rs里的两处匹配改动搬到src/bedrock/tests);测试数前后仍相等(549 个:测试分支 lib 414 个加老测试程序 135 个,名字多重集相同)。一、体系现状(概览,测试 PR #358 头
9915ab4d)上游同一条路:
createAmazonBedrock(amazon-bedrock-provider.ts)用createSigV4FetchFunction/createApiKeyFetchFunction(amazon-bedrock-sigv4-fetch.ts)和resolveAmazonBedrockBaseUrl(resolve-amazon-bedrock-base-url.ts)给每个模型一份配置,建AmazonBedrockChatLanguageModel、-EmbeddingModel、-ImageModel和reranking/下的-RerankingModel;消息转换、工具准备、Claude 能力表、usage、finish reason、Mistral 的 tool call id、错误处理、event stream 解码和响应处理、API 类型、各模型的选项各在自己的文件。aimux 把这些放在 9 个文件里:mod.rs(provider、Auth、transport、设置、错误处理)、convert.rs(消息转换、工具、能力表、getArgs的检查、finish reason、usage)、model.rs、embedding.rs、image.rs、reranking.rs、event_stream.rs、tools.rs、types.rs,加上 aimux 自己的options.rs。测试:#358 的新用例在
src/bedrock/tests/(408 个);event_stream.rs里还有 6 个单元测试;老用例在七个独立测试程序里:tests/amazon_bedrock_image_test.rs(8)、tests/bedrock_convert_test.rs(51)、tests/bedrock_embedding_test.rs(8)、tests/bedrock_remaining_test.rs(45)、tests/bedrock_upstream_e2e_test.rs(12)、tests/bedrock_stream_replay_test.rs(4)、tests/bedrock_user_agent_test.rs(10)。二、本 PR 改动(细节)
mod.rs的模块文档、mod、pub usemod.rs(只有模块声明和导出)index.tsmod.rs的常量、encode_model_id、AmazonBedrockProviderSettings、create_amazon_bedrock、amazon_bedrock、AmazonBedrockProvider、BedrockEndpoint和Provider/ProviderDiscovery实现provider.rsamazon-bedrock-provider.tsmod.rs的Auth(含base_url)、BedrockAuthFetch、ProcessDefaultFetchsigv4_fetch.rsamazon-bedrock-sigv4-fetch.ts;resolve-amazon-bedrock-base-url.ts在 aimux 是Auth::base_url,也指这里mod.rs的bedrock_failed_response_handlererror.rsamazon-bedrock-error.tsmod.rs的AmazonBedrockChatModelFamily、AmazonBedrockChatModelSettings;convert.rs的validate_optionschat_language_model_options.rsamazon-bedrock-chat-language-model-options.tsmod.rs的AmazonBedrockEmbeddingModelFamily、AmazonBedrockEmbeddingModelSettings;embedding.rs的BedrockEmbeddingProviderOptions、parse_bedrock_provider_optionsembedding_model_options.rsamazon-bedrock-embedding-model-options.tsmodel.rs除bedrock_event_stream_response_handler;convert.rs的reasoning_capabilities、build_request_body_checkedchat_language_model.rsamazon-bedrock-chat-language-model.ts(getArgs在这个文件);amazon-bedrock-reasoning-metadata.ts、amazon-bedrock-stream-error.ts在 aimux 是流里就地处理的,也指这里model.rs的bedrock_event_stream_response_handlerevent_stream_response_handler.rsamazon-bedrock-event-stream-response-handler.tsevent_stream.rs(去掉单元测试)event_stream_decoder.rsamazon-bedrock-event-stream-decoder.tsconvert.rs的消息转换(convert_prompt等、validate_prompt)convert_to_chat_messages.rsconvert-to-amazon-bedrock-chat-messages.tsconvert.rs的normalize_tool_call_idnormalize_tool_call_id.rsnormalize-tool-call-id.tsconvert.rs的supports_strict_tools、MODELS_WITHOUT_STRICT_TOOL_SUPPORT、supports_native_structured_outputanthropic_model_support.rsamazon-bedrock-anthropic-model-support.tstools.rs;convert.rs的is_strict_schema_compatible、prepare_toolsprepare_tools.rsamazon-bedrock-prepare-tools.tsconvert.rs的map_finish_reasonmap_finish_reason.rsmap-amazon-bedrock-finish-reason.tsconvert.rs的convert_usageconvert_usage.rsconvert-amazon-bedrock-usage.tstypes.rsapi_types.rs(原样)amazon-bedrock-api-types.tsembedding.rs其余embedding_model.rsamazon-bedrock-embedding-model.tsimage.rsimage_model.rsamazon-bedrock-image-model.ts;-image-model-options.ts、-image-settings.ts在 aimux 没有单独的代码,指这里reranking.rs的响应类型reranking/reranking_api.rsreranking/amazon-bedrock-reranking-api.tsreranking.rs的BedrockRerankingOptions、parse_bedrock_reranking_optionsreranking/reranking_model_options.rsreranking/amazon-bedrock-reranking-model-options.tsreranking.rs其余reranking/reranking_model.rsreranking/amazon-bedrock-reranking-model.tsoptions.rsbedrock::convert不再公开。原来经它公开的convert_prompt_to_bedrock、normalize_tool_call_id、validate_prompt、supports_strict_tools、prepare_tools、build_request_body_checked、map_finish_reason、convert_usage、BedrockUsage都变成 crate 内部;只给老测试用的convert_prompt_to_bedrock现在是#[cfg(test)] pub(super)。bedrock::embedding、bedrock::image不再公开;里面的BedrockEmbeddingModel、BedrockImageModel仍可从bedrock::和 crate 根拿到。bedrock::event_stream改名为bedrock::event_stream_decoder,仍是pub mod(跨厂商的tests/bedrock_user_agent_test.rs和tests/data_loss_regression_test.rs用encode_message(s),两处 import 已改)。bedrock::reranking仍是公开模块,bedrock::reranking::BedrockRerankingModel照旧。pub(super):provider.rs的PROVIDER、SIGV4_SERVICE和五个*_ENV_VAR常量;Auth的六个字段和bearer、static_credentials、credentials、preflight、base_url;BedrockAuthFetch(及signing、inner字段)、ProcessDefaultFetch;validate_options、supports_native_structured_output、is_strict_schema_compatible、bedrock_event_stream_response_handler;BedrockEmbeddingProviderOptions(及字段)、parse_bedrock_provider_options;BedrockRerankingResponse/BedrockRerankingResult/BedrockRerankingOptions(及字段)、parse_bedrock_reranking_options。BEARER_TOKEN_ENV_VAR由bedrock以pub(crate) use导出,default_providers.rs不用改。mod.rs文档里的[`SigV4Fetch`]链接改写成完整路径,因为mod.rs不再 import 它。tests/amazon_bedrock_image_test.rs→tests/image_model.rs末尾的amazon_bedrock_image模块;tests/bedrock_embedding_test.rs→tests/embedding_model.rs的bedrock_embedding模块。tests/bedrock_convert_test.rs按上游测试文件拆三段,各在一个bedrock_convert模块里:消息转换 39 个进tests/convert_to_chat_messages.rs,prepare-tools 5 个进tests/prepare_tools.rs,usage 7 个进tests/convert_usage.rs。tests/bedrock_remaining_test.rs按每个用例/// partial:标注里的 “full port in …” 文件拆,各在一个bedrock_remaining模块里:chat_language_model.rs21、provider.rs9、normalize_tool_call_id.rs7、convert_usage.rs3、convert_to_chat_messages.rs3、chat_language_model_event_stream.rs1(流里的 checksum 错误)、sigv4_fetch.rs1(默认 transport 按请求查找);共用的make_model、collect_stream、clear_bedrock_env等 17 个助手放到新的tests/remaining_support.rs。tests/bedrock_upstream_e2e_test.rs同样按标注拆进chat_language_model.rs6、image_model.rs2、prepare_tools.rs1、embedding_model.rs1、error.rs1、reranking/reranking_model.rs1,各在bedrock_upstream_e2e模块里;provider、options、chat_body、stream_response放到tests/upstream_e2e_support.rs。mock_fetch改用crate::test_support::mock_fetch。event_stream.rs的 6 个单元测试进tests/event_stream_decoder.rs的frame_round_trip_and_crc模块。convert::…、event_stream::…、bedrock::{Auth, …}、bedrock::bedrock_failed_response_handler、bedrock::{BedrockAuthFetch, SIGV4_SERVICE}import 改到新路径,两处文件头注释里的bedrock/mod.rs改成新文件。断言都没改(172 个老函数体去掉路径和空白后逐个比对一致;rustfmt因缩进多一层重排了一处 match 分支)。tests/的:tests/bedrock_stream_replay_test.rs(单厂商的 cassette 回放,按 refactor: move the Anthropic AWS files to the upstream layout #320 的做法留下)和tests/bedrock_user_agent_test.rs(Converse、Anthropic-on-Bedrock、Mantle 跨厂商的 user-agent 字面量)。layout.toml的[bedrock]25 个rust字段改到新路径。scripts/check_provider_boundaries.sh:规则 7 的from_env改成\bfrom_env\b,因为老用例provider_from_env_*现在在src/bedrock/下,测试名不是 builder 时代的from_env;规则 7b 的bedrock::sigv4|bedrock/sigv4改成bedrock(::|/)sigv4\b,否则会命中上游同名的sigv4_fetch.rs。两条对真正的::from_env(和bedrock::sigv4/bedrock/sigv4.rs仍然报。共享进程状态:老测试原来各是单独的测试程序,现在和 #358 的用例同在 lib 的一个测试程序里。
#[serial]用例设AWS_REGION、AWS_BEARER_TOKEN_BEDROCK、AWS_ENDPOINT_URL(_BEDROCK_RUNTIME / _AGENT_RUNTIME)等变量。搬来的用例里没给base_url、会读端点变量的两个加了#[serial_test::serial],函数体不变:provider.rs的bedrock_remaining::provider_custom_region_base_url(断言 URL)、provider_bearer_token_auth。sigv4_fetch.rs的bedrock_remaining::provider_default_transport_is_looked_up_per_request(本来就是#[serial])在运行期间把进程默认 transport 换成一个代理。原来它单独一个程序,现在同一程序里其他用fetch: None访问本机 wiremock 的用例(Bedrock 的 image、embedding,兼容层的 chat 等)会被这个代理截走。它的ProxyConfig加了no_proxy: "localhost,127.0.0.1",和 test: port the upstream Amazon Bedrock tests #358 在sigv4_fetch.rs:273的写法一样;它自己的请求发往example.com,断言不受影响。这样不用给别的用例逐个加#[serial]。其余搬来的用例都给了
base_url、api_key和fetch,或者本来就是#[serial],不读这些状态。没有全局计数器;fixture 路径按CARGO_MANIFEST_DIR算,位置不影响。CHANGELOG
CHANGELOG Unreleased 的 Breaking 加了一条,列出本家变了的公开子模块路径和替代入口(RFC-0046 §4.5 第 2 条)。
验证
cargo test -p aimux-providers --lib加原来七个--test:前后都是 688 个测试(前 lib 550 + 138,后 lib 674 + 回放 4 + user-agent 10),函数名多重集相同;bedrock::下 414 → 538。改了代理设置之后,lib 测试程序又连跑 29 次,674 个全过。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(2793 过,5 ignored)通过。Type of change
Checklist
https://claude.ai/code/session_0116HPMoqaLfFr1TyqDq1hrW
Generated by Claude Code