@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
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
# Query 搜索结果分层、降噪与路径/预览优化(合并记录)
|
|
2
|
-
|
|
3
|
-
## 变更概述
|
|
4
|
-
|
|
5
|
-
- 初始实现:为 `cr query` 搜索类命令引入结果分层展示(详情窗口 + 压缩输出)。
|
|
6
|
-
- 参数命名收敛:将 `--prefer` 直接改为 `--detail-offset`(不保留兼容别名)。
|
|
7
|
-
- 输出降噪:删除冗长提示,保留定位核心信息(定义、路径、命中片段)。
|
|
8
|
-
- 路径统一:搜索输出与 `--start-path` 示例统一为点号分隔;解析层仅接受点号输入。
|
|
9
|
-
- 详情窗口进一步从 5 缩小为 3,并在窗口内增加“所在表达式 + 父表达式”预览(可省略复杂父表达式)。
|
|
10
|
-
|
|
11
|
-
## 覆盖命令
|
|
12
|
-
|
|
13
|
-
- `cr query find`
|
|
14
|
-
- `cr query usages`
|
|
15
|
-
- `cr query search`
|
|
16
|
-
- `cr query search-expr`
|
|
17
|
-
|
|
18
|
-
## 关键实现
|
|
19
|
-
|
|
20
|
-
- `src/cli_args.rs`
|
|
21
|
-
- 参数字段统一为 `detail_offset`。
|
|
22
|
-
- 参数统一为 `#[argh(option, long = "detail-offset", default = "0")]`。
|
|
23
|
-
- 参数说明更新为“3 detailed items”。
|
|
24
|
-
- `query search --start-path` 示例更新为点号格式 `2.1.0`。
|
|
25
|
-
|
|
26
|
-
- `src/bin/cli_handlers/query.rs`
|
|
27
|
-
- 结果窗口逻辑:
|
|
28
|
-
- `DETAILED_RESULTS_WINDOW = 3`
|
|
29
|
-
- `detailed_window(detail_offset, total)`
|
|
30
|
-
- `in_detail_window(index, total, detail_offset)`
|
|
31
|
-
- `print_detail_window_hint(...)`
|
|
32
|
-
- 搜索结果降噪:
|
|
33
|
-
- `search/search-expr` 按命中数排序定义(高命中优先)。
|
|
34
|
-
- 详情行输出为 `[path] <preview>`;窗口外仅输出压缩条数(`N matches compressed outside window`)。
|
|
35
|
-
- 移除 `Next steps`/批量替换等长提示块。
|
|
36
|
-
- 预览增强:
|
|
37
|
-
- 新增 `preview_node_oneline(...)` 并修复叶子节点空预览问题。
|
|
38
|
-
- 新增 `path_parent(...)`、`get_node_at_path(...)`、`count_nodes_limited(...)`、`can_show_parent_preview(...)`、`expression_and_parent_preview(...)`。
|
|
39
|
-
- 最终形态改为“单行预览”:优先显示父节点预览;无父节点时回退到当前表达式(避免重复展示两遍)。
|
|
40
|
-
|
|
41
|
-
- Tips 与 exact 语义修正:
|
|
42
|
-
- `--exact` 高优先级提示文案统一为英文:`Many matches (N); add --exact to show exact matches only`。
|
|
43
|
-
- 仅在 contains 模式且命中数 `> 10` 时展示该提示;`--exact` 模式不再显示冗余提示。
|
|
44
|
-
- 修复 exact 模式下的误导性高亮:只在 token 边界高亮,避免将 `states` 中的 `state` 误标为命中。
|
|
45
|
-
|
|
46
|
-
- 命名收敛:将旧命名 `prefer` 在函数参数/调用链/提示文案中统一改为 `detail_offset` / `detail-offset`。
|
|
47
|
-
|
|
48
|
-
- `src/bin/cli_handlers/common.rs`
|
|
49
|
-
- `parse_path(...)` 改为仅接受点号分隔;逗号输入报错并提示改用点号。
|
|
50
|
-
|
|
51
|
-
## 降噪策略
|
|
52
|
-
|
|
53
|
-
- 深度嵌套(路径过深)或分支复杂(节点过大)时,父表达式预览自动省略。
|
|
54
|
-
- 详细窗口外仍然输出压缩占位,不展开上下文。
|
|
55
|
-
|
|
56
|
-
## 验证
|
|
57
|
-
|
|
58
|
-
- `cargo check --bin cr` 通过。
|
|
59
|
-
- `cargo run --bin cr -- /Users/jon.chen/repo/respo/respo/calcit.cirru query find --help`
|
|
60
|
-
- 可见 `--detail-offset` 参数。
|
|
61
|
-
- `cargo run --bin cr -- /Users/jon.chen/repo/respo/respo/calcit.cirru query search --help`
|
|
62
|
-
- `--start-path` 示例为点号格式。
|
|
63
|
-
- `cargo run --bin cr -- /Users/jon.chen/repo/respo/respo/calcit.cirru query search state --filter respo.app.comp.todolist/comp-todolist --detail-offset 5`
|
|
64
|
-
- 输出降噪,路径为点号,窗口外压缩。
|
|
65
|
-
- `cargo run --bin cr -- /Users/jon.chen/repo/respo/respo/calcit.cirru query search state --filter respo.app.comp.todolist/comp-todolist --detail-offset 0`
|
|
66
|
-
- 详情窗口为 `[0, 3)`,每条命中仅展示一行(优先父节点预览)。
|
|
67
|
-
- `cargo run --bin cr -- /Users/jon.chen/repo/respo/respo/calcit.cirru query search state --filter respo.app.comp.todolist/comp-todolist --detail-offset 0 --exact`
|
|
68
|
-
- 精确命中不再把 `states` 视觉误判为 `state`;且不显示“add --exact”提示。
|
|
69
|
-
- `cargo run --bin cr -- /Users/jon.chen/repo/respo/respo/calcit.cirru query search-expr state --filter respo.app.comp.todolist/comp-todolist --detail-offset 0`
|
|
70
|
-
- 输出样式一致(单行预览)。
|
|
71
|
-
- `cargo run --bin cr -- /Users/jon.chen/repo/respo/respo/calcit.cirru query search-expr state --filter respo.app.comp.todolist/comp-todolist --detail-offset 0 --exact`
|
|
72
|
-
- 结果为 `No matches found`,符合结构精确匹配预期。
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
# Command Echo 主导的工具输出收敛与 tree replace 差异摘要
|
|
2
|
-
|
|
3
|
-
## 变更概述
|
|
4
|
-
|
|
5
|
-
- 将 `cr` 的命令回显进一步固定为工具主语境:前置、单行、语义化参数展示。
|
|
6
|
-
- 为工具型命令引入更安静的 runtime 输出模式,避免版本、模块目录、模块加载、平台 API 注册等噪音干扰结果读取。
|
|
7
|
-
- 大范围清理 `docs/query/tree` 正文里对 `target/path/pattern/entry/deps` 的重复回显,统一交给 command echo 表达。
|
|
8
|
-
- 修正 `docs/CalcitAgent.md` 中示意性 Cirru 代码块的检查模式,避免 `check-md` 将结构示例误判为 runnable 程序。
|
|
9
|
-
- 单独重构 `tree replace` 输出:从“Preview + From/To”双份重复,改成“Changed node + Containing expression”的单次差异摘要。
|
|
10
|
-
|
|
11
|
-
## 关键实现
|
|
12
|
-
|
|
13
|
-
- `src/bin/cr.rs`
|
|
14
|
-
- 在启用 command echo 时同步启用 `calcit::set_quiet_tool_output(true)`。
|
|
15
|
-
- 屏蔽工具模式下的运行环境提示:
|
|
16
|
-
- `calcit version`
|
|
17
|
-
- `module folder`
|
|
18
|
-
- `stack trace disabled`
|
|
19
|
-
- `running entry`
|
|
20
|
-
|
|
21
|
-
- `src/lib.rs`
|
|
22
|
-
- 新增全局 quiet flag:
|
|
23
|
-
- `set_quiet_tool_output(...)`
|
|
24
|
-
- `quiet_tool_output()`
|
|
25
|
-
- `load_module(...)` 在工具模式下不再打印 `loading: ...`。
|
|
26
|
-
|
|
27
|
-
- `src/bin/injection/mod.rs`
|
|
28
|
-
- `inject_platform_apis()` 在工具模式下不再打印 `registered platform APIs`。
|
|
29
|
-
|
|
30
|
-
- `src/bin/cli_handlers/docs.rs`
|
|
31
|
-
- `docs check-md` 不再重复回显 `entry/deps`。
|
|
32
|
-
- 移除只服务旧回显的路径展示 helper。
|
|
33
|
-
|
|
34
|
-
- `src/bin/cli_handlers/query.rs`
|
|
35
|
-
- 删除 `query def/peek/schema/examples/usages` 中重复的 target 标题。
|
|
36
|
-
- 删除 `query search/search-expr` 中重复的 pattern/filter/entry/start-path 摘要。
|
|
37
|
-
- `query find` 摘要从“重复 symbol”收敛为纯结果计数。
|
|
38
|
-
|
|
39
|
-
- `src/bin/cli_handlers/tree.rs`
|
|
40
|
-
- 删除 `tree show` 与多类 tree 写操作中的冗余 follow-up 命令提示。
|
|
41
|
-
- 删除成功文案里重复的 `path/target/pattern` 回显。
|
|
42
|
-
- `tree replace` 改为:
|
|
43
|
-
- `✓ Replaced node`
|
|
44
|
-
- `Changed node` 下单次展示 `Before/After`
|
|
45
|
-
- 非 root path 额外展示 `Containing expression`,帮助快速看出修改落点。
|
|
46
|
-
|
|
47
|
-
- `docs/CalcitAgent.md`
|
|
48
|
-
- 将示意性代码块改成 `cirru.no-check`,避免 `docs check-md` 因不存在的符号或非独立程序片段失败。
|
|
49
|
-
|
|
50
|
-
## 输出策略结论
|
|
51
|
-
|
|
52
|
-
- 输入参数语境:由 `Command: ...` 统一承担。
|
|
53
|
-
- 正文输出:只保留结果、差异、结构上下文、或真正新增的信息。
|
|
54
|
-
- 不再在正文里重复打印 command echo 已经覆盖的 target/path/pattern/entry/deps。
|
|
55
|
-
|
|
56
|
-
## 验证摘要
|
|
57
|
-
|
|
58
|
-
- `cargo fmt`
|
|
59
|
-
- `cargo run --bin cr -- calcit/test.cirru analyze js-escape 'demo?'`
|
|
60
|
-
- `cargo run --bin cr -- calcit/test.cirru analyze js-unescape 'demo_$q_'`
|
|
61
|
-
- `cargo run --bin cr -- calcit/test.cirru query ns app.main`
|
|
62
|
-
- `cargo run --bin cr -- calcit/test.cirru query find render`
|
|
63
|
-
- `cargo run --bin cr -- calcit/test.cirru tree show app.main/test-json --path ''`
|
|
64
|
-
- `cargo run --bin cr -- calcit/test.cirru docs search chunk --filename agent-advanced.md`
|
|
65
|
-
- `cargo run --bin cr -- demos/calcit.cirru docs check-md docs/CalcitAgent.md`
|
|
66
|
-
- `cargo run --bin cr -- /tmp/calcit-cli-demo/calcit.cirru tree replace ...` 多次人工检查 replace 输出形态
|
|
67
|
-
|
|
68
|
-
## 经验
|
|
69
|
-
|
|
70
|
-
- command echo 一旦语义化,就应把正文里的“参数再描述一遍”系统性删掉,否则会让工具输出看起来像教程而不是结果。
|
|
71
|
-
- tree 类命令相比简单成功提示,更需要“差异摘要 + 所在表达式”,这样既不冗余,也能快速判断改动是否落在预期结构。
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
# 2026-0410-0011 — 修复 snapshot `configs.version` 对 `||` 空字符串的漏判
|
|
2
|
-
|
|
3
|
-
## 背景
|
|
4
|
-
|
|
5
|
-
PR `snapshot-format` 新增了空 `configs.version` 的回归测试,但 GitHub Actions 上加载运行时快照文件(`calcit.cirru` / legacy `compact.cirru`)时,`(:version ||)` 会解析成字符串 `"|"`,没有命中原先仅检查空白字符串的校验。
|
|
6
|
-
|
|
7
|
-
## 知识点
|
|
8
|
-
|
|
9
|
-
- Cirru 的空字符串字面量 `||` 在这条解析路径里会落成 `"|"`,不能只靠 `trim().is_empty()` 判断是否为空。
|
|
10
|
-
- `configs.version` 的校验要同时覆盖真正空串和这个 pipe marker,才能在加载阶段稳定报出 `configs.version cannot be empty`。
|
|
11
|
-
|
|
12
|
-
## 修改
|
|
13
|
-
|
|
14
|
-
- `src/snapshot.rs`
|
|
15
|
-
- 将 `parse_snapshot_config_string_field` 中 `version` 的空值判断扩展为:`text.trim().is_empty() || text == "|"`。
|
|
16
|
-
|
|
17
|
-
## 验证
|
|
18
|
-
|
|
19
|
-
```bash
|
|
20
|
-
cargo fmt -- src/snapshot.rs
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
本地 `cargo test` 在当前机器仍受 macOS 链接器环境影响(`ld: library 'System' not found`),实际正确性改由 GitHub Actions 复核。
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
# 202604160131 — WASM codegen 扩展: 数学函数 + 测试集成
|
|
2
|
-
|
|
3
|
-
## 新增 WASM 操作
|
|
4
|
-
|
|
5
|
-
- `floor` → `f64.floor`
|
|
6
|
-
- `ceil` → `f64.ceil`
|
|
7
|
-
- `round` → `f64.nearest`
|
|
8
|
-
- `sqrt` → `f64.sqrt`
|
|
9
|
-
- `identical?` → `f64.eq`
|
|
10
|
-
- `sin`/`cos`/`pow` 明确报错(WASM 无对应指令)
|
|
11
|
-
|
|
12
|
-
## 新增文件
|
|
13
|
-
|
|
14
|
-
- `calcit/test-wasm.cirru` — 17 个纯数值函数测试(fibo, factorial, add-two, sum-range, floor, ceil, round, sqrt, rem, compare, not, let-chain, collatz-steps, gcd 等)
|
|
15
|
-
- `scripts/test-wasm.sh` — WASM 验证脚本(生成 WAT → wasmtime compile → 逐函数验证返回值)
|
|
16
|
-
|
|
17
|
-
## 修改文件
|
|
18
|
-
|
|
19
|
-
- `src/codegen/emit_wasm.rs` — 新增 `unary_op` 辅助函数, 添加 Floor/Ceil/Round/Sqrt/Identical 分支
|
|
20
|
-
- `package.json` — `check-all` 加入 `try-wasm` 步骤; 新增 `try-wasm` 脚本
|
|
21
|
-
- `docs/wasm-codegen.md` — 更新支持列表、测试说明、路线图
|
|
22
|
-
|
|
23
|
-
## 验证
|
|
24
|
-
|
|
25
|
-
- `yarn check-all` 通过(含 compile, try-rs, try-js, try-ir, try-wasm)
|
|
26
|
-
- `cargo test` 246/246 pass
|
|
27
|
-
- `cargo clippy -- -D warnings` clean
|
|
28
|
-
- wasmtime 逐函数验证: 17/17 assertions pass
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
# 202604161507 - WASM 数据结构编译 & rfc 目录重命名
|
|
2
|
-
|
|
3
|
-
## rfc 目录整理
|
|
4
|
-
|
|
5
|
-
- `drafts/` 重命名为 `rfc/`,所有文件加上 `MM-DD-` 创建日期前缀(从 git 历史提取)
|
|
6
|
-
- README.md 更新为完整索引,补全之前遗漏的 5 个文件条目
|
|
7
|
-
- Cargo.toml 中 `drafts/` 引用更新为 `rfc/`
|
|
8
|
-
|
|
9
|
-
## WASM 数据结构编译
|
|
10
|
-
|
|
11
|
-
### 新增能力
|
|
12
|
-
|
|
13
|
-
- **Memory Section**: 1 页 64KB 线性内存,Global section 维护 `heap_ptr` 作为 bump allocator
|
|
14
|
-
- **Tag 编译**: `collect_all_tags()` 在编译期为所有 tag 字面量分配整数 ID,运行时直接用 f64 表示
|
|
15
|
-
- **Record 编译**: `emit_record_new()` 在堆上分配 `[struct_tag_id, field0, field1, ...]`,`emit_record_nth()` 通过偏移直接读取
|
|
16
|
-
- **Tuple 编译**: `emit_tuple_new()` 在堆上分配 `[tag_id, payload0, payload1, ...]`,`emit_tuple_nth()` 直接读取
|
|
17
|
-
- **静态结构解析**: `try_parse_defrecord_form()` 从源码 AST 静态提取 `defrecord` 的字段定义,不依赖运行时宏展开
|
|
18
|
-
|
|
19
|
-
### 关键设计决策
|
|
20
|
-
|
|
21
|
-
- 全 f64 ABI:所有值(包括指针)用 f64 传递,需要 `i32.trunc_f64_u` / `f64.convert_i32_u` 转换
|
|
22
|
-
- record 字段按字母序排列(与 Calcit runtime 一致)
|
|
23
|
-
- bump allocator 不回收,适合短生命周期 WASM 模块
|
|
24
|
-
|
|
25
|
-
### 测试覆盖
|
|
26
|
-
|
|
27
|
-
- 22 项 WASM 检查全部通过:17 个数值运算 + 2 个 tag 比较 + 2 个 record 求和 + 1 个 tuple 求和
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
# 202604161520 - WASM 位运算 & match 语法编译
|
|
2
|
-
|
|
3
|
-
## 位运算 (bitwise operations)
|
|
4
|
-
|
|
5
|
-
- 新增 `bit-and`, `bit-or`, `bit-xor`, `bit-not`, `bit-shl`, `bit-shr` 6 个 WASM 编译支持
|
|
6
|
-
- 策略: f64 → i32 (trunc_f64_s) → 执行 i32 位运算 → i32 → f64 (convert_i32_s)
|
|
7
|
-
- 使用有符号转换 (I32TruncF64S / F64ConvertI32S) 保持负数语义
|
|
8
|
-
|
|
9
|
-
## match 语法编译
|
|
10
|
-
|
|
11
|
-
- 实现 `match` 表达式的 WASM codegen, 支持 enum tuple 模式匹配
|
|
12
|
-
- 策略: 加载 tuple 的 tag_id (offset 0), 对各分支做嵌套 if/else 比较
|
|
13
|
-
- 支持 tag 模式 `(:variant a b)` — 从 tuple 内存按偏移读取 payload 绑定到局部变量
|
|
14
|
-
- 支持 wildcard `_` 作为 fallback 分支
|
|
15
|
-
- 注意 block_depth 正确更新以保持 recur 分支跳转的一致性
|
|
16
|
-
|
|
17
|
-
## 测试覆盖
|
|
18
|
-
|
|
19
|
-
- 31 项 WASM 检查全部通过 (原 22 + 6 bitwise + 3 match)
|
|
20
|
-
- 246 cargo tests 通过 (179 + 67)
|
|
21
|
-
- clippy 零警告
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
# WASM: Cross-namespace calls & host imports (pow, sin, cos)
|
|
2
|
-
|
|
3
|
-
## 概要
|
|
4
|
-
|
|
5
|
-
为 WASM codegen 增加了跨命名空间函数调用和宿主函数导入两大功能。
|
|
6
|
-
|
|
7
|
-
## 知识点
|
|
8
|
-
|
|
9
|
-
### 跨命名空间调用
|
|
10
|
-
|
|
11
|
-
- `emit_wasm()` 从只处理 `init_ns` 改为遍历 `program_data` 全部命名空间
|
|
12
|
-
- `fn_defs` 从 3-tuple `(def, args, body)` 扩展为 4-tuple `(ns, def, args, body)`
|
|
13
|
-
- `fn_index` 同时保存 `"ns/def"` 全限定名和 `"def"` 裸名两种键
|
|
14
|
-
- `emit_call_expr` 中遇到 `Import` 节点时,先尝试全限定名再尝试裸名
|
|
15
|
-
- `collect_all_tags` 更名为 `collect_all_tags_from` 适配 4-tuple
|
|
16
|
-
|
|
17
|
-
### 宿主函数导入 (Host Imports)
|
|
18
|
-
|
|
19
|
-
- 新增 `HostImport` 结构体和 `HOST_IMPORTS` 常量数组(pow/sin/cos)
|
|
20
|
-
- WASM 模块新增 `ImportSection`,从 `"math"` 模块导入函数
|
|
21
|
-
- **关键约束**:导入函数占据函数索引 0..N,用户函数从 N 开始
|
|
22
|
-
- TypeSection: 先写 host import 的类型, 再写 user function 的类型
|
|
23
|
-
- FunctionSection: 只写 user function(import 自动拥有类型)
|
|
24
|
-
- ExportSection / fn_index: 用户函数索引均需加 `num_imports` 偏移
|
|
25
|
-
- `emit_host_call()` 辅助函数:按名称查找 HOST_IMPORTS 并发出 Call 指令
|
|
26
|
-
- `CalcitProc::Sin/Cos/Pow` 从返回错误改为调用 `emit_host_call`
|
|
27
|
-
|
|
28
|
-
### 测试
|
|
29
|
-
|
|
30
|
-
- `test-wasm.cirru` 新增 `test-wasm.helper` 命名空间(含 `add-and-double`)
|
|
31
|
-
- `test-wasm.mjs` 新增 `math` 导入对象 + `checkApprox()` 浮点近似断言
|
|
32
|
-
- 测试从 31 项增加到 39 项,全部通过
|
|
33
|
-
|
|
34
|
-
## 注意事项
|
|
35
|
-
|
|
36
|
-
- WASM 规范要求 Import section 必须在 Function section 之前
|
|
37
|
-
- 添加新 host import 时需更新 HOST_IMPORTS 数组,并确认 JS 测试 runner 提供对应实现
|
|
38
|
-
- 后续可考虑将 host import 模块名参数化(目前硬编码 `"math"`)
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
# WASM: 可变参数 (rest args) 支持
|
|
2
|
-
|
|
3
|
-
## 背景
|
|
4
|
-
|
|
5
|
-
此前 `(defn f (a b & xs) ...)` 形式的函数在 WASM codegen 中会直接报错
|
|
6
|
-
"rest args not supported in WASM codegen" 而被跳过。这阻塞了 `calcit.core` 中
|
|
7
|
-
`<`、`-`、`/`、`dissoc`、`exclude`、`intersection`、`difference`、
|
|
8
|
-
`merge-non-nil`、`&str-spaced` 等大量可变参数函数的 WASM 编译。
|
|
9
|
-
|
|
10
|
-
## 实现
|
|
11
|
-
|
|
12
|
-
函数签名约定(匹配现有数据结构表示):
|
|
13
|
-
|
|
14
|
-
- rest 参数表现为一个 f64 参数,承载一个 list 指针。
|
|
15
|
-
- `(defn f (a b & xs) ...)` 的 WASM 签名是 `(a: f64, b: f64, xs: f64) -> f64`,
|
|
16
|
-
其中 `xs` 是调用方构造的 list 指针。
|
|
17
|
-
|
|
18
|
-
关键改动(全部在 `src/codegen/emit_wasm.rs`):
|
|
19
|
-
|
|
20
|
-
1. 新增 `compute_fn_arity(args) -> (wasm_arity, Option<rest_fixed>)`:
|
|
21
|
-
替代原来散落的 arity 计算,同时返回是否含 rest 以及固定参数数。
|
|
22
|
-
2. 新增 `fn_has_rest: HashMap<String, u32>`,记录每个有 rest 的函数的固定
|
|
23
|
-
参数数(`wasm_arity - 1`)。随 `fn_index` / `fn_arity` 一起在
|
|
24
|
-
`compile_fn` 之前建好。
|
|
25
|
-
3. `WasmGenCtx` 新增 `fn_has_rest` 字段,与其他 lookup 表一起 clone 进上下文。
|
|
26
|
-
4. `compile_fn`:
|
|
27
|
-
- 不再对 `CalcitArgLabel::RestMark` 报错。
|
|
28
|
-
- 跳过 `RestMark` 本身,但把 `&` 后的 `Idx` 仍然作为一个普通 f64 参数
|
|
29
|
-
压入 `param_names`(它承载 list 指针)。
|
|
30
|
-
5. `emit_call_expr`:提取新助手 `emit_call_args`,根据 callee 是否有 rest
|
|
31
|
-
分两条路径:
|
|
32
|
-
- 无 rest:照旧逐个 `emit_expr`,缺失的 optional 参数用 `f64_const(0.0)` 填补。
|
|
33
|
-
- 有 rest:前 `fixed` 个参数照旧求值,多余参数调用 `emit_list_new` 打包
|
|
34
|
-
成 list 指针作为最后一个参数。
|
|
35
|
-
|
|
36
|
-
## 踩坑记录
|
|
37
|
-
|
|
38
|
-
- **`bash scripts/test-wasm.sh` 用的是 release 产物,不是 `cargo run`**。改完
|
|
39
|
-
Rust 代码后一定要 `cargo build --release --bin cr`,否则看到的仍是旧行为。
|
|
40
|
-
这次调试时一度以为 `collect-rest` 还会被跳过,源头是 release binary 陈旧。
|
|
41
|
-
- `emit_list_new` 签名接受 `&[Calcit]`,直接传入 `&args_list[fixed..]`
|
|
42
|
-
就够用;不需要手动写 header/slot。
|
|
43
|
-
|
|
44
|
-
## 测试
|
|
45
|
-
|
|
46
|
-
新增 `calcit/test-wasm.cirru` 三个用例:
|
|
47
|
-
|
|
48
|
-
- `test-rest-count`:`collect-rest 1 2 3 4` 返回的 list 长度为 3。
|
|
49
|
-
- `test-rest-sum`:`sum-rest 1 2 3 4 5 = 15`,验证打包 list 后由被调函数
|
|
50
|
-
通过 `&list:first` / `&list:rest` / `recur` 逐项展开并求和。
|
|
51
|
-
- `test-rest-empty`:`sum-rest 10 20 = 30`,验证没有额外参数时 list 为空。
|
|
52
|
-
|
|
53
|
-
`scripts/test-wasm.mjs` 对应 3 条 `check(...)`。`yarn check-all` 全绿。
|
|
54
|
-
|
|
55
|
-
## 遗留
|
|
56
|
-
|
|
57
|
-
尚未支持的 WASM 功能(下一步继续攻克):
|
|
58
|
-
|
|
59
|
-
- `type-of`、各类 `xxx?` 谓词(需要运行时类型标记,难度较大)。
|
|
60
|
-
- `foldl` / `foldl-shortcut`(依赖闭包或函数指针)。
|
|
61
|
-
- 嵌套 `defn` / 闭包。
|
|
62
|
-
- 字符串字面量和字符串操作。
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
# WASM codegen: implement `type-of` via heap type headers
|
|
2
|
-
|
|
3
|
-
## 背景
|
|
4
|
-
|
|
5
|
-
在 WASM 子集里实现 `type-of` 是解锁 ~20 个核心函数(`list?`、`map?`、`set?`、
|
|
6
|
-
`number?` 等)的前置。所有值统一用 f64 表示,堆对象是“整数值 f64”的指针
|
|
7
|
-
(byte offset);没有 NaN-boxing,无法仅凭位模式区分类型。
|
|
8
|
-
|
|
9
|
-
## 方案
|
|
10
|
-
|
|
11
|
-
每一次堆分配前置 8 字节类型头:
|
|
12
|
-
|
|
13
|
-
```
|
|
14
|
-
raw_base + 0 : i32 MAGIC (0xCA1C17A9)
|
|
15
|
-
raw_base + 4 : i32 tag_id (BUILTIN_TYPE_TAGS 里的下标对应的 tag_index 值)
|
|
16
|
-
raw_base + 8 : 原本的 payload
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
`emit_bump_alloc` / `emit_bump_alloc_dynamic` 实际申请 `byte_size + 8` 字节,
|
|
20
|
-
返回的 **logical pointer** 仍然是 `raw_base + 8`,所以所有既有 offset 算术
|
|
21
|
-
(count at offset 0、fields at offset 8/16/…)无需改动。
|
|
22
|
-
|
|
23
|
-
### 11 个内建 type tag
|
|
24
|
-
|
|
25
|
-
`BUILTIN_TYPE_TAGS = ["nil","bool","number","tag","string","list","map","set",
|
|
26
|
-
"record","tuple","fn"]`。在 `collect_all_tags_from` 第一步 seed,确保
|
|
27
|
-
`:list` / `:map` 等关键字字面量和 `type-of` 返回值落到同一个 tag id。
|
|
28
|
-
|
|
29
|
-
### `type-of` 运行时判定
|
|
30
|
-
|
|
31
|
-
```
|
|
32
|
-
if v == trunc(v) // 整数
|
|
33
|
-
&& v >= (HEAP_START + 8) // 在堆范围内
|
|
34
|
-
&& v < current_heap_ptr {
|
|
35
|
-
raw_base = trunc(v) - 8
|
|
36
|
-
if load_i32(raw_base, 0) == MAGIC { // 魔数校验,排除纯数字误判
|
|
37
|
-
return f64(load_i32(raw_base, 4)) // 返回 tag id
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
return f64(number_tag)
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
之前只用“整数 + 在堆范围”做判定时,`42` 这类数字会被错误识别成指针 →
|
|
44
|
-
读到垃圾 tag;加上 `MAGIC` 校验后 `test-type-of-number` 通过。
|
|
45
|
-
|
|
46
|
-
## 踩坑
|
|
47
|
-
|
|
48
|
-
1. **签名顺序**:`emit_bump_alloc` 的参数顺序从
|
|
49
|
-
`(ctx, byte_size, type_tag, ptr_local)` 调整为
|
|
50
|
-
`(ctx, byte_size, ptr_local, type_tag)`,以匹配 21 处调用点的脚本化改写。
|
|
51
|
-
2. **Magic 必须**:只有“指针范围 + 整数值”不足以区分指针和裸数字,必须加
|
|
52
|
-
唯一性较高的 magic(这里用 `0xCA1C17A9`)。
|
|
53
|
-
3. **f64 ↔ i32**:`tag_id` 是小整数,用 i32 存取更便宜;新增
|
|
54
|
-
`mem_arg_i32` 辅助函数(align=2)。
|
|
55
|
-
4. **If/Else 嵌套返回 f64**:`type-of` 用两层 `BlockType::Result(ValType::F64)`
|
|
56
|
-
实现短路,避免在非指针情况下去读内存。
|
|
57
|
-
|
|
58
|
-
## 测试
|
|
59
|
-
|
|
60
|
-
`calcit/test-wasm.cirru` + `scripts/test-wasm.mjs` 新增 5 个用例:
|
|
61
|
-
`test-type-of-list/map/set/number/tuple`。全部返回 1(`&= (type-of x) :list`
|
|
62
|
-
之类比较)。已执行 `cargo fmt && cargo clippy --release -- -D warnings &&
|
|
63
|
-
cargo test --release && yarn check-all`,全部通过。
|
|
64
|
-
|
|
65
|
-
## 后续
|
|
66
|
-
|
|
67
|
-
解锁后可以把 `list?` / `map?` / `set?` / `number?` / `tuple?` / `record?`
|
|
68
|
-
等 proc 映射成 `(&= (type-of x) :xxx)` 或直接基于 tag 比较。下一轮挑战:
|
|
69
|
-
字符串支持 (24 个 skip)、nested defn/闭包 (19 个 skip)、`foldl` /
|
|
70
|
-
`foldl-shortcut` (13 个 skip)。
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
# WASM codegen: test derived type predicates on top of `type-of`
|
|
2
|
-
|
|
3
|
-
## 背景
|
|
4
|
-
|
|
5
|
-
刚在上一条 commit 里把 `type-of` 跑通了,语料里 `calcit.core` 的几个核心
|
|
6
|
-
predicates (`list?` / `map?` / `number?` / `set?` / `tuple?` / ...) 都是
|
|
7
|
-
`(defn pred? (x) (&= (type-of x) :tag))` 这种薄包装。既然 `type-of`、`&=`、
|
|
8
|
-
keyword 字面量都已经支持,这些 predicate 本来就会被 WASM 编译器吐出来,
|
|
9
|
-
只是一直缺少验证。
|
|
10
|
-
|
|
11
|
-
## 改动
|
|
12
|
-
|
|
13
|
-
`calcit/test-wasm.cirru` + `scripts/test-wasm.mjs` 增加 4 个样例:
|
|
14
|
-
|
|
15
|
-
- `test-list?-true` : `(list? ([] 1 2))` → 1
|
|
16
|
-
- `test-list?-false` : `(list? 42)` → 0 (验证魔数检查能挡住整数伪装)
|
|
17
|
-
- `test-number?-true` : `(number? 42)` → 1
|
|
18
|
-
- `test-map?-true` : `(map? (&{} :a 1))` → 1
|
|
19
|
-
|
|
20
|
-
`yarn check-all` 全部通过,81 个 WASM 检查全绿。
|
|
21
|
-
|
|
22
|
-
## 当前 WASM skip 分类(跑 `cr wasm` 的 stderr)
|
|
23
|
-
|
|
24
|
-
总计 123 条 skipping,主要集中在:
|
|
25
|
-
|
|
26
|
-
- 24 String values not yet supported
|
|
27
|
-
- 19 nested defn not supported
|
|
28
|
-
- 13 foldl / foldl-shortcut / foldr-shortcut
|
|
29
|
-
- 7 `&call-spread`
|
|
30
|
-
- 4 `Tuple operation %:: not yet supported`
|
|
31
|
-
- 3 `&set:destruct`
|
|
32
|
-
- 少量其它(`sort`, `range`, `println`, `deref`, `turn-string` 等)
|
|
33
|
-
|
|
34
|
-
下一轮切入点优先级:字符串 → nested defn/闭包 → 高阶函数 (`call_indirect`)。
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
# 202604172316 — WASM `do` body 与 println host import 修复
|
|
2
|
-
|
|
3
|
-
## 修复内容
|
|
4
|
-
|
|
5
|
-
### 1. `do` 在 defn body 中的 WASM 编译问题
|
|
6
|
-
|
|
7
|
-
**现象**:`defn test-println () do (println 42) 1` 编译后生成 `f64.const 0`(函数体为空)。
|
|
8
|
-
|
|
9
|
-
**根因**:Cirru 语法中 `defn f () do expr1 expr2` 解析为 `(defn f () do expr1 expr2)`,body 数组为 `[do, expr1, expr2]` 三个独立元素(不是 `[(do expr1 expr2)]`)。`do` 作为裸 Import 节点出现在 `emit_expr` 时,触发 "unsupported WASM expression" 错误,导致函数被跳过并 fallback 为 `f64.const 0`。
|
|
10
|
-
|
|
11
|
-
**修复**:在 `emit_expr` 中为 `Calcit::Import { def: "do" }` 添加特例,将其视为 no-op(emit 0.0 后由 `emit_body` 的 Drop 消耗掉)。
|
|
12
|
-
|
|
13
|
-
```rust
|
|
14
|
-
// `do` as bare body expression is a no-op sequencer
|
|
15
|
-
Calcit::Import(import) if import.def.as_ref() == "do" => {
|
|
16
|
-
ctx.emit(f64_const(0.0));
|
|
17
|
-
}
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
### 2. io.log_value host import(WASM println)
|
|
21
|
-
|
|
22
|
-
- WASM codegen 对 `println`/`eprintln`/`echo` 调用 host import `io.log_value`。
|
|
23
|
-
- `test-wasm.mjs` 提供 `io.log_value` 实现:读取堆内存判断类型,字符串解码 UTF-8,数字直接输出。
|
|
24
|
-
- 添加 `test-println` 测试用例验证功能。
|
|
25
|
-
|
|
26
|
-
### 3. TypeScript 运行时 BufList 修复
|
|
27
|
-
|
|
28
|
-
`_$n_buf_list_$o_concat` 中 `CalcitSliceList` 的 `items` 是方法而非属性,需调用 `xs.items()` 并手动迭代 Generator(TS 配置不支持 `for...of` Generator)。
|
|
29
|
-
|
|
30
|
-
## 受影响文件
|
|
31
|
-
|
|
32
|
-
- `src/codegen/emit_wasm.rs`:`emit_expr` 新增 `do` no-op 特例;`emit_call_expr` Import 分支也保留 `do` 处理(用于 `(do ...)` 调用形式)
|
|
33
|
-
- `ts-src/calcit.procs.mts`:修正 `_$n_buf_list_$o_concat` 迭代逻辑
|
|
34
|
-
- `calcit/test-wasm.cirru`:新增 `test-println`
|
|
35
|
-
- `scripts/test-wasm.mjs`:新增 `io.log_value` 实现与 `test-println` 断言
|
|
36
|
-
|
|
37
|
-
## 关键经验
|
|
38
|
-
|
|
39
|
-
- `do` 在 Calcit defn body 中是语法糖/占位符,预处理后展开为多个独立 body 表达式,不是 `(do ...)` 调用形式。WASM codegen 需将其视为 no-op。
|
|
40
|
-
- WASM 编译错误时 fallback 为 `f64.const 0`(静默),调试时需检查 stderr 中的 `[wasm] skipping` 日志。
|
|
41
|
-
- TS 的 Generator 不能直接 `for...of`,需手动调用 `.next()`。
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
## Summary
|
|
2
|
-
|
|
3
|
-
- Split the WASM code generator so `src/codegen/emit_wasm.rs` keeps orchestration while runtime helpers, method dispatch, and record/tuple emitters live in dedicated submodules.
|
|
4
|
-
- Bumped the Calcit patch version from `0.12.20` to `0.12.21` for the next release.
|
|
5
|
-
|
|
6
|
-
## Module Layout
|
|
7
|
-
|
|
8
|
-
- `src/codegen/emit_wasm/runtime.rs` now owns host import definitions, module assembly, and internal runtime helper builders.
|
|
9
|
-
- `src/codegen/emit_wasm/methods.rs` now owns dynamic method dispatch and rest-arg call argument packing.
|
|
10
|
-
- `src/codegen/emit_wasm/records.rs` now owns record and tuple emission helpers.
|
|
11
|
-
|
|
12
|
-
## Notes
|
|
13
|
-
|
|
14
|
-
- The split is intended to be behavior-preserving; no WASM semantics were changed as part of this refactor.
|
|
15
|
-
- Version strings were updated in `Cargo.toml`, `package.json`, and `lib/package.json`, while generated JS version text will be refreshed by the validation build.
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
- WASM export names now stay unique by qualifying only colliding defs with `ns/def`.
|
|
2
|
-
- `list-match` macro now uses `&list:empty?` after the existing list guard, avoiding the unsupported generic `empty?` invoke path in WASM.
|
|
3
|
-
- Added minimal `Calcit::Method` handling in WASM for dynamic `.empty?`, `.count`, `.nth`, and `.get` calls.
|
|
4
|
-
- `&tuple:nth` in WASM now accepts dynamic indices instead of literal-only indices.
|
|
5
|
-
- Verified `yarn try-all` still passes in calcit after the WASM changes.
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
# 2026-04-18 20:41 CR WASM Split and Runtime Stability
|
|
2
|
-
|
|
3
|
-
## 关键修改
|
|
4
|
-
|
|
5
|
-
- 将 `cr wasm` 拆分为独立二进制 `cr-wasm`,避免主 `cr` 命令体积和职责继续膨胀。
|
|
6
|
-
- `calcit` 的 WASM 相关验证脚本和 CI 调整为优先走 `cr-wasm`。
|
|
7
|
-
- 修复 `emit_wasm` 中 map/set/tuple 相关回归点,恢复 `yarn check-all` 的可通过性。
|
|
8
|
-
- 修复 `recollect` 在 Rust 运行时下的 `patch-map` 路径,避免本地变量解析异常导致测试阻断。
|
|
9
|
-
- 将 `recollect` 的 wasm 测试分为核心 smoke(阻断)与扩展 probes(非阻断),保证 wasm 独立验证但不影响 rust/js 主链路。
|
|
10
|
-
- 版本提升到 patch:`0.12.22`。
|
|
11
|
-
|
|
12
|
-
## 经验与注意事项
|
|
13
|
-
|
|
14
|
-
- 对运行时快照文件(`calcit.cirru` / legacy `compact.cirru`)的修改必须通过 `cr edit`/`cr tree` 完成,避免文本直接编辑破坏结构。
|
|
15
|
-
- 在多项目联动(calcit + recollect)场景下,发布前验证至少应覆盖:
|
|
16
|
-
- calcit: `yarn check-all`
|
|
17
|
-
- recollect: `yarn test:cr`、`yarn test:js`、`yarn test:wasm`
|
|
18
|
-
- macOS 上遇到 `iconv` 链接问题时,需带 `SDKROOT` 执行构建命令进行最终回归确认。
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
# 2026-04-18 20:45 v0.12.23 CI WASM Fix
|
|
2
|
-
|
|
3
|
-
## 变更摘要
|
|
4
|
-
|
|
5
|
-
- 解决 GitHub Actions `try wasm` 步骤失败(exit 127)的问题。
|
|
6
|
-
- 原因:workflow 直接调用 `./target/debug/cr-wasm`,但未提前构建二进制。
|
|
7
|
-
- 修复:在 `.github/workflows/test.yaml` 的 wasm 步骤中先执行 `cargo build --bin cr-wasm`,再运行 `scripts/test-wasm.sh`。
|
|
8
|
-
- 版本升级:`0.12.22` -> `0.12.23`(`Cargo.toml` 与 `package.json` 同步)。
|
|
9
|
-
|
|
10
|
-
## 验证
|
|
11
|
-
|
|
12
|
-
- 本地 `cargo check` 通过。
|
|
13
|
-
- 后续以推送后的 Actions `Test` 工作流成功作为发布门禁,再创建 GitHub Release。
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
# WASM String Ops 扩展 v2
|
|
2
|
-
|
|
3
|
-
## 本次修改概要
|
|
4
|
-
|
|
5
|
-
继上一轮字符串实现(count/nth/first/rest/slice/concat/compare)之后,补充剩余实用 API。
|
|
6
|
-
|
|
7
|
-
## 新增 API
|
|
8
|
-
|
|
9
|
-
| Proc | 实现位置 | 说明 |
|
|
10
|
-
|------|----------|------|
|
|
11
|
-
| `&str:contains?` | `emit_str_contains` | 字节索引范围检查:`byte_len > idx` |
|
|
12
|
-
| `&str:find-index` | `__rt_str_find_index` (runtime.rs) | 朴素 O(n·m) 字节子串搜索,返回偏移或 -1 |
|
|
13
|
-
| `&str:includes?` | `emit_str_includes` | 调用 `find-index`,判断 `>= 0` |
|
|
14
|
-
| `&str:pad-left` | `__rt_str_pad_left` (emit_wasm.rs) | 循环填充 pattern 字节于左侧 |
|
|
15
|
-
| `&str:pad-right` | `__rt_str_pad_right` (emit_wasm.rs) | 循环填充 pattern 字节于右侧 |
|
|
16
|
-
|
|
17
|
-
## 关键实现细节
|
|
18
|
-
|
|
19
|
-
### `__rt_str_find_index`
|
|
20
|
-
|
|
21
|
-
- 放在 `runtime.rs`,不需要 `str_tag_id`(只读不分配)
|
|
22
|
-
- 使用双层嵌套 Loop/Block 结构,WASM 控制流通过 `Br(N)` 跳出多层
|
|
23
|
-
- 空 needle 返回 0.0;needle 长于 haystack 返回 -1.0
|
|
24
|
-
- `Br(5)` 从内层 If 跳出到 `$outer` Block 返回找到的索引
|
|
25
|
-
|
|
26
|
-
### `__rt_str_pad_left` / `__rt_str_pad_right`
|
|
27
|
-
|
|
28
|
-
- 放在 `emit_wasm.rs`,接受 `str_tag_id: i32` 参数(需分配 tagged 堆内存)
|
|
29
|
-
- 早退条件:`str_len >= target_size` 直接返回原指针
|
|
30
|
-
- 使用 j 变量追踪 pattern 偏移,超出 pat_len 时归零,避免 modulo 除法
|
|
31
|
-
- 注册在 `build_runtime_fns` 之后(与 `__str_new` 同一阶段)
|
|
32
|
-
|
|
33
|
-
### `emit_str_contains` 修复
|
|
34
|
-
|
|
35
|
-
初始版本使用 `I32LtU`(`byte_len < idx`)导致逻辑反转,修正为 `I32GtU`(`byte_len > idx`)。
|
|
36
|
-
|
|
37
|
-
## 测试
|
|
38
|
-
|
|
39
|
-
新增 8 个测试函数(`test-wasm.main`):
|
|
40
|
-
- `test-str-contains-true` → 1
|
|
41
|
-
- `test-str-contains-false` → 0
|
|
42
|
-
- `test-str-find-index-found` → 1("ell" 在 "hello" 偏移 1)
|
|
43
|
-
- `test-str-find-index-not-found` → -1
|
|
44
|
-
- `test-str-includes-true` → 1
|
|
45
|
-
- `test-str-includes-false` → 0
|
|
46
|
-
- `test-str-pad-left` → 5(`pad-left "hi" 5 "-"` → "---hi",count=5)
|
|
47
|
-
- `test-str-pad-right` → 5(`pad-right "hi" 5 "-"` → "hi---",count=5)
|
|
48
|
-
|
|
49
|
-
`yarn try-wasm` 全部通过(release build)。
|
|
50
|
-
|
|
51
|
-
## 文件变更
|
|
52
|
-
|
|
53
|
-
- `src/codegen/emit_wasm/runtime.rs`:新增 `build_rt_str_find_index`,在 `build_runtime_fns` 中注册
|
|
54
|
-
- `src/codegen/emit_wasm.rs`:新增 `build_str_pad_left_fn`、`build_str_pad_right_fn`、`emit_str_contains`、`emit_str_find_index`、`emit_str_includes`、`emit_str_pad_left`、`emit_str_pad_right`;修复 contains 比较方向
|
|
55
|
-
- `calcit/test-wasm.cirru`:通过 `cr edit def` 添加 8 个测试定义
|
|
56
|
-
- `scripts/test-wasm.mjs`:新增 8 个 `check()` 调用
|
|
57
|
-
- `docs/wasm-codegen.md`:更新支持表格,移除已实现项
|