@calcit/procs 0.13.50 → 0.13.52

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.
Binary file
package/README.md CHANGED
@@ -19,7 +19,7 @@ Core design:
19
19
 
20
20
  Current direction:
21
21
 
22
- - `calcit.cirru` is the primary source snapshot; legacy `compact.cirru` is still compatible
22
+ - `calcit.cirru` is the canonical source snapshot; retired `compact.cirru` inputs receive migration guidance
23
23
  - CLI-first development with `calcit` and `caps`, designed to work well with AI agents in terminal workflows
24
24
  - Better CLI editing and validation for CI, docs lookup, module management, and incremental updates
25
25
 
@@ -62,18 +62,16 @@ calcit eval 'range 100'
62
62
  calcit eval -- '-> 100 range (map $ \ * % %)'
63
63
  ```
64
64
 
65
- Run with a runtime snapshot such as `calcit.cirru` (legacy filename: `compact.cirru`):
65
+ Run with the canonical runtime snapshot `calcit.cirru`:
66
66
 
67
67
  ```bash
68
68
  calcit calcit.cirru # run once (default)
69
- calcit compact.cirru # legacy filename still works
70
-
71
- calcit # by default, it picks `calcit.cirru`, then falls back to `compact.cirru`
69
+ calcit # reads calcit.cirru from the current directory
72
70
 
73
71
  calcit -w # watch mode (explicit flag required)
74
72
  ```
75
73
 
76
- By default Calcit reads `:init-fn` and `:reload-fn` from `calcit.cirru` configs (falling back to `compact.cirru`). You may also specify functions:
74
+ By default Calcit reads `:init-fn` and `:reload-fn` from `calcit.cirru` `:entries.default`. You may also specify functions:
77
75
 
78
76
  ```bash
79
77
  calcit --init-fn='app.main/main!' --reload-fn='app.main/reload!'
@@ -150,7 +148,7 @@ Use `caps add --dev <org/repo>@<ref>` and `caps remove --dev <org/repo>` to mana
150
148
 
151
149
  `:calcit-version` helps with version checks and provides hints in [CI](https://github.com/calcit-lang/setup-calcit).
152
150
 
153
- To load modules, use `:modules` configuration and the runtime snapshot file `calcit.cirru` (legacy: `compact.cirru`):
151
+ To load modules, use `:modules` configuration and the runtime snapshot file `calcit.cirru`:
154
152
 
155
153
  ```cirru.no-check
156
154
  :entries $ {}
@@ -161,7 +159,7 @@ To load modules, use `:modules` configuration and the runtime snapshot file `cal
161
159
  Paths defined in `:modules` load from the snapshot directory's `.calcit/modules/`, e.g.
162
160
  `.calcit/modules/memof/calcit.cirru`. Run `caps` to materialize or refresh that project-local view.
163
161
 
164
- Modules ending with `/` are automatically suffixed with `calcit.cirru`, and still fall back to `compact.cirru` for compatibility.
162
+ Modules ending with `/` are automatically suffixed with `calcit.cirru`. A module containing only retired `compact.cirru` is rejected with migration guidance.
165
163
 
166
164
  Inspect and verify the resolved graph with:
167
165
 
@@ -203,7 +201,7 @@ yarn check-all
203
201
  ```
204
202
 
205
203
  - [Cirru Parser](https://github.com/Cirru/parser.rs) for indentation-based syntax parsing.
206
- - [Cirru EDN](https://github.com/Cirru/cirru-edn.rs) for runtime snapshot file parsing (`calcit.cirru` / legacy `compact.cirru`).
204
+ - [Cirru EDN](https://github.com/Cirru/cirru-edn.rs) for canonical runtime snapshot parsing (`calcit.cirru`).
207
205
  - [Ternary Tree](https://github.com/calcit-lang/ternary-tree.rs) for immutable list data structure.
208
206
 
209
207
  Other tools:
@@ -11,7 +11,7 @@
11
11
 
12
12
  - `calcit analyze program-diff <GIT REF>`
13
13
 
14
- 该命令从 Git 中读取指定版本的完整运行时快照文件(默认沿用当前 `calcit` 的输入文件路径,优先 `calcit.cirru`,兼容旧文件名 `compact.cirru`),确保**历史版本**与**当前工作区版本**都能被正确解析为 Calcit snapshot,然后做**结构化 diff**。
14
+ 该命令从 Git 中读取指定版本的完整运行时快照文件(默认沿用当前 `calcit` canonical `calcit.cirru` 输入路径;退休的 `compact.cirru` 会被拒绝并提示迁移),确保**历史版本**与**当前工作区版本**都能被正确解析为 Calcit snapshot,然后做**结构化 diff**。
15
15
 
16
16
  输出目标不是纯文本行 diff,而是面向程序结构的树形 diff:
17
17
 
@@ -27,7 +27,7 @@
27
27
 
28
28
  当前针对运行时快照文件的版本对比主要依赖 Git 行 diff,但它有几个明显问题:
29
29
 
30
- 1. **对结构不友好**:`calcit.cirru`(兼容旧文件名 `compact.cirru`)是机器生成的 snapshot,行 diff 容易受格式、字段顺序和长表达式影响;
30
+ 1. **对结构不友好**:`calcit.cirru` 是机器生成的 snapshot,行 diff 容易受格式、字段顺序和长表达式影响;
31
31
  2. **对表达式内部变化不友好**:definition 代码改动往往是局部子树变化,行 diff 很难快速看出 AST 层面的增删改;
32
32
  3. **对 LLM / CLI 阅读不友好**:调用 `git diff` 后很难一眼区分“只是某个 def 变了”还是“整个 namespace 被搬动了”;
33
33
  4. **缺少 parse guard**:历史版本文件如果本身损坏,应该先明确报解析失败,而不是直接进入错误 diff。
@@ -43,7 +43,7 @@ calcit analyze program-diff <GIT REF>
43
43
  语义:
44
44
 
45
45
  - `<GIT REF>` 可以是 `HEAD~1`、tag、branch、commit SHA 等;
46
- - 当前侧使用 `calcit` 输入路径(默认优先 `calcit.cirru`,兼容旧文件名 `compact.cirru`);
46
+ - 当前侧使用 `calcit` 输入路径(默认是 canonical `calcit.cirru`;退休的 `compact.cirru` 不参与 diff);
47
47
  - 历史侧使用 `git show <ref>:<repo-relative-input-path>` 读取文件内容;
48
48
  - 两边都必须先经过:
49
49
  1. `cirru_edn::parse`
@@ -177,7 +177,7 @@ list 内部子节点对比采用“带替换代价的序列对齐”策略:
177
177
 
178
178
  ## 7. 预期收益
179
179
 
180
- - 更适合 review `calcit.cirru`(兼容旧文件名 `compact.cirru`)的语义变化;
180
+ - 更适合 review canonical `calcit.cirru` 的语义变化;
181
181
  - 更容易理解大型 definition 的局部 AST 改动;
182
182
  - 对 agent/LLM 更友好,能直接拿到层级化变化;
183
183
  - 为后续抽象成 Cirru diff 模块提供实现样本。
package/build.rs CHANGED
@@ -64,20 +64,6 @@ pub struct SnapshotEntry {
64
64
  pub target: Option<String>,
65
65
  }
66
66
 
67
- #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
68
- pub struct LegacySnapshotConfigs {
69
- #[serde(rename = "init-fn", deserialize_with = "deserialize_ns_def")]
70
- pub init_fn: String,
71
- #[serde(rename = "reload-fn", deserialize_with = "deserialize_ns_def")]
72
- pub reload_fn: String,
73
- #[serde(default)]
74
- pub modules: Vec<String>,
75
- #[serde(default)]
76
- pub version: String,
77
- #[serde(default, rename = "type-slots")]
78
- pub type_slots: HashMap<String, String>,
79
- }
80
-
81
67
  #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
82
68
  pub struct CodeEntry {
83
69
  pub doc: String,
@@ -613,30 +599,15 @@ fn main() {
613
599
 
614
600
  let files = parse_files(data.get_or_nil("files")).unwrap_or_else(|e| panic!("failed to parse calcit-core `:files`: {e}"));
615
601
 
616
- let legacy_configs = match data.get_or_nil("configs") {
617
- Edn::Nil => None,
618
- value => {
619
- Some(from_edn::<LegacySnapshotConfigs>(value).unwrap_or_else(|e| panic!("failed to parse calcit-core legacy `:configs`: {e}")))
620
- }
621
- };
622
- let mut entries = parse_entries(data.get_or_nil("entries")).unwrap_or_else(|e| panic!("failed to parse calcit-core `:entries`: {e}"));
623
- if let Some(configs) = &legacy_configs {
624
- entries.insert(
625
- "default".to_owned(),
626
- SnapshotEntry {
627
- mode: SnapshotRunMode::Native,
628
- init_fn: configs.init_fn.clone(),
629
- reload_fn: configs.reload_fn.clone(),
630
- description: String::new(),
631
- modules: configs.modules.clone(),
632
- type_slots: configs.type_slots.clone(),
633
- feature_policy: HashMap::new(),
634
- target: None,
635
- },
636
- );
602
+ if data.contains_key("configs") {
603
+ panic!("calcit-core uses retired top-level `:configs`; migrate it with Calcit 0.13.50 before building")
604
+ }
605
+ let entries = parse_entries(data.get_or_nil("entries")).unwrap_or_else(|e| panic!("failed to parse calcit-core `:entries`: {e}"));
606
+ if !entries.contains_key("default") {
607
+ panic!("calcit-core `:entries` must contain `:default`");
637
608
  }
638
609
  let version = match data.get_or_nil("version") {
639
- Edn::Nil => legacy_configs.map(|configs| configs.version).unwrap_or_default(),
610
+ Edn::Nil => String::new(),
640
611
  value => from_edn(value).unwrap_or_else(|e| panic!("failed to parse calcit-core `:version`: {e}")),
641
612
  };
642
613
 
@@ -0,0 +1,6 @@
1
+ # Retire legacy Snapshot config aliases
2
+
3
+ - Stop decoding top-level `:configs` at runtime and while embedding `calcit.core`; point legacy projects to Calcit 0.13.50 for the one-way `:entries.default` migration.
4
+ - Remove silent `calcit.cirru` to `compact.cirru` path aliasing across runtime, query, docs, and diff commands while retaining sibling detection for an actionable error.
5
+ - Remove the formatter advisory for a shape that current Calcit no longer loads, and align README, Agent guidance, and Snapshot docs with the released filename cutoff.
6
+ - Validate the strict loader against the latest `Respo/respo` and `calcit-lang/recollect` main branches: native checks/tests, Markdown examples, generated JavaScript tests, quality gates, and production Vite builds remain green.
@@ -0,0 +1,38 @@
1
+ # Remove legacy macro schemas
2
+
3
+ ## Context
4
+
5
+ Issue #480 ends the migration window for runtime-shaped macro schemas. A
6
+ `defmacro` now has one persisted and executable schema representation: the
7
+ phase-aware `Macro` contract.
8
+
9
+ ## Changes
10
+
11
+ - Removed the legacy macro compatibility state, provenance metadata, staged
12
+ warning environment switch, metrics/cache exceptions, and coverage-report
13
+ fields.
14
+ - Made Snapshot loading reject a `defmacro` with a `Fn`, `Dynamic`, or other
15
+ non-`Macro` schema before compilation. Errors include the Snapshot
16
+ definition path and the final compatible Calcit version, 0.13.51.
17
+ - Made schema editing reject legacy `:kind :macro` function maps, preventing
18
+ current tools from emitting a schema the loader will reject.
19
+ - Made preprocessing and runtime macro evaluation use only strict parameter,
20
+ expansion, and capability checks.
21
+ - Migrated the JS integration fixture and direct temporary-Snapshot test helper
22
+ to explicit strict macro contracts.
23
+ - Updated migration, static-analysis, macro-contract, and agent documentation.
24
+
25
+ ## Validation
26
+
27
+ - `cargo fmt --check`
28
+ - `cargo clippy -- -D warnings`
29
+ - `cargo test -- --test-threads=1`
30
+ - `yarn compile`
31
+ - `yarn check-agent-interface`
32
+ - latest Respo and Recollect `--check-only` plus
33
+ `analyze check-types --deps --summary-only --format json` with the local
34
+ release binary
35
+
36
+ `yarn check-all` was also run after the agent-interface lock cleared; its
37
+ component gates are covered by the full Rust, integration-fixture, and release
38
+ checks above.
@@ -0,0 +1,52 @@
1
+ # C-safe blocking FFI protocol v1
2
+
3
+ ## Goal
4
+
5
+ Remove Rust closures, trait objects, `Vec<Edn>`, `Result`, and `FnOnce` from
6
+ the supported `&blocking-dylib-edn-fn` boundary while preserving methods that
7
+ must own and call back on the Calcit host thread.
8
+
9
+ ## Protocol decisions
10
+
11
+ - use a distinct `<method>_calcit_ffi_blocking_v1` symbol so blocking and
12
+ asynchronous starts cannot be confused;
13
+ - reuse `calcit_ffi_async_version() -> 1`, the generation task registry,
14
+ OneShot lifecycle, serial event sequence, task descriptor, status codes, and
15
+ Cirru EDN request encoding;
16
+ - invoke the Calcit callback directly only on the task's owner thread instead
17
+ of enqueueing work that cannot drain while the dylib owns that thread;
18
+ - let modules finish explicitly exactly once, with method return providing the
19
+ implicit finish when no explicit finish occurred;
20
+ - keep callback result bytes host-owned and indexed by exact pointer/length;
21
+ modules release them through the task-bound host `free_buffer` function;
22
+ - report foreign-thread access, callback failures, forged/duplicate frees, and
23
+ leaked host buffers even if the module ignores the returned status;
24
+ - probe the migrated method before allocating runtime task state, preserving
25
+ the build-ID-guarded per-method Rust ABI fallback for unmigrated modules;
26
+ - make legacy blocking task release exactly once on explicit finish or method
27
+ return, fixing the previous pending-task leak on error paths.
28
+
29
+ ## Tests
30
+
31
+ - C-layout host table and versioned method name;
32
+ - inline callback execution and host-owned EDN result;
33
+ - exact buffer metadata and duplicate-free rejection;
34
+ - owner-thread enforcement;
35
+ - explicit finish exactly once and callback rejection after finish.
36
+
37
+ ## Native verification
38
+
39
+ An optimized standalone C dylib was loaded by the debug Calcit host and
40
+ verified both explicit and implicit finish. Separate methods confirmed that a
41
+ foreign pthread callback, an unfreed callback buffer, and a Calcit callback
42
+ error all fail deterministically and release the pending task.
43
+
44
+ ## Full verification
45
+
46
+ - `cargo fmt -- --check`
47
+ - `cargo clippy --all-targets -- -D warnings`
48
+ - `cargo test` (864 Rust tests)
49
+ - `yarn compile`
50
+ - `yarn check-agent-interface` (17/17)
51
+ - `yarn check-all` (Calcit core 221/221, JS, IR, WASM and runtime benchmarks)
52
+ - `bash scripts/check-docs-md.sh` (57 files, 325 blocks)
@@ -0,0 +1,17 @@
1
+ # Release 0.13.52
2
+
3
+ Release the C-safe asynchronous and blocking FFI runtime completed after
4
+ 0.13.51.
5
+
6
+ Highlights:
7
+
8
+ - bounded C-safe async task/event queue and host-thread callback drain;
9
+ - native callback-v1 with per-method guarded fallback;
10
+ - cancellable Server tasks and exactly-once response capabilities;
11
+ - C-safe blocking callback-v1 with owner-thread dispatch, explicit/implicit
12
+ finish, and host-owned callback buffer tracking;
13
+ - removal of the remaining supported Rust closure/container boundary for
14
+ migrated blocking methods.
15
+
16
+ The release provides the stable host version required for the Phase 6 module
17
+ migration under issue #482.
@@ -0,0 +1,33 @@
1
+ # FsPath file-effect boundary
2
+
3
+ ## Summary
4
+
5
+ - Removed `.read-file`, `.read-dir`, and `.write-file` from the built-in String method table.
6
+ - Added the nominal, UTF-8-backed `FsPath` type and the explicit `fs:path` constructor.
7
+ - Added `FsPath` methods `.read-text`, `.write-text`, `.read-dir`, `.walk-dir`, and `.to-string` through a nominal trait implementation.
8
+ - Kept `try-read-file`, `try-read-dir`, `try-write-file` and the raw raising primitives as String-path compatibility APIs.
9
+
10
+ ## Design notes
11
+
12
+ - `path` remains available for generic AST, data, and query path concepts; the filesystem-specific type is named `FsPath`.
13
+ - Calcit uses one immutable path value rather than copying Rust's borrowed `Path` versus owned mutable `PathBuf` split.
14
+ - `fs:path` stores the original UTF-8 text without lexical normalization or filesystem access.
15
+ - `.read-dir` is non-recursive and `.walk-dir` is recursive, avoiding an `Option<Bool>` mode in the new public method API.
16
+ - Text operations are named `.read-text` and `.write-text` so future byte-oriented operations have an unambiguous place.
17
+
18
+ ## Implementation lesson
19
+
20
+ Keep `defstruct FsPath` directly inside the public `FsPath` definition before `impl-traits`, matching the core `Result` pattern. Hiding the base struct in an intermediate `FsPath0` definition prevents required-field analysis from resolving `:value` through the nominal reference.
21
+
22
+ For an expression receiver, prefix method syntax such as `.read-text $ fs:path |file` is always explicit. The ergonomic suffix form should use a typed binding such as `source.read-text`; `(fs:path |file) .read-text` is not a general runtime rewrite for arbitrary expression receivers.
23
+
24
+ ## Validation
25
+
26
+ - `cargo fmt --all`
27
+ - `cargo clippy --all-targets -- -D warnings`
28
+ - `cargo test`
29
+ - `yarn check-all`
30
+ - changed Markdown snippets via `calcit docs check-md`
31
+ - latest Respo main: 27/27 tests, 111/111 documentation blocks, JS codegen
32
+ - latest Recollect main: 9/9 native tests, generated-JS tests, production build, and required WASM checks
33
+
@@ -0,0 +1,20 @@
1
+ # Legacy macro schema inventory
2
+
3
+ ## Summary
4
+
5
+ - Added the stable `W_LEGACY_MACRO_SCHEMA` diagnostic to `analyze check-types`.
6
+ - Preserved whether a compatibility macro came from an old runtime `Fn` schema or a whole `Dynamic` schema.
7
+ - Added check-types JSON schema v2 fields for the aggregate count and per-definition source, legacy signature, Snapshot path, and migration guidance.
8
+ - Kept compatibility loading and execution unchanged; the analyzer does not infer phase-aware contracts.
9
+
10
+ ## Release constraint
11
+
12
+ Release audits must use `check-types --deps` against resolved module artifacts. A dependency's main branch may already be strict while its published module still exposes legacy macro schemas. Migrate and release providers before setting consumer graphs to a zero-legacy target.
13
+
14
+ ## Validation
15
+
16
+ - `cargo fmt --all`
17
+ - `cargo clippy --all-targets -- -D warnings`
18
+ - `cargo test`
19
+ - `yarn check-all`
20
+ - latest Respo and Recollect source plus Recollect's resolved published dependency graph
@@ -0,0 +1,19 @@
1
+ # Legacy macro inventory review follow-up
2
+
3
+ ## Summary
4
+
5
+ - Persisted the `Dynamic` legacy macro origin through canonical Snapshot serialization instead of reclassifying it as `Fn` after reload.
6
+ - Limited legacy macro parameter-shape validation to old `Fn` contracts; a whole-`Dynamic` schema carries no arity contract.
7
+ - Corrected the Agent guide to use the complete `data.summary.legacy_macro_schemas` JSON path.
8
+
9
+ ## Compatibility
10
+
11
+ Old wrapped macro schemas omit `:legacy-origin` and continue to load as `Fn`. Only whole-`Dynamic` compatibility schemas write `:legacy-origin :dynamic`, so existing `Fn` serialization remains unchanged.
12
+
13
+ ## Validation
14
+
15
+ - focused origin round-trip and Dynamic-parameter regression tests
16
+ - `cargo fmt --all -- --check`
17
+ - `cargo clippy --all-targets -- -D warnings`
18
+ - `cargo test -- --test-threads=1`
19
+ - `yarn check-all`
@@ -0,0 +1,6 @@
1
+ # Release 0.13.51
2
+
3
+ - Added nominal `FsPath` values and explicit filesystem effect methods.
4
+ - Retired top-level `:configs` and the `compact.cirru` filename alias after the 0.13.50 migration window.
5
+ - Added dependency-aware legacy macro schema inventory and schema-v2 `check-types` diagnostics for the staged strict-macro rollout.
6
+ - Kept Cargo and npm package versions synchronized and refreshed the workspace lockfile.
@@ -0,0 +1,28 @@
1
+ # Async FFI protocol foundation
2
+
3
+ ## Summary
4
+
5
+ - Defined a versioned, C-safe async task descriptor for one-shot, stream,
6
+ server, and response handles without changing the existing synchronous FFI.
7
+ - Added a thread-safe generational handle registry with ordered event
8
+ sequences, explicit close/finish/release transitions, and host shutdown.
9
+ - Retired exhausted generation slots so stale handles cannot become valid
10
+ again after counter wraparound.
11
+ - Documented the transport-neutral lifecycle intended for timers, watchers,
12
+ HTTP/WebSocket servers, and a future WASM adapter.
13
+
14
+ ## Compatibility constraint
15
+
16
+ Native libraries must enqueue events for the Calcit host instead of invoking
17
+ Calcit callbacks from foreign threads. The protocol models stable integer
18
+ handles and byte payloads; a WASM adapter may map them to imports/exports
19
+ without reproducing native pointers or function pointers.
20
+
21
+ ## Validation
22
+
23
+ - `cargo fmt --check`
24
+ - `cargo clippy -- -D warnings`
25
+ - `cargo test -- --test-threads=1`
26
+ - `yarn compile`
27
+ - `yarn check-agent-interface`
28
+ - `yarn check-all`
@@ -0,0 +1,29 @@
1
+ # Async FFI host event queue
2
+
3
+ ## Summary
4
+
5
+ - Added a C-layout event descriptor for repeating emit and terminal
6
+ complete/fail events.
7
+ - Added a bounded multi-producer queue that only its creating host thread may
8
+ wait on or drain into the Calcit runtime.
9
+ - Kept sequence reservation atomic with queue admission, made terminal events
10
+ exactly once, and limited coalescing to explicitly opted-in stream events.
11
+ - Returned callback and lifecycle failures as structured drain diagnostics;
12
+ callback failure finishes the task and purges its remaining queued events.
13
+ - Retained producer-thread and queue-delay metadata for low-payload FFI traces.
14
+
15
+ ## Compatibility constraint
16
+
17
+ Existing Rust callback and blocking dylib calls remain unchanged. This queue
18
+ is the scheduling foundation for the next C host-function-table PR; native
19
+ threads and a future WASM polling adapter share descriptors and lifecycle
20
+ semantics without sharing pointers or callback layouts.
21
+
22
+ ## Validation
23
+
24
+ - `cargo fmt --all`
25
+ - `cargo clippy --all-targets -- -D warnings`
26
+ - `cargo test -- --test-threads=1`
27
+ - `yarn compile`
28
+ - `yarn check-agent-interface`
29
+ - `yarn check-all`
@@ -0,0 +1,15 @@
1
+ # Preserve async FFI drain accounting
2
+
3
+ ## Summary
4
+
5
+ - Kept malformed event-kind failures inside the structured drain report rather
6
+ than returning after a batch had already been removed from the queue.
7
+ - Recorded queue-purge failures alongside callback and lifecycle failures.
8
+ - Separated discarded batch events from events purged before drain, preserving
9
+ the invariant that every dequeued event is delivered or discarded.
10
+
11
+ ## Validation
12
+
13
+ - `cargo fmt --all`
14
+ - `cargo clippy --all-targets -- -D warnings`
15
+ - `cargo test ffi_async::tests -- --nocapture`
@@ -0,0 +1,31 @@
1
+ # Native C-safe callback FFI v1
2
+
3
+ ## Goal
4
+
5
+ Move `&call-dylib-edn-fn` onto the versioned asynchronous C ABI without
6
+ breaking modules that still expose the guarded Rust callback ABI.
7
+
8
+ ## Changes
9
+
10
+ - added the versioned native async start symbol and process-lifetime C host
11
+ function table;
12
+ - copied and validated foreign byte payloads before placing them in the
13
+ bounded host queue;
14
+ - decoded `Emit` arguments on the CLI host thread, required explicit `&unit`
15
+ completion, and surfaced structured `Fail` diagnostics;
16
+ - reclaimed handles and tracking state on terminal delivery, callback failure,
17
+ and start failure;
18
+ - kept per-method fallback to the build-identity-guarded Rust ABI while making
19
+ an advertised version mismatch a hard error;
20
+ - added ABI, payload, foreign-producer, host-drain, lifecycle, and failure
21
+ regression coverage;
22
+ - documented symbols, ownership, payload rules, statuses, and rollout.
23
+
24
+ ## Verification
25
+
26
+ - `cargo fmt --all`
27
+ - `cargo clippy --all-targets -- -D warnings`
28
+ - `cargo test -- --test-threads=1`
29
+ - `yarn compile`
30
+ - `yarn check-agent-interface`
31
+ - `yarn check-all`
@@ -0,0 +1,45 @@
1
+ # Async FFI response and server protocol v1
2
+
3
+ ## Goal
4
+
5
+ Extend native callback-v1 with cancellable Server tasks and exactly-once
6
+ response capabilities without exposing generation handles as lossy Calcit
7
+ numbers or allowing foreign threads to enter the runtime.
8
+
9
+ ## Changes
10
+
11
+ - appended C-safe task configuration and response registration functions to
12
+ the versioned host table;
13
+ - allowed modules to declare OneShot, Stream, or Server semantics before the
14
+ first event and install a Server cancellation hook;
15
+ - returned opaque task capabilities from callback-v1 methods that install a
16
+ cancel hook, preserved `&unit` for non-cancellable methods, and added
17
+ `&ffi-task-cancel`;
18
+ - issued opaque AnyRef response capabilities, appended them to request callback
19
+ arguments, and added `&ffi-response-resolve` / `&ffi-response-reject`;
20
+ - enforced response owner, kind, active lifecycle, `REQUIRES_RESPONSE`, timeout,
21
+ and non-coalescing queue rules;
22
+ - rejected and released unresolved responses on timeout or owner completion,
23
+ while startup rollback discards handles without entering untransferred module
24
+ context;
25
+ - added registry configuration/snapshot, response queue invariants,
26
+ exactly-once/stale reuse, timeout, cross-server, and foreign producer tests;
27
+ - documented the expanded C ABI, Calcit capability API, ownership, timeout,
28
+ cancellation, backpressure, and WASM representation boundary.
29
+
30
+ ## Runtime verification
31
+
32
+ A standalone C dylib configured a cancellable Server, opened a response,
33
+ published a request from a pthread, received the Calcit response on the host
34
+ thread, enqueued explicit `&unit` completion, and released with pending task
35
+ count zero. A second idle Server fixture verified `&ffi-task-cancel` and its
36
+ terminal acknowledgement path.
37
+
38
+ ## Verification
39
+
40
+ - `cargo fmt --all`
41
+ - `cargo clippy --all-targets -- -D warnings`
42
+ - `cargo test -- --test-threads=1`
43
+ - `yarn compile`
44
+ - `yarn check-agent-interface`
45
+ - `yarn check-all`
@@ -0,0 +1,33 @@
1
+ # Async FFI response review fixes
2
+
3
+ ## 中文
4
+
5
+ - 将每个 host table 的 context 绑定到对应 task handle,阻止不同任务或模块意外复用 host context;
6
+ - 在调用 dylib resolver 前原子 claim response,保证并发 resolve/reject 只会进入模块一次,模块返回错误时也会释放 capability;
7
+ - 使用 ordered deadline index、response lookup 与 owner index 代替每轮 drain 和 task 结束时的全 registry clone/scan;
8
+ - 每个任务最多允许 1024 个并发未完成 response,避免只 open 不 enqueue 导致无界增长;
9
+ - response 在队列等待期间过期时只 reject/skip 当前 request,不再把整个长期 Server 标记失败并清空后续事件;
10
+ - 修正文档中的 `REQUIRES_RESPONSE` 术语,并补充 host table 生命周期、并发与超时语义。
11
+
12
+ ## English
13
+
14
+ - bound each host-table context to its task handle so another task or module cannot accidentally reuse it;
15
+ - atomically claim a response before entering the dylib resolver, ensuring concurrent resolve/reject attempts invoke the module at most once and release the capability even when the module reports an error;
16
+ - replaced full-registry clones/scans during drains and task completion with an ordered deadline index, response lookup, and owner index;
17
+ - capped concurrent outstanding responses at 1024 per task to prevent unbounded open-without-enqueue growth;
18
+ - reject and skip a request that expires in the queue without failing the long-lived Server or purging later events;
19
+ - aligned documentation with `REQUIRES_RESPONSE` terminology and clarified host-table lifetime, concurrency, and timeout semantics.
20
+
21
+ ## Validation
22
+
23
+ - `cargo fmt --all`;
24
+ - `cargo clippy --all-targets -- -D warnings`;
25
+ - `cargo test -- --test-threads=1` (855 Rust tests passed);
26
+ - `yarn compile`;
27
+ - `yarn check-agent-interface` (17/17);
28
+ - `yarn check-all` (Calcit core 221/221 plus JS, IR, WASM, and benchmark checks);
29
+ - rebuilt the standalone C dylib and verified pthread Server request → Calcit
30
+ callback → response resolver → explicit `&unit` completion with no runtime
31
+ errors;
32
+ - verified an idle Server task capability can still be cancelled and reaches
33
+ explicit `&unit` completion with no runtime errors.
package/lib/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@calcit/procs",
3
- "version": "0.13.50",
3
+ "version": "0.13.52",
4
4
  "main": "./lib/calcit.procs.mjs",
5
5
  "devDependencies": {
6
6
  "@types/node": "^25.7.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@calcit/procs",
3
- "version": "0.13.50",
3
+ "version": "0.13.52",
4
4
  "main": "./lib/calcit.procs.mjs",
5
5
  "devDependencies": {
6
6
  "@types/node": "^25.7.0",