@calcit/procs 0.12.55 → 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.
- package/.yarn/install-state.gz +0 -0
- package/RFCs/07-31-unsafe-coerce-driven-static-type-boundary-plan.md +170 -0
- package/build.rs +36 -2
- package/editing-history/202607310224-strengthen-namespace-import-diagnostics.md +23 -0
- package/editing-history/202607311940-strengthen-unsafe-coerce-boundaries.md +20 -0
- package/editing-history/202608010103-warn-on-duplicate-imports.md +18 -0
- package/editing-history/202608010111-release-0.12.56.md +15 -0
- package/editing-history/202608011654-library-quality-gates.md +23 -0
- package/editing-history/202608011759-issue-routing-in-agent-guide.md +17 -0
- package/editing-history/202608011833-schema-type-symbols.md +20 -0
- package/editing-history/202608011852-wasm-dynamic-string-tag.md +7 -0
- package/editing-history/202608011908-consolidate-history.md +6 -0
- package/editing-history/202608012022-consolidate-cli-and-test-duplication.md +28 -0
- package/editing-history/202608012123-review-follow-up.md +18 -0
- package/editing-history/202608012320-release-0.12.57.md +5 -0
- package/editing-history/ARCHIVE.md +15 -0
- package/editing-history/README.md +21 -0
- package/lib/package.json +1 -1
- package/package.json +1 -1
- package/editing-history/2026-02-13-1841-trait-origin-structural-eq.md +0 -91
- package/editing-history/2026-02-14-2050-js-codegen-recursion-tag-migration.md +0 -39
- package/editing-history/2026-02-14-2358-emit-js-modularization-shift-left.md +0 -63
- package/editing-history/2026-02-15-0000-diagnostics-consolidated.md +0 -35
- package/editing-history/2026-02-15-1941-macro-diagnostics-refinement.md +0 -39
- package/editing-history/2026-02-16-2043-core-api-docs-cleanup.md +0 -40
- package/editing-history/2026-02-23-0834-migrate-to-defstruct.md +0 -91
- package/editing-history/2026-02-23-2321-ns-imports-code-fixes.md +0 -42
- package/editing-history/2026-02-25-0002-language-behavior-eval-mode.md +0 -93
- package/editing-history/2026-02-25-0111-guidebook-no-check-block-upgrades.md +0 -52
- package/editing-history/2026-02-25-0113-runtime-type-validation-and-macro-quoting.md +0 -41
- package/editing-history/2026-02-25-1131-check-md-eval-improvements.md +0 -13
- package/editing-history/2026-02-26-1324-check-md-inprocess-cache-and-path-labels.md +0 -7
- package/editing-history/2026-02-27-1640-unify-markdown-readers.md +0 -16
- package/editing-history/2026-02-27-1958-tree-rewrite-command-and-reference-model.md +0 -18
- package/editing-history/2026-02-27-2200-split-def-command.md +0 -29
- package/editing-history/2026-02-27-2212-tree-raise-wrap.md +0 -33
- package/editing-history/2026-02-27-2223-calcit-agent-docs-optimize.md +0 -41
- package/editing-history/2026-03-01-0212-query-search-entry-and-ffi-warning.md +0 -53
- package/editing-history/2026-03-03-1934-check-types-and-core-annotations.md +0 -17
- package/editing-history/2026-03-04-0000-generics-fn-typevar-identity.md +0 -30
- package/editing-history/2026-03-04-1331-tag-call-warning-and-dot-access-migration.md +0 -28
- package/editing-history/2026-03-04-1548-impl-new-dot-method-input-and-doc-hints.md +0 -33
- package/editing-history/2026-03-04-1645-calcit-eq-contract-refactor-and-macro-tests.md +0 -28
- package/editing-history/2026-03-04-2200-assert-type-assert-traits-composable-runtime-checks.md +0 -18
- package/editing-history/2026-03-05-0042-type-inference-argtypes-and-core-hints.md +0 -54
- package/editing-history/2026-03-05-0115-calcit-core-generic-refinements.md +0 -57
- package/editing-history/2026-03-05-1930-schema-migration-cr-edit.md +0 -30
- package/editing-history/2026-03-05-1939-query-schema-adaptation.md +0 -42
- package/editing-history/2026-03-06-0120-schema-hint-migration-batch.md +0 -38
- package/editing-history/2026-03-06-1416-core-macro-schema-migration.md +0 -20
- package/editing-history/2026-03-06-1552-core-schema-and-hintfn-migration.md +0 -63
- package/editing-history/2026-03-06-1936-schema-normalization-and-preprocess-preload.md +0 -12
- package/editing-history/2026-03-07-0000-migrate-hint-fn-to-schema.md +0 -29
- package/editing-history/2026-03-07-0000-remove-enum-prototype-field.md +0 -43
- package/editing-history/2026-03-07-0000-schema-args-type-enforcement.md +0 -66
- package/editing-history/2026-03-07-0142-unit-type-and-builtin-schemas.md +0 -82
- package/editing-history/2026-03-07-1652-decouple-snapshot-schema-to-calcit-type.md +0 -112
- package/editing-history/2026-03-07-1821-snapshot-schema-validation.md +0 -6
- package/editing-history/2026-03-07-1959-schema-def-kind-arity-validation.md +0 -96
- package/editing-history/2026-03-08-0031-schema-generics-quote-normalization.md +0 -35
- package/editing-history/2026-03-08-1905-schema-typeref-and-assert-migration.md +0 -34
- package/editing-history/2026-03-08-2033-schema-wrapper-migration.md +0 -45
- package/editing-history/2026-03-08-2315-late-schema-cleanup-and-warning-compat.md +0 -27
- package/editing-history/2026-03-09-1753-schema-type-fail-tests.md +0 -17
- package/editing-history/2026-03-10-1040-edit-schema-primitive-tag-support.md +0 -42
- package/editing-history/2026-03-10-1754-ns-entry-snapshot-migration.md +0 -66
- package/editing-history/2026-03-13-2216-validate-struct-type-arg-arity.md +0 -24
- package/editing-history/2026-03-16-2353-runtime-boundary-cleanup.md +0 -14
- package/editing-history/2026-03-17-0150-runtime-boundary-lookup-cleanup.md +0 -28
- package/editing-history/2026-03-20-0116-json-builtins-and-runtime-docs.md +0 -48
- package/editing-history/2026-03-26-2013-docs-frontmatter-and-module-search.md +0 -58
- package/editing-history/2026-04-07-1550-path-format-at-prefix-migration.md +0 -46
- package/editing-history/2026-04-12-1524-js-codegen-map-to-record.md +0 -26
- package/editing-history/2026-04-12-1549-map-to-record-field-validation.md +0 -29
- package/editing-history/2026-04-13-1600-tuple-to-enum-rewrite.md +0 -13
- package/editing-history/2026-04-13-2309-typeslot-enum-compile-safety.md +0 -45
- package/editing-history/2026-04-14-1500-loose-record-syntax.md +0 -32
- package/editing-history/2026-04-14-2259-bidir-type-check-refactor.md +0 -63
- package/editing-history/2026-04-15-0120-match-syntax-exhaustiveness.md +0 -20
- package/editing-history/2026-04-15-1211-record-nth-optimization.md +0 -44
- package/editing-history/2026-04-16-1936-predicate-narrowing-expansion.md +0 -31
- package/editing-history/2026-04-17-0132-monomorphize-map-filter.md +0 -50
- package/editing-history/2026-04-17-0135-monomorphize-includes-reverse.md +0 -31
- package/editing-history/2026-04-17-0140-fold-type-predicates.md +0 -44
- package/editing-history/2026-04-17-0154-generic-dispatch-records-tuples.md +0 -52
- package/editing-history/2026-04-17-0520-simplify-generic-defns-via-method-dispatch.md +0 -49
- package/editing-history/2026-05-21-0055-tree-show-cr-config-and-edit-cleanup.md +0 -81
- package/editing-history/2026-05-31-2052-macro-schema-roundtrip-and-weak-types.md +0 -6
- package/editing-history/2026-05-31-2105-map-generic-weak-types-followup.md +0 -15
- package/editing-history/2026-06-01-0003-update-callback-field-specialization.md +0 -19
- package/editing-history/2026-06-01-2317-data-definition-where-bounds.md +0 -6
- package/editing-history/2026-06-02-0114-data-definition-where-macro-followup.md +0 -21
- package/editing-history/2026-06-03-0000-check-md-edn-errors.md +0 -5
- package/editing-history/2026-06-03-1600-check-md-entry-modules.md +0 -6
- package/editing-history/2026-06-04-0000-check-md-app-main-init.md +0 -6
- package/editing-history/2026-06-04-2218-compiled-executable-runtime-backfill.md +0 -6
- package/editing-history/2026-06-09-0000-with-type-slot-scoped-binding.md +0 -83
- package/editing-history/2026-06-09-1241-remove-bind-type.md +0 -64
- package/editing-history/2026-06-09-1800-core-effect-tags.md +0 -57
- package/editing-history/2026-06-10-1200-get-def-doc-schema-builtin.md +0 -7
- package/editing-history/2026-06-15-1500-effects-graph-mvp.md +0 -30
- package/editing-history/2026-06-16-1700-effects-graph-ste-tree.md +0 -84
- package/editing-history/2026-06-27-0052-cli-improvements.md +0 -41
- package/editing-history/2026-06-27-0202-docs-indexing-improvements.md +0 -22
- package/editing-history/2026-06-27-0315-file-splits.md +0 -17
- package/editing-history/2026-06-27-0416-agent-advanced-split.md +0 -15
- package/editing-history/archived/2025-04-12-1453-map-to-record-rewrite.md +0 -33
- package/editing-history/archived/2025-04-16-0117-wasm-codegen-and-catalog-update.md +0 -40
- package/editing-history/archived/2025-07-16-0207-wasm-encoder-migration.md +0 -48
- package/editing-history/archived/2025-07-16-1633-wasm-data-structures.md +0 -61
- package/editing-history/archived/2026-02-13-1926-docs-tests-followup.md +0 -33
- package/editing-history/archived/2026-02-16-2128-docs-smoke-and-trait-errors.md +0 -20
- package/editing-history/archived/2026-02-25-1234-watch-mode-default-once.md +0 -5
- package/editing-history/archived/2026-03-07-1302-calcit-agent-docs-update.md +0 -32
- package/editing-history/archived/2026-03-09-1819-add-test-fail-script.md +0 -5
- package/editing-history/archived/2026-03-09-1944-split-type-fail-tests.md +0 -8
- package/editing-history/archived/2026-03-16-1449-profiling-tools-reorg.md +0 -13
- package/editing-history/archived/2026-03-17-2026-afternoon-runtime-boundary-optimization-summary.md +0 -87
- package/editing-history/archived/2026-03-18-1802-tips-level-and-overwrite-schema-preservation.md +0 -26
- package/editing-history/archived/2026-03-20-1229-query-window-3-with-parent-preview.md +0 -72
- package/editing-history/archived/2026-03-23-1137-command-echo-tool-output-cleanup.md +0 -71
- package/editing-history/archived/2026-04-10-0011-snapshot-empty-version-pipe-marker.md +0 -23
- package/editing-history/archived/2026-04-16-0131-wasm-math-and-test-integration.md +0 -28
- package/editing-history/archived/2026-04-16-1507-wasm-data-structures-and-rfc-rename.md +0 -27
- package/editing-history/archived/2026-04-16-1520-wasm-bitwise-and-match.md +0 -21
- package/editing-history/archived/2026-04-16-1542-wasm-cross-ns-host-imports.md +0 -38
- package/editing-history/archived/2026-04-17-0026-wasm-rest-args.md +0 -62
- package/editing-history/archived/2026-04-17-0048-wasm-type-of.md +0 -70
- package/editing-history/archived/2026-04-17-0051-wasm-derived-predicates.md +0 -34
- package/editing-history/archived/2026-04-17-2316-wasm-do-println-fixes.md +0 -41
- package/editing-history/archived/2026-04-18-1208-split-emit-wasm-and-bump-version.md +0 -15
- package/editing-history/archived/2026-04-18-1430-wasm-list-match-and-method-dispatch.md +0 -5
- package/editing-history/archived/2026-04-18-2041-cr-wasm-split-and-runtime-stability.md +0 -18
- package/editing-history/archived/2026-04-18-2045-v0.12.23-ci-wasm-fix.md +0 -13
- package/editing-history/archived/2026-04-21-1818-wasm-string-ops-v2.md +0 -57
- package/editing-history/archived/2026-04-21-2332-split-emit-wasm.md +0 -45
- package/editing-history/archived/2026-04-22-0114-wasm-hof-intercepts-and-set-intersection.md +0 -82
- package/editing-history/archived/2026-04-22-0136-wasm-enum-tuple-bool-str-fixes.md +0 -68
- package/editing-history/archived/2026-04-22-1340-wasm-map-diff-new-and-let-intercept.md +0 -53
- package/editing-history/archived/2026-04-23-1419-v0.12.26-wasm-bisection-fixes.md +0 -7
- package/editing-history/archived/2026-04-23-1645-release-conventions.md +0 -14
- package/editing-history/archived/2026-04-25-1940-wasm-suite-multi-module-entry.md +0 -53
- package/editing-history/archived/2026-04-25-2003-wasm-method-includes-string-and-set-refactor.md +0 -71
- package/editing-history/archived/2026-04-25-2010-wasm-suite-add-fn-lens-edn.md +0 -43
- package/editing-history/archived/2026-04-25-2051-display-by.md +0 -39
- package/editing-history/archived/2026-04-28-1728-fix-gensym-stable.md +0 -31
- package/editing-history/archived/2026-04-29-1400-fix-bind-type-precompile.md +0 -38
- package/editing-history/archived/2026-05-26-0957-match-docs-check-md.md +0 -24
- package/editing-history/archived/2026-05-31-2059-ci-docs-test-and-fn-helper-tightening.md +0 -3
- package/editing-history/archived/2026-06-01-0005-release-0.12.36.md +0 -16
- package/editing-history/archived/2026-06-01-2230-enum-struct-payload-docs.md +0 -4
- package/editing-history/archived/2026-06-03-1620-release-0.12.38.md +0 -6
- package/editing-history/archived/2026-06-04-0000-release-0.12.39.md +0 -4
- package/editing-history/archived/2026-06-04-2230-release-0.12.40.md +0 -5
- package/editing-history/archived/2026-06-12-1525-weak-types-dots-format.md +0 -15
- package/editing-history/archived/2026-06-13-1200-primitive_schema_tags.md +0 -9
- package/editing-history/archived/2026-06-20-1142-ts-declaration-d-mts.md +0 -5
- package/editing-history/archived/2026-06-29-0117-upgrade-doc-snapshot-migration.md +0 -2
- package/editing-history/archived/2026-06-29-calcit-cli.md +0 -80
- package/editing-history/archived/2026-06-29-typed-calcit-cli-schemas.md +0 -23
- package/editing-history/archived/20260630-duplication-analysis.md +0 -116
package/.yarn/install-state.gz
CHANGED
|
Binary file
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
# RFC: `unsafe-coerce` 驱动的动态边界治理与静态类型强化计划
|
|
2
|
+
|
|
3
|
+
状态:Draft
|
|
4
|
+
日期:2026-07-31
|
|
5
|
+
关联:`07-26-static-semantic-analysis-rfc.md`、`07-08-ffi-features-and-js-object-type-rfc.md`、`06-01-generic-binding-unification-rfc.md`
|
|
6
|
+
|
|
7
|
+
## 1. 现状与目标
|
|
8
|
+
|
|
9
|
+
我们将本阶段主目标聚焦在类型边界治理,而不是单纯推进 WASM 后端。
|
|
10
|
+
针对 FFI(特别是 JS object)和外部大树形结构中大量动态值的问题,`unsafe-coerce` 要成为“静态分析可利用的类型入口点”,降低 `:dynamic` 退化。
|
|
11
|
+
|
|
12
|
+
目标如下:
|
|
13
|
+
|
|
14
|
+
- 让动态边界明确化:能指出哪些值是故意进入静态盲区,哪些是可治理缺口;
|
|
15
|
+
- 提升静态可用信息:`unsafe-coerce` 后的类型关系要能在后续分析中被持续传播;
|
|
16
|
+
- 降低告警噪音:减少因隐式动态而产生的误报,转而给出可执行的收紧建议。
|
|
17
|
+
|
|
18
|
+
## 2. 问题定义
|
|
19
|
+
|
|
20
|
+
当前主要痛点是三类:
|
|
21
|
+
|
|
22
|
+
1. 外部输入(JS Object、外部树形数据)一旦进入,会被频繁打散成 `:dynamic`;
|
|
23
|
+
2. `unsafe-coerce` 当前只附加声明类型,不转换值,也不提供运行时校验,静态分析无法区分“推导所得”与“用户信任声明”;
|
|
24
|
+
3. 未通过显式边界收敛的动态传播,会导致高阶函数、容器、回调、trait 调用处丧失可验证关系。
|
|
25
|
+
|
|
26
|
+
## 3. 设计思路
|
|
27
|
+
|
|
28
|
+
我们将类型边界分为五档,贯穿检查与诊断链路:
|
|
29
|
+
|
|
30
|
+
- `sealed-boundary`:明确的外部边界,需经过显式操作收窄;
|
|
31
|
+
- `trusted`:`unsafe-coerce` 给出的用户信任声明,可传播但不视为运行时证明;
|
|
32
|
+
- `validated`:由未来的实际校验操作建立的证据;
|
|
33
|
+
- `unvalidated`:未经过转换但可继续跟踪的弱上下文;
|
|
34
|
+
- `dynamic`:有意接受的动态盲区(可选 opt-in)。
|
|
35
|
+
|
|
36
|
+
`unsafe-coerce` 必须具备两个产出:
|
|
37
|
+
|
|
38
|
+
- 运行时行为:保持原值不变,不承诺验证;
|
|
39
|
+
- 静态元信息:来源类型、声明目标类型、边界位置和 `trusted` 置信等级。
|
|
40
|
+
|
|
41
|
+
实际完成运行时验证的能力应使用独立操作,并把置信等级提升为 `validated`,不能由 `unsafe-coerce` 冒充。
|
|
42
|
+
|
|
43
|
+
## 4. 规范草案
|
|
44
|
+
|
|
45
|
+
### 4.1 `unsafe-coerce` 的静态签名
|
|
46
|
+
|
|
47
|
+
`unsafe-coerce` 调用应显式携带目标类型表达式,并在静态树或旁路分析元数据中记录:
|
|
48
|
+
|
|
49
|
+
- `from-type`:调用点推断来源;
|
|
50
|
+
- `to-type`:目标类型表达式;
|
|
51
|
+
- `confidence`:固定为 `trusted`,不可标为 `validated`;
|
|
52
|
+
- `evidence`:字段集合、泛型约束、变体等。
|
|
53
|
+
|
|
54
|
+
示例:
|
|
55
|
+
|
|
56
|
+
```cirru
|
|
57
|
+
unsafe-coerce user-json :js-object
|
|
58
|
+
unsafe-coerce user-json (:: :record User)
|
|
59
|
+
unsafe-coerce tree-data (:: :list (:: :ref TreeNode))
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### 4.2 结构化构造的类型加强策略(enum / struct)
|
|
63
|
+
|
|
64
|
+
当调用头能够静态确认就是某个 `defstruct` 或 `defenum` 定义时,类型收敛可走“无缝构造”策略,减少 `::` / `%::` / `%{}` 的显式写法。普通 record 实例或 enum tuple 即使携带相同类型信息,也不得被当作构造器:
|
|
65
|
+
|
|
66
|
+
- `enum`:在可推断为 enum 的位置,允许直接写 `Result :ok value`,由类型驱动 rewrite 成 `%:: Result :ok value`;
|
|
67
|
+
- `struct`:在可推断为结构体的上下文,允许按字段对写 `Person :name |Alice :age 20`,并在类型上下文中改写为 `%{} Person :name |Alice :age 20` 的有序结构构造;
|
|
68
|
+
- 规则约束仍保留:
|
|
69
|
+
- `struct` 必须是偶数个参数,按 key/value 成对出现;
|
|
70
|
+
- 字段不能重复;非 `:optional` 字段不能缺失;
|
|
71
|
+
- `enum` 的 tag 与 payload 必须匹配该 enum 的 variant;
|
|
72
|
+
- 任何 key 不在目标 struct 字段中的,回退到原有调用并给出 warning。
|
|
73
|
+
|
|
74
|
+
示例:
|
|
75
|
+
|
|
76
|
+
```cirru
|
|
77
|
+
let
|
|
78
|
+
maybe-ok $ Result :ok 1
|
|
79
|
+
person $ Person :name |Alice :age 20
|
|
80
|
+
...
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
负向示例(应保持原样并给 warning):
|
|
84
|
+
|
|
85
|
+
```cirru
|
|
86
|
+
Person :name |Alice :age
|
|
87
|
+
Result
|
|
88
|
+
Result :bad 1
|
|
89
|
+
Person :email |x
|
|
90
|
+
Result ok 1
|
|
91
|
+
kitty .rename |LagopusB
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
说明:
|
|
95
|
+
|
|
96
|
+
- `Person :email |x`:字段不在结构定义中 → 回退并 warning;
|
|
97
|
+
- `Person :name |Alice :age`:奇数参数 → 回退并 warning;
|
|
98
|
+
- `Result ok 1`:enum 首参不是 tag(需 `:ok`)→ 回退并 warning;
|
|
99
|
+
- `kitty .rename |LagopusB`:记录/结构方法调用不能被误判为构造调用。
|
|
100
|
+
|
|
101
|
+
### 4.3 动态边界的使用规则
|
|
102
|
+
|
|
103
|
+
1. 来自 FFI/主机接口的值默认进入 `sealed-boundary`;
|
|
104
|
+
2. 若值要进入“纯 Calcit 计算路径”,必须通过 `unsafe-coerce` 进入可信声明类型,或通过实际校验操作进入已验证类型;
|
|
105
|
+
3. 对容器与回调关系,`unsafe-coerce` 后应尽量保留内含关系(如 `:: :list T`、`:: :fn` 的参数/返回关联);
|
|
106
|
+
4. 对于无法构建精确信息的对象(如完全开放结构),允许 `:dynamic`,但必须记录“故意动态”标签与边界位置。
|
|
107
|
+
|
|
108
|
+
### 4.4 与现有警告体系对齐
|
|
109
|
+
|
|
110
|
+
- 引入/保留告警码:
|
|
111
|
+
- `W_SEALED_BOUNDARY_PASS`
|
|
112
|
+
- `W_MISSING_COERCE`
|
|
113
|
+
- `W_COERCE_COVERAGE_GAP`
|
|
114
|
+
- `W_DYNAMIC_EXIT`
|
|
115
|
+
- `unsafe-coerce` 使用不足的动态传播点应由 `W_MISSING_COERCE` 定位,并给出可替换的目标类型示例;
|
|
116
|
+
- `unsafe-coerce` 后仍不能稳定推断的情况,转为 `W_COERCE_COVERAGE_GAP` 并输出缺失字段/参数位置。
|
|
117
|
+
|
|
118
|
+
### 4.5 与函数签名协同
|
|
119
|
+
|
|
120
|
+
`unsafe-coerce` 不是为了替代 schema,而是使 schema 可恢复:
|
|
121
|
+
|
|
122
|
+
- 大树节点进入列表/record 时,优先映射为命名结构体或 enum;
|
|
123
|
+
- 回调参数在边界后保持 `:fn` 的关系(arg/return / generics / where);
|
|
124
|
+
- 若同一结构反复出现,鼓励提升为 `defstruct` + `:where` + 类型参数,减少重复 `:dynamic`。
|
|
125
|
+
|
|
126
|
+
## 5. 实施路线
|
|
127
|
+
|
|
128
|
+
### Phase 1(1~2 周):把边界变可见
|
|
129
|
+
|
|
130
|
+
- 明确 `unsafe-coerce` 在静态元数据中的记录模型,并保证 local 场景不会擦除边界节点;
|
|
131
|
+
- 增加 `sealed-boundary` / `trusted` / `validated` / `unvalidated` / `dynamic` 标签在诊断中可见;
|
|
132
|
+
- 在 `type-at` 与 `check-types` 输出中显示 `unsafe-coerce` evidence 链路;
|
|
133
|
+
- 增加 `unsafe-coerce` 相关正向用例:JS Object → 记录/列表/enum。
|
|
134
|
+
|
|
135
|
+
### Phase 2(2~3 周):增强 `unsafe-coerce` 的传播能力
|
|
136
|
+
|
|
137
|
+
- 在 container / fn / struct / enum 场景保留内含关系;
|
|
138
|
+
- 增强跨文件、跨 def 的类型传播,支持大树结构递归字段推断;
|
|
139
|
+
- 给 FFI 边界添加可执行的“首入场 unsafe-coerce 指南”(必须声明哪些层级,以及哪些位置需要真实校验)。
|
|
140
|
+
|
|
141
|
+
### Phase 3(1~2 周):治理现有动态盲区
|
|
142
|
+
|
|
143
|
+
- 统计 `:dynamic` 产生原因:未转换、边界故意、兼容旧行为;
|
|
144
|
+
- 逐步把“可修复” `:dynamic` 转为结构化 `unsafe-coerce` 或真实校验,保留“故意动态”最小集合;
|
|
145
|
+
- 在 `analyze weak-types` 中增加类型边界报告:按定义、路径、优先级排序。
|
|
146
|
+
|
|
147
|
+
## 6. 验收指标(建议)
|
|
148
|
+
|
|
149
|
+
1. 关键 FFI 边界进入非纯路径时,`type-at` 能标出 `sealed-boundary`;
|
|
150
|
+
2. 对树形/树状 JSON 数据,核心字段至少一层以上可从 `:dynamic` 收窄;
|
|
151
|
+
3. 同一入口内的未转换动态访问点告警下降且可定位;
|
|
152
|
+
4. 新增样例在 `check-types` 下可通过,不产生“类型丢失无法解释”的模糊告警。
|
|
153
|
+
|
|
154
|
+
## 7. 风险与缓解
|
|
155
|
+
|
|
156
|
+
- 风险:`unsafe-coerce` 过度强约束导致现有生态迁移成本上升。
|
|
157
|
+
缓解:保持 warning-first,逐步收紧。
|
|
158
|
+
- 风险:分析时间上升。
|
|
159
|
+
缓解:对 `unsafe-coerce` evidence 做缓存并只在必要路径传播。
|
|
160
|
+
- 风险:FFI 数据本身不稳定结构导致验证失败。
|
|
161
|
+
缓解:支持“部分声明 + `:dynamic` fallback”,让用户明确知道保留了什么边界。
|
|
162
|
+
|
|
163
|
+
## 8. 依赖关系
|
|
164
|
+
|
|
165
|
+
优先参考并复用:
|
|
166
|
+
|
|
167
|
+
- `06-01-generic-binding-unification-rfc.md`
|
|
168
|
+
- `07-26-static-semantic-analysis-rfc.md`
|
|
169
|
+
- `07-08-ffi-features-and-js-object-type-rfc.md`
|
|
170
|
+
- 现有类型诊断体系与 `analyze weak-types` 输出规范
|
package/build.rs
CHANGED
|
@@ -107,6 +107,41 @@ pub struct Snapshot {
|
|
|
107
107
|
pub files: HashMap<String, FileInSnapShot>,
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
+
fn parse_snapshot_entry(data: Edn) -> Result<SnapshotEntry, String> {
|
|
111
|
+
let map = data.view_map().map_err(|e| format!("entry must be a map: {e}"))?;
|
|
112
|
+
let ns_def = |key: &str| match map.get_or_nil(key) {
|
|
113
|
+
Edn::Str(text) | Edn::Symbol(text) => Ok(text.to_string()),
|
|
114
|
+
other => Err(format!(
|
|
115
|
+
"entry `:{key}` must be a namespace/definition string or symbol, got {other:?}"
|
|
116
|
+
)),
|
|
117
|
+
};
|
|
118
|
+
let mode = match map.get_or_nil("mode") {
|
|
119
|
+
Edn::Tag(tag) if tag.ref_str() == "native" => SnapshotRunMode::Native,
|
|
120
|
+
Edn::Tag(tag) if tag.ref_str() == "js" => SnapshotRunMode::Js,
|
|
121
|
+
Edn::Str(text) | Edn::Symbol(text) if text.trim_start_matches(':') == "native" => SnapshotRunMode::Native,
|
|
122
|
+
Edn::Str(text) | Edn::Symbol(text) if text.trim_start_matches(':') == "js" => SnapshotRunMode::Js,
|
|
123
|
+
other => return Err(format!("entry `:mode` must be :native or :js, got {other:?}")),
|
|
124
|
+
};
|
|
125
|
+
Ok(SnapshotEntry {
|
|
126
|
+
mode,
|
|
127
|
+
init_fn: ns_def("init-fn")?,
|
|
128
|
+
reload_fn: ns_def("reload-fn")?,
|
|
129
|
+
description: from_edn(map.get_or_nil("description")).map_err(|e| format!("entry `:description`: {e}"))?,
|
|
130
|
+
modules: from_edn(map.get_or_nil("modules")).map_err(|e| format!("entry `:modules`: {e}"))?,
|
|
131
|
+
type_slots: from_edn(map.get_or_nil("type-slots")).map_err(|e| format!("entry `:type-slots`: {e}"))?,
|
|
132
|
+
})
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
fn parse_entries(data: Edn) -> Result<HashMap<String, SnapshotEntry>, String> {
|
|
136
|
+
let map = data.view_map().map_err(|e| format!("entries must be a map: {e}"))?;
|
|
137
|
+
let mut entries = HashMap::with_capacity(map.0.len());
|
|
138
|
+
for (name, value) in map.0 {
|
|
139
|
+
let name: String = from_edn(name).map_err(|e| format!("invalid entry name: {e}"))?;
|
|
140
|
+
entries.insert(name, parse_snapshot_entry(value)?);
|
|
141
|
+
}
|
|
142
|
+
Ok(entries)
|
|
143
|
+
}
|
|
144
|
+
|
|
110
145
|
fn format_edn_preview(value: &Edn) -> String {
|
|
111
146
|
let raw = cirru_edn::format(value, true).unwrap_or_else(|_| format!("{value:?}"));
|
|
112
147
|
const LIMIT: usize = 220;
|
|
@@ -479,8 +514,7 @@ fn main() {
|
|
|
479
514
|
Some(from_edn::<LegacySnapshotConfigs>(value).unwrap_or_else(|e| panic!("failed to parse calcit-core legacy `:configs`: {e}")))
|
|
480
515
|
}
|
|
481
516
|
};
|
|
482
|
-
let mut entries
|
|
483
|
-
from_edn(data.get_or_nil("entries")).unwrap_or_else(|e| panic!("failed to parse calcit-core `:entries`: {e}"));
|
|
517
|
+
let mut entries = parse_entries(data.get_or_nil("entries")).unwrap_or_else(|e| panic!("failed to parse calcit-core `:entries`: {e}"));
|
|
484
518
|
if let Some(configs) = &legacy_configs {
|
|
485
519
|
entries.insert(
|
|
486
520
|
"default".to_owned(),
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Strengthen namespace import diagnostics
|
|
2
|
+
|
|
3
|
+
## Summary
|
|
4
|
+
|
|
5
|
+
- Replaced namespace/import parser panics and silent fallbacks with contextual errors for malformed namespace forms, short rules, invalid rule kinds, and invalid node shapes.
|
|
6
|
+
- Added one shared import-rule validator for program loading and `cr edit add-import` / `cr edit imports`, so invalid edits are rejected before the snapshot is saved.
|
|
7
|
+
- Detect duplicate local bindings across rules and repeated `:refer` definitions within one rule instead of silently overwriting the earlier import.
|
|
8
|
+
- Preserved legacy `(:ns namespace)` compatibility while validating supported `:require` structures.
|
|
9
|
+
- Clarified that `call-graph --show-unused` reports definitions unreachable from the selected entry, not proven dead code or unused import declarations.
|
|
10
|
+
- Kept unused-definition analysis independent from `--max-depth`, preventing display truncation from producing false dead-code reports.
|
|
11
|
+
- Documented validation behavior, atomic edits, dead-code analysis limits, and the relevant CLI workflow.
|
|
12
|
+
|
|
13
|
+
## Validation
|
|
14
|
+
|
|
15
|
+
- `cargo fmt`
|
|
16
|
+
- `cargo clippy -- -D warnings`
|
|
17
|
+
- `cargo test`
|
|
18
|
+
- `yarn compile`
|
|
19
|
+
- `yarn check-all`
|
|
20
|
+
- `yarn check-agent-interface` (12/12 scenarios)
|
|
21
|
+
- `cr docs check-md docs/features/imports.md --entry calcit/test.cirru` (4/4 blocks)
|
|
22
|
+
- Isolated CLI regressions confirming malformed and duplicate imports are rejected without changing the snapshot.
|
|
23
|
+
- Compared `call-graph --show-unused` with unlimited depth and `--max-depth 1`; unused-definition results are identical.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Strengthen unsafe-coerce boundaries
|
|
2
|
+
|
|
3
|
+
## Summary
|
|
4
|
+
|
|
5
|
+
- Kept `unsafe-coerce` visible in preprocessed expressions instead of mutating the source local's type globally, preserving a stable boundary node for later static evidence reporting.
|
|
6
|
+
- Added type-directed shorthand construction for confirmed `defstruct` and `defenum` definitions while preventing record and enum tuple instances from being treated as constructors.
|
|
7
|
+
- Validated shorthand struct fields for pair shape, membership, duplication, required-field coverage, and statically known value type mismatches.
|
|
8
|
+
- Reused typed record and enum constructor nodes so native, JavaScript, and WASM backends receive their existing canonical forms.
|
|
9
|
+
- Documented the boundary model, distinguishing trusted `unsafe-coerce` declarations from future runtime-validated evidence.
|
|
10
|
+
- Added positive and negative preprocessing coverage for constructor rewrites, invalid variants, malformed fields, method syntax, and instance/prototype separation.
|
|
11
|
+
|
|
12
|
+
## Validation
|
|
13
|
+
|
|
14
|
+
- `cargo fmt`
|
|
15
|
+
- `cargo clippy -- -D warnings`
|
|
16
|
+
- `cargo test`
|
|
17
|
+
- `yarn compile`
|
|
18
|
+
- `yarn check-agent-interface` (12/12 scenarios)
|
|
19
|
+
- `yarn check-all` (native, JavaScript, and WASM checks passed)
|
|
20
|
+
- Current debug `cr --check-only` against `/Users/jon.chen/repo/respo/respo/calcit.cirru`
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Warn on duplicate imports
|
|
2
|
+
|
|
3
|
+
- Changed duplicate namespace import bindings from validation errors to recoverable warnings on stderr.
|
|
4
|
+
- Preserved the existing last-rule-wins behavior so duplicate aliases and repeated `:refer` entries do not stop program execution.
|
|
5
|
+
- Kept malformed import structures, invalid rule kinds, and invalid node shapes as errors.
|
|
6
|
+
- Updated CLI editing to save valid duplicate imports after displaying the warning.
|
|
7
|
+
- Added tests for warnings and last-rule-wins resolution, plus an isolated CLI/runtime regression proving execution continues.
|
|
8
|
+
- Updated import documentation to distinguish recoverable duplicate bindings from malformed rules.
|
|
9
|
+
|
|
10
|
+
## Validation
|
|
11
|
+
|
|
12
|
+
- `cargo fmt`
|
|
13
|
+
- `cargo clippy -- -D warnings`
|
|
14
|
+
- `cargo test`
|
|
15
|
+
- `yarn compile`
|
|
16
|
+
- `yarn check-all`
|
|
17
|
+
- `yarn check-agent-interface` (12/12 scenarios)
|
|
18
|
+
- `cr docs check-md docs/features/imports.md --entry calcit/test.cirru`
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Release 0.12.56
|
|
2
|
+
|
|
3
|
+
## Summary
|
|
4
|
+
|
|
5
|
+
- Bump the Calcit Rust crate and npm package versions from `0.12.55` to `0.12.56`.
|
|
6
|
+
- Refresh the workspace lockfile so package metadata remains consistent.
|
|
7
|
+
|
|
8
|
+
## Validation
|
|
9
|
+
|
|
10
|
+
- `cargo fmt --check`
|
|
11
|
+
- `cargo clippy -- -D warnings`
|
|
12
|
+
- `yarn compile`
|
|
13
|
+
- `cargo test`
|
|
14
|
+
- `yarn check-all`
|
|
15
|
+
- `yarn check-agent-interface`
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Library quality gates and format advisories
|
|
2
|
+
|
|
3
|
+
## Summary
|
|
4
|
+
|
|
5
|
+
- Add a dedicated Calcit library/module acceptance guide covering Snapshot canonicalization, entries, type slots, weak-type baselines, examples, Markdown checks, entry/backend validation, call-graph limits, consumer regression, and CI evidence.
|
|
6
|
+
- Refresh the project upgrade guide for once-by-default execution, entry modes, unified `:entries`, per-entry type slots, canonical `:dynamic`, and current static-analysis commands.
|
|
7
|
+
- Extend `cr edit format` with recoverable advisories for legacy `:configs`, the `compact.cirru` filename, legacy `:any`, and unresolved dynamic type debt.
|
|
8
|
+
- Keep formatting non-blocking for quality debt and direct users to `check-types` / `weak-types` for semantic paths and recommendations.
|
|
9
|
+
|
|
10
|
+
## Validation
|
|
11
|
+
|
|
12
|
+
- `cargo fmt`
|
|
13
|
+
- `cargo clippy -- -D warnings`
|
|
14
|
+
- focused `cr` format advisory unit tests
|
|
15
|
+
- `cargo test`
|
|
16
|
+
- `yarn compile`
|
|
17
|
+
- `yarn check-all`
|
|
18
|
+
- `yarn check-agent-interface`
|
|
19
|
+
- `cr docs graph check`
|
|
20
|
+
- `cr docs check-md docs/run/library-quality.md`
|
|
21
|
+
- `cr docs check-md docs/run/upgrade.md`
|
|
22
|
+
- legacy config and filename formatting on temporary Snapshots
|
|
23
|
+
- Respo consumer regression on a temporary Snapshot: format, config show, weak-types summary, and `--check-only`
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Route discovered issues to their owning repository
|
|
2
|
+
|
|
3
|
+
## Summary
|
|
4
|
+
|
|
5
|
+
- Add an Agent-guide rule requiring reproducible Calcit language, runtime, compiler, and CLI issues to be filed with their maintenance repository.
|
|
6
|
+
- Route module and library defects from their resolved local path to the library's own GitHub repository, rather than reporting them to the consuming project or Calcit core by default.
|
|
7
|
+
- Document explicit cross-repository issue creation with `gh issue create --repo OWNER/REPO`, target verification with `gh repo view`, evidence requirements, and safe handling of sensitive reproduction data.
|
|
8
|
+
|
|
9
|
+
## Validation
|
|
10
|
+
|
|
11
|
+
- Confirmed `gh issue create --help` exposes `--repo [HOST/]OWNER/REPO` for selecting another repository.
|
|
12
|
+
- Confirmed the current GitHub CLI authentication can query the non-current `calcit-lang/setup-cr` repository.
|
|
13
|
+
- `cargo build --bin cr`
|
|
14
|
+
- `cargo test --bin cr agents_docs_default_to_the_version_matched_embedded_guide`
|
|
15
|
+
- `./target/debug/cr docs check-md docs/CalcitAgent.md --entry calcit/test.cirru --failures-only`
|
|
16
|
+
- `./target/debug/cr docs graph check`
|
|
17
|
+
- `git diff --check`
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Canonical schema types use quoted symbols
|
|
2
|
+
|
|
3
|
+
## Summary
|
|
4
|
+
|
|
5
|
+
- Keep legacy lowercase type tags load-compatible, while making quoted symbols such as `'String`, `'List`, `'Fn`, and `'Dynamic` the canonical schema serialization.
|
|
6
|
+
- Make `cr edit format` rewrite only recognized type positions in schemas, hints, assertions, coercions, structs, and enums; ordinary tag data remains unchanged.
|
|
7
|
+
- Migrate repository Snapshots, type-query/IR/agent-interface output, build-time core Snapshot loading, and primary type documentation.
|
|
8
|
+
|
|
9
|
+
## Validation
|
|
10
|
+
|
|
11
|
+
- `cargo fmt`
|
|
12
|
+
- `cargo test`
|
|
13
|
+
- `cargo clippy -- -D warnings`
|
|
14
|
+
- `yarn compile`
|
|
15
|
+
- `yarn check-all`
|
|
16
|
+
- `yarn check-agent-interface`
|
|
17
|
+
- `cr docs check-md docs/features/static-analysis.md --entry calcit/test.cirru --failures-only`
|
|
18
|
+
- `cr docs check-md docs/CalcitAgent.md --entry calcit/test.cirru --failures-only`
|
|
19
|
+
- `cr docs graph check`
|
|
20
|
+
- formatted every valid repository Snapshot with `cr edit format`, then `cr calcit/test.cirru --check-only`
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# WASM dynamic string tag
|
|
2
|
+
|
|
3
|
+
- Schema type migration removed legacy type tags from program data, which can shift WASM's program-local tag indices.
|
|
4
|
+
- The Node.js WASM test host must not assume that the `string` type tag always has index 34.
|
|
5
|
+
- Export the generated module's actual string tag as `__string_tag` and use that value when the host validates or allocates strings.
|
|
6
|
+
- Keep the test host compatible with older generated modules by recovering the tag from their static string pool when the export is absent.
|
|
7
|
+
- Regression command: `cargo build --bin cr-wasm && CR_WASM_BIN=./target/debug/cr-wasm bash scripts/test-wasm.sh`.
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
# Consolidate historical editing notes
|
|
2
|
+
|
|
3
|
+
- Replaced 142 individual notes from June 2026 and earlier with a compact topic index.
|
|
4
|
+
- Retained all July–August notes for active maintenance context.
|
|
5
|
+
- The removed notes remain recoverable through Git history; `editing-history/README.md` documents the retention rule.
|
|
6
|
+
- Verification: reviewed the tracked path set and checked the resulting Git diff.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Consolidate CLI and test duplication
|
|
2
|
+
|
|
3
|
+
## Summary
|
|
4
|
+
|
|
5
|
+
- Introduced a typed `TreeOperation` model and shared cursor path transforms so edit, tree, and cursor commands use one implementation for structural mutations.
|
|
6
|
+
- Reused one staged-file abstraction for atomic cursor writes and edit transactions, including permission preservation, sync, commit, and cleanup behavior.
|
|
7
|
+
- Consolidated query result collection/rendering and type-coverage scope traversal without changing their JSON envelopes or diagnostics.
|
|
8
|
+
- Added one test-only temporary project fixture shared by edit, cursor, and query tests.
|
|
9
|
+
- Replaced eight identical Calcit test-local `log-title` definitions with `util.core/log-title`, keeping each standalone snapshot loadable through its module configuration.
|
|
10
|
+
- Removed the misspelled `test-gynienic.cirru` snapshot because the typed `test-hygienic.cirru` suite is a strict superset, and removed the identical `test-cond` runtime case from the macro suite.
|
|
11
|
+
- Made the remaining `case-default` macroexpansion assertion deterministic by resetting the gensym counter before checking the generated symbol.
|
|
12
|
+
|
|
13
|
+
## Review notes
|
|
14
|
+
|
|
15
|
+
- Kept repeated `main!` and `reload!` definitions because they are snapshot entry points rather than interchangeable helpers.
|
|
16
|
+
- Kept similarly named macro, native, JS, and WASM tests when they exercise different expansion or backend behavior.
|
|
17
|
+
- The resulting tracked diff removes more code than it adds while retaining the command boundaries and test coverage.
|
|
18
|
+
|
|
19
|
+
## Validation
|
|
20
|
+
|
|
21
|
+
- `cargo fmt`
|
|
22
|
+
- `cargo clippy -- -D warnings`
|
|
23
|
+
- `cargo test`
|
|
24
|
+
- `yarn compile`
|
|
25
|
+
- `yarn check-agent-interface` (12/12 scenarios)
|
|
26
|
+
- `yarn check-all` (native, JS, and WASM)
|
|
27
|
+
- Standalone native runs for the updated Calcit snapshots, including `test-cond.cirru`, `test-macro.cirru`, and `test-hygienic.cirru`
|
|
28
|
+
- Real-project Respo regression with JSON definition query and summary-only type-coverage analysis
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Review follow-up for CLI consolidation
|
|
2
|
+
|
|
3
|
+
## Summary
|
|
4
|
+
|
|
5
|
+
- Updated staged-file rewriting to open the temporary file with write access, truncate it, write through the same handle, and then sync it. This keeps `sync_all` valid on Windows.
|
|
6
|
+
- Reject symbolic-link destinations before staging so an atomic rename cannot silently replace the link while preserving permissions from its target.
|
|
7
|
+
- Avoid copying every definition tree during whole-project search; only a subtree selected by `--start-path` remains owned.
|
|
8
|
+
- Corrected cursor feedback so replace, swap, unwrap, and wrap report an unaffected cursor when their path did not change.
|
|
9
|
+
|
|
10
|
+
## Tests
|
|
11
|
+
|
|
12
|
+
- Added staged write/commit coverage and a Unix symbolic-link rejection test.
|
|
13
|
+
- Added cursor feedback assertions for unrelated paths and single-child unwraps.
|
|
14
|
+
|
|
15
|
+
## Review disposition
|
|
16
|
+
|
|
17
|
+
- Kept the existing parent-context preview for `query search-expr`; it predates this refactor and is intentional shared search presentation rather than a regression.
|
|
18
|
+
- Deferred directory `fsync` after rename: it is a larger crash-durability policy decision, especially for multi-file commits, and is not needed to correct the current atomic rename behavior.
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# Release 0.12.57
|
|
2
|
+
|
|
3
|
+
- Release the merged CLI mutation, atomic staging, and test deduplication work from PR #284.
|
|
4
|
+
- Include the follow-up fixes for Windows staged-file synchronization, symlink destinations, query cloning, and cursor feedback.
|
|
5
|
+
- Synchronize the Rust crate and npm package versions, then refresh the workspace lockfile before publishing.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Consolidated history through June 2026
|
|
2
|
+
|
|
3
|
+
Detailed task notes before July 2026 were consolidated on 2026-08-01. Their
|
|
4
|
+
full text remains recoverable from Git history; this file preserves the useful
|
|
5
|
+
navigation layer.
|
|
6
|
+
|
|
7
|
+
| Period | Durable themes |
|
|
8
|
+
| --- | --- |
|
|
9
|
+
| 2025–Feb 2026 | WASM/codegen groundwork, structural equality, diagnostics, core API documentation, and migration toward `defstruct`. |
|
|
10
|
+
| Mar 2026 | Schema and type-annotation redesign: `hint-fn` migration, schema normalization/validation, generic type references, arity checks, and type-fail coverage. |
|
|
11
|
+
| Apr 2026 | Records/enums, type narrowing and generic dispatch; the WASM runtime gained collections, strings, methods, host imports, and multi-module tests. |
|
|
12
|
+
| May–Jun 2026 | Weak-type analysis, data-definition bounds, markdown checking, compiled-runtime backfill, scoped type slots, effects graph, and Agent/CLI documentation. |
|
|
13
|
+
|
|
14
|
+
For current behavior, prefer `docs/`, tests, and the retained July–August notes
|
|
15
|
+
over this summary.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Editing history
|
|
2
|
+
|
|
3
|
+
This directory keeps short, task-specific notes that help with nearby follow-up
|
|
4
|
+
work. It is not a second changelog: exact prior notes remain available from Git
|
|
5
|
+
history after they leave this directory.
|
|
6
|
+
|
|
7
|
+
## Retention
|
|
8
|
+
|
|
9
|
+
- Keep individual notes for the current development window (normally the most
|
|
10
|
+
recent 45 days).
|
|
11
|
+
- Periodically replace older clusters with a concise topic summary in
|
|
12
|
+
[ARCHIVE.md](ARCHIVE.md), then remove their individual files.
|
|
13
|
+
- Each code commit still adds one timestamped note, but it should capture only
|
|
14
|
+
durable context: the reason for the change, compatibility constraints, and
|
|
15
|
+
the relevant verification command.
|
|
16
|
+
|
|
17
|
+
To recover a removed note, search the repository history, for example:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
git log --all -- editing-history/
|
|
21
|
+
```
|
package/lib/package.json
CHANGED
package/package.json
CHANGED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
# 202602131841 trait origin 匹配与结构化 trait 相等性
|
|
2
|
-
|
|
3
|
-
## 背景
|
|
4
|
-
|
|
5
|
-
本次提交延续了动态方法告警收敛与 trait 分发可靠性改进。
|
|
6
|
-
评审中提出的核心问题是:trait 分发不应只依赖 trait 名称匹配。
|
|
7
|
-
`impl` 记录本身已经携带了 trait 的 origin 元数据,因此匹配应直接基于 origin。
|
|
8
|
-
|
|
9
|
-
## 目标
|
|
10
|
-
|
|
11
|
-
1. 让 `&trait-call` 按 trait origin 相等性选择 impl,而不是按名称字符串匹配。
|
|
12
|
-
2. 让 trait/impl 的相等语义与上述运行时选择模型一致。
|
|
13
|
-
3. 在尽量保持兼容的前提下,提高歧义/重名场景下的正确性。
|
|
14
|
-
4. 保持现有优先级规则不变(用户 impl:后者覆盖前者;内建 impl:前者优先)。
|
|
15
|
-
|
|
16
|
-
## 思考过程
|
|
17
|
-
|
|
18
|
-
### 为什么 name-only 匹配不够
|
|
19
|
-
|
|
20
|
-
- 仅按名称匹配会把“同名但结构不同”的 trait 混为一类。
|
|
21
|
-
- 运行时已有 `CalcitImpl.origin: Option<Arc<CalcitTrait>>`,若忽略它会浪费已有语义信息。
|
|
22
|
-
- 使用显式 `&trait-call` 时,调用方预期的是“精确 trait 命中”,而非按名字近似匹配。
|
|
23
|
-
|
|
24
|
-
### 分发策略决定
|
|
25
|
-
|
|
26
|
-
在 `trait_call` 中:
|
|
27
|
-
|
|
28
|
-
- 旧逻辑:`imp.trait_name()` 与 `trait_def.name` 比较。
|
|
29
|
-
- 新逻辑:`imp.origin()` 与目标 trait 直接通过 `Eq` 比较。
|
|
30
|
-
|
|
31
|
-
该方案改动小、语义清晰,并与当前运行时模型一致,不引入额外解析复杂度。
|
|
32
|
-
|
|
33
|
-
### Eq/Hash 一致性
|
|
34
|
-
|
|
35
|
-
当分发切换到 origin 相等后,`CalcitTrait` 的相等语义就不能继续只看 `name`。
|
|
36
|
-
|
|
37
|
-
因此将 `CalcitTrait` 的 Eq/Hash 升级为结构化比较,包含:
|
|
38
|
-
|
|
39
|
-
- trait 名称
|
|
40
|
-
- 方法名列表
|
|
41
|
-
- 方法类型签名
|
|
42
|
-
- requires(依赖 trait)
|
|
43
|
-
- 默认实现槽位形状(每个位置是 `Some` 还是 `None`)
|
|
44
|
-
|
|
45
|
-
关于默认实现:
|
|
46
|
-
|
|
47
|
-
- 默认函数体(`CalcitFn`)不做深比较/深哈希,因为 `CalcitFn` 当前不提供完整 Eq/Hash。
|
|
48
|
-
- 这里只比较默认槽位可用性形状,以保证 Eq/Hash 契约一致,同时提升结构判断准确性。
|
|
49
|
-
|
|
50
|
-
## 文件级改动
|
|
51
|
-
|
|
52
|
-
### 运行时分发与文档
|
|
53
|
-
|
|
54
|
-
- `src/builtins/meta.rs`
|
|
55
|
-
- `trait_call` 改为按 `impl.origin` 相等匹配。
|
|
56
|
-
- 同步更新函数附近注释,确保文档与实现一致。
|
|
57
|
-
|
|
58
|
-
### impl 相等性
|
|
59
|
-
|
|
60
|
-
- `src/calcit/calcit_impl.rs`
|
|
61
|
-
- `PartialEq` 改为直接比较 `origin`(不再只比较 `origin.name`)。
|
|
62
|
-
|
|
63
|
-
### trait 相等性与哈希语义
|
|
64
|
-
|
|
65
|
-
- `src/calcit/calcit_trait.rs`
|
|
66
|
-
- `PartialEq` 从 name-only 改为结构化比较。
|
|
67
|
-
- `Hash` 同步到相同结构维度。
|
|
68
|
-
- 增加注释,说明默认函数比较策略。
|
|
69
|
-
|
|
70
|
-
### 相关一致性修正(同一工作区变更)
|
|
71
|
-
|
|
72
|
-
- `src/runner/preprocess.rs`
|
|
73
|
-
- 修复重命名后的测试守卫符号残留(`DynTraitCheckGuard` -> `WarnDynMethodGuard`)。
|
|
74
|
-
|
|
75
|
-
## 验证
|
|
76
|
-
|
|
77
|
-
- `cargo fmt`
|
|
78
|
-
- `cargo test -q`
|
|
79
|
-
- 结果:当前工作区下测试全部通过。
|
|
80
|
-
|
|
81
|
-
## 兼容性与风险
|
|
82
|
-
|
|
83
|
-
- 该行为变化是有意为之:同名但结构不同的 trait 不再被视为相等。
|
|
84
|
-
- 默认函数体差异仍不纳入 Eq/Hash。
|
|
85
|
-
- 方法分发优先级规则保持不变。
|
|
86
|
-
|
|
87
|
-
## 后续可选项
|
|
88
|
-
|
|
89
|
-
1. 如有需要,可补强默认实现身份比较(例如优先比较 def ref)。
|
|
90
|
-
2. 增加“同名不同结构 trait”相等性的显式测试用例。
|
|
91
|
-
3. 继续收敛 `warn-dyn-method` 全量运行中的剩余动态调用告警。
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
# 2026-02-14 20:50 JS codegen recursion + tag migration
|
|
2
|
-
|
|
3
|
-
## 背景
|
|
4
|
-
|
|
5
|
-
在 trait/macro 改进后,继续针对 JavaScript 编译目标做性能与可维护性优化。
|
|
6
|
-
|
|
7
|
-
## 本次改动
|
|
8
|
-
|
|
9
|
-
1. 参数个数报错模板统一
|
|
10
|
-
|
|
11
|
-
- 在 runtime 新增 `_args_fewer_throw` / `_args_between_throw`,保留 `_args_throw`。
|
|
12
|
-
- emitter 中 `too few/too many` 模板改为调用统一 helper,错误信息继续携带期望与实际参数个数。
|
|
13
|
-
|
|
14
|
-
2. rest 参数处理优化
|
|
15
|
-
|
|
16
|
-
- 对 `&` rest 参数,仅在函数体实际引用时才注入 `arrayToList` 转换,避免不必要转换。
|
|
17
|
-
- 修复符号引用检测边界:`contains_symbol` 增加 `Calcit::Local` 分支。
|
|
18
|
-
|
|
19
|
-
3. tail recursion 模板优化
|
|
20
|
-
|
|
21
|
-
- watchdog 从每轮检查改为周期检查(`(times & 1023) === 0` 时再判断上限)。
|
|
22
|
-
- 对无 rest/optional 的固定参数函数,recur 回填改为索引赋值(`arg = ret.args[i]`),减少解构开销。
|
|
23
|
-
|
|
24
|
-
4. tag 初始化一次迁移
|
|
25
|
-
|
|
26
|
-
- runtime 新增 `init_tags` 与全局 tag 缓存。
|
|
27
|
-
- emitter 统一改为 `const _t_ = init_tags([...])` / `$clt.init_tags([...])`。
|
|
28
|
-
- 移除每模块内联 `forEach + newTag` 初始化模板。
|
|
29
|
-
- 修复 `calcit.core` 目标缺失导入,补上 `init_tags` import。
|
|
30
|
-
|
|
31
|
-
## 验证
|
|
32
|
-
|
|
33
|
-
- `yarn check-all` 通过。
|
|
34
|
-
- 额外执行了 JS 微基准(`test-recursion.main/test_loop`)用于观察 recursion 模板优化影响。
|
|
35
|
-
|
|
36
|
-
## 经验点
|
|
37
|
-
|
|
38
|
-
- JS 生成模板优化要先保证语义完整,再做结构性收敛(helper 化/去重复)。
|
|
39
|
-
- 对 codegen 的性能优化,建议配套微基准,并与 baseline 做同脚本对比。
|