@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,96 +0,0 @@
1
- # Schema vs Definition Kind/Arity Validation
2
-
3
- ## Summary
4
-
5
- Added structural validation that compares a definition's code form against its schema declaration. This catch mismatches between declared schema metadata (`:kind`, arg count, rest param) and the actual `defn`/`defmacro` code at analysis time.
6
-
7
- ## Key Changes
8
-
9
- ### `src/calcit/type_annotation.rs`
10
-
11
- 1. **Added `SchemaKind` enum** (`pub enum SchemaKind { Fn, Macro }`) — distinguishes `:kind :fn` from `:kind :macro` schemas.
12
-
13
- 2. **Extended `CalcitFnTypeAnnotation`** with two new fields:
14
- - `pub fn_kind: SchemaKind` — schema's declared kind (fn/macro).
15
- - `pub rest_type: Option<Arc<CalcitTypeAnnotation>>` — schema's `:rest` type, if present.
16
-
17
- 3. **`parse_fn_schema_from_edn`** — now reads `:kind :macro` → `SchemaKind::Macro` and `:rest` → `rest_type` from the EDN map.
18
-
19
- 4. **`to_schema_edn`** — now serializes `fn_kind` (`fn`/`macro`) and `rest_type` (`:rest` key in the output map). Previously always emitted `:kind :fn` and omitted `:rest`.
20
-
21
- 5. **All `CalcitFnTypeAnnotation` construction sites** updated to add `fn_kind: SchemaKind::Fn, rest_type: None` defaults (7 total).
22
-
23
- 6. **`substitute_type_vars`** also propagates `fn_kind` and substitutes `rest_type`.
24
-
25
- ### `src/calcit.rs`
26
-
27
- - `SchemaKind` added to the `pub use type_annotation::{ ... }` re-export.
28
-
29
- ### `src/bin/cr.rs`
30
-
31
- 1. **`SchemaKind` imported** in the `use calcit::calcit::{...}` block.
32
-
33
- 2. **`TypeCoverageRow` struct** gained `schema_issues: Vec<String>` field — carries kind/arity mismatch warnings per definition.
34
-
35
- 3. **`validate_def_vs_schema(ns, def_name, code, schema) -> Vec<String>`** — new function:
36
- - `&runtime-inplementation` leaf → skip (builtin proc/syntax).
37
- - Schema not `CalcitTypeAnnotation::Fn` → skip.
38
- - Code head not `defn`/`defmacro` → skip.
39
- - Schema `:kind :fn` + code `defmacro` → error.
40
- - Schema `:kind :macro` + code `defn` → error.
41
- - Required arg count mismatch → error.
42
- - `has_rest` mismatch (schema `:rest` vs code `&`) → error.
43
-
44
- 4. **`analyze_param_arity(args: Option<&Cirru>) -> (usize, bool)`** — helper that counts required params and detects the `&` rest marker in a `defn`/`defmacro` args list.
45
-
46
- 5. **`analyze_code_entry`** calls `validate_def_vs_schema` to populate `schema_issues` on each `TypeCoverageRow`.
47
-
48
- 6. **`run_check_types` output loop** prints a `schema-issues:` section for rows with non-empty issues.
49
-
50
- 7. **10 new unit tests** covering:
51
- - `&runtime-inplementation` skip
52
- - Correct defn/macro → no issues
53
- - Kind mismatch (`:fn` vs `defmacro`, `:macro` vs `defn`)
54
- - Arity mismatch
55
- - Rest param mismatch
56
- - `analyze_param_arity` basics
57
- 8. **`CR_DEBUG_SCHEMA` debug flag** — when `CR_DEBUG_SCHEMA=1`, prints per-entry schema kind debug info to stderr during `analyze check-types`.
58
-
59
- ### `src/runner/preprocess.rs`
60
-
61
- 1. **Runtime/preprocess enforcement added** — schema-vs-definition structural checks now run while preprocessing `defn`/`defmacro`, not only in `analyze check-types`.
62
- 2. **`validate_def_schema_during_preprocess(...)`** — mirrors the `check-types` validation for `:kind`, required arity, and `:rest`, and raises a hard `[Type Error]` during normal execution paths such as `yarn try-rs`.
63
- 3. **Schema hints preserved** — preprocess still injects `hint-fn`, but now only after the definition passes structural schema validation.
64
- 4. **2 new preprocess tests** covering arity mismatch and `:kind` mismatch at preprocess time.
65
-
66
- ### `calcit/test-hygienic.cirru`
67
-
68
- - Updated existing test fixture schemas so they match actual code:
69
- - `add-11` / `add-11-safe`: `:kind :macro`
70
- - `add-2`: arg schema corrected from 2 params to 1
71
-
72
- ### `src/snapshot.rs`
73
-
74
- - **`test_macro_schema_round_trip`** — verifies `schema_cirru_to_edn` + `parse_fn_schema_from_edn` + `normalize_schema_edn` preserve `SchemaKind::Macro` end-to-end.
75
- - **`test_macro_schema_full_file_round_trip`** — verifies full `CodeEntry` serialize (`From<&CodeEntry> for Edn`) → `cirru_edn::format` → `cirru_edn::parse` → `TryFrom<Edn> for CodeEntry` round-trip preserves `fn_kind: Macro`.
76
-
77
- ## Validation Rule Summary
78
-
79
- | Schema `:kind` | Code form | Result |
80
- | -------------- | ------------------------- | --------------- |
81
- | `:fn` | `defn` | ✓ ok |
82
- | `:fn` | `defmacro` | ✗ kind mismatch |
83
- | `:macro` | `defmacro` | ✓ ok |
84
- | `:macro` | `defn` | ✗ kind mismatch |
85
- | any | `&runtime-inplementation` | ✓ skip |
86
-
87
- Arg count and rest param are checked independently of kind.
88
-
89
- ## Notes
90
-
91
- - **`calcit.core` schemas require binary rebuild**: Schema edits to `src/cirru/calcit-core.cirru` do not take effect at runtime until the binary is rebuilt, because the core namespace is always loaded from the embedded `include_bytes!` snapshot produced by `build.rs`. Schema validation is most useful for user-defined namespaces.
92
- - **Normal execution now checks schemas too**: before this follow-up, schema-vs-def mismatches were only reported by `analyze check-types`; now they fail fast during normal preprocess/runtime startup as well.
93
-
94
- ## Test Results
95
-
96
- All 125 tests pass (99 library + 26 binary), including 2 new snapshot round-trip tests and 2 new preprocess validation tests.
@@ -1,35 +0,0 @@
1
- # Schema Generics Quote Normalization
2
-
3
- ## Summary
4
-
5
- Tightened schema loading so legacy generic symbols stored with embedded leading quotes now fail immediately, then normalized existing `calcit-core.cirru` schema generics from `''T`-style output to the correct `'T` source syntax.
6
-
7
- ## Key Changes
8
-
9
- - `src/calcit/type_annotation.rs`
10
- - Stopped serializing schema generics as `Edn::Symbol("'T")`.
11
- - Now writes plain EDN symbols like `Edn::Symbol("T")`, which format back to source as `'T`.
12
- - Keeps compatibility when parsing previously saved legacy symbols, but normalizes them to plain names.
13
-
14
- - `src/snapshot.rs`
15
- - Added load-time rejection for legacy schema generic symbols carrying embedded leading quotes.
16
- - Normalized schema EDN → Cirru conversion to go through format+parse so quoted symbols render correctly.
17
- - Added regression tests for:
18
- - single-quote round-trip,
19
- - rejecting legacy quoted EDN symbols on load,
20
- - rejecting `''T` on schema writes.
21
-
22
- - `build.rs`
23
- - Added the same legacy-generic rejection during build-time loading of `src/cirru/calcit-core.cirru`, so bad schema data fails `yarn check-all` immediately.
24
-
25
- - `src/cirru/calcit-core.cirru`
26
- - Replaced all legacy schema generic forms like `''T`, `''A`, `''K` with correct single-quoted forms.
27
-
28
- - `docs/CalcitAgent.md`
29
- - Updated schema/type-annotation guidance to reflect schema-first top-level typing and correct generic syntax examples.
30
-
31
- ## Validation
32
-
33
- - `cargo fmt`
34
- - `cargo test schema_ -- --nocapture`
35
- - `yarn check-all`
@@ -1,34 +0,0 @@
1
- # 本次修改记录
2
-
3
- ## 主题
4
-
5
- - 完善 schema 类型系统:区分泛型变量与命名类型引用,支持 `'Result` 一类类型引用在 schema 中稳定往返。
6
- - 继续推进 schema-first 迁移:清理 `calcit-core` 与若干测试文件中的 `assert-type`,将约束收敛到 `:schema` 与局部 `hint-fn`。
7
- - 强化诊断:改进运行时参数个数错误与构建期 schema 解析报错,方便定位问题。
8
-
9
- ## 主要改动
10
-
11
- ### 1) Rust 侧类型系统收紧
12
-
13
- - 在 `src/calcit/type_annotation.rs` 中新增命名类型引用分支,并让解析、匹配、显示、序列化都感知泛型作用域。
14
- - `src/builtins/syntax.rs` 与 `src/builtins/records.rs` 改为按泛型上下文解析 schema,避免把命名类型误判成 type var。
15
- - `src/codegen/gen_ir.rs`、`src/snapshot.rs` 同步适配新 schema 结构与 round-trip 测试。
16
-
17
- ### 2) schema / hint-fn 迁移
18
-
19
- - `src/cirru/calcit-core.cirru` 中移除剩余 `assert-type` 调用点,改为顶层 `:schema` 或局部 `hint-fn`。
20
- - `calcit/test.cirru`、`calcit/debug/check-args.cirru`、`calcit/test-fn.cirru`、`calcit/test-types.cirru` 改用更精细的函数签名与局部约束。
21
- - 修正函数类型直写 schema 的参数形式,统一使用 `([] ...)` 表达参数列表。
22
-
23
- ### 3) 错误信息增强
24
-
25
- - `src/runner.rs` 在参数个数不匹配时生成结构化报错,而不是直接触发内部 panic。
26
- - `build.rs` 对 schema EDN 解析错误增加截断与整理,避免输出过长、难以定位。
27
-
28
- ## 验证
29
-
30
- - `cargo fmt` 通过。
31
- - `cargo clippy -- -D warnings` 通过。
32
- - `yarn compile` 通过。
33
- - `cargo test` 通过。
34
- - `yarn check-all` 通过。
@@ -1,45 +0,0 @@
1
- # 2026-03-08 schema wrapper migration
2
-
3
- ## Summary
4
-
5
- - 统一函数 schema 的 snapshot 输出格式,顶层改为 wrapped `:: :fn` / `:: :macro` 形式。
6
- - 修复 schema round-trip 中的类型信息丢失,确保嵌套函数类型与 `:rest` 在格式化后保持稳定。
7
- - 将 macro schema 的顶层格式统一迁移到 `:: :macro`,并让 formatter 在处理 `defmacro` 条目时自动纠正旧的 `fn` 标记。
8
- - 移除 legacy quote-wrapped schema normalization 与 legacy positional `fn` type annotation fallback,收紧到当前 schema-map 形式。
9
- - 更新 `deftrait` 文档与相关说明,避免继续传播旧写法。
10
-
11
- ## Main changes
12
-
13
- ### 1) 顶层 schema 输出统一
14
-
15
- - 在 `src/calcit/type_annotation.rs` 中补充顶层 wrapped schema 的解析与序列化逻辑。
16
- - 在 `src/snapshot.rs` 中让 `CodeEntry.schema` 写回 snapshot 时统一输出为 `:schema $ :: :fn ...` 或 `:schema $ :: :macro ...`。
17
- - 对 plain fn schema 去掉 wrapped payload 内冗余的 `:kind :fn`,但保留宏函数所需的 `:kind :macro`。
18
-
19
- ### 2) macro schema 迁移与规范化
20
-
21
- - 扩展 parser / normalize 逻辑,使其同时接受 wrapped `fn` 与 wrapped `macro`。
22
- - 对 macro schema,序列化时省略冗余的 `:kind :macro` 与 `:return`,仅保留 `:args` 与可选 `:rest`。
23
- - 在 snapshot 读写路径中,根据代码头是否为 `defmacro` 自动纠正 schema kind。
24
-
25
- ### 3) legacy fn syntax 收紧
26
-
27
- - 移除 legacy quote-wrapped schema normalization。
28
- - 拒绝 legacy quoted generic symbols。
29
- - 移除 legacy positional `fn` type annotation parsing fallback。
30
- - 迁移剩余 core trait 与测试注解到 schema-map `:: :fn {}` 形式。
31
-
32
- ### 4) round-trip 与批量格式化
33
-
34
- - 修复 EDN 到 Calcit 的转换路径,补上 `Edn::Map` 的处理,避免嵌套 `fn` schema 的 hashmap payload 被吞掉后退化成 `:dynamic`。
35
- - 调整 schema 校验与 normalize 逻辑,使 wrapped 顶层 fn schema 与旧格式都能稳定读写。
36
- - 重新格式化了 `src/cirru/calcit-core.cirru`、`calcit/util.cirru`、`calcit/test-hygienic.cirru` 等兼容 snapshot 文件。
37
-
38
- ## Validation
39
-
40
- - `cargo fmt`
41
- - `cargo clippy -- -D warnings`
42
- - `yarn compile`
43
- - `cargo test -q`
44
- - `cargo build -q`
45
- - `yarn check-all`
@@ -1,27 +0,0 @@
1
- # 2026-03-08 late schema cleanup and warning compatibility
2
-
3
- ## Summary
4
-
5
- - made snapshot schema loading strict for non-nil schemas, so malformed schema data no longer silently degrades to dynamic
6
- - normalized loaded schema maps so legacy string keys and string `:kind` values are converted into canonical tag-based schema maps
7
- - restored generic type variables in `src/cirru/calcit-core.cirru` where a previous migration had incorrectly replaced them with `:symbol`
8
- - cleaned the remaining mistaken `:symbol` placeholders in core collection schemas, keeping only the intentional `symbol?` runtime type check
9
- - fixed `calcit/test-generics.cirru` after a schema-formatting edit moved `assert-type id ...` into the `let` binding section
10
- - kept `ns/def` warning location reporting for embedded core snapshot loading
11
- - stopped legacy fn-schema warnings from firing on malformed nested `:: :fn` schema payloads parsed from `calcit-core.cirru`
12
- - used a conservative fallback to `DynFn` for malformed nested payloads, avoiding false-positive callback type warnings without re-editing Cirru syntax
13
-
14
- ## Notes
15
-
16
- - `yarn check-all` passed after the generic-schema restoration and remaining `:symbol` cleanup passes
17
- - the `test-generics` fix resolves the runtime error `expected binding of a pair`
18
- - nested function schema payloads coming from Cirru snapshot EDN may currently collapse into malformed map payloads like `(:: :fn ({} (nil ...)))` or `(:: :fn ({}))`
19
- - those malformed payloads are lossy, so partially reconstructing arg/return types can introduce new static-analysis warnings
20
- - decoding the embedded binary core snapshot with per-entry owners is necessary to preserve precise warning locations such as `calcit.core/foo`
21
-
22
- ## Validation
23
-
24
- - `cargo test -q malformed_nested_fn_schema`
25
- - `cargo build -q`
26
- - `target/debug/cr calcit/test.cirru -1`
27
- - `yarn check-all`
@@ -1,17 +0,0 @@
1
- # schema type-fail tests and error codes
2
-
3
- - 新增 `calcit/type-fail/` 下 schema 相关失败 fixture 的自动化测试,覆盖:
4
- - `:args` required arity mismatch
5
- - `:rest` presence mismatch
6
- - `:kind` mismatch
7
- - 基于 schema 的调用参数类型不匹配
8
- - 在 `src/bin/cr.rs` 中补充 fixture 加载 helper,并通过 `run_check_only()` / preprocess warning 断言行为。
9
- - 为类型/预处理相关告警补充 code:
10
- - `W_FN_ARG_TYPE_MISMATCH`
11
- - `W_PROC_ARG_TYPE_MISMATCH`
12
- - `W_CORE_FN_ARG_TYPE_MISMATCH`
13
- - `W_FN_RETURN_TYPE_MISMATCH`
14
- - 为 schema 定义不匹配错误补充 code:
15
- - `E_SCHEMA_DEF_MISMATCH`
16
- - 为 `CalcitErr` 增加 `code` 字段和 `headline()`,让 CLI 输出可携带错误码。
17
- - 更新 `calcit/type-fail/README.md`,记录自动化测试与当前相关 code。
@@ -1,42 +0,0 @@
1
- # cr edit schema: support primitive type tag leaves
2
-
3
- ## 背景
4
-
5
- `cr edit schema` 原来只接受 `:: :fn $ {}` 这样的函数 schema 或 `{}` map 形式。
6
- 有些定义的类型本身就是简单原始类型(如 `:string`、`:number`),不是函数,需要直接用 tag 表达。
7
-
8
- ## 新语法
9
-
10
- ```bash
11
- cr edit schema 'respo.comp.space/style-space' --code 'quote :string'
12
- cr edit schema 'some.ns/my-val' --code 'quote :number'
13
- cr edit schema 'some.ns/my-flag' --code 'quote :bool'
14
- ```
15
-
16
- 接受的 primitive 类型 tag:`bool`, `number`, `string`, `symbol`, `tag`, `list`, `map`, `set`, `fn`, `tuple`, `ref`, `buffer`, `dynamic`, `unit`
17
-
18
- ## 改动文件
19
-
20
- ### `src/calcit/type_annotation.rs`
21
-
22
- - `builtin_tag_name` 改为 `pub(crate)`,供 snapshot 序列化侧调用。
23
-
24
- ### `src/snapshot.rs`
25
-
26
- - 新增常量 `PRIMITIVE_SCHEMA_TAGS`:列出允许作为 leaf schema 的原始类型。
27
- - `validate_schema_for_write`:对 `Cirru::Leaf` 先检查是否在允许列表,允许则直接 Ok;否则给出提示信息。
28
- - `parse_loaded_schema_annotation`:新增对 `Edn::Tag` 的处理,返回对应 `CalcitTypeAnnotation`。
29
- - 两处 `CodeEntry::From` impl:`_ => Edn::Nil` 改为调用 `builtin_tag_name().map(Edn::tag)` 把原始类型 tag 正确序列化到快照。
30
- - 测试 `test_validate_schema_for_write`:更新为测试原始类型 leaf 通过、未知 leaf 拒绝。
31
-
32
- ### `src/bin/cli_handlers/edit.rs`
33
-
34
- - `handle_schema`:`validate_schema_for_write` 通过后,若 `schema_payload` 是 `Cirru::Leaf`,用 `CalcitTypeAnnotation::from_tag_name` 直接设置 schema 并返回,不走函数 schema 解析路径。
35
-
36
- ## 完整数据流(以 `:string` 为例)
37
-
38
- 1. CLI 收到 quoted schema 输入 `--code 'quote :string'`,取出 payload 后得到 `Cirru::Leaf(":string")`
39
- 2. `validate_schema_for_write` → `"string"` 在 `PRIMITIVE_SCHEMA_TAGS` → Ok
40
- 3. `CalcitTypeAnnotation::from_tag_name("string")` → `CalcitTypeAnnotation::String`
41
- 4. 写入快照 → `CodeEntry::From` 序列化为 `Edn::tag("string")`
42
- 5. 读回快照 → `parse_loaded_schema_annotation(Edn::Tag("string"))` → `CalcitTypeAnnotation::String`
@@ -1,66 +0,0 @@
1
- # 2026-0310-1754 — snapshot namespace entry migrate to NsEntry
2
-
3
- ## 背景
4
-
5
- snapshot 里的 `:ns` 之前复用了 `CodeEntry` 结构,导致 namespace 也带着 `:schema` 和 `:examples` 字段,语义上并不合适,而且保存时经常只是写成 `(:schema nil)`。
6
-
7
- 这次改动把 namespace 入口单独收敛到 `NsEntry`,同时保持读取旧 `CodeEntry` 写法的兼容性。
8
-
9
- ## 核心改动
10
-
11
- ### `src/snapshot.rs`
12
-
13
- - 新增 `NsEntry { doc, code }`
14
- - `FileInSnapShot.ns` 从 `CodeEntry` 改为 `NsEntry`
15
- - `RawFileInSnapShot.ns` 同步改为 `NsEntry`
16
- - 新增 `TryFrom<Edn> for NsEntry` 与 `From<NsEntry> for Edn`
17
- - 读取 snapshot 时,`ns` 只解析 `doc` 和 `code`,兼容旧 `CodeEntry` 形状并忽略 `schema/examples`
18
- - 移除 `validate_snapshot_schemas_for_write` 对 `ns.schema` 的校验
19
- - `gen_meta_ns`、`create_file_from_snippet` 等内部构造统一改为写 `NsEntry`
20
-
21
- ### `build.rs`
22
-
23
- - 嵌入式 core snapshot 解析结构新增 `NsEntry`
24
- - build 阶段读取 `src/cirru/calcit-core.cirru` 时,`ns` 不再解析为 `CodeEntry`
25
-
26
- ### `src/detailed_snapshot.rs`
27
-
28
- - 新增 `DetailedNsEntry { doc, code }`
29
- - `DetailedFileInSnapshot.ns` 从 `DetailedCodeEntry` 改为 `DetailedNsEntry`
30
- - 详细快照读取仍兼容旧 namespace record,只提取 `doc` 和 `code`
31
-
32
- ### `src/bin/cr_sync.rs`
33
-
34
- - namespace change payload 从 `CodeEntry` 拆成 `SnapshotEntry::Ns(NsEntry)`
35
- - definition change payload 保持 `SnapshotEntry::Def(CodeEntry)`
36
- - detailed snapshot 写回时,namespace 统一序列化为 `NsEntry`
37
-
38
- ### `src/bin/cli_handlers/edit.rs`
39
-
40
- - `edit add-ns` 创建新 namespace 时直接写入 `NsEntry`
41
-
42
- ## 数据文件迁移
43
-
44
- - 批量运行 `cr edit format`,将 compact snapshot 中旧的 `:ns $ %{} :CodeEntry ... (:schema nil) :examples []` 收敛为 `:NsEntry`
45
- - 运行 `cr-sync` 重写 detailed snapshot:
46
- - `demos/calcit.cirru`
47
- - `calcit/editor/calcit.cirru`
48
- - `src/cirru/calcit-core.cirru` 也已更新为 `NsEntry`
49
-
50
- ## 兼容策略
51
-
52
- 1. **读取兼容**:旧 snapshot/detailed snapshot 中 `ns` 仍然可以是 `CodeEntry` record
53
- 2. **内存收敛**:加载后统一存成 `NsEntry`
54
- 3. **保存统一**:以后重新保存或 format 都写回 `NsEntry`
55
-
56
- ## 验证
57
-
58
- - `cargo fmt` ✅
59
- - `cargo clippy -- -D warnings` ✅
60
- - `cargo test` ✅
61
- - `yarn check-all` ✅
62
-
63
- ## 备注
64
-
65
- - `demos/compact.tmp.cirru` 不是合法 snapshot,`cr edit format` 会报 EDN 解析错误,因此未纳入统一格式化
66
- - `demos/deps.cirru` 不是当前 snapshot loader 支持的结构,因此同样未走 `edit format`
@@ -1,24 +0,0 @@
1
- # 2026-03-13 22:16 validate struct type arg arity
2
-
3
- ## 背景
4
-
5
- 发现类型注解里可以写出 `:: Pair :number :string` 这样的形式,即使 `Pair` 是非泛型 `defstruct`。旧逻辑会把后续类型参数直接附着到 `Struct(...)` 注解上,但并不会校验 `generics` 个数,最终在值匹配时只看 struct 名字,导致漏检。
6
-
7
- ## 本次修改
8
-
9
- - 在 `src/calcit/type_annotation.rs` 为 `CalcitTypeAnnotation` / `CalcitFnTypeAnnotation` 增加 `validate_applied_type_args()`。
10
- - 对 `Struct` 注解增加规则:
11
- - 非泛型 struct 不允许携带类型参数;
12
- - 泛型 struct 必须严格匹配声明的类型参数个数。
13
- - 对 `Enum` 注解增加保守规则:当前不接受额外类型参数。
14
- - 在 `src/builtins/records.rs` 中,`defstruct` 字段类型解析后立即做校验。
15
- - 在 `src/calcit/sum_type.rs` 中,`defenum` payload 类型解析后立即做校验。
16
- - 在 `src/calcit/sum_type.rs` 与 `src/calcit/type_annotation.rs` 补充回归测试,覆盖:
17
- - 非泛型 struct 带类型参数时报错;
18
- - 泛型 struct 类型参数个数不匹配时报错;
19
- - enum payload 中引用非法 struct 类型注解时报错。
20
- - 同时修正 `calcit/test-generics.cirru` 中 `Wrapped` 的 payload 类型,把错误的 `:: Pair :number :string` 改为 `Pair`。
21
-
22
- ## 结论
23
-
24
- 现在像 `:: Pair :number :string` 这种写法不会再静默通过;定义期就会被校验出来,避免文档和测试继续误导后续修改。
@@ -1,14 +0,0 @@
1
- # Runtime Boundary Cleanup
2
-
3
- ## Summary
4
-
5
- - removed the dead `CalcitImport.coord` compatibility path and the related runner parameter flow
6
- - renamed remaining `evaled`-era runtime lookup terminology to `runtime-ready` / `runtime cache`
7
- - synced the runtime boundary refactor draft with the current migration state and recent cleanup progress
8
-
9
- ## Knowledge
10
-
11
- - `CalcitImport.def_id` is now the stable import-side runtime lookup anchor; the old `coord -> EntryBook` path no longer needs to be preserved in import metadata
12
- - type-annotation lookup registration should describe runtime-ready value lookup, not the removed evaled-store model
13
- - incremental reload messaging should talk about clearing runtime caches rather than evaled states to match the current architecture
14
- - this migration tail is now mostly about narrowing fallback bridges and improving reload coverage, not about preserving old runtime naming or lookup compatibility
@@ -1,28 +0,0 @@
1
- # Runtime boundary lookup cleanup
2
-
3
- ## Summary
4
-
5
- - Consolidated runtime-vs-compiled lookup helpers inside `program` and removed extra `runner` bridging paths.
6
- - Tightened snapshot fallback and codegen metadata lookup so source-backed defs no longer silently rely on runtime-derived compiled entries.
7
- - Skipped runtime-only placeholder defs in JS/IR codegen and added program-level regression tests for reload invalidation and snapshot behavior.
8
- - Reframed the runtime-boundary draft into a closure plan focused on stabilizing compiled/runtime boundaries, adding watch-reload regression coverage, and avoiding new architectural layers.
9
- - Simplified `runner` and `preprocess` lookup flow by removing thin wrappers, deduplicating repeated symbol fallback order, and collapsing silent program-value reads onto shared helpers.
10
- - Added regression coverage for reload package clearing, source-backed snapshot rebuild after changes, compiled fallback cache behavior, and strict-vs-lenient runtime resolution semantics.
11
-
12
- ## Knowledge points
13
-
14
- - Runtime execution helpers should live in `program` so `runner` only maps runtime state to evaluation flow and user-facing errors.
15
- - Metadata queries such as codegen type hints should prefer compiled/source schema and only fall back to ready runtime values, never by executing compiled payloads.
16
- - Reload invalidation needs direct transitive-dependency tests plus namespace-header coverage; otherwise runtime cache cleanup regresses quietly.
17
- - If compiled execution is used as a fallback read path, tests must assert it does not implicitly backfill runtime cells; otherwise compiled/runtime boundaries drift back together.
18
- - Keep cleanup work biased toward removing duplicate lookup order and unused parameters before introducing any new abstraction; the stable payoff is clearer boundaries with lower entity count.
19
- - `runner`-side error mapping for strict runtime resolution is still a meaningful boundary, but repeated namespace lookup order and required-value program reads can be shared safely.
20
-
21
- ## Validation
22
-
23
- - `cargo fmt`
24
- - release fibo profiling during optimization review
25
- - `cargo test clear_runtime_caches_for_reload -- --nocapture`
26
- - `cargo test snapshot_rebuilds_changed_source_backed_def_after_reload_changes -- --nocapture`
27
- - `cargo test program::tests -- --nocapture`
28
- - `cargo test -q`
@@ -1,48 +0,0 @@
1
- ## Summary
2
-
3
- This commit moves JSON parsing and serialization into Calcit builtins and aligns the surrounding runtime/docs/tooling updates needed to ship it cleanly.
4
-
5
- 1. Added builtin JSON runtime functions
6
-
7
- - Introduced `json-parse`, `json-stringify`, and `json-pretty` in Rust builtin dispatch and JS runtime exports.
8
- - Added fast arity/type checks on exposed runtime entry points.
9
- - Normalized integer-valued numbers to encode as JSON integers in Rust, matching JS output.
10
- - Added native tests and Calcit-level coverage for parse/stringify/pretty behavior and error paths.
11
-
12
- 2. Updated core docs and runtime placeholder naming
13
-
14
- - Added `calcit.core` docs/examples for the JSON runtime functions.
15
- - Renamed the runtime placeholder spelling from `runtime-inplementation` to `runtime-implementation` across core snapshot metadata and Rust handling.
16
- - Preserved an explicit `cr <snapshot-file> edit format` example in `docs/CalcitAgent.md`.
17
-
18
- 3. Snapshot formatting workflow
19
-
20
- - Re-ran `cr edit format` against the touched Cirru snapshot files:
21
- - `src/cirru/calcit-core.cirru`
22
- - `calcit/test.cirru`
23
-
24
- ## Files touched (high level)
25
-
26
- - Rust builtin registration and implementation for JSON runtime support.
27
- - JS runtime proc exports for JSON behavior and validation.
28
- - Calcit core snapshot docs/examples and test snapshot updates.
29
- - CLI/codegen placeholder spelling cleanup.
30
- - Agent guide example for `edit format`.
31
-
32
- ## Validation notes
33
-
34
- - `cargo test json_`
35
- - `cargo test validate_runtime_impl_is_skipped -- --nocapture`
36
- - `cargo test runtime_placeholder -- --nocapture`
37
- - `cargo run --bin cr -- calcit/test.cirru -1`
38
- - `yarn check-all`
39
-
40
- ## Release size check
41
-
42
- Measured `target/release/cr` against `HEAD` using a detached worktree build:
43
-
44
- - Current: `5192960` bytes (`5.0M`)
45
- - Base: `5174400` bytes (`4.9M`)
46
- - Delta: `+18560` bytes (about `+18.1 KiB`)
47
-
48
- Conclusion: the builtin JSON work increases the release binary size slightly, but the delta is small relative to the ~5 MB target.
@@ -1,58 +0,0 @@
1
- # Docs frontmatter 与模块检索整理
2
-
3
- ## 变更概述
4
-
5
- - 为 `cr docs search/read/read-lines` 增加 `scope/module` 维度,支持核心文档、模块文档和跨域检索。
6
- - 为 core docs 建立统一的 frontmatter 规范,并补充 `title/scope/kind/category/aliases/entry_for` 元数据。
7
- - 将 `docs` 检索逻辑从纯文件名匹配升级为结合 frontmatter、路径、标题与条目词的综合解析与排序。
8
- - 给文档系统补充规范页与验证页,方便后续扩展 `cr docs` 时保持行为稳定。
9
- - 调整 Cirru 校验错误提示,让“其实是字符串”的场景给出更直接的修复建议。
10
-
11
- ## 关键实现
12
-
13
- - `src/cli_args.rs`
14
- - 为 `docs search`、`docs read`、`docs read-lines` 增加 `--scope`、`--module` 参数。
15
-
16
- - `src/bin/cli_handlers/command_echo.rs`
17
- - 同步回显新增 docs 参数,确保工具模式下能看到完整检索上下文。
18
-
19
- - `src/bin/cli_handlers/docs.rs`
20
- - 引入 `GuideDocFrontmatter`、`GuideDocScope`、`DocsSearchScope`。
21
- - 支持解析 Markdown frontmatter,并在加载时校验 `category`。
22
- - 支持从 core docs 与 `~/.config/calcit/modules/<module>/docs/` 同时加载文档。
23
- - 统一 `search/read/read-lines` 的查询解析逻辑,允许通过文件名、路径片段、标题、`aliases`、`entry_for` 命中目标。
24
- - 增加更偏向 guide/reference 页的排序策略,减少 spec/索引页抢占结果。
25
- - 抽出 `match_score`、`accumulate_match_score`、`parse_guide_doc` 等辅助函数,压缩主文件重复逻辑。
26
-
27
- - `src/bin/cli_handlers/docs_tests.rs`
28
- - 将 docs 相关测试从 `docs.rs` 拆出,单独维护解析、排序、模块加载与校验场景。
29
-
30
- - `docs/docs-indexing.md`
31
- - 固化 frontmatter 字段、分类注册表、scope 布局与 authoring 约束。
32
-
33
- - `docs/docs-validation.md`
34
- - 记录 `cr docs` 的可执行回归命令,覆盖 `search/read/read-lines` 与 module scope。
35
-
36
- - `src/bin/cli_handlers/cirru_validator.rs`
37
- - 当 token 更像“应写成字符串的文本”时,提示使用 `|text` 或 `"|text with spaces"`,减少样式值与括号文本误写的排查成本。
38
-
39
- ## 文档整理原则
40
-
41
- - `category` 只允许稳定注册值,避免搜索元数据失控膨胀。
42
- - `aliases` 主要承接用户会直接输入的别名或术语,`entry_for` 主要承接命令/API/任务入口。
43
- - `Agents.md` 与普通 docs 页复用同一套 frontmatter 机制,但渲染时默认隐藏元数据正文。
44
- - 模块领域知识保留在模块 docs 中,Calcit core 只提供通用索引与加载能力,不内置 Respo 特殊语义。
45
-
46
- ## 验证
47
-
48
- - `cargo fmt`
49
- - `cargo test docs --bin cr`
50
- - 手动验证:
51
- - `cargo run --bin cr -- docs search target-replace`
52
- - `cargo run --bin cr -- docs search 'cr eval'`
53
- - `cargo run --bin cr -- docs read polymorphism.md`
54
-
55
- ## 后续经验
56
-
57
- - docs 元数据一旦进入 CLI 行为,就应该配套规范页与验证页,否则后续加字段很容易出现“文档能写、检索却不稳定”的分叉。
58
- - 模块文档检索要尽量和 core docs 走同一套 resolver,这样使用者不需要记两套命令心智模型。
@@ -1,46 +0,0 @@
1
- ## Path format migration: `@` prefix for display paths
2
-
3
- ### What changed
4
-
5
- All display-level Cirru tree paths now use `@` prefix notation when rendered to user.
6
-
7
- ### Display format change
8
-
9
- - `1.2.3.4` → `@1.2.3.4` (bare path)
10
- - `[1.2.3.4]` → `[@1.2.3.4]` (bracketed path)
11
- - `NodeLocation::Display` now outputs `ns/def [@1.2.3]` instead of `ns/def [1.2.3]`
12
-
13
- ### Backward compatibility
14
-
15
- - `parse_path()` strips leading `@` if present, so CLI input still accepts both `@1.2.3` and `1.2.3`
16
- - Error messages and help text updated to show `@` format
17
-
18
- ### Files modified
19
-
20
- **Core functions:**
21
-
22
- - `src/bin/cli_handlers/common.rs`: `format_path()` returns `@1.2.3`; `parse_path()` strips `@` prefix; test assertions updated
23
- - `src/calcit.rs`: `NodeLocation::Display` outputs `[@1.2.3]`; test assertion updated
24
- - `src/bin/cli_handlers/cirru_validator.rs`: local `format_path()` updated
25
- - `src/type_coverage.rs`: `format_cirru_path()` updated
26
- - `src/bin/cli_handlers/chunk_display.rs`: `compare_coords()` strips `@`; test `fragment()` helper uses `@`
27
- - `src/runner/preprocess/mod.rs`: `[&inspect-type]` debug output uses `@`
28
-
29
- **Tree/edit handlers:**
30
-
31
- - `src/bin/cli_handlers/tree.rs`: inline path formatting in swap handler
32
- - `src/bin/cli_handlers/edit.rs`: error message example
33
- - `src/cli_args.rs`: help text examples (3 locations)
34
-
35
- **Documentation:**
36
-
37
- - `docs/CalcitAgent.md`: 19 path examples updated
38
- - `docs/run/agent-advanced.md`: 23 path examples updated
39
- - `docs/run/edit-tree.md`: 6 path examples updated
40
- - `docs/Respo-Agent.md` (respo project): 26 path examples updated
41
-
42
- ### Why
43
-
44
- - `@` prefix helps LLMs distinguish path coordinates from other dotted numeric patterns (like version numbers or floats)
45
- - `@` is safe in shell (no escaping needed)
46
- - All display output now consistent with `@` prefix
@@ -1,26 +0,0 @@
1
- # JS Codegen Fix for Map-to-Record Rewrite
2
-
3
- ## Problem
4
- The map-to-record rewrite (from previous commit) inserted `Calcit::Struct` directly into the AST. The interpreter handles this, but JS codegen (`emit_js.rs` line 319) has no arm for `Calcit::Struct` → panics with `unreachable!`.
5
-
6
- ## Key Insight
7
- The `%{}` macro normally expands to `&%{}` with a **symbol/import reference** as the first arg (not a literal `Calcit::Struct`). JS codegen relies on this — it emits the symbol as a variable reference (e.g., `Element`), and the JS runtime `_$n__PCT__$M_` function accepts the struct object at runtime.
8
-
9
- ## Solution
10
- 1. Added `resolve_to_struct_with_ref()` to `CalcitTypeAnnotation` — returns `Option<(CalcitStruct, Option<(Arc<str>, Arc<str>)>)>` with ns/def path from TypeRef annotations.
11
- 2. Modified `try_rewrite_single_map_to_record()` to emit `Calcit::Import(CalcitImport { ... })` instead of `Calcit::Struct`:
12
- - `ImportInfo::SameFile` when struct is in same namespace (avoids self-import duplicate declaration)
13
- - `ImportInfo::NsReferDef` when struct is in a different namespace (generates proper cross-ns import)
14
- - Falls back to `Calcit::Struct` only when no ns/def path is available
15
-
16
- ## Pitfall: Self-Import Duplicate Declaration
17
- First attempt used `NsReferDef` for all imports — caused `SyntaxError: Identifier 'Point2D' has already been declared` because a self-import was generated when struct is in same namespace. Fix: detect `ns == file_ns` and use `SameFile`.
18
-
19
- ## Verification in Respo
20
- - Typed `element->string` as `'respo.schema/Element`, `make-string` as `'respo.schema/Component`
21
- - Test passes `{}` map to `element->string` → auto-rewritten to `%{} Element ...` record construction
22
- - Generated JS: `import { Element } from "./respo.schema.mjs"` + `$clt._$n__PCT__$M_(Element, ...)`
23
-
24
- ## Files Changed
25
- - `src/calcit/type_annotation.rs`: Added `resolve_to_struct_with_ref()`
26
- - `src/runner/preprocess.rs`: Emit Import reference in `try_rewrite_single_map_to_record()`
@@ -1,29 +0,0 @@
1
- # Map-to-Record Field Validation and Nil Fill
2
-
3
- ## Problem
4
- Map-to-record rewrite was passing through ALL map keys without validation, and emitting only
5
- the keys present in the map. This caused:
6
- 1. Maps with keys not in the struct (e.g., `:x`) being incorrectly rewritten to records
7
- 2. "fields size does not match" runtime error when the map has fewer keys than struct fields
8
-
9
- ## Fix (preprocess.rs)
10
- 1. **Field validation**: Check each map key against `struct_def.fields`. If any key is not a
11
- valid struct field, skip the rewrite entirely (stay as map).
12
- 2. **Nil fill**: Emit ALL struct fields in definition order. For fields not present in the map,
13
- emit `Calcit::Nil`. This ensures the record always has the correct field count.
14
- 3. **HashMap tracking**: Build a `HashMap<EdnTag, &Calcit>` of provided fields for O(1) lookup
15
- during emission.
16
-
17
- ## Key Types
18
- - `struct_def.fields` is `Vec<EdnTag>` — compare with `EdnTag` directly, not `Arc<str>`
19
- - `provided_fields` is `HashMap<EdnTag, &Calcit>` — avoids the `Arc<str>: Borrow<EdnTag>` issue
20
-
21
- ## Respo DomProps Design
22
- - 29 fields with `(:: :optional <type>)` annotations
23
- - Strings: class-name, id, type, href, src, placeholder, name, title, data-name, data-comp, target
24
- - Dynamic: style (map), value, inner-text
25
- - Bools: disabled, checked, spell-check, read-only, selected
26
- - Number: tab-index
27
- - Fns: on-click, on-input, on-focus, on-blur, on-keydown, on-keyup, on-change
28
- - Maps: on, event
29
- - `create-element`/`create-list-element` convert record props to map via `&record:to-map`