Repository navigation
RFC-0044: crate 拆分与依赖反转 - #279
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0116HPMoqaLfFr1TyqDq1hrW
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0116HPMoqaLfFr1TyqDq1hrW
aimux-stream is a ~120-line adapter over sse-stream plus an unused extract_lines; its only caller is provider-utils. Upstream keeps SSE decoding in provider-utils over eventsource-parser. Registers the change to alignment doc D17. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0116HPMoqaLfFr1TyqDq1hrW
RFC-0044 keeps the crate split and dependency inversion; the per-vendor directory, test placement and cross-vendor reuse rules move to a separate RFC-0046. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0116HPMoqaLfFr1TyqDq1hrW
…presets) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0116HPMoqaLfFr1TyqDq1hrW
Merged
5 tasks done
Fix the recording, session, download and trace call stacks against master; assign the unassigned modules (decision, files and skills models, math, util, prelude, replay mocks, rebuild_decision_provider); name the three upward edges C2 must cut; add test ownership rules; register the alignment-doc conflicts and list the open questions. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0116HPMoqaLfFr1TyqDq1hrW
Record li's opinion that aimux-core keeps its name instead of the D17 rename to aimux; register the difference for the maintainer to decide. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0116HPMoqaLfFr1TyqDq1hrW
Contributor opinions go to PR comments, not the RFC text. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0116HPMoqaLfFr1TyqDq1hrW
Contributor
Author
|
贡献者意见(li),供维护者决定:
Generated by Claude Code |
Contributor
Author
|
有三个问题想先对齐。
几处小问题:
|
…bservation wording, register devtools differences Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0116HPMoqaLfFr1TyqDq1hrW
Contributor
Author
|
逐条处理如下,都在 d23cef1。
Generated by Claude Code |
3 tasks done
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0116HPMoqaLfFr1TyqDq1hrW
…ests/it Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0116HPMoqaLfFr1TyqDq1hrW
Follows RFC-0046 section 5: each module directory has a tests/ child, one Rust file per upstream test file; crate tests/ keeps only cross-module scenarios. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0116HPMoqaLfFr1TyqDq1hrW
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0116HPMoqaLfFr1TyqDq1hrW
cunninghamcard-bit
marked this pull request as ready for review
October 20, 2026 10:01
This was referenced Oct 20, 2026
eric8810
reviewed
Oct 20, 2026
eric8810
left a comment
Contributor
There was a problem hiding this comment.
Review
现状调用图基本准确,但步骤按文本走不通:
- 阻塞
ProviderDiscovery搬去aimux-providers,但Provider::discovery()返回&dyn ProviderDiscovery,会形成aimux-provider -> aimux-providers反向依赖;建议把 trait 留在 provider,或移除Provider::discovery()。 - 阻塞
StreamPart::into_text_stream_part是 inherent impl;StreamPart去 provider、TextStreamPart去 aimux 后,这个 impl 无法跟着走,需要改成 aimux 中的自由函数/扩展 trait。 - 重要 C3 的
DiagnosticScope只有call_id,录制需要 attempt/exchange index/observer route;与 #325 是同一缺口。 - 重要 C4 统一下载会改变 proxy、UA、错误变体;当前 core 下载
no_proxy()且带aimux/<version>UA,需要明确 parity。 - 重要 C7 依赖 C6,C6 依赖 C5,而 C5 等未写的观测 RFC;
aimux-ops/src/manifest/controls.rs还硬编码 14 处aimux_core::...,重生成不会自动改成新 crate 名。 - 重要 C0 删除已发布的
aimux-stream,没有 deprecation/最终版本方案。
Keep ProviderDiscovery beside Provider and turn into_text_stream_part into a free function in aimux. Spell out what DiagnosticScope carries (call id, seq/attempt/parent, exchange counter, observers) and the download parity C4 keeps. Let the C7 rename follow C4 instead of the devtools steps, note that #268 removed the generated aimux_core paths, and plan a final aimux-stream release before C0 deletes it. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0116HPMoqaLfFr1TyqDq1hrW
Contributor
Author
|
逐条处理如下,都在 adf6c61。左列是 @eric8810 的原话。
Generated by Claude Code |
eric8810
reviewed
Oct 20, 2026
eric8810
left a comment
Contributor
There was a problem hiding this comment.
复审(adf6c618)
之前 6 条基本都改到了:ProviderDiscovery 留在 provider、StreamPart 改自由函数、C3 scope 补齐、C4 parity、C7/C0 补方案。还有两个需要先改:
- 重要 C7 的发布顺序仍不成立:C7 现在只需 C4,可以在 C6 前做;此时 providers 仍依赖 core,改名后 providers 会依赖未发布的
aimux,而发布顺序写的是 providers 在 aimux 前。把 C7 放回 C6 之后,或把顺序改成provider → provider-utils → aimux → providers。 - 重要 §4.2 说 observers 通过
OperationSettings安装,但OperationSettings是Serialize/Deserialize/Clone/Eq且会写进录制,放不了Arc<dyn Observer>。请明确载体(独立 task-local/scope 构造参数)和 C3–C5 期间用 core Recorder 做 observer 的过渡。 - 次要 C4 的 parity 还需要 UA 和错误映射参数,单靠“连接策略参数”不够。
- 次要 §4.3 引用 “RFC-0047 (#290)”,RFC-0047 是 #286,#290 是错误 cause 的实现 PR。
- 提示 基线
5743a40a与部分行号不匹配(stream_part.rs:456-461、generate.rs:1903在声明的基线上是492、1925)。
Publish order puts aimux before providers so C7 can land before C6; observers ride on DiagnosticScope instead of OperationSettings, with core's Recorder as the C3-C5 observer; C4's download takes connection, user-agent and error-mapping parameters; RFC-0047 cited as #286; line references refreshed at 5743a40. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0116HPMoqaLfFr1TyqDq1hrW
Contributor
Author
|
第二轮复审(review 5586872522)逐条处理,改动在 22a4e90。下表左列是 eric 的原话(摘要),每条都在 master@
Generated by Claude Code |
eric8810
approved these changes
Oct 21, 2026
eric8810
left a comment
Contributor
There was a problem hiding this comment.
复审通过。C7 发布顺序、DiagnosticScope 的 observer 载体、C4 的 proxy/UA/错误映射参数、RFC 引用和基线行号都已修正。Approve。
2 of 9 tasks
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/0044-crate-layering-and-dependency-inversion.md,只有这一个文件,不改代码。对齐文档第 2 章 D17 定了五层目标,但没有说怎么从现在的代码走过去。本文补上这部分:
aimux-core按职责拆进aimux-provider、aimux-provider-utils、aimux、aimux-devtools;core 里直接调用的录制、session、trace、下载改成依赖反转;aimux-stream并入 provider-utils。aimux-providers内部的厂商目录和测试不在本文范围,见 RFC-0046(#294),本文的步骤不依赖它。实施进度在 #328 跟踪。
一、体系现状(概览,master
5743a40a)crate 依赖
一次文本生成从入口走到网络(右侧是所在 crate)
上游同一条路:
generateText(ai)→model.doGenerate(@ai-sdk/openai)→postJsonToApi(provider-utils)→fetch。规格类型在 @ai-sdk/provider,运行时不管录制和 session,devtools 从外面接入。二、本 PR 改动(细节)
1. 录制:provider-utils 不再读写 core 的录制
现在:
改成:
provider-utils 不再认识 RecordingContext。C3 就定下这一组关联,文本生成和 decide 两条路径(
http.rs:118-128、:130-140)和写录制(:861-867)一起改,C3 到 C5 之间录制不丢调用关联。RFC-0048(#325)的exchangeId建在这上面。上游没有 Fetch 层观察者:每个 telemetry 事件都带
callId(ai/src/generate-text/generate-text.ts:669生成),executeLanguageModelCall(ai/src/telemetry/telemetry.ts:332-337)让模型调用跑在集成提供的上下文里;devtools 是 telemetry 集成加模型 middleware(devtools/src/integration.ts:113、devtools/src/middleware.ts:101)。Fetch 层录制是 aimux 扩展(RFC-0036 的 L0),已在 §7 登记。2. session:运行时只传一个字符串
现在:
改成:
上游
generateText没有 session。去掉AIMUX_SESSION_INFER是公开行为变化,已在 §7 登记。3. 下载:两份重定向循环合成一份
现在:
改成:
C4 是重构:各路径的代理、UA、错误变体保持现状(§4.3 对照表)。上游只有一份:
ai/src/generate-video/generate-video.ts:387→ai/src/util/download/download.ts:39→ provider-utilsfetchUntrustedUrl,UA 是ai-sdk/<版本>,失败抛DownloadError;要不要照上游改是 §9 的待讨论项。4. SSE:aimux-stream 并入 provider-utils
现在:
改成:
上游:provider-utils
parseJsonEventStream直接用第三方eventsource-parser。这是对 D17 的改动,已在 §7 登记。aimux-stream0.5.0 已发布,删除前用当前代码发最后一个版本说明去向,不撤回旧版本。5. 改完后的 crate 依赖
Provider和ProviderDiscovery都在aimux-provider(Provider::discovery()返回&dyn ProviderDiscovery);StreamPart::into_text_stream_part改成aimux里的自由函数。发布顺序:provider → provider-utils → aimux → providers → ops → ffi,C6 之后 devtools 排在 providers 和 ops 之间。C7 可以早于 C6,那时 providers 还依赖
aimux;aimux不依赖 providers,所以这个顺序在 C6 前后都成立。步骤
aimux-stream并入 provider-utils(删除前发最后一个版本)aimux-provider,先断三条往上的边aimux-devtoolsType of change
Checklist
rfc/)纯文档,cargo 检查不受影响。
Notes for reviewers
ProviderDiscovery留在aimux-provider、into_text_stream_part改自由函数、DiagnosticScope的内容(§4.2)、下载对等表(§4.3)、C7 不再等观测 RFC、aimux-stream的最后一个版本。[15/15] feat!: generate binding DTOs from the Rust types #268 已删掉controls.rs和schema/ops/type-*.json,生成物里不再有aimux_core路径。DiagnosticScope本身,C3 到 C5 期间由 core 的 Recorder 充当观察者;C4 的下载带连接策略、UA、错误映射三个参数;RFC-0047 改引 RFC-0047: 错误体系与错误原因(cause) #286;全文行号在基线上重新核对。cause另见 RFC-0047(RFC-0047: 错误体系与错误原因(cause) #286)。🤖 Generated with Claude Code
https://claude.ai/code/session_0116HPMoqaLfFr1TyqDq1hrW