@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.
- package/.yarn/install-state.gz +0 -0
- package/build.rs +36 -2
- 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
|
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,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 做同脚本对比。
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
# 2026-02-14 23:58 emit_js modularization + shift-left contracts
|
|
2
|
-
|
|
3
|
-
## Scope
|
|
4
|
-
|
|
5
|
-
This round focuses on two tracks:
|
|
6
|
-
|
|
7
|
-
1. Continue low-risk modularization of `src/codegen/emit_js.rs` without changing runtime semantics.
|
|
8
|
-
2. Introduce AI-oriented "shift-left" validation contracts for expected warning/error paths.
|
|
9
|
-
|
|
10
|
-
## What changed
|
|
11
|
-
|
|
12
|
-
### Rust codegen modularization
|
|
13
|
-
|
|
14
|
-
- Removed duplicate legacy module file:
|
|
15
|
-
- `src/calcit/struct.rs`
|
|
16
|
-
- Split helpers from `emit_js.rs` into cohesive submodules:
|
|
17
|
-
- `src/codegen/emit_js/tags.rs`
|
|
18
|
-
- `src/codegen/emit_js/symbols.rs`
|
|
19
|
-
- `src/codegen/emit_js/paths.rs`
|
|
20
|
-
- `src/codegen/emit_js/runtime.rs`
|
|
21
|
-
- `src/codegen/emit_js/args.rs`
|
|
22
|
-
- `src/codegen/emit_js/deps.rs`
|
|
23
|
-
- `src/codegen/emit_js/helpers.rs`
|
|
24
|
-
- Kept behavior stable by only moving logic and wiring imports/call sites.
|
|
25
|
-
- Added targeted unit tests in extracted modules.
|
|
26
|
-
|
|
27
|
-
### Runtime helper boundary cleanup (TS)
|
|
28
|
-
|
|
29
|
-
- Grouped runtime helpers into dedicated modules:
|
|
30
|
-
- `ts-src/js-arity-helpers.mts` (`_args_throw`, `_args_fewer_throw`, `_args_between_throw`)
|
|
31
|
-
- `ts-src/js-tag-helpers.mts` (`init_tags` + internal cache)
|
|
32
|
-
- Switched `ts-src/calcit.procs.mts` to re-export these modules, keeping public API names unchanged.
|
|
33
|
-
|
|
34
|
-
### Test/validation workflow improvements
|
|
35
|
-
|
|
36
|
-
- Added contract-based shift-left script:
|
|
37
|
-
- `scripts/check-shift-left.mjs`
|
|
38
|
-
- Added npm script:
|
|
39
|
-
- `check-shift-left` in `package.json`
|
|
40
|
-
- This script enforces both:
|
|
41
|
-
- positive baseline must pass (`calcit/test.cirru -1`)
|
|
42
|
-
- selected negative cases must fail with expected diagnostic tokens.
|
|
43
|
-
|
|
44
|
-
### Planning/documentation updates
|
|
45
|
-
|
|
46
|
-
- Expanded and updated roadmap status:
|
|
47
|
-
- `drafts/project-modernization-roadmap.md`
|
|
48
|
-
- Added AI-oriented long-term section for:
|
|
49
|
-
- immutable core constraints
|
|
50
|
-
- earlier error detection
|
|
51
|
-
- contractized diagnostics
|
|
52
|
-
- staged execution strategy.
|
|
53
|
-
|
|
54
|
-
## Verification
|
|
55
|
-
|
|
56
|
-
- Ran targeted unit tests for extracted modules (`tags/symbols/paths/runtime/args/deps/helpers` where applicable).
|
|
57
|
-
- Repeated full validation with `yarn check-all` after each refactor batch.
|
|
58
|
-
- Ran `yarn check-shift-left` to validate diagnostic contracts.
|
|
59
|
-
|
|
60
|
-
## Notes
|
|
61
|
-
|
|
62
|
-
- Some standalone `calcit/test-*.cirru` files are intentionally warning/error reproductions or independent package entries; they are not safe to inline into `test.cirru` module list directly.
|
|
63
|
-
- Using a separate shift-left contract script avoids namespace collisions and preserves intent.
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
# 2026-02-15 diagnostics 合并记录
|
|
2
|
-
|
|
3
|
-
本文件合并以下 diagnostics 相关记录,避免碎片化:
|
|
4
|
-
|
|
5
|
-
- 2026-0215-1011-preprocess-diagnostic-v1.md
|
|
6
|
-
- 2026-0215-1026-cli-diag-json.md
|
|
7
|
-
- 2026-0215-1104-diag-expected-actual-action-let.md
|
|
8
|
-
- 2026-0215-1110-eval-diag-fallbacks.md
|
|
9
|
-
- 2026-0215-1116-macro-diagnostic-protocol.md
|
|
10
|
-
- 2026-0215-1134-macro-diag-expansion-if-defn-assert.md
|
|
11
|
-
- 2026-0215-1152-runtime-fallback-tag-match-arity.md
|
|
12
|
-
- 2026-0215-1202-warning-arity-fallback-compat.md
|
|
13
|
-
- 2026-0215-1211-warning-learning-fields.md
|
|
14
|
-
- 2026-0215-1238-convergence-help-docs-diag.md
|
|
15
|
-
- 2026-0215-1306-text-diagnostics-convergence-fix.md
|
|
16
|
-
- 2026-0215-1332-diagnostics-simplification-example-driven.md
|
|
17
|
-
|
|
18
|
-
## 合并后的结论(当前保留)
|
|
19
|
-
|
|
20
|
-
- 已移除 `--diag json` 路径,CLI 统一使用文本诊断输出。
|
|
21
|
-
- warning 维持最小字段与文本展示,不再维护 JSON 结构演进。
|
|
22
|
-
- error 维持 call stack + examples 辅助定位,避免复杂规则映射。
|
|
23
|
-
- 文本模式保持简洁:优先 message/hint/location/stack,便于直接修复。
|
|
24
|
-
|
|
25
|
-
## 本轮简化(减法)
|
|
26
|
-
|
|
27
|
-
- 移除 warning 侧复杂增强字段:`fingerprint/convergence/help/learning`。
|
|
28
|
-
- 移除 error 侧复杂增强字段:`fingerprint/convergence/help/learning` 与大段规则映射。
|
|
29
|
-
- 将 error 的 expected/actual/action 处理改为“hint 优先 + 通用 message 提取 + 最小 fallback”。
|
|
30
|
-
|
|
31
|
-
## 设计原则(后续继续遵循)
|
|
32
|
-
|
|
33
|
-
- 诊断能力优先复用编译器已有信息(hint、message、stack、examples)。
|
|
34
|
-
- 尽量减少按错误码硬编码规则,避免语言层复杂度膨胀。
|
|
35
|
-
- LLM 修复入口尽量通用化:`query examples` + 最小可执行动作。
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
# Macro Diagnostics Refinement (2026-02-15 19:41)
|
|
2
|
-
|
|
3
|
-
## Summary
|
|
4
|
-
|
|
5
|
-
This change improves diagnostic quality for macro misuse and warning flows without changing macro semantics.
|
|
6
|
-
|
|
7
|
-
## Key updates
|
|
8
|
-
|
|
9
|
-
- Added a shared diagnostics helper module:
|
|
10
|
-
- `src/diagnostics_help.rs`
|
|
11
|
-
- Centralizes message-to-help inference logic.
|
|
12
|
-
- Improved stack-rendered failure guidance:
|
|
13
|
-
- `src/call_stack.rs`
|
|
14
|
-
- Uses macro-context-aware help text.
|
|
15
|
-
- Keeps examples targeting user-facing macros over internal helper macros.
|
|
16
|
-
- Improved warning-path guidance:
|
|
17
|
-
- `src/bin/cr.rs`
|
|
18
|
-
- Reuses shared help inference for preprocessing/codegen warning blocks.
|
|
19
|
-
- Improved macro argument binding diagnostics in runtime:
|
|
20
|
-
- `src/runner.rs`
|
|
21
|
-
- Replaces low-level `Idx(...)` style arity failures with readable signatures and missing argument names.
|
|
22
|
-
- Refined macro-side error wording:
|
|
23
|
-
- `src/cirru/calcit-core.cirru`
|
|
24
|
-
- Better `list-match` branch-shape messages.
|
|
25
|
-
- Kept macro signatures intact where requested:
|
|
26
|
-
- `when`, `when-not`, `when-let` remain with explicit parameter forms.
|
|
27
|
-
|
|
28
|
-
## Validation
|
|
29
|
-
|
|
30
|
-
- Spot checks executed with `cr eval` for macro misuse cases:
|
|
31
|
-
- `when`, `when-not`, `when-let`, `if-not`, `tag-match`, `record-match`, `list-match`, `cond`, `let`, `thread-first`, `thread-last`.
|
|
32
|
-
- Confirmed help text differentiates macro misuse vs proc/function arity warnings.
|
|
33
|
-
- Full regression passed:
|
|
34
|
-
- `yarn check-all` => `EXIT:0`.
|
|
35
|
-
|
|
36
|
-
## Notes
|
|
37
|
-
|
|
38
|
-
- This iteration focuses on user-facing diagnostics quality.
|
|
39
|
-
- Behavior and compatibility are preserved; changes are primarily in error/help reporting paths.
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
# 2026-02-16 20:43 core API/docs cleanup
|
|
2
|
-
|
|
3
|
-
## Scope
|
|
4
|
-
|
|
5
|
-
- Cleaned outdated draft references and status notes.
|
|
6
|
-
- Aligned core internal API names around trait attachment (`*:impl-traits`).
|
|
7
|
-
- Fixed `wo-js-log` export/definition mismatch.
|
|
8
|
-
- Merged symbol-resolution note into drafts and removed duplicated doc file.
|
|
9
|
-
|
|
10
|
-
## Key updates
|
|
11
|
-
|
|
12
|
-
1. **drafts cleanup**
|
|
13
|
-
- Added `drafts/README.md` as a state index (active/review-needed/archived).
|
|
14
|
-
- Fixed stale links between `assert-types-plan.md` and `assert-types.md`.
|
|
15
|
-
- Marked `drafts/last-session.md` as archived historical snapshot.
|
|
16
|
-
|
|
17
|
-
2. **core naming consistency**
|
|
18
|
-
- Updated internal entries in `src/cirru/calcit-core.cirru`:
|
|
19
|
-
- `&record:with-impls` -> `&record:impl-traits`
|
|
20
|
-
- `&tuple:with-impls` -> `&tuple:impl-traits`
|
|
21
|
-
- `&struct:with-impls` -> `&struct:impl-traits`
|
|
22
|
-
- `&enum:with-impls` -> `&enum:impl-traits`
|
|
23
|
-
- Updated `%::` doc hint to reference `&tuple:impl-traits`.
|
|
24
|
-
|
|
25
|
-
3. **debug macro fix**
|
|
26
|
-
- Fixed `wo-js-log` entry to define `wo-js-log` (not `w-js-log`).
|
|
27
|
-
|
|
28
|
-
4. **symbol note consolidation**
|
|
29
|
-
- Appended symbol-resolution appendix into `drafts/runtime-traits-plan.md`.
|
|
30
|
-
- Removed duplicated `docs/symbol-spec.md` after migration.
|
|
31
|
-
|
|
32
|
-
## Validation notes
|
|
33
|
-
|
|
34
|
-
- Verified `wo-js-log` evaluates successfully.
|
|
35
|
-
- Verified `&struct:impl-traits` resolves as runtime proc.
|
|
36
|
-
- Confirmed old `&struct:with-impls` now reports unknown symbol (no compatibility layer, by design).
|
|
37
|
-
|
|
38
|
-
## Follow-up
|
|
39
|
-
|
|
40
|
-
- If needed, add explicit migration note/changelog entry for removed `*-with-impls` internal names.
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
# 2026-0223-0834 — 迁移到 defstruct 方案并实现 `%{}?` 可选字段 Record 宏
|
|
2
|
-
|
|
3
|
-
## 背景
|
|
4
|
-
|
|
5
|
-
将 Calcit Record 系统从旧的 `new-record`/`defrecord`/`defrecord!` 方案全面迁移到基于 `defstruct` 的新方案,同时新增 `%{}?` / `&%{}?` 支持可选字段初始化与更新。
|
|
6
|
-
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
## 知识点一:`%{}?` 与 `&%{}?` 的语义设计
|
|
10
|
-
|
|
11
|
-
`struct` 初始化为 record 时,部分字段在语义上是可选的,对应 TypeScript 中的 `{ a?: number; b?: number }`。原有的 `%{}` / `&%{}` 要求所有字段都必须显式传入。
|
|
12
|
-
|
|
13
|
-
### `%{}?`(macro)
|
|
14
|
-
|
|
15
|
-
- 初始化 record 时允许省略字段,省略的字段自动填 `nil`。
|
|
16
|
-
- 用法:`%{}? MyRecord (:x 1)`
|
|
17
|
-
|
|
18
|
-
### `&%{}?`(proc)
|
|
19
|
-
|
|
20
|
-
`call_record_partial` 的语义:
|
|
21
|
-
|
|
22
|
-
- **proto 是 Struct**:以全 `nil` 为基础 `values`,用传入的 k-v 覆盖对应位置。
|
|
23
|
-
- 传入未知字段 → 报错;传入重复字段 → 报错;`(args_size - 1) % 2 != 0` → 报错。
|
|
24
|
-
|
|
25
|
-
关键实现细节:`CalcitStruct.fields` 元素类型是 `EdnTag`,比较时用 `f.ref_str()` 而非 `f.as_ref()`(后者无 `AsRef` impl)。
|
|
26
|
-
|
|
27
|
-
### `%{}?` 宏定义
|
|
28
|
-
|
|
29
|
-
```cirru
|
|
30
|
-
defmacro %{}? (R & xs)
|
|
31
|
-
if
|
|
32
|
-
not $ and (list? xs) (every? xs list?)
|
|
33
|
-
raise $ str-spaced "|%{}? expects field entries in list, got:" xs
|
|
34
|
-
&let
|
|
35
|
-
args $ &list:concat & xs
|
|
36
|
-
quasiquote $ &%{}? ~R ~@args
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
---
|
|
40
|
-
|
|
41
|
-
## 知识点二:Rust proc 注册流程
|
|
42
|
-
|
|
43
|
-
新增一个内置 proc 需要同时修改四处:
|
|
44
|
-
|
|
45
|
-
| 文件 | 修改内容 |
|
|
46
|
-
| -------------------------- | -------------------------------------------------------- |
|
|
47
|
-
| `src/calcit/proc_name.rs` | 添加枚举变体 `NativeRecordPartial` + `ProcTypeSignature` |
|
|
48
|
-
| `src/builtins/records.rs` | 实现 `call_record_partial` 函数 |
|
|
49
|
-
| `src/builtins.rs` | 在 `match proc` 中添加分发分支 |
|
|
50
|
-
| `src/runner/preprocess.rs` | 将新 proc 加入"跳过 arity 检查"的 `matches!` 列表 |
|
|
51
|
-
|
|
52
|
-
---
|
|
53
|
-
|
|
54
|
-
## 知识点三:`%{}` 严格要求 Struct proto
|
|
55
|
-
|
|
56
|
-
- `call_record`(`%{}`):若 proto 为 `Calcit::Record`,直接返回错误提示改用 `defstruct`。
|
|
57
|
-
- `defstruct` 产生 `Calcit::Struct`(含 `field_types`),并作为 `%{}` / `%{}?` 的唯一原型来源。
|
|
58
|
-
|
|
59
|
-
### `&record:get-name` / `&record:struct` 的参数约束
|
|
60
|
-
|
|
61
|
-
- 两者统一要求传入 `record`,避免 `struct` / `record` 混用语义。
|
|
62
|
-
|
|
63
|
-
### `&record:matches?` 的参数约束
|
|
64
|
-
|
|
65
|
-
- 第一参数要求 `record`。
|
|
66
|
-
- 第二参数接受 `record` 或 `struct`(用于 `record-match` 的模式匹配场景)。
|
|
67
|
-
|
|
68
|
-
---
|
|
69
|
-
|
|
70
|
-
## 修改文件
|
|
71
|
-
|
|
72
|
-
| 文件 | 变更内容 |
|
|
73
|
-
| ----------------------------- | ------------------------------------------------------------------------------------------------------------- |
|
|
74
|
-
| `src/calcit/proc_name.rs` | 新增 `NativeRecordPartial` 枚举变体与类型签名;移除 `NewRecord` 变体 |
|
|
75
|
-
| `src/builtins/records.rs` | 新增 `call_record_partial`(struct-only);`matches` 调整为 `(record, record/struct)`;移除 `new_record` 函数 |
|
|
76
|
-
| `src/builtins.rs` | 分发 `NativeRecordPartial`;移除 `NewRecord` 分发 |
|
|
77
|
-
| `src/runner/preprocess.rs` | arity 检查豁免新增 `NativeRecordPartial` |
|
|
78
|
-
| `src/cirru/calcit-core.cirru` | 新增 `%{}?` 宏定义与 `&%{}?` 文档条目;`defrecord`/`defrecord!` 改为 raise error;删除 `new-record` 定义 |
|
|
79
|
-
| `calcit/test-record.cirru` | Cat/BirdShape/Person/City/A/B/C/Demo 全部改为 `defstruct`;删除所有 `new-record` let 绑定;修复各测试函数体 |
|
|
80
|
-
| `docs/CalcitAgent.md` | 类型标注示例中 `new-record` 改为 `defstruct` |
|
|
81
|
-
|
|
82
|
-
---
|
|
83
|
-
|
|
84
|
-
## 验证
|
|
85
|
-
|
|
86
|
-
```bash
|
|
87
|
-
cargo run --bin cr -- calcit/test-record.cirru -1
|
|
88
|
-
cargo clippy -- -D warnings
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
全部通过,无 warning。
|