@calcit/procs 0.13.51 → 0.13.53

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
@@ -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,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.
@@ -0,0 +1,8 @@
1
+ # C-safe opaque resource v1
2
+
3
+ - 在同步 buffer v1 上增加保留的 `CalcitFfiResourceV1` token,以 little-endian `u64` handle 和 generation 表示模块资源。
4
+ - 宿主将 token 水合为自动生命周期的 `AnyRef`,固定创建资源的 dylib,并在最后一个引用释放时 exactly-once 调用模块 C ABI release。
5
+ - 调用前递归校验资源归属;拒绝 wrong-module、普通 AnyRef、伪造 token 和畸形 token。
6
+ - 覆盖嵌套资源、并发 clone/drop、错误边界和协议格式测试,并为 `--trace-ffi` 增加资源创建与释放事件。
7
+ - 新增中英双语协议文档,并从 FFI bindings 与升级手册链接。
8
+
@@ -0,0 +1,7 @@
1
+ # Intern FFI resource leases
2
+
3
+ - 根据 review 修复重复 resource token 产生独立 lease、提前释放和重复释放的问题。
4
+ - 宿主按 `(module, handle, generation)` 保存 weak intern entry;同一响应及跨响应 alias 复用同一 lease。
5
+ - 最后一个强引用析构后 exactly-once release,并清理失效的 weak entry。
6
+ - 增加同响应重复 token 与跨响应重复 token 的回归测试,并同步协议文档。
7
+
@@ -0,0 +1,5 @@
1
+ # Release 0.13.53
2
+
3
+ - 发布 C-safe opaque resource protocol v1。
4
+ - 包含宿主资源归属校验、dylib pin、weak lease interning、自动 exactly-once release 与 trace 事件。
5
+ - 为 `calcit-regex` 的 Rust ABI/AnyRef 边界迁移提供正式版本基线。
package/lib/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@calcit/procs",
3
- "version": "0.13.51",
3
+ "version": "0.13.53",
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.51",
3
+ "version": "0.13.53",
4
4
  "main": "./lib/calcit.procs.mjs",
5
5
  "devDependencies": {
6
6
  "@types/node": "^25.7.0",