@calcit/procs 0.12.56 → 0.12.57

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (155) hide show
  1. package/.yarn/install-state.gz +0 -0
  2. package/build.rs +36 -2
  3. package/editing-history/202608011759-issue-routing-in-agent-guide.md +17 -0
  4. package/editing-history/202608011833-schema-type-symbols.md +20 -0
  5. package/editing-history/202608011852-wasm-dynamic-string-tag.md +7 -0
  6. package/editing-history/202608011908-consolidate-history.md +6 -0
  7. package/editing-history/202608012022-consolidate-cli-and-test-duplication.md +28 -0
  8. package/editing-history/202608012123-review-follow-up.md +18 -0
  9. package/editing-history/202608012320-release-0.12.57.md +5 -0
  10. package/editing-history/ARCHIVE.md +15 -0
  11. package/editing-history/README.md +21 -0
  12. package/lib/package.json +1 -1
  13. package/package.json +1 -1
  14. package/editing-history/2026-02-13-1841-trait-origin-structural-eq.md +0 -91
  15. package/editing-history/2026-02-14-2050-js-codegen-recursion-tag-migration.md +0 -39
  16. package/editing-history/2026-02-14-2358-emit-js-modularization-shift-left.md +0 -63
  17. package/editing-history/2026-02-15-0000-diagnostics-consolidated.md +0 -35
  18. package/editing-history/2026-02-15-1941-macro-diagnostics-refinement.md +0 -39
  19. package/editing-history/2026-02-16-2043-core-api-docs-cleanup.md +0 -40
  20. package/editing-history/2026-02-23-0834-migrate-to-defstruct.md +0 -91
  21. package/editing-history/2026-02-23-2321-ns-imports-code-fixes.md +0 -42
  22. package/editing-history/2026-02-25-0002-language-behavior-eval-mode.md +0 -93
  23. package/editing-history/2026-02-25-0111-guidebook-no-check-block-upgrades.md +0 -52
  24. package/editing-history/2026-02-25-0113-runtime-type-validation-and-macro-quoting.md +0 -41
  25. package/editing-history/2026-02-25-1131-check-md-eval-improvements.md +0 -13
  26. package/editing-history/2026-02-26-1324-check-md-inprocess-cache-and-path-labels.md +0 -7
  27. package/editing-history/2026-02-27-1640-unify-markdown-readers.md +0 -16
  28. package/editing-history/2026-02-27-1958-tree-rewrite-command-and-reference-model.md +0 -18
  29. package/editing-history/2026-02-27-2200-split-def-command.md +0 -29
  30. package/editing-history/2026-02-27-2212-tree-raise-wrap.md +0 -33
  31. package/editing-history/2026-02-27-2223-calcit-agent-docs-optimize.md +0 -41
  32. package/editing-history/2026-03-01-0212-query-search-entry-and-ffi-warning.md +0 -53
  33. package/editing-history/2026-03-03-1934-check-types-and-core-annotations.md +0 -17
  34. package/editing-history/2026-03-04-0000-generics-fn-typevar-identity.md +0 -30
  35. package/editing-history/2026-03-04-1331-tag-call-warning-and-dot-access-migration.md +0 -28
  36. package/editing-history/2026-03-04-1548-impl-new-dot-method-input-and-doc-hints.md +0 -33
  37. package/editing-history/2026-03-04-1645-calcit-eq-contract-refactor-and-macro-tests.md +0 -28
  38. package/editing-history/2026-03-04-2200-assert-type-assert-traits-composable-runtime-checks.md +0 -18
  39. package/editing-history/2026-03-05-0042-type-inference-argtypes-and-core-hints.md +0 -54
  40. package/editing-history/2026-03-05-0115-calcit-core-generic-refinements.md +0 -57
  41. package/editing-history/2026-03-05-1930-schema-migration-cr-edit.md +0 -30
  42. package/editing-history/2026-03-05-1939-query-schema-adaptation.md +0 -42
  43. package/editing-history/2026-03-06-0120-schema-hint-migration-batch.md +0 -38
  44. package/editing-history/2026-03-06-1416-core-macro-schema-migration.md +0 -20
  45. package/editing-history/2026-03-06-1552-core-schema-and-hintfn-migration.md +0 -63
  46. package/editing-history/2026-03-06-1936-schema-normalization-and-preprocess-preload.md +0 -12
  47. package/editing-history/2026-03-07-0000-migrate-hint-fn-to-schema.md +0 -29
  48. package/editing-history/2026-03-07-0000-remove-enum-prototype-field.md +0 -43
  49. package/editing-history/2026-03-07-0000-schema-args-type-enforcement.md +0 -66
  50. package/editing-history/2026-03-07-0142-unit-type-and-builtin-schemas.md +0 -82
  51. package/editing-history/2026-03-07-1652-decouple-snapshot-schema-to-calcit-type.md +0 -112
  52. package/editing-history/2026-03-07-1821-snapshot-schema-validation.md +0 -6
  53. package/editing-history/2026-03-07-1959-schema-def-kind-arity-validation.md +0 -96
  54. package/editing-history/2026-03-08-0031-schema-generics-quote-normalization.md +0 -35
  55. package/editing-history/2026-03-08-1905-schema-typeref-and-assert-migration.md +0 -34
  56. package/editing-history/2026-03-08-2033-schema-wrapper-migration.md +0 -45
  57. package/editing-history/2026-03-08-2315-late-schema-cleanup-and-warning-compat.md +0 -27
  58. package/editing-history/2026-03-09-1753-schema-type-fail-tests.md +0 -17
  59. package/editing-history/2026-03-10-1040-edit-schema-primitive-tag-support.md +0 -42
  60. package/editing-history/2026-03-10-1754-ns-entry-snapshot-migration.md +0 -66
  61. package/editing-history/2026-03-13-2216-validate-struct-type-arg-arity.md +0 -24
  62. package/editing-history/2026-03-16-2353-runtime-boundary-cleanup.md +0 -14
  63. package/editing-history/2026-03-17-0150-runtime-boundary-lookup-cleanup.md +0 -28
  64. package/editing-history/2026-03-20-0116-json-builtins-and-runtime-docs.md +0 -48
  65. package/editing-history/2026-03-26-2013-docs-frontmatter-and-module-search.md +0 -58
  66. package/editing-history/2026-04-07-1550-path-format-at-prefix-migration.md +0 -46
  67. package/editing-history/2026-04-12-1524-js-codegen-map-to-record.md +0 -26
  68. package/editing-history/2026-04-12-1549-map-to-record-field-validation.md +0 -29
  69. package/editing-history/2026-04-13-1600-tuple-to-enum-rewrite.md +0 -13
  70. package/editing-history/2026-04-13-2309-typeslot-enum-compile-safety.md +0 -45
  71. package/editing-history/2026-04-14-1500-loose-record-syntax.md +0 -32
  72. package/editing-history/2026-04-14-2259-bidir-type-check-refactor.md +0 -63
  73. package/editing-history/2026-04-15-0120-match-syntax-exhaustiveness.md +0 -20
  74. package/editing-history/2026-04-15-1211-record-nth-optimization.md +0 -44
  75. package/editing-history/2026-04-16-1936-predicate-narrowing-expansion.md +0 -31
  76. package/editing-history/2026-04-17-0132-monomorphize-map-filter.md +0 -50
  77. package/editing-history/2026-04-17-0135-monomorphize-includes-reverse.md +0 -31
  78. package/editing-history/2026-04-17-0140-fold-type-predicates.md +0 -44
  79. package/editing-history/2026-04-17-0154-generic-dispatch-records-tuples.md +0 -52
  80. package/editing-history/2026-04-17-0520-simplify-generic-defns-via-method-dispatch.md +0 -49
  81. package/editing-history/2026-05-21-0055-tree-show-cr-config-and-edit-cleanup.md +0 -81
  82. package/editing-history/2026-05-31-2052-macro-schema-roundtrip-and-weak-types.md +0 -6
  83. package/editing-history/2026-05-31-2105-map-generic-weak-types-followup.md +0 -15
  84. package/editing-history/2026-06-01-0003-update-callback-field-specialization.md +0 -19
  85. package/editing-history/2026-06-01-2317-data-definition-where-bounds.md +0 -6
  86. package/editing-history/2026-06-02-0114-data-definition-where-macro-followup.md +0 -21
  87. package/editing-history/2026-06-03-0000-check-md-edn-errors.md +0 -5
  88. package/editing-history/2026-06-03-1600-check-md-entry-modules.md +0 -6
  89. package/editing-history/2026-06-04-0000-check-md-app-main-init.md +0 -6
  90. package/editing-history/2026-06-04-2218-compiled-executable-runtime-backfill.md +0 -6
  91. package/editing-history/2026-06-09-0000-with-type-slot-scoped-binding.md +0 -83
  92. package/editing-history/2026-06-09-1241-remove-bind-type.md +0 -64
  93. package/editing-history/2026-06-09-1800-core-effect-tags.md +0 -57
  94. package/editing-history/2026-06-10-1200-get-def-doc-schema-builtin.md +0 -7
  95. package/editing-history/2026-06-15-1500-effects-graph-mvp.md +0 -30
  96. package/editing-history/2026-06-16-1700-effects-graph-ste-tree.md +0 -84
  97. package/editing-history/2026-06-27-0052-cli-improvements.md +0 -41
  98. package/editing-history/2026-06-27-0202-docs-indexing-improvements.md +0 -22
  99. package/editing-history/2026-06-27-0315-file-splits.md +0 -17
  100. package/editing-history/2026-06-27-0416-agent-advanced-split.md +0 -15
  101. package/editing-history/archived/2025-04-12-1453-map-to-record-rewrite.md +0 -33
  102. package/editing-history/archived/2025-04-16-0117-wasm-codegen-and-catalog-update.md +0 -40
  103. package/editing-history/archived/2025-07-16-0207-wasm-encoder-migration.md +0 -48
  104. package/editing-history/archived/2025-07-16-1633-wasm-data-structures.md +0 -61
  105. package/editing-history/archived/2026-02-13-1926-docs-tests-followup.md +0 -33
  106. package/editing-history/archived/2026-02-16-2128-docs-smoke-and-trait-errors.md +0 -20
  107. package/editing-history/archived/2026-02-25-1234-watch-mode-default-once.md +0 -5
  108. package/editing-history/archived/2026-03-07-1302-calcit-agent-docs-update.md +0 -32
  109. package/editing-history/archived/2026-03-09-1819-add-test-fail-script.md +0 -5
  110. package/editing-history/archived/2026-03-09-1944-split-type-fail-tests.md +0 -8
  111. package/editing-history/archived/2026-03-16-1449-profiling-tools-reorg.md +0 -13
  112. package/editing-history/archived/2026-03-17-2026-afternoon-runtime-boundary-optimization-summary.md +0 -87
  113. package/editing-history/archived/2026-03-18-1802-tips-level-and-overwrite-schema-preservation.md +0 -26
  114. package/editing-history/archived/2026-03-20-1229-query-window-3-with-parent-preview.md +0 -72
  115. package/editing-history/archived/2026-03-23-1137-command-echo-tool-output-cleanup.md +0 -71
  116. package/editing-history/archived/2026-04-10-0011-snapshot-empty-version-pipe-marker.md +0 -23
  117. package/editing-history/archived/2026-04-16-0131-wasm-math-and-test-integration.md +0 -28
  118. package/editing-history/archived/2026-04-16-1507-wasm-data-structures-and-rfc-rename.md +0 -27
  119. package/editing-history/archived/2026-04-16-1520-wasm-bitwise-and-match.md +0 -21
  120. package/editing-history/archived/2026-04-16-1542-wasm-cross-ns-host-imports.md +0 -38
  121. package/editing-history/archived/2026-04-17-0026-wasm-rest-args.md +0 -62
  122. package/editing-history/archived/2026-04-17-0048-wasm-type-of.md +0 -70
  123. package/editing-history/archived/2026-04-17-0051-wasm-derived-predicates.md +0 -34
  124. package/editing-history/archived/2026-04-17-2316-wasm-do-println-fixes.md +0 -41
  125. package/editing-history/archived/2026-04-18-1208-split-emit-wasm-and-bump-version.md +0 -15
  126. package/editing-history/archived/2026-04-18-1430-wasm-list-match-and-method-dispatch.md +0 -5
  127. package/editing-history/archived/2026-04-18-2041-cr-wasm-split-and-runtime-stability.md +0 -18
  128. package/editing-history/archived/2026-04-18-2045-v0.12.23-ci-wasm-fix.md +0 -13
  129. package/editing-history/archived/2026-04-21-1818-wasm-string-ops-v2.md +0 -57
  130. package/editing-history/archived/2026-04-21-2332-split-emit-wasm.md +0 -45
  131. package/editing-history/archived/2026-04-22-0114-wasm-hof-intercepts-and-set-intersection.md +0 -82
  132. package/editing-history/archived/2026-04-22-0136-wasm-enum-tuple-bool-str-fixes.md +0 -68
  133. package/editing-history/archived/2026-04-22-1340-wasm-map-diff-new-and-let-intercept.md +0 -53
  134. package/editing-history/archived/2026-04-23-1419-v0.12.26-wasm-bisection-fixes.md +0 -7
  135. package/editing-history/archived/2026-04-23-1645-release-conventions.md +0 -14
  136. package/editing-history/archived/2026-04-25-1940-wasm-suite-multi-module-entry.md +0 -53
  137. package/editing-history/archived/2026-04-25-2003-wasm-method-includes-string-and-set-refactor.md +0 -71
  138. package/editing-history/archived/2026-04-25-2010-wasm-suite-add-fn-lens-edn.md +0 -43
  139. package/editing-history/archived/2026-04-25-2051-display-by.md +0 -39
  140. package/editing-history/archived/2026-04-28-1728-fix-gensym-stable.md +0 -31
  141. package/editing-history/archived/2026-04-29-1400-fix-bind-type-precompile.md +0 -38
  142. package/editing-history/archived/2026-05-26-0957-match-docs-check-md.md +0 -24
  143. package/editing-history/archived/2026-05-31-2059-ci-docs-test-and-fn-helper-tightening.md +0 -3
  144. package/editing-history/archived/2026-06-01-0005-release-0.12.36.md +0 -16
  145. package/editing-history/archived/2026-06-01-2230-enum-struct-payload-docs.md +0 -4
  146. package/editing-history/archived/2026-06-03-1620-release-0.12.38.md +0 -6
  147. package/editing-history/archived/2026-06-04-0000-release-0.12.39.md +0 -4
  148. package/editing-history/archived/2026-06-04-2230-release-0.12.40.md +0 -5
  149. package/editing-history/archived/2026-06-12-1525-weak-types-dots-format.md +0 -15
  150. package/editing-history/archived/2026-06-13-1200-primitive_schema_tags.md +0 -9
  151. package/editing-history/archived/2026-06-20-1142-ts-declaration-d-mts.md +0 -5
  152. package/editing-history/archived/2026-06-29-0117-upgrade-doc-snapshot-migration.md +0 -2
  153. package/editing-history/archived/2026-06-29-calcit-cli.md +0 -80
  154. package/editing-history/archived/2026-06-29-typed-calcit-cli-schemas.md +0 -23
  155. package/editing-history/archived/20260630-duplication-analysis.md +0 -116
@@ -1,13 +0,0 @@
1
- ## 概要
2
-
3
- 为 tuple-to-enum 自动改写实现预处理阶段支持。当函数参数 schema 标注为 enum 类型时,
4
- 调用者传递的 untyped tuple `:: :tag payload` 自动改写为 `%:: Enum :tag payload`。
5
-
6
- ## 知识点
7
-
8
- - `CalcitTypeAnnotation::resolve_to_enum_with_ref()` 对应 struct 端已有的 `resolve_to_struct_with_ref()`
9
- - `resolve_enum_from_program()` 通过 `lookup_runtime_ready_registered` + `lookup_def_code_registered` 两级缓存查找
10
- - tuple 改写只替换 head proc (`NativeTuple` → `NativeEnumTupleNew`) 并插入 enum 引用,不对 tag/payload 做验证(由 `check_enum_tuple_construction` 兜底)
11
- - JS codegen 需要 `Calcit::Import` 而非 `Calcit::Enum` 内联值,通过 TypeRef 路径判断走 SameFile 还是 NsReferDef
12
- - map-to-record 改写验证 key 合法性,tuple-to-enum 改写不验证(差异源于 struct field 是封闭集合,enum tag 验证已有独立检查)
13
- - Cirru tag-match 零载荷变体的 pattern 是 `(:ok)` 而非 `:ok`(后者在 pair 中被当作 body)
@@ -1,45 +0,0 @@
1
- # TypeSlot + Enum 编译期安全增强
2
-
3
- ## 概要
4
-
5
- 让 `deftype-slot` / `bind-type` 机制真正实现编译期 enum variant 校验。此前 TypeSlot 绑定的 enum 在自动推导 (`:: → %::`) 路径上缺乏变体验证,导致拼写错误或不存在的 variant 无法在 `cr js` / `--check-only` 时报出。
6
-
7
- ## 修改的文件
8
-
9
- ### `src/calcit/type_annotation.rs`
10
-
11
- - `resolve_to_enum_with_ref()`: 新增 `TypeSlot` 分支,通过 `resolve_type_slot()` 解析绑定类型后委托
12
- - `matches_with_bindings()`: 双向 `Tuple/Enum` 匹配 — 原先只有 `(Tuple, Enum)` 方向,TypeSlot 解析后顺序会翻转,新增 `(Enum, Tuple)` 方向
13
-
14
- ### `src/calcit.rs`
15
-
16
- - 将 `resolve_type_slot` 加入 `pub use` 导出列表
17
-
18
- ### `src/runner/preprocess.rs`
19
-
20
- - `resolve_enum_value()`: 在 `as_struct()` 调用前增加 TypeSlot 解析(避免 `&CalcitStruct` 生命周期问题)
21
- - 新增 `try_rewrite_local_fn_tuple_args_to_enum_tuples()`: 对本地函数调用(如回调 `d!`)也执行 tuple→enum 自动重写
22
- - 主预处理 `Calcit::Local` 分支: 增加 local fn 调用的重写+类型检查(clone 避免借用冲突)
23
- - `try_rewrite_single_tuple_to_enum_tuple()`: 增加变体验证 — 重写后立即检查 tag 是否是 enum 的合法 variant,不合法则发出警告
24
-
25
- ### `src/bin/cr_tests/type_fail.rs`
26
-
27
- - 新增 `type_fail_type_slot_enum_invalid_variant` 测试,验证 TypeSlot 绑定的 enum 在自动重写路径下能正确检测不存在的 variant
28
-
29
- ### `calcit/type-fail/type-slot-enum-invalid-variant.cirru`
30
-
31
- - 新增测试 fixture:声明 `defenum Action`、通过 TypeSlot 绑定、调用 `takes-action $ :: :nonexistent |hello`,期望产生 variant 不存在警告
32
-
33
- ## 知识点
34
-
35
- 1. **TypeSlot 解析链**: `TypeSlot(name) → resolve_type_slot(name) → CalcitTypeAnnotation (通常是 TypeRef)` → 再通过 `resolve_to_enum_with_ref()` 得到 enum 定义。这是一个两步间接过程。
36
-
37
- 2. **`matches_with_bindings` 双向性**: TypeSlot 被解析后会调 `bound.matches_with_bindings(other, bindings)`,此时 self/other 顺序可能翻转。所有组合型匹配(如 Tuple/Enum)都需要双向 pattern。
38
-
39
- 3. **`as_struct()` 返回引用**: `CalcitTypeAnnotation::as_struct()` 返回 `Option<&CalcitStruct>`,无法从临时解析结果中返回引用。修复方案是在调用点先解析 TypeSlot 再调 `as_struct()`。
40
-
41
- 4. **自动重写的 `%::` 不经过 `preprocess_expr`**: `try_rewrite_single_tuple_to_enum_tuple` 构造的 `[NativeEnumTupleNew, ...]` 列表是在预处理完参数后生成的,不会经过 `check_proc_arg_types` 中的 `check_enum_tuple_construction`。因此变体验证必须在重写函数内部完成。
42
-
43
- 5. **Local fn 调用缺少自动重写**: 原先只有 `CalcitFn` 调用走 `try_rewrite_tuple_args_to_enum_tuples`。`Calcit::Local` 调用(如回调参数 `d!`)需要单独处理。新函数接受 `CalcitFnTypeAnnotation` 而非 `CalcitFn`。
44
-
45
- 6. **Lambda-in-map 的 EXPECTED_FN_TYPE 盲区**: `fn (e d!)` 在 hashmap 值(如 `:on-click`)中时,`d!` 不会获得 `EXPECTED_FN_TYPE` 注入的类型信息。目前通过显式 `%:: Op :variant` 写法绕过,属于已知架构限制。
@@ -1,32 +0,0 @@
1
- # 2026-04-14 15:00 — `?{}` 松散 Record 语法
2
-
3
- ## 概要
4
-
5
- 新增 `?{}` 松散 record 语法,允许不声明 struct 就创建 record,与 `::` 无类型 tuple 对称。
6
- 在函数参数有 struct 类型标注时,预处理阶段自动改写为 `%{} StructDef ...`。
7
-
8
- ## 改动文件
9
-
10
- | 文件 | 变更 |
11
- |------|------|
12
- | `src/calcit/proc_name.rs` | 新增 `NativeLooseRecord` proc 变体,`?{}` 序列化,类型签名 |
13
- | `src/data/cirru.rs` | `"?{}"` token 解析为 `Calcit::Proc(NativeLooseRecord)` |
14
- | `src/calcit/record.rs` | `LOOSE_RECORD_NAME`、`is_loose()`、`from_loose_pairs()` |
15
- | `src/builtins/records.rs` | `call_loose_record()` 运行时:验证 tag 键、排序、排重 |
16
- | `src/builtins.rs` | 分发 `NativeLooseRecord => call_loose_record(args)` |
17
- | `src/calcit.rs` | Display: 松散 record 显示为 `(?{} ...)` |
18
- | `src/runner/preprocess.rs` | `try_rewrite_loose_record_args_to_struct_records`、类型推断、skip core arg check |
19
- | `ts-src/js-record.mts` | JS 运行时 `_$q__$M_` 函数 |
20
- | `calcit/test-record.cirru` | `test-loose-record-rewrite` 集成测试 |
21
- | `docs/features/records.md` | 文档:松散 record 语法、自动改写、类型对称表 |
22
-
23
- ## 性能优化
24
-
25
- - **预处理改写链合并重建**:三步改写(map→record、loose→struct、tuple→enum)原先每步都重建 `ys` (CalcitList),优化为仅在有改写时统一重建一次,减少 CalcitList push 操作。
26
- - **JS 排序比较器修正**:将重复字段检测从 sort comparator 中移出(comparator 内 throw 违反排序契约),改为排序后线性扫描相邻元素,行为更可靠。
27
-
28
- ## 知识点
29
-
30
- - `EdnTag::cmp` 按全局 tag 池分配顺序排序(整数 index),**不是**字典序。record 字段排序必须用 `ref_str().cmp()` 保持字母序。
31
- - CalcitList 基于 persistent ternary tree,`.clone()` 是 O(1) 引用计数操作。
32
- - Sort comparator 不应抛异常——不同排序算法对异常行为未定义。
@@ -1,63 +0,0 @@
1
- # 202604142259 — Bidirectional Type Checking Architecture Refactoring
2
-
3
- ## 概要
4
-
5
- 将 `src/runner/preprocess.rs`(6199 行单体文件)拆分为模块化目录结构,
6
- 按双向类型检查(bidirectional type checking)的概念分离关注点。
7
-
8
- ## 改动详情
9
-
10
- ### 模块拆分
11
-
12
- `preprocess.rs` → `preprocess/` 目录模块:
13
-
14
- | 模块 | 行数 | 职责 |
15
- |---|---|---|
16
- | `mod.rs` | ~4744 | 预处理核心:符号解析、宏展开、作用域管理、特殊语法 |
17
- | `type_inference.rs` | ~693 | 类型合成(synthesis):自下而上推导表达式类型 |
18
- | `type_checking.rs` | ~402 | 类型检查(checking):自上而下验证参数类型 |
19
- | `type_rewriting.rs` | ~398 | 类型定向重写:根据期望类型重写 AST 字面量 |
20
-
21
- ### 代码去重
22
-
23
- 1. **统一参数重写循环** (`rewrite_args_by_expected_type`):
24
- - 原先 4 个 `try_rewrite_*_args_to_*` 函数各自包含相同的外层循环(~30 LOC × 4)
25
- - 提取为泛型 `rewrite_args_by_expected_type<F>` 函数,4 个入口各只保留闭包调用
26
-
27
- 2. **统一参数类型检查循环** (`check_arg_types_loop`):
28
- - 原先 `check_local_fn_call_arg_types` 和 `check_user_fn_arg_types` 共享相同的
29
- zip → resolve_type_value → matches_with_bindings → gen_check_warning 模式
30
- - 提取为泛型 `check_arg_types_loop<F>` 函数,包含 variadic 处理和 spread 跳过逻辑
31
-
32
- 3. **统一引用节点构建** (`build_struct_ref_node` / `build_enum_ref_node`):
33
- - 原先 map→record 和 loose-record→struct 各自复制 Import vs Struct/Enum 分支
34
- - 提取为共享的 `build_struct_ref_node` 和 `build_enum_ref_node` 函数
35
-
36
- ### Proc 推导提取
37
-
38
- - `infer_type_from_expr` 中的 `Calcit::Proc` 分支(~100 行 match arms)
39
- 提取为独立的 `infer_proc_call_return_type` 函数,提高可读性
40
-
41
- ## 双向类型检查映射
42
-
43
- 参照 Dunfield & Krishnaswami 的框架:
44
-
45
- | 方向 | 模块 | 入口函数 |
46
- |---|---|---|
47
- | **Synthesis** (⇒) | `type_inference` | `infer_type_from_expr`, `resolve_type_value` |
48
- | **Checking** (⇐) | `type_checking` | `check_*_arg_types`, `check_function_return_type` |
49
- | **Rewriting** (结构适配) | `type_rewriting` | `try_rewrite_*` |
50
- | **Context** (线程局部) | `mod.rs` | `EXPECTED_FN_TYPE`, `EXPECTED_STRUCT_TYPE` |
51
-
52
- ## 为后续 match 语法扩展铺路
53
-
54
- - `type_checking.rs` 的 `check_arg_types_loop` 模式可直接复用于 match 分支检查
55
- - `type_inference.rs` 中已有 `infer_if_return_type` 作为分支合并的模板
56
- - 未来只需在相应模块中添加新函数,无需修改 `mod.rs` 的核心调度
57
-
58
- ## 验证
59
-
60
- - `cargo check --lib` ✅ 零警告
61
- - `cargo clippy --lib -- -D warnings` ✅ 零警告
62
- - `cargo fmt` ✅ 格式一致
63
- - 链接器问题(`ld: library 'System' not found`)是环境问题,非代码变更引起
@@ -1,20 +0,0 @@
1
- # match syntax with exhaustiveness checking
2
-
3
- ## Summary
4
-
5
- Added native `match` syntax for enum pattern matching with compile-time exhaustiveness detection,
6
- as a safer alternative to `tag-match` macro. See `drafts/match-syntax-rfc.md` for full design.
7
-
8
- ## Files modified
9
-
10
- - `src/calcit/syntax_name.rs` — `CalcitSyntax::Match`
11
- - `src/builtins/syntax.rs` — `syntax_match()` runtime
12
- - `src/builtins.rs` — dispatch entry
13
- - `src/runner/preprocess/mod.rs` — `preprocess_match()` with exhaustiveness
14
- - `src/codegen/emit_js.rs` — `gen_match_code()` JS output
15
- - `calcit/test-enum.cirru` — test cases
16
-
17
- ## Key takeaway
18
-
19
- Cirru indentation creates pair-based `(pattern body)` children — same format as `tag-match`.
20
- Flat alternating format doesn't survive Cirru serialization round-trips.
@@ -1,44 +0,0 @@
1
- # `&record:nth` — Compile-Time Record Field Index Optimization
2
-
3
- ## 概述
4
-
5
- 新增 `NativeRecordNth` / `&record:nth` 过程,在预处理阶段将 record 字段访问优化为 O(1) 索引访问,绕过运行时的类型分发链和二分查找。
6
-
7
- ## 优化前访问路径
8
-
9
- - `(:field record)` → 重写为 `(get arg :field)` → 运行时 6 次类型判断 (`nil?` → `string?` → `map?` → `list?` → `tuple?` → `record?`) → `&record:get` → `index_of()` O(log n) 二分查找
10
- - `&record:get record :field` → 运行时 `index_of()` O(log n) 二分查找
11
-
12
- ## 优化后访问路径
13
-
14
- 当预处理阶段可以通过 `resolve_type_value` + `as_struct()` 解析出 record 的 struct 定义时:
15
-
16
- - `(:field record)` → 直接重写为 `(&record:nth record <compile-time-idx>)` → 运行时 O(1) `values[idx]`
17
- - `&record:get record :field` → 重写为 `(&record:nth record <compile-time-idx>)` → 运行时 O(1)
18
-
19
- ## 触发条件
20
-
21
- 优化仅在类型信息明确时激活:
22
- - record 由 `%Struct ...` 构造器在本地 `let` 中创建
23
- - 函数参数有显式 struct 类型的 schema 标注
24
-
25
- 若类型不明,回 fallback 到原有路径,不影响运行时行为。
26
-
27
- ## 修改文件
28
-
29
- 1. **`src/calcit/proc_name.rs`** — 新增 `NativeRecordNth` 变体 (`&record:nth`),签名 `(record, number) → dynamic`
30
- 2. **`src/builtins/records.rs`** — 实现 `record_nth(xs)` 运行时函数,直接 `values[idx]` 访问
31
- 3. **`src/builtins.rs`** — 分发表连线 `NativeRecordNth => records::record_nth`
32
- 4. **`src/runner/preprocess/mod.rs`** — 两个重写点:
33
- - Tag-call (`Calcit::Tag` as head):解析 arg 类型后索引重写
34
- - `NativeRecordGet` proc call:解析 record arg 类型后索引重写
35
- 5. **`src/runner/preprocess/type_inference.rs`** — `infer_record_nth_type()` 根据 struct 的 `field_types[idx]` 推断返回类型
36
- 6. **`src/runner/preprocess/type_checking.rs`** — 将 `NativeRecordNth` 加入 core arg type check 跳过列表
37
- 7. **`src/codegen/emit_js.rs`** — JS 内联代码生成 `record.values[idx]`,无函数调用开销
38
-
39
- ## 知识点
40
-
41
- - `CalcitStruct.index_of(field_str)` 在编译期使用,用字段名解析排序位置
42
- - `resolve_type_value()` 返回 `None` 时优化不触发,安全回退
43
- - JS CalcitRecord 的 `.values` 数组和 Rust 端的 `values` Vec 索引一致(均按字段名字母序排序)
44
- - 对于真实项目(如 respo),函数参数通常缺少 struct 类型标注,优化暂不触发;后续若 schema 推断增强,无需改动 rewrite 逻辑即可自动生效
@@ -1,31 +0,0 @@
1
- # 扩展 extract_predicate_binding 支持更多类型谓词
2
-
3
- ## 改动概要
4
-
5
- 将 `extract_predicate_binding` 重构为 `extract_predicate_bindings`,支持双向窄化(true/false 分支),并新增 6 个类型谓词的窄化支持。
6
-
7
- ## 修改文件
8
-
9
- ### src/runner/preprocess/mod.rs
10
-
11
- - 重构 `extract_predicate_binding` → `extract_predicate_bindings`,返回 `PredicateNarrowing` 结构体(包含 `true_binding` 和 `false_binding`)
12
- - `preprocess_if` 中 false 分支也应用窄化信息
13
- - 新增谓词:`tag?` → `:tag`、`bool?` → `:bool`、`symbol?` → `:symbol`、`fn?` → `:fn`
14
- - 新增 `nil?`/`some?`:当变量已知为 `Optional(T)` 时,nil? 的 false 分支窄化为 `T`,some? 的 true 分支窄化为 `T`
15
-
16
- ### src/calcit/proc_name.rs
17
-
18
- - `TurnTag` 的参数签名从 `some_tag("string")` 改为 `dynamic_tag()`,因为 `turn-tag` 在运行时接受 tag/symbol/string,旧签名在 `tag?` 窄化后误报
19
-
20
- ## 知识点
21
-
22
- 1. **双向窄化**:`if (nil? x) ... else ...`,false 分支可从 `Optional(T)` 解包为 `T`,这在链式 if 模式中可以传播类型信息
23
- 2. **新窄化暴露的类型签名问题**:`tag?` 窄化后,`(turn-tag x)` 触发了 arg-type-mismatch 警告,因为 `turn-tag` 签名过严。类似 coercion 函数应使用 `dynamic_tag()`
24
- 3. **核心库中 `if (tag? ...)` 出现 5 次、`if (nil? ...)` 26 次、`if (list? ...)` 41 次**——窄化覆盖面广
25
- 4. **JS 端 tuple `.nth` 缺失**:prior session 简化了多态函数(移除 tuple? 分支),但 JS runtime 的 `invoke_method` 没有对应的 core-tuple-methods 注册,导致 JS 测试 `test_refs` 失败。这是 JS procs 层的问题,不是预处理阶段的问题
26
-
27
- ## 测试结果
28
-
29
- - Rust: 246 tests pass(67 cirru + 179 unit)
30
- - Clippy: clean
31
- - JS: 已知 pre-existing failure(tuple .nth in JS runtime)
@@ -1,50 +0,0 @@
1
- # Monomorphize `map` / `filter` at Compile Time
2
-
3
- ## 背景
4
-
5
- `try_specialize_polymorphic_call`(`src/runner/preprocess/mod.rs`)原本只能把
6
- `count`、`empty?`、`first`、`rest`、`nth`、`get`、`assoc`、`contains?` 等
7
- **built-in 多态 proc** 特化成 native proc(`NativeListCount` / `NativeMapGet`
8
- 等),彻底避免运行时按 `type_of` 做分支。
9
-
10
- 但是 Calcit 里最常见的集合高阶函数 `map` / `filter` / `reduce` 等都是在
11
- `calcit-core.cirru` 里用 Calcit 本身定义的用户级 defn(例如 `&list:map`、
12
- `&map:map`、`&set:filter`),原先不能在预处理阶段复用这套机制,运行时仍要靠
13
- `list?`/`map?`/`set?` 三条 `cond` 分支来分发。
14
-
15
- 本次把能力扩展到 Calcit 级别的 core def,当 receiver 的静态类型可推断时,
16
- 直接把 `(map xs f)` 改写成 `(calcit.core/&list:map xs f)` 等形式。
17
-
18
- ## 关键改动
19
-
20
- - `src/runner/preprocess/mod.rs`
21
- - `try_specialize_polymorphic_call` 新增 `file_ns: &str` 参数,用于构造
22
- `Calcit::Import` 头的 `ImportInfo::Core { at_ns }`。
23
- - 在已有的 proc 特化表之前新增一张“core def 特化表”:
24
- - `("map", List(_)) -> &list:map`
25
- - `("map", Map(_, _)) -> &map:map`
26
- - `("filter", List(_)) -> &list:filter`
27
- - `("filter", Map(_, _)) -> &map:filter`
28
- - `("filter", Set(_)) -> &set:filter`
29
- - 命中时直接构造 `Calcit::Import(CalcitImport { ns: "calcit.core", def, info:
30
- Core { at_ns: file_ns }, def_id: Some(program::ensure_def_id(...).0) })`
31
- 作为新的 head,保持已 preprocess 过的参数不变,避免重复预处理。
32
- - 禁止对 `&list:map` / `&map:map` / `&set:map` / `&list:filter` /
33
- `&map:filter` / `&set:filter` 自身再次 monomorphize,避免潜在 cycle。
34
- - 调用点 `Ok(Calcit::from(CalcitList::from(ys)))` 前的 specialize 调用传入
35
- `file_ns`。
36
-
37
- ## 验证
38
-
39
- - `cargo fmt && cargo clippy --release -- -D warnings` ✓
40
- - `cargo test --release` ✓ 所有现有测试通过
41
- - `yarn check-all` ✓ 全量集成测试 + WASM 测试全部 OK
42
-
43
- ## 后续思路
44
-
45
- - 可继续把 `reduce` / `last` / `reverse` / `concat` / `to-list` / `to-set`
46
- 等也加入特化表;其中 `concat` / `reverse` 已有 native proc(`NativeListConcat`
47
- / `NativeListReverse`),加到已有 proc 表即可。
48
- - 可以考虑把谓词(`list?`、`map?`、`number?`、`string?` …)在类型已知时直接折叠成
49
- `true` / `false`,进一步帮 WASM / JS codegen 消冗余分支。
50
- - 未来 `&set:map` 如果单独实现,即可补齐 `("map", Set(_))` 分支。
@@ -1,31 +0,0 @@
1
- # Monomorphize `includes?` and `reverse`
2
-
3
- ## 背景
4
-
5
- 继 `map` / `filter` 之后,继续扩展 `try_specialize_polymorphic_call`:
6
-
7
- - `includes?` 原实现(calcit-core.cirru L3228)有 5 条 `if` 分支
8
- (`nil?` / `list?` / `map?` / `set?` / `string?` fallback `.includes?`)。
9
- - `reverse` 实际上在 runtime 就是 `&list:reverse` 的别名,但以前每次调用还是要
10
- 经过一层 Calcit user-def 间接。
11
-
12
- ## 改动
13
-
14
- 在 `src/runner/preprocess/mod.rs` 的 proc 特化表中追加:
15
-
16
- ```text
17
- ("includes?", T::List(_)) -> NativeListIncludes
18
- ("includes?", T::Map(_, _)) -> NativeMapIncludes
19
- ("includes?", T::Set(_)) -> NativeSetIncludes
20
- ("includes?", T::String) -> NativeStrIncludes
21
- ("reverse", T::List(_)) -> NativeListReverse
22
- ```
23
-
24
- `concat` 因为是变长参数 defn,暂不在这里处理;后续可以在 preprocess 阶段
25
- 把已知都是 list 的 `(concat a b)` 展开为 `(&list:concat a b)` 的折叠形式。
26
-
27
- ## 验证
28
-
29
- - `cargo fmt && cargo clippy --release -- -D warnings` ✓
30
- - `cargo test --release` ✓
31
- - `yarn check-all` ✓
@@ -1,44 +0,0 @@
1
- # Fold type predicates when static type is known
2
-
3
- ## 背景
4
-
5
- `list?` / `map?` / `set?` / `string?` / `number?` / `bool?` / `tag?` / `fn?` /
6
- `tuple?` / `record?` 这些 type predicate defn 都是 `(&= (type-of x) :xxx)`
7
- 的形式。如果 preprocess 能拿到 `x` 的静态类型,整个调用就可以折叠成一个字面的
8
- `true` 常量(或者保留运行时 check,但不把 `false` 折叠以保持安全)。
9
-
10
- 在 WASM / JS codegen 场景下这尤其有收益:谓词出现在 `if` / `cond` 里,
11
- 折叠成常量后整个分支会被后续 dead-code 消除。
12
-
13
- ## 改动
14
-
15
- `src/runner/preprocess/mod.rs::try_specialize_polymorphic_call` 新增一段在
16
- proc 特化表之前的折叠逻辑:
17
-
18
- ```rust
19
- let predicate_true = matches!(
20
- (fn_def, receiver_type.as_ref()),
21
- ("list?", T::List(_))
22
- | ("map?", T::Map(_, _))
23
- | ("set?", T::Set(_))
24
- | ("string?", T::String)
25
- | ("number?", T::Number)
26
- | ("bool?", T::Bool)
27
- | ("tag?", T::Tag)
28
- | ("fn?", T::Fn(_) | T::DynFn)
29
- | ("tuple?", T::Tuple(_) | T::DynTuple)
30
- | ("record?", T::Record(_) | T::Struct(_, _))
31
- );
32
- if predicate_true { return Some(Calcit::Bool(true)); }
33
- ```
34
-
35
- **设计选择**:只折叠“肯定为 true”的情形,不折叠“肯定为 false”的情形。
36
- 原因:`CalcitTypeAnnotation` 枚举有 30+ variant(包括 `Optional`、`Ref`、
37
- `TypeVar`、`TypeRef`、`Trait` 等等),要列全“除此之外的全部”枚举会很脆弱、
38
- 以后新增 variant 容易漏。保留 runtime check 是安全的 fallback。
39
-
40
- ## 验证
41
-
42
- - `cargo fmt && cargo clippy --release -- -D warnings` ✓
43
- - `cargo test --release` ✓(179 + 67 测试全通过)
44
- - `yarn check-all` ✓
@@ -1,52 +0,0 @@
1
- # Extend generic assoc/nth/get/count/contains?/empty?/first to records & tuples
2
-
3
- ## 背景
4
-
5
- Recollect 升级到 `defstruct` + `%{}` 构造记录后,在 JS 运行时调用 `assoc` /
6
- `nth` / `get` 等会 fallback 到 `.method`,再经过 `invoke_method` 在
7
- `structRef.impls` 中查找;但默认构造的 struct 并没有自动挂上 core 的
8
- `:assoc` / `:nth` / `:get` impls,导致 `Error: No implementation for ... to
9
- lookup .assoc` 等。
10
-
11
- Rust 解释器路径能自动解析到 `&record:*` 内置 proc,所以 `cr --entry test`
12
- 能跑过,但 JS 输出(`cr js` + Node)跑不过。
13
-
14
- ## 改动
15
-
16
- 在 `src/cirru/calcit-core.cirru` 的若干 generic 分发函数里显式增加
17
- `record?` / `tuple?` 分支,直接路由到内置 proc,不再依赖 method lookup:
18
-
19
- | 函数 | 新增分支 |
20
- | ----------- | -------------------------------------------------------- |
21
- | `assoc` | `record? -> &record:assoc`, `tuple? -> &tuple:assoc` |
22
- | `nth` | `tuple? -> &tuple:nth`, `record? -> &record:nth` |
23
- | `get` | `tuple? -> &tuple:nth`, `record? -> &record:get` |
24
- | `count` | `tuple? -> &tuple:count`, `record? -> &record:count` |
25
- | `contains?` | `record? -> &record:contains?` |
26
- | `empty?` | `record? -> (&= 0 (&record:count x))`, tuple 同理 |
27
- | `first` | `tuple? -> (&tuple:nth x 0)` |
28
-
29
- 这几处与“运行时按 `type-of` 分支”的方向是一致的——在当前 Calcit 语义下
30
- records / tuples 是独立 kind,本来就应该在 generic 分发里显式处理,而不是
31
- 掉到“最后一条 method lookup” 的兜底里。
32
-
33
- 与此前添加的 **编译期单态化**(`try_specialize_polymorphic_call`)是互补的:
34
- 当静态类型已知时在预处理阶段直接改写成 proc 调用;静态类型未知时,运行时
35
- 分支也能正确分发到 `&record:*` / `&tuple:*`,而不再需要结构实现端配合
36
- impls。
37
-
38
- ## 验证
39
-
40
- - `cargo fmt && cargo clippy --release -- -D warnings` ✓
41
- - `cargo test --release` ✓(179 + 67 全过)
42
- - `yarn check-all` ✓
43
- - recollect 全套:
44
- - `cr --entry test` ✓
45
- - `cr --entry test js && env=ci node test.mjs` ✓(此前 `.assoc` 报错修复)
46
- - `cr js && yarn vite build --base=./` ✓
47
-
48
- ## 后续
49
-
50
- 随着 Calcit 继续演进,这些 chain-of-if 分发仍然是临时形态。更彻底的做法是
51
- 在预处理阶段通过类型推断消除所有 generic 分发 defn,让核心库只暴露
52
- `&list:*` / `&map:*` / `&record:*` 等单态 proc —— 见下一步语言简化计划。
@@ -1,49 +0,0 @@
1
- # Simplify generic core defns via `.method` dispatch
2
-
3
- ## 概要
4
-
5
- 将 `calcit-core.cirru` 中的泛型 defn(`assoc` / `contains?` / `count` / `empty` / `empty?` / `filter` / `first` / `get` / `includes?` / `nth` / `rest` / `map`)从多分支 `if (list? x) ... if (map? x) ... if (record? x) ...` 链简化为 `list?` 快速路径 + `.method` 动态分发。
6
-
7
- ## 动机
8
-
9
- - 用户要求:优先使用 `.method` 这套已有概念承担多态分发,避免每新增类型(record / tuple / set 等)都要在每个 defn 中追加分支。
10
- - 所有 built-in 类型已在 `&core-*-methods` 中注册了对应的 `.assoc` `.count` `.empty?` `.get` `.nth` 等方法条目,编译期 `try_inline_method_call` 已能在静态类型已知时把方法调用内联为直接 proc 调用,runtime 则由 `invoke_method` 处理。这使得 defn 自身不再需要枚举类型。
11
-
12
- ## 实现
13
-
14
- 以 `empty?` 为例:
15
-
16
- ```cirru
17
- defn empty? (x)
18
- if (nil? x) true $ if (list? x) (&list:empty? x) (.empty? x)
19
- ```
20
-
21
- 保留 `nil?` 与 `list?` 两个前置分支,其余类型全部交给 `.empty?`。
22
-
23
- **为什么保留 `list?` 快速路径**:
24
- `ensure_ns_def_compiled(CORE_NS, &init-builtin-impls!)` 在预处理期会展开 `do` 等 macro,其中 `(empty? body)` 会在 impls 还未注册到 runtime 时被调用;若此时 `empty?` 体里就走 `.empty?` → `invoke_method` → `evaluate_symbol_from_program("&core-list-impls", ...)` 会命中 quick-path 失败(循环依赖),导致 panic:
25
-
26
- ```
27
- preprocess builtin impls: CalcitErr { kind: Var, msg: "expected symbol `&core-list-impls` from path `calcit.core`, this is a quick path, should succeed", ... }
28
- ```
29
-
30
- `list?` 本身只用 `(&= (type-of x) :list)` 等 proc,不依赖 impl 注册,能在 bootstrap 期安全使用,打破循环;其余类型的 methods 此时已构建完毕,可顺利走方法派发。
31
-
32
- ## 波及范围
33
-
34
- - `src/cirru/calcit-core.cirru`:12 个 defn 的 body 瘦身。
35
- - 预处理期的 `try_specialize_polymorphic_call`(已有)照常将 `(assoc x k v)` 等静态可推断调用折叠为 `&list:assoc`/`&map:assoc` 等 proc。
36
- - runtime 侧未变:仍由 `invoke_method` + `&core-*-impls` 完成最终派发。
37
-
38
- ## 验证
39
-
40
- - `cargo fmt`
41
- - `cargo clippy --release -- -D warnings`
42
- - `cargo test --release`:179 + 67 通过
43
- - `yarn check-all`:全部 WASM/JS/解释执行测试通过
44
- - recollect (`cr --entry test` + `cr --entry test js` + `node test.mjs`) ✓
45
- - respo (`cr --check-only` + `cr js` + `yarn vite build`) ✓
46
-
47
- ## 备注
48
-
49
- - 下一步可以考虑:把那些只剩 `list?` 单分支的 defn 再收拢到一个运行时 primitive,或在 preprocess 阶段对 macro 展开期调用的 `empty?` 等函数强制内联 proc,从而彻底去掉这条 fast path。
@@ -1,81 +0,0 @@
1
- # 202605210055 — tree show 可选路径 + cr config 顶级命令 + cr edit 清理
2
-
3
- ## 修改概要
4
-
5
- ### 1. `cr tree show` — `-p` 参数改为可选,缺失时警告而非报错
6
-
7
- **动机**: Agent 调用 `cr tree show ns/def` 时若忘记 `-p`,原来直接报错导致 token 浪费。
8
-
9
- **变更文件**:
10
-
11
- - `src/cli_args.rs`: `TreeShowCommand.path` 类型从 `String` → `Option<String>`,doc 注释更新
12
- - `src/bin/cli_handlers/tree.rs`: `handle_show` 中对 `None` 输出黄色 `[Warn]`,默认使用空路径(root)
13
- - `src/bin/cli_handlers/command_echo.rs`: `push_tree` Show 分支改用 `opt "path"` 宏处理 Option 类型
14
-
15
- **效果**:
16
-
17
- ```
18
- $ cr calcit.cirru tree show "ns/def"
19
- [Warn] No path (-p) specified; showing from root. Use -p '0' to start from a child node.
20
- Type: list (4 items)
21
- ...
22
- ```
23
-
24
- ---
25
-
26
- ### 2. `cr config` — 顶级配置管理命令
27
-
28
- **动机**: `cr query config`、`cr query modules`、`cr edit config`、`cr edit add-module`、`cr edit rm-module` 分散在不同子命令下,操作配置需要记忆多个入口。新增统一入口 `cr config`。
29
-
30
- **新命令**:
31
- | 命令 | 等价旧命令 |
32
- |---|---|
33
- | `cr config show` | `cr query config` |
34
- | `cr config modules` | `cr query modules` |
35
- | `cr config version [value]` | `cr edit config version ...` |
36
- | `cr config set <key> <value>` | `cr edit config <key> <value>` |
37
- | `cr config add-module <path>` | `cr edit add-module <path>` |
38
- | `cr config rm-module <path>` | `cr edit rm-module <path>` |
39
-
40
- `cr config version` 可独立使用(无参数显示当前版本,传 `patch/minor/major` 递增,传 semver 直接设置)。
41
-
42
- **变更文件**:
43
-
44
- - `src/cli_args.rs`: 添加 `CalcitCommand::Config`、`ConfigCommand`、`ConfigSubcommand`(含 `ConfigVersionCommand`)及各子命令 struct
45
- - `src/bin/cli_handlers/config.rs`: 新建,实现 `handle_config_command` 及各子命令处理函数(含 `handle_version`)
46
- - `src/bin/cli_handlers/edit.rs`: `parse_semver_value`、`bump_semver_value` 改为 `pub(crate)`
47
- - `src/bin/cli_handlers/mod.rs`: 注册 `mod config` 并 re-export `handle_config_command`
48
- - `src/bin/cli_handlers/command_echo.rs`: 添加 `config_name`、`push_config`,并在 `should_echo_command` / `render_command_echo` 中处理 `Config` 变体
49
- - `src/bin/cr.rs`: 添加 `CalcitCommand::Config` 分支
50
-
51
- ---
52
-
53
- ### 3. `cr edit` 清理 — 移除已迁移至 `cr config` 的子命令
54
-
55
- **动机**: `cr edit add-module`、`cr edit rm-module`、`cr edit config` 与新增的 `cr config` 重复,保持单一职责。
56
-
57
- **删除内容**:
58
-
59
- - `EditSubcommand::AddModule / RmModule / Config` 及对应 struct(`cli_args.rs`)
60
- - `handle_add_module / handle_rm_module / handle_config` 函数体(`edit.rs`)
61
- - `command_echo.rs` 中 `edit_name` 和 `push_edit` 两处 match 的三个变体
62
-
63
- **保留**(被 `config.rs` 和单元测试引用):
64
-
65
- - `pub(crate) fn parse_semver_value` — semver 字符串解析
66
- - `pub(crate) fn bump_semver_value` — patch/minor/major 递增
67
-
68
- **文档更新**:
69
-
70
- - `docs/run/agent-advanced.md` "模块和配置" 章节、快速参考示例 → 全部改为 `cr config` 命令
71
- - `docs/CalcitAgent.md` 第 9 节"cr 能力地图" → 新增"配置管理"条目
72
-
73
- ---
74
-
75
- ## 知识点
76
-
77
- - `argh` 中将 `#[argh(option)]` 字段类型改为 `Option<T>` 可使该选项变为可选
78
- - `pub(crate)` 可在同一 crate 内跨模块共享;被其他模块引用时,不能因删除调用方而一并删除
79
- - 新增顶级命令时需同步更新 `command_echo.rs` 的三处:`should_echo_command`、`render_command_echo`(名称映射和 token push)
80
- - 移除 enum 变体时,需同时检查 `command_echo.rs` 的两处 match(`edit_name` 和 `push_edit`)
81
- - 单元测试也会引用函数,删除前要 grep `tests` 模块确认
@@ -1,6 +0,0 @@
1
- - refined weak-types reporting in `cr analyze weak-types` to classify schema/code hits with detail paths
2
- - tightened builtin proc signatures for list/map/set/buf-list helpers toward generic compound types
3
- - kept `field-match` / `record-match` macro schema inputs precise in `calcit-core` while preserving round-trip behavior
4
- - fixed macro schema serialization to keep non-dynamic returns like `:record` instead of dropping them during snapshot save/load
5
- - aligned bare marker tag parsing for `:record` and related special tags with schema normalization behavior
6
- - updated docs and parser tests to current wrapped schema / guidebook-loading behavior
@@ -1,15 +0,0 @@
1
- - tightened multiple calcit.core snapshot schemas that safely remove weak composite internals without narrowing runtime behavior: typed path lists for `assoc-in`/`get-in`/`dissoc-in`/`update-in`/`contains-in?`, typed collection helpers like `apply`, `join-str`, `foldr-shortcut`, and explicit output map generics for `map-kv` and `pairs-map`
2
- - corrected one weak-types false lead by changing `keys` from returning `:list` to `:set`, matching runtime/tests and moving that hit out of the list family
3
- - extended `cr analyze weak-types` to classify nested schema-dynamic shapes/families, include per-definition summaries, split family/shape counts by `arg`/`return` position, and show per-definition `shape@position` contributors for the remaining hotspots
4
- - confirmed the current lower-bound weak hits under the existing type system: `&record:to-map` for heterogeneous record values; `&tuple:params`, `&cirru-quote:to-list`, `parse-cirru-list`, `&format-ternary-tree`, `&list:flatten`, `format-cirru`, and `format-cirru-one-liner` for mixed list payloads that cannot be soundly collapsed to `list<'T>`
5
- - verified the final baseline at schema-dynamic=290 with `cargo test --bin cr analyze_weak_types -- --nocapture`, repeated `cargo run --bin cr -- calcit/test.cirru analyze weak-types --ns calcit.core --only schema-dynamic`, and runtime suite checks via `cargo run --bin cr -- calcit/test.cirru`
6
- - aligned `parse-float` runtime behavior with the existing optional-number schema across Rust and JS: invalid input now yields `nil`/`null` instead of throwing or leaking `NaN`, and added inference coverage in `calcit/test-types-inference.cirru`
7
- - aligned JS record missing-field behavior with Rust/eval by making `CalcitRecord.get` return `undefined` on absent fields, which keeps top-level `get` and `get-in` optional semantics consistent across runtimes
8
- - refined preprocess return inference for `calcit.core/get` and `calcit.core/get-in`, so list/string/map/record accesses produce precise `optional<...>` results for literal paths instead of collapsing to broad `dynamic` in the common safe cases
9
- - tightened the generic matching path so `Struct` annotations and bare `TypeRef` names bind declared type variables consistently when only one side carries applied type arguments, reducing a gap that previously skipped bindings needed by later generic specialization and `:where` checks
10
- - validated the follow-up with `cargo run --bin cr -- calcit/test-types-inference.cirru`, `cargo test binds_generic_args_from`, `cargo fmt && cargo test binds_generic_args_from`, and `yarn try-rs`
11
- - added RFC `RFCs/06-01-generic-binding-unification-rfc.md` to document the next step for Rust-like generic binding unification across `Struct` / `Enum` / `TypeRef`, including concrete examples, rollout stages, and the tradeoff that enum support needs deeper metadata changes than the struct-side fix
12
- - extended the enum-generic foundation end to end: runtime enum metadata now preserves declared generics, `&enum::new` accepts generic parameter lists, and applied named enum annotations like `(:: 'ResultX :number :string)` validate against payload creation instead of being rejected as "enum cannot be generic"
13
- - fixed the remaining struct declaration gap in the core macros/runtime boundary: `defstruct Box ([] 'T) (:value 'T)` now lowers to a real generics list for `&struct::new`, and generic field annotations are preserved as type forms instead of being evaluated away before runtime parsing
14
- - documented the current runnable generic data-structure entry points in `docs/features/records.md` and `docs/features/enums.md`, including a high-level generic `defstruct` example and the current stable generic-enum constructor form via `&enum::new`
15
- - validated the new docs/examples with direct eval smoke checks for the struct and enum snippets, `cargo run --bin cr -- demos/calcit.cirru docs check-md docs/features/records.md`, `cargo run --bin cr -- demos/calcit.cirru docs check-md docs/features/enums.md`, and `cargo run --bin cr -- calcit/test-generics.cirru`
@@ -1,19 +0,0 @@
1
- # 2026-06-01 00:03 update callback field specialization
2
-
3
- ## Summary
4
-
5
- - specialized `calcit.core/update` call checking so the 3rd callback arg can inherit a known record/struct field type instead of always staying at generic `fn('T) -> 'T`
6
- - fixed record field inference to resolve `TypeRef`-based struct annotations, not only direct `Record`/`Struct` annotations
7
- - aligned native `not` proc signature with calcit-core semantics by accepting dynamic input and returning `:bool`
8
-
9
- ## Why
10
-
11
- - `respo` used precise type refs like `'respo.app.schema/Task`, but `infer_record_field_type` only looked through direct `Record`/`Struct` annotations, so `update task :done? not` could not see the field type
12
- - even after specializing `update`, Rust-side proc metadata still described `not` as `fn(:bool?) -> :bool`, which was stricter and inconsistent with the core schema/docs path
13
-
14
- ## Validation
15
-
16
- - `cargo test specialize_update_uses_record_field_type_for_callback`
17
- - `cargo run --manifest-path /Users/chenyong/repo/calcit-lang/calcit/Cargo.toml --bin cr -- js` from `respo`
18
- - `yarn try-rs`
19
- - `cargo test`
@@ -1,6 +0,0 @@
1
- - added where-bound metadata to struct and enum definitions, preserving it through parsing, hashing, compare, serialization, and enum prototype reconstruction
2
- - enforced data-definition generic trait bounds at runtime for `%{}`, `%{}?`, and `%::` by inferring concrete type bindings from record fields and enum payloads
3
- - kept builtin `Show` satisfaction narrow to builtin value families so function-level missing-impl warnings still fire correctly during preprocess
4
- - covered the new runtime path with focused Rust tests for accepting and rejecting struct/enum payloads under generic where-bounds
5
- - validated the calcit side with `cargo test where_bounds --lib`, `yarn check-all`, release `cr` build, and downstream respo compilation via `../../calcit-lang/calcit/target/release/cr js`
6
- - downstream follow-up in respo needed one explicit `assert-type text :string` for the `Op::update` payload under the stricter enum payload check