Repository navigation
feat(core,ops,bindings): RFC-0049 compact GenerateTextResult wire, IncludeOptions, and 7-language accessors - #539
Conversation
3aab9c3 to
cd1a179
Compare
eric8810
left a comment
There was a problem hiding this comment.
CD1A179B 复审。compact wire 本身做得扎实:我用同一组 scripted 调用在 base/head 做了差分,12 个 Rust 派生访问器逐字节一致,7 个 binding 的派生规则一致,trace fingerprint 在 body 剥离前计算所以安全,include 默认 false 对直接 Rust 调用无回归,codegen --check 在 head 通过,CI 22/22 绿。
[P2] output 在 Rust 和所有 binding 之间语义不一致,且相对 0.7.0 是静默变化。 对未解析结果(如 finishReason: tool-calls、无 output spec),compact wire 没有 output key。实测:原生 Rust result.output() → Err(NoOutputGenerated);但 TryFrom 把 absent 映射成 PlainText(step.text())(generate.rs:588-595),wire 往返后 Rust 返回 Ok(text);7 个 binding 全部返回 Ok(text)。0.7.0 时旧 wire 文档明确 output "Absent when the output was not parsed",binding 返回 undefined;现在变成文本字符串。Swift 测试 WireTests.swift 甚至把这个行为固化了(finishReason tool-calls + 无 output → .value(.string("hello"))),但 CHANGELOG 只说"Otherwise use the derived text",没说这与 Rust 不一致。请二选一:在 wire 上区分 NotParsed(例如 output: null 保留语义,或加标志),或者显式文档化 Rust/binding 的分歧并修正 output() 的 rustdoc。
[必须] rebase。 #537 已合入,现在 CONFLICTING。我在 scratch 里 cherry-pick 验证过:真实冲突只有 CHANGELOG.md(两边 Breaking 块都保留),manifest.rs/generated-files.json 自动合并;但 #537 后 manifest 走嵌入式快照,rebase 后 codegen --check 会因 manifest.digest / manifest.json.zlib 过期而失败——重跑 codegen 即可,digest 仍是 2b2e518b… 所以 binding 常量和 manifest.rs:294-297 的断言都不用改。
非阻塞:generate.rs:166 rustdoc 仍说 "Both are included by default",实际默认 false;PR 没写目标版本(这是 breaking wire,按 pre-1.0 规则应是 0.8.0),abiVersion 未 bump 是否合适请明确。
cd1a179 to
ebbfae6
Compare
|
@eric8810 Thanks for the thorough review! All items have been addressed in
Local gates ( |
eric8810
left a comment
There was a problem hiding this comment.
ebbfae6 复审。
outputParsed 方案通过。 三态编码(PlainText / Parsed 含 null / NotParsed)在 Rust 侧正确;我用同一 scripted 调用在 6c2954e 和 ebbfae6 做了差分,stop、tool-calls、结构化输出三个 case 原生 Rust output() 与 wire 往返一致;output + outputParsed:false 矛盾输入在 Rust 和 Node/Python/Go/Java/Dart/Swift 六个生成路径都被拒绝(Kotlin 复用 Java);codegen --check 通过,2f8a4b75… 是真实派生的 digest;[0.7.0] 段未碰,版本号未动。rustdoc、0.8.0 目标、abiVersion 说明也都补了。
[P2] CI 的 Java 失败是真失败,且与 JDK 版本无关。 MultimodalTypesTest > generateTextResultOutputStates() 在 JDK 8 红,但我在 JDK 17 上复现了同样的失败——"Java passes locally" 应该是跑的不是这个状态。
根因在测试 fixture,不在 outputParsed 逻辑:roundTrip 第 22 行做 valueToTree(readValue(encoded)) 等于 readTree(encoded) 的严格比较,而 StepResultPerformance 的四个字段是 BigDecimal,fixture 里写的是整数 0。valueToTree 给 DecimalNode,readTree(开了 USE_BIG_INTEGER_FOR_INTS)给 BigIntegerNode,DecimalNode(0).equals(BigIntegerNode(0)) 为 false。第一个 case(plain,第 40 行调用)就挂在这。
把 bindings/java/src/test/.../MultimodalTypesTest.java fixture 里 performance 的 0 改成 0.0(和 contract-tests/dto/GenerateTextResult/003.json 里 12.0 / 60.0 / 260.0 的写法一致,那个就是对的)三个 case 全过。改完 CI 绿我就 approve。
非阻塞:这个测试只覆盖 JDK 8 跑失败就 skip 后面的设计,让"JDK 8 红"看起来像 JDK 问题;CI 的 Java tests (JDK 11/17/21) 是 skipped 而不是独立跑,建议改成不受前一个 JDK 结果影响,否则下次还会误判。
…cludeOptions, and 7-language accessors
ebbfae6 to
4e062e2
Compare
|
@eric8810 Thanks for the review! Both items are done in
Local Rust ( |
eric8810
left a comment
There was a problem hiding this comment.
4e062e2 复审通过。Java fixture 四个 StepResultPerformance 字段已改为 0.0,JDK 8 job 绿(17/21 现在也跑了);rebase 到 #517 后 codegen 刷新,manifest.digest = 6914772f… = schema/manifest.json 的 digest/inputHash = 6 个 binding 的 MANIFEST_DIGEST,且已包含 #517 的 schemaHash/sources 和你的 outputParsed;版本号未动,[0.7.0] 段与 master 逐字节一致;20/20 CI 绿。outputParsed 三态方案上一轮已通过差分验证。Approve,合入后进 0.8.0。
非阻塞:CI 的 Java tests (JDK 11/17/21) 仍依赖 JDK 8 先过,建议后续拆成独立 job,避免再出现"JDK 8 红"被误读为 JDK 问题。
Rebased cleanly onto
master(f4b208253, post-#538, v0.7.0#546,#537, and#517) as a single standalone commit (4e062e24f).Target release:
0.8.0(pre-1.0 breaking wire change; documented underCHANGELOG.md## [Unreleased]).abiVersioncompatibility:AIMUX_ABI_VERSIONremains65536(1.0) because the 16 exported C ABI function signatures, memory ownership rules, and error/stream calling conventions are unchanged. Wire payload and schema compatibility are enforced at handshake time byAIMUX_MANIFEST_DIGEST(6914772fdc03df08cba497def41cb354fe52e40eba49844a66938b4cd38c5d83) so mismatched native libraries and bindings fail fast on load.Summary
Breaking wire and schema changes from RFC-0049:
GenerateTextResultwire format with lossless 3-stateoutputencoding:text.generate,text.consume,toolRepair.applyResult, and language-modelreplay.liveserialize only the wire facts (steps,totalUsage, optionaloutput, and optionaloutputParsed) instead of duplicatingtext,content,reasoning,files,sources,toolCalls,toolResults,warnings,request,response, andresponseMessagesat the top level.OutputState::PlainText(hot path):outputomitted,outputParsedomitted — zero duplicate bytes; Rust and all 7 bindings expose the final step's derivedtext.OutputState::Parsed(value)(including JSONnull):outputkey present ("output": nullpreserved); Rust and all 7 bindings expose the exact parsed value.OutputState::NotParsed(e.g., finaltool-callsstep without an output spec, or failed streamed parse):outputomitted and"outputParsed": false; Rust round-trips back toOutputState::NotParsed(result.output()->Err(NoOutputGenerated)), and all 7 bindings expose absent output (undefinedin Node,Nonein Python,nilin Go,null+hasOutput() == falsein Java/Kotlin,Field.absent()in Dart,.missingin Swift).outputandoutputParsed: falseare rejected across Rust and all 7 bindings.GenerateTextResultprovides derived methods in Rust (aimux-core) and generated accessors across all 7 language bindings.IncludeOptionsbody opt-in (defaultfalse):include.requestBodyandinclude.responseBodydefault tofalse(including whenincludeis omitted), eliminating large body round-trips across FFI unless opted in.StreamResponseInfo.bodyso streamed responses can opt into returning response bodies when supplied by the model.aimux-ops/src/manifest.json.zlib,aimux-ops/src/manifest.digest,schema/manifest.json, and all 7 bindings to6914772fdc03df08cba497def41cb354fe52e40eba49844a66938b4cd38c5d83(aimux-codegen --check:680files in sync, preserving#517per-type schema hashes and closed-type checks).IncludeOptionsschema and DTO contract vectors (273vectors total, includingGenerateTextResult/001.jsonplain text,002.jsonparsednull, and003.jsonoutputParsed: false).CHANGELOG.md## [Unreleased](preserving#537and leaving## [0.7.0]untouched) anddocs/upgrading-to-ops-abi.md.request-200k-no-bodieswire-size contract check in.github/workflows/ci.yml.opt-level = "z"preserved):[profile.release]remainsopt-level = "z"and workspaceCargo.tomlstaysversion = "0.7.0".Verification (on
4e062e24f/ basef4b208253)cargo fmt --all -- --check: PASScargo run -p aimux-codegen -- --check: PASS (680generated files, digest6914772fdc03df08cba497def41cb354fe52e40eba49844a66938b4cd38c5d83)cargo clippy -p aimux-ops -p aimux-ffi --no-default-features --all-targets -- -D warnings: PASScargo test -p aimux-ops --no-default-features: PASScargo test -p aimux-ops -p aimux-codegen: PASSaimux.h==aimux_ops.h) +scripts/test-c-abi.sh --asan-compile-only: PASS (4/4)./bindings/go/test-abi.sh -count=1,./bindings/go/test-native.sh -count=1(-race),check_dto_vectors.py go(273/273vectors): PASSnpm run build:typed,node --experimental-strip-types --test __test__/dto.test.ts __test__/facade.test.ts(29/29),check_dto_vectors.py node(273/273vectors): PASScheck_dto_vectors.py python(273/273vectors),pytest bindings/python/tests/test_dto_types.py(5/5): PASS