feat: convert go types and structs to rust drafts #19

Merged
arnold.cui merged 2 commits from feat/go-struct-to-rust into main 2026-11-18 04:08:49 +00:00
Member

背景

Go struct 与命名类型到 Rust 侧的目标形态需全部由脚本转化产出(目标:类型与结构 100% 机器生成,手写/生成以文件名划界);csv-records/ 被 gitignore,新 worktree 需能自举重建记录表。

变更内容

  • 转化管线 scripts/go_struct_to_rust.rs + 叶子:struct_scan、struct_fields、anon_struct(匿名 struct 提升)、interface_scan(接口方法集)、go_type_mapping(类型映射三态 + 判别族载体参数)、error_rules(error 判别族)、rust_emit(归拢产出)、rust_mapping(包名/命名/落点/std 表)、csv_util。
  • 产物布局:机器产物按 go 包目录归拢,每目录一个 generated.rs(_test.go 归 generated_test.rs);三个固定替身(GoAnyValue/ReadWriteCloser/ErrorValue)合并产出 tsox_core/generated.rs;mod.rs/lib.rs 为派生模块树;生成器永不改写其余文件,手写/生成文件名级区分。
  • 覆盖范围:具名 struct 2304/2378(tools/ 74 个有意跳过);命名别名 864 并入 generated.rs;接口 108 个转 trait(方法签名同一映射,receiver &self),接口字段 Option<Box<dyn X>>;匿名 struct 字段提升伴生命名 struct(19 个,同形体去重);分组参数 a, b string 展开。
  • error 双载体:消息类固定 Result<T, String>/Option<String>;判别族(fswatch/ipc/ls-autoimport)走 ErrorValue 枚举(变体来自 go-error-inventory.csv:37 哨兵 + 控制流哨兵 + Errno(i32),Message 兜底);keep 机制退役。
  • std 决策表:sync/atomic/time/strings/io/fs/bufio/os 21 行;io.ReadWriteCloser 经 blanket trait 合流;prelude 撞名(Box/Result)加 Go 前缀。
  • 引用解析:crate 绝对路径(同文件裸名),列式档位 Table 后缀同步。
  • 盘点配套:go-error-inventory.csv(哨兵/自定义/外部三类 99 项)及口径文档 csv-records.md。

自测结果

  • cargo check 全绿 0 error;连续重跑 diff -r 零差异(幂等);树 2435 → 235 文件(一 struct 一文件旧布局经 prune 自动迁移)。
  • 字段 9236:pointer 2681、func 261、todo 163(待人工:chan/context/sync 等需架构决策项)、keep 1、匿名伴生 19;trait 108;ErrorValue 变体 51。
  • 新 worktree 自举:清单 CSV 缺失或 schema 旧时自动经盘点脚本重建。
  • 评审修改(6837345):移除本 PR 脚本中的全部注释(10 文件 112 行纯删除),与既有脚本零注释惯例一致;3 个入口脚本 rustc 编译通过,query 模式输出与移除前一致。

• 脚本迁出(本分支末尾提交 8335c4e):scripts/ 全目录(含本 PR 新增的转化管线与 testdata)移至私有仓库 tsox-scripts,运行路径改为 ../tsox-scripts(见 agents-docs/contributing/scripts.md);csv-records.md 收敛为列语义摘要,完整口径迁至 tsox-scripts 的 docs/inventory-columns.md;docs/porting/alias-todos.md 生成来源指向同步改写。self-test:cargo check 通过、全仓 scripts/ 旧路径零残留、清单/函数/bench 三脚本冒烟正常。

## 背景 Go struct 与命名类型到 Rust 侧的目标形态需全部由脚本转化产出(目标:类型与结构 100% 机器生成,手写/生成以文件名划界);csv-records/ 被 gitignore,新 worktree 需能自举重建记录表。 ## 变更内容 - **转化管线** scripts/go_struct_to_rust.rs + 叶子:struct_scan、struct_fields、anon_struct(匿名 struct 提升)、interface_scan(接口方法集)、go_type_mapping(类型映射三态 + 判别族载体参数)、error_rules(error 判别族)、rust_emit(归拢产出)、rust_mapping(包名/命名/落点/std 表)、csv_util。 - **产物布局**:机器产物按 go 包目录归拢,每目录一个 generated.rs(_test.go 归 generated_test.rs);三个固定替身(GoAnyValue/ReadWriteCloser/ErrorValue)合并产出 tsox_core/generated.rs;mod.rs/lib.rs 为派生模块树;生成器永不改写其余文件,手写/生成文件名级区分。 - **覆盖范围**:具名 struct 2304/2378(tools/ 74 个有意跳过);命名别名 864 并入 generated.rs;接口 108 个转 trait(方法签名同一映射,receiver &self),接口字段 `Option<Box<dyn X>>`;匿名 struct 字段提升伴生命名 struct(19 个,同形体去重);分组参数 a, b string 展开。 - **error 双载体**:消息类固定 `Result<T, String>`/`Option<String>`;判别族(fswatch/ipc/ls-autoimport)走 ErrorValue 枚举(变体来自 go-error-inventory.csv:37 哨兵 + 控制流哨兵 + Errno(i32),Message 兜底);keep 机制退役。 - **std 决策表**:sync/atomic/time/strings/io/fs/bufio/os 21 行;io.ReadWriteCloser 经 blanket trait 合流;prelude 撞名(Box/Result)加 Go 前缀。 - **引用解析**:crate 绝对路径(同文件裸名),列式档位 Table 后缀同步。 - **盘点配套**:go-error-inventory.csv(哨兵/自定义/外部三类 99 项)及口径文档 csv-records.md。 ## 自测结果 - cargo check 全绿 0 error;连续重跑 diff -r 零差异(幂等);树 2435 → 235 文件(一 struct 一文件旧布局经 prune 自动迁移)。 - 字段 9236:pointer 2681、func 261、todo 163(待人工:chan/context/sync 等需架构决策项)、keep 1、匿名伴生 19;trait 108;ErrorValue 变体 51。 - 新 worktree 自举:清单 CSV 缺失或 schema 旧时自动经盘点脚本重建。 - 评审修改(6837345):移除本 PR 脚本中的全部注释(10 文件 112 行纯删除),与既有脚本零注释惯例一致;3 个入口脚本 rustc 编译通过,query 模式输出与移除前一致。 • **脚本迁出(本分支末尾提交 8335c4e)**:scripts/ 全目录(含本 PR 新增的转化管线与 testdata)移至私有仓库 tsox-scripts,运行路径改为 ../tsox-scripts(见 agents-docs/contributing/scripts.md);csv-records.md 收敛为列语义摘要,完整口径迁至 tsox-scripts 的 docs/inventory-columns.md;docs/porting/alias-todos.md 生成来源指向同步改写。self-test:cargo check 通过、全仓 scripts/ 旧路径零残留、清单/函数/bench 三脚本冒烟正常。
arnold.cui-agent changed title from feat: convert go structs to rust drafts by layout tier to feat: convert go types and structs to rust drafts 2026-11-08 15:34:44 +00:00
arnold.cui-agent requested review from arnold.cui 2026-11-08 15:35:44 +00:00
arnold.cui-agent force-pushed feat/go-struct-to-rust from 0b4373dfb8 to 0768a007e5 2026-11-09 05:23:24 +00:00 Compare
arnold.cui-agent force-pushed feat/go-struct-to-rust from 8335c4eab2 to 18f81a177b 2026-11-14 09:10:12 +00:00 Compare
arnold.cui-agent force-pushed feat/go-struct-to-rust from 18f81a177b to 1974264dd7 2026-11-14 09:57:28 +00:00 Compare
arnold.cui-agent force-pushed feat/go-struct-to-rust from 1974264dd7 to 938d30f08e 2026-11-14 10:07:44 +00:00 Compare
arnold.cui-agent force-pushed feat/go-struct-to-rust from 938d30f08e to 55fbee42ce 2026-11-14 10:07:54 +00:00 Compare
arnold.cui-agent force-pushed feat/go-struct-to-rust from 55fbee42ce to 144af64293 2026-11-14 10:18:08 +00:00 Compare
arnold.cui-agent force-pushed feat/go-struct-to-rust from 144af64293 to 0eeeb31507 2026-11-14 11:28:26 +00:00 Compare
arnold.cui-agent force-pushed feat/go-struct-to-rust from 0eeeb31507 to 00aba2756f 2026-11-14 11:37:27 +00:00 Compare
arnold.cui-agent force-pushed feat/go-struct-to-rust from 00aba2756f to d1d5e64a82 2026-11-14 11:38:14 +00:00 Compare
arnold.cui-agent force-pushed feat/go-struct-to-rust from d1d5e64a82 to 0317c75048 2026-11-14 11:42:30 +00:00 Compare
arnold.cui-agent force-pushed feat/go-struct-to-rust from 0317c75048 to aae2018acd 2026-11-14 11:43:52 +00:00 Compare
arnold.cui-agent force-pushed feat/go-struct-to-rust from aae2018acd to 1aaf843832 2026-11-14 12:55:55 +00:00 Compare
arnold.cui-agent force-pushed feat/go-struct-to-rust from 1aaf843832 to cb29b98418 2026-11-14 14:16:41 +00:00 Compare
arnold.cui-agent force-pushed feat/go-struct-to-rust from cb29b98418 to 4ff3046330 2026-11-14 14:44:41 +00:00 Compare
arnold.cui-agent force-pushed feat/go-struct-to-rust from 4ff3046330 to 778bf405c4 2026-11-15 02:39:47 +00:00 Compare
arnold.cui-agent force-pushed feat/go-struct-to-rust from 778bf405c4 to 3ae31aaa8f 2026-11-15 05:53:45 +00:00 Compare
arnold.cui-agent force-pushed feat/go-struct-to-rust from 3ae31aaa8f to 5990c5c8ee 2026-11-15 14:34:21 +00:00 Compare
arnold.cui-agent force-pushed feat/go-struct-to-rust from 5990c5c8ee to f7b6b975f5 2026-11-15 15:38:54 +00:00 Compare
arnold.cui-agent force-pushed feat/go-struct-to-rust from f7b6b975f5 to 10d6912a31 2026-11-15 16:02:46 +00:00 Compare
arnold.cui-agent force-pushed feat/go-struct-to-rust from 10d6912a31 to 9e8d21fc45 2026-11-15 16:45:36 +00:00 Compare
arnold.cui-agent force-pushed feat/go-struct-to-rust from 9e8d21fc45 to fa3080cc68 2026-11-15 16:59:42 +00:00 Compare
arnold.cui-agent force-pushed feat/go-struct-to-rust from fa3080cc68 to d3ee639f47 2026-11-16 06:28:26 +00:00 Compare
arnold.cui-agent force-pushed feat/go-struct-to-rust from d3ee639f47 to 8dd1c59a9a 2026-11-17 01:51:22 +00:00 Compare
arnold.cui-agent force-pushed feat/go-struct-to-rust from 8dd1c59a9a to cf56e388db 2026-11-17 02:17:38 +00:00 Compare
arnold.cui-agent force-pushed feat/go-struct-to-rust from cf56e388db to 076a68a05e 2026-11-17 07:27:18 +00:00 Compare
arnold.cui-agent force-pushed feat/go-struct-to-rust from 076a68a05e to c390fdf699 2026-11-17 10:17:26 +00:00 Compare
arnold.cui-agent force-pushed feat/go-struct-to-rust from c390fdf699 to 04216dddf5 2026-11-17 10:18:03 +00:00 Compare
arnold.cui-agent force-pushed feat/go-struct-to-rust from 04216dddf5 to ef3844940a 2026-11-17 10:19:00 +00:00 Compare
arnold.cui-agent force-pushed feat/go-struct-to-rust from ef3844940a to 6eee06ab06 2026-11-17 13:33:03 +00:00 Compare
arnold.cui-agent force-pushed feat/go-struct-to-rust from 6eee06ab06 to c62cce408e 2026-11-17 13:36:49 +00:00 Compare
arnold.cui-agent force-pushed feat/go-struct-to-rust from c62cce408e to 54c1d87462 2026-11-17 13:54:17 +00:00 Compare
arnold.cui-agent force-pushed feat/go-struct-to-rust from 54c1d87462 to bb0ed79dfe 2026-11-17 14:17:37 +00:00 Compare
arnold.cui-agent force-pushed feat/go-struct-to-rust from bb0ed79dfe to dbf879d8cb 2026-11-17 15:09:30 +00:00 Compare
arnold.cui-agent force-pushed feat/go-struct-to-rust from dbf879d8cb to abd4be52cf 2026-11-17 15:18:58 +00:00 Compare
arnold.cui-agent force-pushed feat/go-struct-to-rust from abd4be52cf to 7c317816d7 2026-11-17 15:25:42 +00:00 Compare
arnold.cui-agent force-pushed feat/go-struct-to-rust from 7c317816d7 to 7bc5bfdbe3 2026-11-17 15:43:22 +00:00 Compare
arnold.cui-agent force-pushed feat/go-struct-to-rust from 7bc5bfdbe3 to 210ce74958 2026-11-17 15:46:16 +00:00 Compare
arnold.cui-agent added 1 commit 2026-11-18 03:38:52 +00:00
Convert all inventory structs to their target rust forms: columnar
tables for the soa tier, row structs otherwise, enums for pointer-only
sum types with *struct{}. Undecided zero-size payloads (struct{},
sync.Mutex/RWMutex locks) and unknown types emit !todo_unit / !todo
sentinels that fail compilation on purpose, so every remaining gap is
a loud build error instead of a silently compiling unit; grep counts
the debt.

The tools/ tree (customlint and friends) translates into tsox_tools
mirroring the go layout, and the lsproto structcodec skip list is
gone, so every inventory struct converts. Qualified-name resolution
disambiguates same-named packages (the customlint tspath testdata
shadow) by longest common directory prefix with the caller. The
tsox_compat package grows to 22 modules: json v2 family, xml, zip,
x/text family, xxh3, errgroup, testing, go/ast, go/token, go/types,
reflect and the x/tools go/analysis family (analysis, inspector,
ctrlflow, packages), wired through std_type so tools structs map
analysis.Pass, ast.Node, types.Type and friends.
arnold.cui-agent force-pushed feat/go-struct-to-rust from 210ce74958 to eb9abd7993 2026-11-18 03:38:52 +00:00 Compare
arnold.cui-agent added 1 commit 2026-11-18 04:03:40 +00:00
Upstream sync through 2026-11-18 (e086ad3b): 50 new structs and 3 new
named types across ast (CaseClause/DefaultClause split from
CaseOrDefaultClause), checker (ResolvingObjectType, clearableMap),
project (ContentMapperSelector), incremental build info, vfsmatch and
tsoptions. Converted surface grows 2317 -> 2361 structs, excluded
grows 61 -> 67 (new test fixtures), audit stays fully green with zero
missing entries and zero pending fields; cargo build remains at zero
errors and zero warnings.
arnold.cui approved these changes 2026-11-18 04:08:24 +00:00
arnold.cui merged commit 9add5a783e into main 2026-11-18 04:08:49 +00:00
arnold.cui deleted branch feat/go-struct-to-rust 2026-11-18 04:08:49 +00:00
Sign in to join this conversation.
No Reviewers
No labels
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: idealjs/tsox#19