44
55状态:** APPROVED_FOR_IMPLEMENTATION**
66
7- 用户已明确要求按 OpenSpec 继续 3.0.x canonical implementation。当前仅对 ` kimi- typed- protocol` 已实现范围记录证据;跨 Jackson / 三分支同步尚未完成 。
7+ 用户已明确要求按 OpenSpec 推进 3.0.x canonical implementation,并在 canonical 通过后同步 2.0.x / 1.0.x。本文记录 typed protocol 的 TDD 与三线语义证据 。
88
99## Strict Validation
1010
1111OpenSpec CLI:` 1.13.1 `
1212
13- 所有本轮提交在主 CI 中先执行 8 个 Change 的 strict validate,再进入 Maven verify;strict validate 持续通过。
13+ 3.0.x 主 CI 在 Maven verify 前执行 8 个 Change 的 strict validate;` kimi-typed-protocol ` 持续通过。
14+
15+ ## Fixture Inventory
16+
17+ 当前 typed protocol 只对“有证据的 shape”做强类型化;不确定数据继续通过 raw / extensions 保留。
18+
19+ | Fixture / Harness | 来源 | 用途 | 状态 |
20+ | --- | --- | --- | --- |
21+ | ` KimiProtocolMapperTest ` inline JSON | SDK contract fixture | Message/Text/UnknownBlock/unknown message fields | VERIFIED_FOR_SDK_CONTRACT |
22+ | ` KimiProtocolCoreModelTest ` inline JSON | SDK contract fixture | Session/PromptResult/Usage/StopReason/immutability | VERIFIED_FOR_SDK_CONTRACT |
23+ | ` KimiProtocolDescriptorModelTest ` inline JSON | SDK contract fixture | ToolCall/Error/Model/Mode/Provider | VERIFIED_FOR_SDK_CONTRACT |
24+ | ` KimiProtocolRawTypedParityTest ` inline raw JsonNode | SDK cross-Jackson contract fixture | typed/raw fact parity、future fields、defensive snapshot | VERIFIED_CROSS_BRANCH |
25+ | ` fake-acp-agent.py ` | controlled ACP process fixture | typed ACP prompt adapter + legacy raw API coexistence | VERIFIED_E2E |
26+ | CLI stream-json typed mapping | 尚未纳入本 Change | CLI transport → domain | NOT_CLAIMED |
27+ | Server REST/WS typed mapping | 尚未纳入本 Change | Server transport → domain | NOT_CLAIMED |
28+
29+ 因此本 Change 的完成只表示核心 typed domain + ACP typed adapter + raw escape hatch 完成,不表示 CLI/Server 全部 transport 已类型化。
1430
1531## TDD Cycle 1 — Message / ContentBlock / Unknown preservation
1632
@@ -20,7 +36,7 @@ Commit: `26f886b54d0a2821ee2f2275d408463fbab86428`
2036
2137CI run: ` 35546109040 `
2238
23- 结果:BUILD FAILURE。testCompile 因 ` KimiProtocolMapper ` 等 typed model 尚不存在而失败 。
39+ 结果:BUILD FAILURE, typed mapper/ model 尚不存在 。
2440
2541### GREEN
2642
@@ -35,9 +51,8 @@ CI run: `35546177832`
3551- ` KimiContentBlock `
3652- ` KimiTextContentBlock `
3753- ` KimiUnknownContentBlock `
38- - ` KimiProtocolMapper.readMessage `
39- - unknown content block 保留 raw payload
40- - unknown message field 保留 extensions
54+ - unknown content block raw payload preservation
55+ - unknown message field extensions
4156
4257## TDD Cycle 2 — Session / PromptResult / Usage / StopReason
4358
@@ -47,7 +62,7 @@ Commit: `a4e7e00d69e18facfabae7572daa955ddf63ebc0`
4762
4863CI run: ` 35546235871 `
4964
50- 结果:BUILD FAILURE。6 个编译错误全部来自 ` KimiSession ` 、 ` KimiPromptResult ` 和 mapper 方法缺失。
65+ 结果:BUILD FAILURE。
5166
5267### GREEN
5368
@@ -62,7 +77,7 @@ CI run: `35546316085`
6277- ` KimiPromptResult `
6378- ` KimiUsage `
6479- ` KimiStopReason `
65- - session/result future-field preservation
80+ - future-field preservation
6681- immutable extension map / defensive copy
6782
6883## TDD Cycle 3 — ToolCall / Error / Model / Mode / Provider
@@ -73,7 +88,7 @@ Commit: `d44c84b0790575f5ff8758804d5509161318d3c4`
7388
7489CI run: ` 35546382766 `
7590
76- 结果:BUILD FAILURE,typed descriptor model 与 mapper 方法尚不存在 。
91+ 结果:BUILD FAILURE。
7792
7893### GREEN
7994
@@ -89,7 +104,7 @@ CI run: `35546441152`
89104- ` KimiModel `
90105- ` KimiMode `
91106- ` KimiProvider `
92- - raw arguments / error data / unknown descriptor fields 保留
107+ - raw arguments / error data / unknown descriptor fields
93108
94109## TDD Cycle 4 — PromptRequest + ACP Typed Adapter
95110
@@ -99,7 +114,7 @@ Commit: `ab7bfb924398adddaca9b47fcfcd6058a2e9244b`
99114
100115CI run: ` 35546529461 `
101116
102- 结果:BUILD FAILURE, ` KimiPromptRequest ` 与 ACP typed prompt overload 缺失 。
117+ 结果:BUILD FAILURE。
103118
104119### GREEN
105120
@@ -112,34 +127,128 @@ CI run: `35546611696`
112127实现:
113128- immutable ` KimiPromptRequest.builder() `
114129- required sessionId/text validation
115- - ` KimiAcpClient.prompt(KimiPromptRequest, Consumer<String>) `
116- - ` KimiAcpClient.promptAsync(KimiPromptRequest, Consumer<String>) `
117- - typed adapter 返回 ` KimiPromptResult `
118- - legacy string-based ACP API 与 raw JsonNode API 保持可用
130+ - ACP typed sync/async prompt overload
131+ - typed ` KimiPromptResult `
132+ - legacy string ACP API 与 raw JsonNode API 保留
133+
134+ ## TDD Cycle 5 — Full Raw-Node Typed Parity on 3.0.x
135+
136+ ### Initial attempt and fixture correction
137+
138+ 第一次 mapper refactor 暴露 raw-node overload fixture 不完整;在补齐完整 descriptor/session raw-node fixture 后,先恢复 pre-refactor mapper 形成有效 RED。
139+
140+ ### RED
141+
142+ Commit: ` 77ff135a3c270dda0ff9d1b733b2637d34815d68 `
143+
144+ CI run: ` 35558539907 `
145+
146+ 结果:BUILD FAILURE。
147+
148+ 失败证明:Session / ToolCall / Error / Model / Mode / Provider 尚不能与 caller-owned raw JsonNode 使用同一 typed mapper 路径。
149+
150+ ### GREEN
151+
152+ Commit: ` 4cb727ef61e79d19a8ea37c43c0bb13eb39acd75 `
153+
154+ CI run: ` 35558587378 `
155+
156+ 结果:BUILD SUCCESS。
157+
158+ 实现:
159+ - 所有核心 typed model 同时支持 String JSON 与 caller-owned JsonNode;
160+ - String 入口统一委托 raw-node 入口,消除重复解析;
161+ - typed model 对 caller raw data 做 defensive snapshot;
162+ - unknown fields 在 raw-node 和 string 两条入口中保持同一语义。
163+
164+ 覆盖:
165+ - TYP-05 raw/typed parity;
166+ - 4.1 transport/domain parsing deduplication。
167+
168+ ## TDD Cycle 6 — Jackson 2.22 / 2.18 Cross-Branch Parity
169+
170+ ### 2.0.x RED
171+
172+ Commit: ` e2a11a8ec405e94082eac382cdacdd5e95fe0849 `
173+
174+ CI run: ` 35558668945 `
175+
176+ 结果:BUILD FAILURE。
177+
178+ ### 2.0.x GREEN
179+
180+ Commit: ` 4fa4d1eb9ccfc821c5f24ad482b2360ceaacf6db `
181+
182+ CI run: ` 35561433011 `
183+
184+ 结果:BUILD SUCCESS。
185+
186+ ### 1.0.x RED
187+
188+ Commit: ` 862f28995f87bb71aba4b0d65337eccfb1246293 `
189+
190+ CI run: ` 35558674566 `
191+
192+ 结果:BUILD FAILURE。
193+
194+ ### 1.0.x GREEN
195+
196+ Commit: ` 27772d3bf4897cd494047f4a38a03a777787b296 `
197+
198+ CI run: ` 35561436043 `
199+
200+ 结果:BUILD SUCCESS。
201+
202+ 实现差异:
203+ - 3.0.x:Jackson 3 ` tools.jackson.* ` ,object properties 使用 Jackson 3 API;
204+ - 2.0.x / 1.0.x:Jackson 2 ` com.fasterxml.jackson.* ` ,extension traversal 使用 ` fields() ` iterator;
205+ - core typed model、raw-node overload、future-field preservation、defensive-copy 行为保持一致。
206+
207+ ` KimiProtocolRawTypedParityTest ` 三线在仅归一化 Jackson package 名后内容一致,作为 TYP-06 semantic fixture contract。
208+
209+ ## Model Safety Review
210+
211+ - 新 typed domain models 未增加自动输出完整 prompt/token/secret 的自定义 ` toString() ` ;
212+ - raw JsonNode/extension 数据通过 getter 显式访问,不被 logger 自动序列化;
213+ - collection/map 构造使用 defensive copy/unmodifiable view 的已测试路径;
214+ - Error/ToolCall raw data 可包含业务内容,因此后续 observability/logging 层仍必须执行 redaction;typed protocol 本身不把这些对象自动写入日志。
215+
216+ ## Verified Requirements
217+
218+ - TYP-01 Typed core models:PASS
219+ - TYP-02 Preserve unknown data:PASS
220+ - TYP-03 Unknown content block:PASS
221+ - TYP-04 Immutable observable state:PASS
222+ - TYP-05 Raw API remains available / typed-raw fact parity:PASS
223+ - TYP-06 Cross-Jackson semantic parity:PASS
224+
225+ ## Branch Verification
226+
227+ - ` feature/3.0.x@4cb727ef61e79d19a8ea37c43c0bb13eb39acd75 `
228+ - CI run ` 35558587378 ` : success
229+ - ` feature/2.0.x@4fa4d1eb9ccfc821c5f24ad482b2360ceaacf6db `
230+ - CI run ` 35561433011 ` : success
231+ - ` feature/1.0.x@27772d3bf4897cd494047f4a38a03a777787b296 `
232+ - CI run ` 35561436043 ` : success
233+
234+ ### Important compatibility caveat
119235
120- ## Current Coverage
236+ 当前 1.0.x / 2.0.x 的 GitHub CI workflow 仍显示使用 JDK 21 执行 Maven verify。上述证据足以支持本 Change 的 ** Jackson 2/3 semantic parity ** ,但不作为“Java 8 / Java 17 真实运行时已验证”的证据。
121237
122- 当前 3.0.x 已实际覆盖:
123- - TYP-01 typed core model 的主要模型集合
124- - TYP-02 unknown field preservation
125- - TYP-03 unknown content block
126- - TYP-04 immutable builder / defensive copy 的主要路径
127- - TYP-05 additive typed ACP adapter,raw API 未删除
128- - feature/3.0.x fixtures + unit/E2E tests:PASS
238+ 真实 JDK baseline、CI label 与 java-version 一致性属于 ` kimi-branch-parity ` 的 BRP-05 门禁,后续必须单独纠正和验证。
129239
130- ## Remaining Scope
240+ ## Review Conclusion
131241
132- 以下仍未完成,不得将 Change 标记 COMPLETE:
242+ ` kimi-typed-protocol ` 在其批准范围内已经完成:
243+ - 规范门禁;
244+ - 6 轮可追溯 TDD / parity 工作;
245+ - raw escape hatch;
246+ - caller-owned JsonNode parity;
247+ - Jackson 3 / 2.22 / 2.18 语义适配;
248+ - 3.0.x / 2.0.x / 1.0.x 同 fixture 验证。
133249
134- - 固定并记录 CLI / ACP / Server 的上游真实 fixture 清单;
135- - TYP-05:同一响应的 typed/raw 底层事实一致性专项验证;
136- - TYP-06:Jackson 3 → Jackson 2.22 / 2.18 adapter 与 semantic parity;
137- - transport/domain 重复解析重构;
138- - equals/hashCode/toString 与敏感数据审查;
139- - feature/2.0.x 移植与测试;
140- - feature/1.0.x 移植与测试;
141- - 三线 serialized/parsed semantic snapshot 比较。
250+ 最终状态:
142251
143- 当前状态:
252+ > ** COMPLETE / VERIFIED **
144253
145- > ** IMPLEMENTATION_IN_PROGRESS **
254+ 该状态仅表示 ` kimi-typed-protocol ` Change 完成,不代表 CLI/Server typed transport、其它 6 个未完成 OpenSpec Change 或 Java 8/17 runtime gate 已完成。
0 commit comments