Skip to content

直接保留已验证的 Gen Code 草稿类型 - #67

Open
tiye wants to merge 3 commits into
mainfrom
refine/gen-code-nominal-draft
Open

tiye wants to merge 3 commits into
mainfrom
refine/gen-code-nominal-draft

Conversation

@tiye

@tiye tiye commented Nov 14, 2026 •

Copy link
Copy Markdown
Member

对使用者的影响

旧草稿 Map 和现有存档继续按原格式读取。已经是本库 GenCodeState 的草稿可以直接用于渲染和恢复。

改动与风险

草稿读取先核对具名记录的身份,匹配时直接返回。旧 Map 和其他 Struct 沿用字段解码,保留原校验。原 8 项测试、全定义检查、strict、离线 stream 回归和构建已通过。

:states 事件也会直接保留已验证的具名草稿。新增回归确认兼容的 Map 仍保持原载荷,错误字段仍被拒绝。最新版本通过 9 项测试、全定义检查、strict 和离线流式回归。

SDK 实例在 JavaScript 宿主边界使用 js-cast 绑定已有 trait,质量检查中的 unsafe-coerce 计数降至 0。离线回归覆盖流式响应和派发,实际 SDK 请求未纳入本次验证。

Summary by CodeRabbit

  • Bug Fixes
    • Draft decoding now accepts both nominal state values and legacy map-shaped state data, while continuing to reject malformed inputs.
    • Drafts represented as nominal structs are now validated before decoding. This improves compatibility across supported draft formats and helps prevent invalid state data from being accepted.

@coderabbitai

coderabbitai Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Draft decoding now handles nominal GenCodeState values and legacy map-shaped values. initialize-chat! uses js-cast to convert the Gemini client to its host type.

Changes

Draft decoding

Layer / File(s) Summary
Draft state decoding
calcit.cirru
:states operation decoding and read-draft assert nominal GenCodeState values and continue to decode other inputs as maps. Tests cover nominal values, legacy maps, and an invalid numeric :query payload.

Gemini client cast

Layer / File(s) Summary
Client initialization cast
calcit.cirru
initialize-chat! uses js-cast instead of unsafe-coerce to convert the Gemini client to its host type.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Feature

Merge Risk: Minimal · up to 44c24

This change lets validated Gen Code drafts keep their named type while older map-shaped drafts still decode as before. No concrete merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "直接保留已验证的 Gen Code 草稿类型" (keep verified Gen Code draft types directly) matches the main change. The PR keeps nominal GenCodeState values for :states operations and returns them directly when…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "直接保留已验证的 Gen Code 草稿类型" (keep verified Gen Code draft types directly) matches the main change. The PR keeps nominal GenCodeState values for :states operations and returns them directly when the nominal record identity matches. The raw summary also covers the decode-gen-code-op and read-draft changes that support this. The title does not mention the js-cast change for the Gemini client, but the PR objectives list that as a secondary commit note, so the title is still a fair summary of the primary change.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: f21a9cdd-3c69-4526-8457-05b44301cc64
Commits

Reviewing files that changed from the base of the PR and between e5900e9 and 44c242f.

Files selected for processing: 1

  • calcit.cirru

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant