Skip to content

refactor: decode untyped store and wire maps instead of erasing Option to nil - #33

Merged
tiye merged 2 commits into
mainfrom
claude/option-nil-cleanup
Oct 20, 2026
Merged

tiye merged 2 commits into
mainfrom
claude/option-nil-cleanup

Conversation

@tiye

@tiye tiye commented Oct 19, 2026 •

Copy link
Copy Markdown
Member

对用户的影响

正常协作和线上 wire/存储格式保持不变。缺失目标段落的移动不再写入 nil 或移动光标;缺少必需标题/正文的操作明确报错。登录后路由暂时缺少 data 时用空 Map 渲染,存在的颜色、路由名和段落 ID 会校验类型。

CLI 与 @calcit/procs 现在精确配对 0.30.1-alpha.5。正式 0.30.1 tag 已发布,但目前 CLI assets 为空、npm runtime 仍为 404,不混用不完整的正式版本。服务器也需要匹配工具与依赖;准备状态未确认,本 PR 不应直接合并部署生产。

改动

  • 客户端每次渲染只将开放 store 解码一次为 StoreView;组件使用带类型字段或 Option,twig/updater 在实际读取处校验。
  • app.decode 提供 required-field、optional-field、field-or、field-is?、present? 等读操作,保留 false、0、合法默认值和已存在的 nil 语义。option-nil-roundtrip 89→6,保留项在协议边界注明原因。
  • 沿用原提交新增的 12 项语义测试,本次 alpha.5 跟进不再增加测试框架、基线或额外验证脚本,业务 Snapshot 与原提交字节一致。
  • 更新配对 CLI/runtime 和 lock;CI 用官方 query/--ns 按浏览器与 native server 入口检查全部应用命名空间,不把 WSS 依赖塞入浏览器。
  • COS 仅上传前端,保留 action 内置公共 URL 校验、原服务器目录和后端部署流程。

验证与范围

  • alpha.5:28 个应用命名空间、131 个定义全部通过(浏览器 115,server 16);双入口完整 strict 通过,废弃调用 0。
  • 共同原生测试 63/63,server-effect 2/2;浏览器/共享命名空间 62 项 native/生成 JS 回放均通过,断言和日志一致,无选择内排除项。
  • app.server 的 1 项 wire 测试与 2 项 effect 测试只计为 native 通过。JS 回放仅临时适配构建错误文件路径、旧 npm 扩展名和启动 DOM lookup,不修改业务实现或模拟 native FFI;不是实际 DOM/浏览器验收,临时脚本不提交。
  • Yarn immutable、canonical 格式与 CDN 前缀生产构建通过。Snapshot SHA256 9b28691f32f7163b6241f92a04059820798542b28ea78691ecdc11f6587f65dc 未变。
  • 原提交记录的 8 种 store SSR HTML 对比为清理前后逐字节一致;此前 alpha.4 双客户端/持久化验收不冒充本次 alpha.5 重验。

风险与未完成项

开放状态、宿主边界与类型审阅债务仍存在,不宣称全应用静态化;不放宽预算以获得通过。Text 导出弹窗、alpha.5 双客户端实际协作与生产服务器升级尚未完成验收。保留原 Highlight.js legacy 提示与 Vite 大 chunk 警告。

关联 calcit-lang/calcit#2124。

claude and others added 2 commits October 19, 2026 18:03
… nil

Add app.decode field readers (required-field, optional-field, field-or,
field-is?, option-is?, present?) and use them in client components,
twigs and updaters in place of `.unwrap-or (get m k) nil`.

Client: comp-container now takes the store Option and matches on it;
the store map is decoded once into a StoreView struct (navigation,
router, route name, route data, editing paragraph id, color, messages).
comp-editor-panel takes the editing id as an Option; comp-previewer
compares the focused paragraph via option-is?.

Genuine nil boundaries are kept and named: payload-to-wire,
action-data-from-wire, paragraph-id-to-wire, user-name-to-wire, plus
the recollect patch/diff bases (first sync is nil).

Behavior changes: paragraph/move with a missing target is a no-op
instead of inserting a nil paragraph; malformed :article/title and
:paragraph/content ops raise instead of writing nil-keyed data.

option-nil-roundtrip findings: 89 -> 6.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0117eRu6N8pRpJgbkTYk3LZr
@tiye

tiye commented Oct 20, 2026

Copy link
Copy Markdown
Member Author

本轮跟进已完成:对用户的 wire/存储格式不变,原 Option 清理对缺失目标段落和非法操作的保护不回退。配对升级到 CLI/procs 0.30.1-alpha.5;正式 0.30.1 的 CLI assets/npm runtime 目前不完整,未强行改成不可安装的正式版本。

精确提交 5890481 的 CI 已成功:https://github.com/TopixIM/tabletwo/actions/runs/39367835627 。独立 Caps/immutable/toolchain、28 个命名空间按双入口完整检查、原有 strict/测试/构建和 COS action 内置上传校验均通过;前后端生产 rsync 均跳过。没有新增额外验证器或放宽基线。

本地 131 个应用定义通过,原生共同测试 63/63、effect 2/2;浏览器/共享部分 62 项 native/JS 原断言及日志一致。服务端 1 项 wire 测试仅计 native 通过,不模拟 native FFI。JS 回放的临时 Node DOM lookup/路径适配不算真实浏览器验收,未提交。Snapshot 和断言与 e31e02f 原提交完全一致。

README 与 PR 说明已纠正旧 nil 清理描述并按用户影响优先使用中文。开放类型边界、alpha.5 双客户端实际协作/持久化、Text 弹窗和后端准备仍需后续验收;未合并、发版或生产部署。

@tiye
tiye merged commit 5bacd03 into main Oct 20, 2026
1 check passed
@tiye
tiye deleted the claude/option-nil-cleanup branch October 20, 2026 05:23
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.

2 participants