@czap/core 0.1.0

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 (372) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +19 -0
  3. package/dist/addressed-digest.d.ts +15 -0
  4. package/dist/addressed-digest.d.ts.map +1 -0
  5. package/dist/addressed-digest.js +35 -0
  6. package/dist/addressed-digest.js.map +1 -0
  7. package/dist/animation.d.ts +46 -0
  8. package/dist/animation.d.ts.map +1 -0
  9. package/dist/animation.js +70 -0
  10. package/dist/animation.js.map +1 -0
  11. package/dist/assembly.d.ts +25 -0
  12. package/dist/assembly.d.ts.map +1 -0
  13. package/dist/assembly.js +58 -0
  14. package/dist/assembly.js.map +1 -0
  15. package/dist/av-bridge.d.ts +74 -0
  16. package/dist/av-bridge.d.ts.map +1 -0
  17. package/dist/av-bridge.js +107 -0
  18. package/dist/av-bridge.js.map +1 -0
  19. package/dist/av-renderer.d.ts +56 -0
  20. package/dist/av-renderer.d.ts.map +1 -0
  21. package/dist/av-renderer.js +65 -0
  22. package/dist/av-renderer.js.map +1 -0
  23. package/dist/blend.d.ts +61 -0
  24. package/dist/blend.d.ts.map +1 -0
  25. package/dist/blend.js +100 -0
  26. package/dist/blend.js.map +1 -0
  27. package/dist/boundary.d.ts +154 -0
  28. package/dist/boundary.d.ts.map +1 -0
  29. package/dist/boundary.js +269 -0
  30. package/dist/boundary.js.map +1 -0
  31. package/dist/brands.d.ts +63 -0
  32. package/dist/brands.d.ts.map +1 -0
  33. package/dist/brands.js +31 -0
  34. package/dist/brands.js.map +1 -0
  35. package/dist/caps.d.ts +49 -0
  36. package/dist/caps.d.ts.map +1 -0
  37. package/dist/caps.js +73 -0
  38. package/dist/caps.js.map +1 -0
  39. package/dist/capsule.d.ts +77 -0
  40. package/dist/capsule.d.ts.map +1 -0
  41. package/dist/capsule.js +18 -0
  42. package/dist/capsule.js.map +1 -0
  43. package/dist/capsules/boundary-evaluate.d.ts +28 -0
  44. package/dist/capsules/boundary-evaluate.d.ts.map +1 -0
  45. package/dist/capsules/boundary-evaluate.js +117 -0
  46. package/dist/capsules/boundary-evaluate.js.map +1 -0
  47. package/dist/capsules/canonical-cbor.d.ts +13 -0
  48. package/dist/capsules/canonical-cbor.d.ts.map +1 -0
  49. package/dist/capsules/canonical-cbor.js +60 -0
  50. package/dist/capsules/canonical-cbor.js.map +1 -0
  51. package/dist/capsules/token-buffer.d.ts +24 -0
  52. package/dist/capsules/token-buffer.d.ts.map +1 -0
  53. package/dist/capsules/token-buffer.js +53 -0
  54. package/dist/capsules/token-buffer.js.map +1 -0
  55. package/dist/capture.d.ts +40 -0
  56. package/dist/capture.d.ts.map +1 -0
  57. package/dist/capture.js +10 -0
  58. package/dist/capture.js.map +1 -0
  59. package/dist/cbor.d.ts +33 -0
  60. package/dist/cbor.d.ts.map +1 -0
  61. package/dist/cbor.js +179 -0
  62. package/dist/cbor.js.map +1 -0
  63. package/dist/cell.d.ts +53 -0
  64. package/dist/cell.d.ts.map +1 -0
  65. package/dist/cell.js +83 -0
  66. package/dist/cell.js.map +1 -0
  67. package/dist/codec.d.ts +30 -0
  68. package/dist/codec.d.ts.map +1 -0
  69. package/dist/codec.js +25 -0
  70. package/dist/codec.js.map +1 -0
  71. package/dist/component.d.ts +52 -0
  72. package/dist/component.d.ts.map +1 -0
  73. package/dist/component.js +44 -0
  74. package/dist/component.js.map +1 -0
  75. package/dist/composable.d.ts +76 -0
  76. package/dist/composable.d.ts.map +1 -0
  77. package/dist/composable.js +221 -0
  78. package/dist/composable.js.map +1 -0
  79. package/dist/compositor-pool.d.ts +74 -0
  80. package/dist/compositor-pool.d.ts.map +1 -0
  81. package/dist/compositor-pool.js +119 -0
  82. package/dist/compositor-pool.js.map +1 -0
  83. package/dist/compositor.d.ts +90 -0
  84. package/dist/compositor.d.ts.map +1 -0
  85. package/dist/compositor.js +278 -0
  86. package/dist/compositor.js.map +1 -0
  87. package/dist/config.d.ts +72 -0
  88. package/dist/config.d.ts.map +1 -0
  89. package/dist/config.js +97 -0
  90. package/dist/config.js.map +1 -0
  91. package/dist/dag.d.ts +251 -0
  92. package/dist/dag.d.ts.map +1 -0
  93. package/dist/dag.js +450 -0
  94. package/dist/dag.js.map +1 -0
  95. package/dist/defaults.d.ts +45 -0
  96. package/dist/defaults.d.ts.map +1 -0
  97. package/dist/defaults.js +45 -0
  98. package/dist/defaults.js.map +1 -0
  99. package/dist/derived.d.ts +34 -0
  100. package/dist/derived.d.ts.map +1 -0
  101. package/dist/derived.js +101 -0
  102. package/dist/derived.js.map +1 -0
  103. package/dist/diagnostics.d.ts +77 -0
  104. package/dist/diagnostics.d.ts.map +1 -0
  105. package/dist/diagnostics.js +122 -0
  106. package/dist/diagnostics.js.map +1 -0
  107. package/dist/dirty.d.ts +55 -0
  108. package/dist/dirty.d.ts.map +1 -0
  109. package/dist/dirty.js +80 -0
  110. package/dist/dirty.js.map +1 -0
  111. package/dist/easing.d.ts +55 -0
  112. package/dist/easing.d.ts.map +1 -0
  113. package/dist/easing.js +291 -0
  114. package/dist/easing.js.map +1 -0
  115. package/dist/ecs.d.ts +105 -0
  116. package/dist/ecs.d.ts.map +1 -0
  117. package/dist/ecs.js +245 -0
  118. package/dist/ecs.js.map +1 -0
  119. package/dist/fnv.d.ts +14 -0
  120. package/dist/fnv.d.ts.map +1 -0
  121. package/dist/fnv.js +28 -0
  122. package/dist/fnv.js.map +1 -0
  123. package/dist/frame-budget.d.ts +73 -0
  124. package/dist/frame-budget.d.ts.map +1 -0
  125. package/dist/frame-budget.js +114 -0
  126. package/dist/frame-budget.js.map +1 -0
  127. package/dist/gen-frame.d.ts +102 -0
  128. package/dist/gen-frame.d.ts.map +1 -0
  129. package/dist/gen-frame.js +121 -0
  130. package/dist/gen-frame.js.map +1 -0
  131. package/dist/harness/arbitrary-from-schema.d.ts +28 -0
  132. package/dist/harness/arbitrary-from-schema.d.ts.map +1 -0
  133. package/dist/harness/arbitrary-from-schema.js +262 -0
  134. package/dist/harness/arbitrary-from-schema.js.map +1 -0
  135. package/dist/harness/cached-projection.d.ts +19 -0
  136. package/dist/harness/cached-projection.d.ts.map +1 -0
  137. package/dist/harness/cached-projection.js +39 -0
  138. package/dist/harness/cached-projection.js.map +1 -0
  139. package/dist/harness/index.d.ts +16 -0
  140. package/dist/harness/index.d.ts.map +1 -0
  141. package/dist/harness/index.js +15 -0
  142. package/dist/harness/index.js.map +1 -0
  143. package/dist/harness/policy-gate.d.ts +18 -0
  144. package/dist/harness/policy-gate.d.ts.map +1 -0
  145. package/dist/harness/policy-gate.js +46 -0
  146. package/dist/harness/policy-gate.js.map +1 -0
  147. package/dist/harness/pure-transform.d.ts +42 -0
  148. package/dist/harness/pure-transform.d.ts.map +1 -0
  149. package/dist/harness/pure-transform.js +76 -0
  150. package/dist/harness/pure-transform.js.map +1 -0
  151. package/dist/harness/receipted-mutation.d.ts +23 -0
  152. package/dist/harness/receipted-mutation.d.ts.map +1 -0
  153. package/dist/harness/receipted-mutation.js +52 -0
  154. package/dist/harness/receipted-mutation.js.map +1 -0
  155. package/dist/harness/scene-composition.d.ts +19 -0
  156. package/dist/harness/scene-composition.d.ts.map +1 -0
  157. package/dist/harness/scene-composition.js +47 -0
  158. package/dist/harness/scene-composition.js.map +1 -0
  159. package/dist/harness/site-adapter.d.ts +18 -0
  160. package/dist/harness/site-adapter.d.ts.map +1 -0
  161. package/dist/harness/site-adapter.js +38 -0
  162. package/dist/harness/site-adapter.js.map +1 -0
  163. package/dist/harness/state-machine.d.ts +19 -0
  164. package/dist/harness/state-machine.d.ts.map +1 -0
  165. package/dist/harness/state-machine.js +44 -0
  166. package/dist/harness/state-machine.js.map +1 -0
  167. package/dist/hlc.d.ts +99 -0
  168. package/dist/hlc.d.ts.map +1 -0
  169. package/dist/hlc.js +219 -0
  170. package/dist/hlc.js.map +1 -0
  171. package/dist/index.d.ts +104 -0
  172. package/dist/index.d.ts.map +1 -0
  173. package/dist/index.js +137 -0
  174. package/dist/index.js.map +1 -0
  175. package/dist/interpolate.d.ts +14 -0
  176. package/dist/interpolate.d.ts.map +1 -0
  177. package/dist/interpolate.js +31 -0
  178. package/dist/interpolate.js.map +1 -0
  179. package/dist/live-cell.d.ts +46 -0
  180. package/dist/live-cell.d.ts.map +1 -0
  181. package/dist/live-cell.js +154 -0
  182. package/dist/live-cell.js.map +1 -0
  183. package/dist/op.d.ts +58 -0
  184. package/dist/op.d.ts.map +1 -0
  185. package/dist/op.js +171 -0
  186. package/dist/op.js.map +1 -0
  187. package/dist/plan.d.ts +195 -0
  188. package/dist/plan.d.ts.map +1 -0
  189. package/dist/plan.js +211 -0
  190. package/dist/plan.js.map +1 -0
  191. package/dist/protocol.d.ts +33 -0
  192. package/dist/protocol.d.ts.map +1 -0
  193. package/dist/protocol.js +10 -0
  194. package/dist/protocol.js.map +1 -0
  195. package/dist/quantizer-types.d.ts +28 -0
  196. package/dist/quantizer-types.d.ts.map +1 -0
  197. package/dist/quantizer-types.js +9 -0
  198. package/dist/quantizer-types.js.map +1 -0
  199. package/dist/receipt.d.ts +294 -0
  200. package/dist/receipt.d.ts.map +1 -0
  201. package/dist/receipt.js +352 -0
  202. package/dist/receipt.js.map +1 -0
  203. package/dist/runtime-coordinator.d.ts +75 -0
  204. package/dist/runtime-coordinator.d.ts.map +1 -0
  205. package/dist/runtime-coordinator.js +149 -0
  206. package/dist/runtime-coordinator.js.map +1 -0
  207. package/dist/scheduler.d.ts +58 -0
  208. package/dist/scheduler.d.ts.map +1 -0
  209. package/dist/scheduler.js +109 -0
  210. package/dist/scheduler.js.map +1 -0
  211. package/dist/ship-capsule.d.ts +54 -0
  212. package/dist/ship-capsule.d.ts.map +1 -0
  213. package/dist/ship-capsule.js +142 -0
  214. package/dist/ship-capsule.js.map +1 -0
  215. package/dist/ship-manifest.d.ts +45 -0
  216. package/dist/ship-manifest.d.ts.map +1 -0
  217. package/dist/ship-manifest.js +175 -0
  218. package/dist/ship-manifest.js.map +1 -0
  219. package/dist/signal.d.ts +149 -0
  220. package/dist/signal.d.ts.map +1 -0
  221. package/dist/signal.js +277 -0
  222. package/dist/signal.js.map +1 -0
  223. package/dist/speculative.d.ts +67 -0
  224. package/dist/speculative.d.ts.map +1 -0
  225. package/dist/speculative.js +139 -0
  226. package/dist/speculative.js.map +1 -0
  227. package/dist/store.d.ts +39 -0
  228. package/dist/store.d.ts.map +1 -0
  229. package/dist/store.js +42 -0
  230. package/dist/store.js.map +1 -0
  231. package/dist/style.d.ts +119 -0
  232. package/dist/style.d.ts.map +1 -0
  233. package/dist/style.js +168 -0
  234. package/dist/style.js.map +1 -0
  235. package/dist/testing.d.ts +14 -0
  236. package/dist/testing.d.ts.map +1 -0
  237. package/dist/testing.js +14 -0
  238. package/dist/testing.js.map +1 -0
  239. package/dist/theme.d.ts +78 -0
  240. package/dist/theme.d.ts.map +1 -0
  241. package/dist/theme.js +109 -0
  242. package/dist/theme.js.map +1 -0
  243. package/dist/timeline.d.ts +45 -0
  244. package/dist/timeline.d.ts.map +1 -0
  245. package/dist/timeline.js +101 -0
  246. package/dist/timeline.js.map +1 -0
  247. package/dist/token-buffer.d.ts +43 -0
  248. package/dist/token-buffer.d.ts.map +1 -0
  249. package/dist/token-buffer.js +112 -0
  250. package/dist/token-buffer.js.map +1 -0
  251. package/dist/token.d.ts +107 -0
  252. package/dist/token.d.ts.map +1 -0
  253. package/dist/token.js +143 -0
  254. package/dist/token.js.map +1 -0
  255. package/dist/tuple.d.ts +16 -0
  256. package/dist/tuple.d.ts.map +1 -0
  257. package/dist/tuple.js +16 -0
  258. package/dist/tuple.js.map +1 -0
  259. package/dist/type-utils.d.ts +41 -0
  260. package/dist/type-utils.d.ts.map +1 -0
  261. package/dist/type-utils.js +10 -0
  262. package/dist/type-utils.js.map +1 -0
  263. package/dist/typed-ref.d.ts +50 -0
  264. package/dist/typed-ref.d.ts.map +1 -0
  265. package/dist/typed-ref.js +59 -0
  266. package/dist/typed-ref.js.map +1 -0
  267. package/dist/ui-quality.d.ts +50 -0
  268. package/dist/ui-quality.d.ts.map +1 -0
  269. package/dist/ui-quality.js +64 -0
  270. package/dist/ui-quality.js.map +1 -0
  271. package/dist/validation-error.d.ts +25 -0
  272. package/dist/validation-error.d.ts.map +1 -0
  273. package/dist/validation-error.js +32 -0
  274. package/dist/validation-error.js.map +1 -0
  275. package/dist/vector-clock.d.ts +46 -0
  276. package/dist/vector-clock.d.ts.map +1 -0
  277. package/dist/vector-clock.js +91 -0
  278. package/dist/vector-clock.js.map +1 -0
  279. package/dist/video.d.ts +62 -0
  280. package/dist/video.d.ts.map +1 -0
  281. package/dist/video.js +59 -0
  282. package/dist/video.js.map +1 -0
  283. package/dist/wasm-dispatch.d.ts +52 -0
  284. package/dist/wasm-dispatch.d.ts.map +1 -0
  285. package/dist/wasm-dispatch.js +204 -0
  286. package/dist/wasm-dispatch.js.map +1 -0
  287. package/dist/wasm-fallback.d.ts +19 -0
  288. package/dist/wasm-fallback.d.ts.map +1 -0
  289. package/dist/wasm-fallback.js +93 -0
  290. package/dist/wasm-fallback.js.map +1 -0
  291. package/dist/wire.d.ts +49 -0
  292. package/dist/wire.d.ts.map +1 -0
  293. package/dist/wire.js +201 -0
  294. package/dist/wire.js.map +1 -0
  295. package/dist/zap.d.ts +42 -0
  296. package/dist/zap.d.ts.map +1 -0
  297. package/dist/zap.js +172 -0
  298. package/dist/zap.js.map +1 -0
  299. package/package.json +71 -0
  300. package/src/addressed-digest.ts +48 -0
  301. package/src/animation.ts +103 -0
  302. package/src/assembly.ts +76 -0
  303. package/src/av-bridge.ts +161 -0
  304. package/src/av-renderer.ts +118 -0
  305. package/src/blend.ts +135 -0
  306. package/src/boundary.ts +363 -0
  307. package/src/brands.ts +86 -0
  308. package/src/caps.ts +100 -0
  309. package/src/capsule.ts +95 -0
  310. package/src/capsules/boundary-evaluate.ts +128 -0
  311. package/src/capsules/canonical-cbor.ts +60 -0
  312. package/src/capsules/token-buffer.ts +57 -0
  313. package/src/capture.ts +48 -0
  314. package/src/cbor.ts +199 -0
  315. package/src/cell.ts +130 -0
  316. package/src/codec.ts +39 -0
  317. package/src/component.ts +102 -0
  318. package/src/composable.ts +328 -0
  319. package/src/compositor-pool.ts +162 -0
  320. package/src/compositor.ts +387 -0
  321. package/src/config.ts +157 -0
  322. package/src/dag.ts +527 -0
  323. package/src/defaults.ts +60 -0
  324. package/src/derived.ts +164 -0
  325. package/src/diagnostics.ts +186 -0
  326. package/src/dirty.ts +101 -0
  327. package/src/easing.ts +334 -0
  328. package/src/ecs.ts +382 -0
  329. package/src/fnv.ts +31 -0
  330. package/src/frame-budget.ts +149 -0
  331. package/src/gen-frame.ts +229 -0
  332. package/src/harness/arbitrary-from-schema.ts +270 -0
  333. package/src/harness/cached-projection.ts +46 -0
  334. package/src/harness/index.ts +16 -0
  335. package/src/harness/policy-gate.ts +51 -0
  336. package/src/harness/pure-transform.ts +121 -0
  337. package/src/harness/receipted-mutation.ts +59 -0
  338. package/src/harness/scene-composition.ts +54 -0
  339. package/src/harness/site-adapter.ts +43 -0
  340. package/src/harness/state-machine.ts +49 -0
  341. package/src/hlc.ts +238 -0
  342. package/src/index.ts +274 -0
  343. package/src/interpolate.ts +37 -0
  344. package/src/live-cell.ts +199 -0
  345. package/src/op.ts +233 -0
  346. package/src/plan.ts +317 -0
  347. package/src/protocol.ts +49 -0
  348. package/src/quantizer-types.ts +29 -0
  349. package/src/receipt.ts +444 -0
  350. package/src/runtime-coordinator.ts +230 -0
  351. package/src/scheduler.ts +161 -0
  352. package/src/ship-capsule.ts +191 -0
  353. package/src/signal.ts +345 -0
  354. package/src/speculative.ts +186 -0
  355. package/src/store.ts +77 -0
  356. package/src/style.ts +249 -0
  357. package/src/testing.ts +14 -0
  358. package/src/theme.ts +153 -0
  359. package/src/timeline.ts +146 -0
  360. package/src/token-buffer.ts +151 -0
  361. package/src/token.ts +197 -0
  362. package/src/tuple.ts +19 -0
  363. package/src/type-utils.ts +48 -0
  364. package/src/typed-ref.ts +79 -0
  365. package/src/ui-quality.ts +105 -0
  366. package/src/validation-error.ts +34 -0
  367. package/src/vector-clock.ts +111 -0
  368. package/src/video.ts +106 -0
  369. package/src/wasm-dispatch.ts +300 -0
  370. package/src/wasm-fallback.ts +102 -0
  371. package/src/wire.ts +274 -0
  372. package/src/zap.ts +241 -0
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Harness template for the `pureTransform` assembly arm.
3
+ *
4
+ * Emits a property test per declared invariant: derives a fast-check
5
+ * arbitrary from the capsule's input schema (`schemaToArbitrary`),
6
+ * invokes the capsule's `run` handler against each sample, and asserts
7
+ * the invariant `check(input, output)` holds.
8
+ *
9
+ * If the capsule does not export a `run` handler the test is emitted as
10
+ * `it.skip` with a TODO comment — vacuous `() => true` placeholders are
11
+ * banned (per memory: "no vanity tests, real APIs, deterministic
12
+ * assertions").
13
+ *
14
+ * @module
15
+ */
16
+ import type { CapsuleDef } from '../assembly.js';
17
+ /** Emitted file contents for a capsule harness (test + bench pair). */
18
+ export interface HarnessOutput {
19
+ readonly testFile: string;
20
+ readonly benchFile: string;
21
+ }
22
+ /**
23
+ * Optional metadata the compile-time driver passes to harness templates so
24
+ * the generated test file can `import` the real capsule binding from its
25
+ * source file. When `bindingImport` is undefined, the harness emits an
26
+ * `it.skip` placeholder rather than a vacuous test.
27
+ */
28
+ export interface HarnessContext {
29
+ /** ESM-style import specifier (with `.js` extension) for the test file. */
30
+ readonly bindingImport?: string;
31
+ /** Exported binding name to import from `bindingImport`. */
32
+ readonly bindingName?: string;
33
+ /** Import specifier for `schemaToArbitrary`, default to source path. */
34
+ readonly arbitraryImport?: string;
35
+ }
36
+ /**
37
+ * Generate the test + bench file contents for a `pureTransform` capsule.
38
+ * The emitted files are strings; the repo compiler writes them to
39
+ * `tests/generated/<name>.{test,bench}.ts`.
40
+ */
41
+ export declare function generatePureTransform(cap: CapsuleDef<'pureTransform', unknown, unknown, unknown>, ctx?: HarnessContext): HarnessOutput;
42
+ //# sourceMappingURL=pure-transform.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pure-transform.d.ts","sourceRoot":"","sources":["../../src/harness/pure-transform.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEjD,uEAAuE;AACvE,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAED;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC7B,2EAA2E;IAC3E,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC,4DAA4D;IAC5D,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,wEAAwE;IACxE,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;CACnC;AAID;;;;GAIG;AACH,wBAAgB,qBAAqB,CACnC,GAAG,EAAE,UAAU,CAAC,eAAe,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,EAC3D,GAAG,GAAE,cAAmB,GACvB,aAAa,CAwEf"}
@@ -0,0 +1,76 @@
1
+ const DEFAULT_ARBITRARY_IMPORT = '../../packages/core/src/harness/arbitrary-from-schema.js';
2
+ /**
3
+ * Generate the test + bench file contents for a `pureTransform` capsule.
4
+ * The emitted files are strings; the repo compiler writes them to
5
+ * `tests/generated/<name>.{test,bench}.ts`.
6
+ */
7
+ export function generatePureTransform(cap, ctx = {}) {
8
+ const arbitraryImport = ctx.arbitraryImport ?? DEFAULT_ARBITRARY_IMPORT;
9
+ if (ctx.bindingImport === undefined || ctx.bindingName === undefined) {
10
+ // No real binding wired — emit honest skip per task constraint.
11
+ const testFile = `// GENERATED — do not edit by hand
12
+ import { describe, it } from 'vitest';
13
+
14
+ describe('${cap.name}', () => {
15
+ it.skip('invariants under random input (no binding wired)', () => {
16
+ // TODO(harness): no capsule binding import wired by capsule-compile.
17
+ // Add bindingImport + bindingName to the manifest entry to enable.
18
+ });
19
+ });
20
+ `;
21
+ const benchFile = `// GENERATED — do not edit by hand
22
+ import { bench } from 'vitest';
23
+
24
+ bench('${cap.name}', () => {
25
+ // handler invocation with a canonical fixture
26
+ }, { time: 500 });
27
+ `;
28
+ return { testFile, benchFile };
29
+ }
30
+ const testFile = `// GENERATED — do not edit by hand
31
+ import { describe, it } from 'vitest';
32
+ import * as fc from 'fast-check';
33
+ import { ${ctx.bindingName} } from '${ctx.bindingImport}';
34
+ import { schemaToArbitrary, UnsupportedSchemaError } from '${arbitraryImport}';
35
+
36
+ describe('${cap.name}', () => {
37
+ const cap = ${ctx.bindingName};
38
+ let arb: fc.Arbitrary<unknown>;
39
+ let arbError: unknown;
40
+ try {
41
+ arb = schemaToArbitrary(cap.input as never) as fc.Arbitrary<unknown>;
42
+ } catch (err) {
43
+ arbError = err;
44
+ }
45
+ if (cap.run === undefined || arbError !== undefined) {
46
+ it.skip(
47
+ arbError instanceof UnsupportedSchemaError
48
+ ? \`invariants — input schema not arbitrary-derivable (\${arbError.message})\`
49
+ : 'invariants — capsule has no run handler',
50
+ () => {},
51
+ );
52
+ } else {
53
+ for (const inv of cap.invariants) {
54
+ it(\`invariant: \${inv.name}\`, () => {
55
+ fc.assert(
56
+ fc.property(arb, (input) => {
57
+ const output = cap.run!(input as never);
58
+ return inv.check(input as never, output as never);
59
+ }),
60
+ { numRuns: 100 },
61
+ );
62
+ });
63
+ }
64
+ }
65
+ });
66
+ `;
67
+ const benchFile = `// GENERATED — do not edit by hand
68
+ import { bench } from 'vitest';
69
+
70
+ bench('${cap.name}', () => {
71
+ // handler invocation with a canonical fixture
72
+ }, { time: 500 });
73
+ `;
74
+ return { testFile, benchFile };
75
+ }
76
+ //# sourceMappingURL=pure-transform.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pure-transform.js","sourceRoot":"","sources":["../../src/harness/pure-transform.ts"],"names":[],"mappings":"AAsCA,MAAM,wBAAwB,GAAG,0DAA0D,CAAC;AAE5F;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CACnC,GAA2D,EAC3D,MAAsB,EAAE;IAExB,MAAM,eAAe,GAAG,GAAG,CAAC,eAAe,IAAI,wBAAwB,CAAC;IAExE,IAAI,GAAG,CAAC,aAAa,KAAK,SAAS,IAAI,GAAG,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;QACrE,gEAAgE;QAChE,MAAM,QAAQ,GAAG;;;YAGT,GAAG,CAAC,IAAI;;;;;;CAMnB,CAAC;QACE,MAAM,SAAS,GAAG;;;SAGb,GAAG,CAAC,IAAI;;;CAGhB,CAAC;QACE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;IACjC,CAAC;IAED,MAAM,QAAQ,GAAG;;;WAGR,GAAG,CAAC,WAAW,YAAY,GAAG,CAAC,aAAa;6DACM,eAAe;;YAEhE,GAAG,CAAC,IAAI;gBACJ,GAAG,CAAC,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6B9B,CAAC;IAEA,MAAM,SAAS,GAAG;;;SAGX,GAAG,CAAC,IAAI;;;CAGhB,CAAC;IAEA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;AACjC,CAAC"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Harness template for the `receiptedMutation` assembly arm.
3
+ *
4
+ * Receipted mutations have side effects, so the harness can't drive them
5
+ * with random inputs and assert generic invariants. Each test case is
6
+ * emitted as `it.skip` with a TODO until the arm acquires a typed
7
+ * runtime invocation channel.
8
+ *
9
+ * Per memory: "no vanity tests" — emitting a `() => true` placeholder
10
+ * pretending to verify behavior is worse than skipping honestly.
11
+ *
12
+ * @module
13
+ */
14
+ import type { CapsuleDef } from '../assembly.js';
15
+ import type { HarnessOutput } from './pure-transform.js';
16
+ /**
17
+ * Generate the test + bench file contents for a `receiptedMutation` capsule.
18
+ * Emits `it.skip` placeholders covering contract shape, idempotency, audit
19
+ * receipt, and fault reachability — each carries a TODO naming the
20
+ * invocation channel it would need.
21
+ */
22
+ export declare function generateReceiptedMutation(cap: CapsuleDef<'receiptedMutation', unknown, unknown, unknown>): HarnessOutput;
23
+ //# sourceMappingURL=receipted-mutation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"receipted-mutation.d.ts","sourceRoot":"","sources":["../../src/harness/receipted-mutation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD;;;;;GAKG;AACH,wBAAgB,yBAAyB,CACvC,GAAG,EAAE,UAAU,CAAC,mBAAmB,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,GAC9D,aAAa,CAiCf"}
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Harness template for the `receiptedMutation` assembly arm.
3
+ *
4
+ * Receipted mutations have side effects, so the harness can't drive them
5
+ * with random inputs and assert generic invariants. Each test case is
6
+ * emitted as `it.skip` with a TODO until the arm acquires a typed
7
+ * runtime invocation channel.
8
+ *
9
+ * Per memory: "no vanity tests" — emitting a `() => true` placeholder
10
+ * pretending to verify behavior is worse than skipping honestly.
11
+ *
12
+ * @module
13
+ */
14
+ /**
15
+ * Generate the test + bench file contents for a `receiptedMutation` capsule.
16
+ * Emits `it.skip` placeholders covering contract shape, idempotency, audit
17
+ * receipt, and fault reachability — each carries a TODO naming the
18
+ * invocation channel it would need.
19
+ */
20
+ export function generateReceiptedMutation(cap) {
21
+ const testFile = `// GENERATED — do not edit by hand
22
+ import { describe, it } from 'vitest';
23
+
24
+ describe('${cap.name}', () => {
25
+ it.skip('contract shape: input and output decode/encode round-trip', () => {
26
+ // TODO(harness): wire schema round-trip via cap.input / cap.output.
27
+ });
28
+
29
+ it.skip('is idempotent: two identical inputs produce equivalent receipts', () => {
30
+ // TODO(harness): receipted mutations need a runtime channel to invoke
31
+ // — until cap exposes a typed mutate handler, skip rather than fake.
32
+ });
33
+
34
+ it.skip('emits audit receipt with declared capabilities', () => {
35
+ // TODO(harness): same — needs runtime channel to read emitted receipts.
36
+ });
37
+
38
+ it.skip('fault injection: declared faults are reachable', () => {
39
+ // TODO(harness): faults table not yet on the capsule contract.
40
+ });
41
+ });
42
+ `;
43
+ const benchFile = `// GENERATED — do not edit by hand
44
+ import { bench } from 'vitest';
45
+
46
+ bench('${cap.name}', () => {
47
+ // mutation invocation with a canonical fixture
48
+ }, { time: 500 });
49
+ `;
50
+ return { testFile, benchFile };
51
+ }
52
+ //# sourceMappingURL=receipted-mutation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"receipted-mutation.js","sourceRoot":"","sources":["../../src/harness/receipted-mutation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAKH;;;;;GAKG;AACH,MAAM,UAAU,yBAAyB,CACvC,GAA+D;IAE/D,MAAM,QAAQ,GAAG;;;YAGP,GAAG,CAAC,IAAI;;;;;;;;;;;;;;;;;;CAkBnB,CAAC;IAEA,MAAM,SAAS,GAAG;;;SAGX,GAAG,CAAC,IAAI;;;CAGhB,CAAC;IAEA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;AACjC,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Harness template for the `sceneComposition` assembly arm.
3
+ *
4
+ * Scene composition tests need a deterministic frame-stream channel
5
+ * (`compileScene` + `renderFrame`) on the capsule contract to drive
6
+ * determinism, sync-accuracy, per-frame budget, and invariant
7
+ * preservation. Without that channel each case is emitted as `it.skip`.
8
+ *
9
+ * @module
10
+ */
11
+ import type { CapsuleDef } from '../assembly.js';
12
+ import type { HarnessOutput } from './pure-transform.js';
13
+ /**
14
+ * Generate the test + bench file contents for a `sceneComposition` capsule.
15
+ * Emits `it.skip` placeholders for determinism, sync, budget, and
16
+ * invariant-preservation cases.
17
+ */
18
+ export declare function generateSceneComposition(cap: CapsuleDef<'sceneComposition', unknown, unknown, unknown>): HarnessOutput;
19
+ //# sourceMappingURL=scene-composition.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scene-composition.d.ts","sourceRoot":"","sources":["../../src/harness/scene-composition.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD;;;;GAIG;AACH,wBAAgB,wBAAwB,CACtC,GAAG,EAAE,UAAU,CAAC,kBAAkB,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,GAC7D,aAAa,CAgCf"}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Harness template for the `sceneComposition` assembly arm.
3
+ *
4
+ * Scene composition tests need a deterministic frame-stream channel
5
+ * (`compileScene` + `renderFrame`) on the capsule contract to drive
6
+ * determinism, sync-accuracy, per-frame budget, and invariant
7
+ * preservation. Without that channel each case is emitted as `it.skip`.
8
+ *
9
+ * @module
10
+ */
11
+ /**
12
+ * Generate the test + bench file contents for a `sceneComposition` capsule.
13
+ * Emits `it.skip` placeholders for determinism, sync, budget, and
14
+ * invariant-preservation cases.
15
+ */
16
+ export function generateSceneComposition(cap) {
17
+ const testFile = `// GENERATED — do not edit by hand
18
+ import { describe, it } from 'vitest';
19
+
20
+ describe('${cap.name}', () => {
21
+ it.skip('determinism: identical seed produces identical frame stream across 3 runs', () => {
22
+ // TODO(harness): needs cap.compile + cap.renderFrame on the contract.
23
+ });
24
+
25
+ it.skip('sync accuracy: audio and video frame timestamps align within +/- 1ms', () => {
26
+ // TODO(harness): same — needs typed frame stream.
27
+ });
28
+
29
+ it.skip('per-frame budget: p95 frame time below declared budget (${cap.budgets.p95Ms ?? 'n/a'}ms)', () => {
30
+ // TODO(harness): needs cap.renderFrame to time individual frames.
31
+ });
32
+
33
+ it.skip('invariant preservation: every declared scene invariant holds across playback', () => {
34
+ // TODO(harness): same — needs frame walker.
35
+ });
36
+ });
37
+ `;
38
+ const benchFile = `// GENERATED — do not edit by hand
39
+ import { bench } from 'vitest';
40
+
41
+ bench('${cap.name} — full playback', () => {
42
+ // render full scene duration, measure total wall-clock
43
+ }, { time: 2000 });
44
+ `;
45
+ return { testFile, benchFile };
46
+ }
47
+ //# sourceMappingURL=scene-composition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scene-composition.js","sourceRoot":"","sources":["../../src/harness/scene-composition.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH;;;;GAIG;AACH,MAAM,UAAU,wBAAwB,CACtC,GAA8D;IAE9D,MAAM,QAAQ,GAAG;;;YAGP,GAAG,CAAC,IAAI;;;;;;;;;qEASiD,GAAG,CAAC,OAAO,CAAC,KAAK,IAAI,KAAK;;;;;;;;CAQ9F,CAAC;IAEA,MAAM,SAAS,GAAG;;;SAGX,GAAG,CAAC,IAAI;;;CAGhB,CAAC;IAEA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;AACjC,CAAC"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Harness template for the `siteAdapter` assembly arm.
3
+ *
4
+ * Site adapters convert between native host objects and czap representations.
5
+ * Without typed `toCzap` / `fromCzap` channels on the capsule contract the
6
+ * harness can't drive round-trip equality, so each case is emitted as
7
+ * `it.skip` rather than a vacuous placeholder.
8
+ *
9
+ * @module
10
+ */
11
+ import type { CapsuleDef } from '../assembly.js';
12
+ import type { HarnessOutput } from './pure-transform.js';
13
+ /**
14
+ * Generate the test + bench file contents for a `siteAdapter` capsule.
15
+ * Emits `it.skip` placeholders for round-trip and host-capability tests.
16
+ */
17
+ export declare function generateSiteAdapter(cap: CapsuleDef<'siteAdapter', unknown, unknown, unknown>): HarnessOutput;
18
+ //# sourceMappingURL=site-adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"site-adapter.d.ts","sourceRoot":"","sources":["../../src/harness/site-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,UAAU,CAAC,aAAa,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,GAAG,aAAa,CAwB5G"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Harness template for the `siteAdapter` assembly arm.
3
+ *
4
+ * Site adapters convert between native host objects and czap representations.
5
+ * Without typed `toCzap` / `fromCzap` channels on the capsule contract the
6
+ * harness can't drive round-trip equality, so each case is emitted as
7
+ * `it.skip` rather than a vacuous placeholder.
8
+ *
9
+ * @module
10
+ */
11
+ /**
12
+ * Generate the test + bench file contents for a `siteAdapter` capsule.
13
+ * Emits `it.skip` placeholders for round-trip and host-capability tests.
14
+ */
15
+ export function generateSiteAdapter(cap) {
16
+ const testFile = `// GENERATED — do not edit by hand
17
+ import { describe, it } from 'vitest';
18
+
19
+ describe('${cap.name}', () => {
20
+ it.skip('round-trip equality: native -> czap -> native preserves structure', () => {
21
+ // TODO(harness): needs cap.toCzap / cap.fromCzap on the contract.
22
+ });
23
+
24
+ it.skip('host capability matrix: each declared site supports the adapter', () => {
25
+ // TODO(harness): needs per-site dispatcher to invoke under each runtime.
26
+ });
27
+ });
28
+ `;
29
+ const benchFile = `// GENERATED — do not edit by hand
30
+ import { bench } from 'vitest';
31
+
32
+ bench('${cap.name}', () => {
33
+ // adapter call with a canonical native fixture
34
+ }, { time: 500 });
35
+ `;
36
+ return { testFile, benchFile };
37
+ }
38
+ //# sourceMappingURL=site-adapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"site-adapter.js","sourceRoot":"","sources":["../../src/harness/site-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,GAAyD;IAC3F,MAAM,QAAQ,GAAG;;;YAGP,GAAG,CAAC,IAAI;;;;;;;;;CASnB,CAAC;IAEA,MAAM,SAAS,GAAG;;;SAGX,GAAG,CAAC,IAAI;;;CAGhB,CAAC;IAEA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;AACjC,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Harness template for the `stateMachine` assembly arm.
3
+ *
4
+ * State machines need a typed `step(state, event)` channel to drive
5
+ * randomized event sequences and check invariants at every step. The
6
+ * capsule contract doesn't yet expose one, so each case is emitted as
7
+ * `it.skip` rather than a vacuous `() => true` placeholder.
8
+ *
9
+ * @module
10
+ */
11
+ import type { CapsuleDef } from '../assembly.js';
12
+ import type { HarnessOutput } from './pure-transform.js';
13
+ /**
14
+ * Generate the test + bench file contents for a `stateMachine` capsule.
15
+ * Emits `it.skip` placeholders covering illegal transitions, replay, and
16
+ * invariant preservation — each carries a TODO naming the missing handler.
17
+ */
18
+ export declare function generateStateMachine(cap: CapsuleDef<'stateMachine', unknown, unknown, unknown>): HarnessOutput;
19
+ //# sourceMappingURL=state-machine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state-machine.d.ts","sourceRoot":"","sources":["../../src/harness/state-machine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,UAAU,CAAC,cAAc,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,GAAG,aAAa,CA6B9G"}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Harness template for the `stateMachine` assembly arm.
3
+ *
4
+ * State machines need a typed `step(state, event)` channel to drive
5
+ * randomized event sequences and check invariants at every step. The
6
+ * capsule contract doesn't yet expose one, so each case is emitted as
7
+ * `it.skip` rather than a vacuous `() => true` placeholder.
8
+ *
9
+ * @module
10
+ */
11
+ /**
12
+ * Generate the test + bench file contents for a `stateMachine` capsule.
13
+ * Emits `it.skip` placeholders covering illegal transitions, replay, and
14
+ * invariant preservation — each carries a TODO naming the missing handler.
15
+ */
16
+ export function generateStateMachine(cap) {
17
+ const testFile = `// GENERATED — do not edit by hand
18
+ import { describe, it } from 'vitest';
19
+
20
+ describe('${cap.name}', () => {
21
+ it.skip('rejects every illegal transition', () => {
22
+ // TODO(harness): needs cap.transitions table + cap.step handler.
23
+ });
24
+
25
+ it.skip('replays deterministically from an event log', () => {
26
+ // TODO(harness): needs cap.step + cap.initialState.
27
+ });
28
+
29
+ it.skip('invariant holds across random event paths', () => {
30
+ // TODO(harness): same — schemaToArbitrary on cap.input would feed
31
+ // events, but invariants need (state, event) → state to be checkable.
32
+ });
33
+ });
34
+ `;
35
+ const benchFile = `// GENERATED — do not edit by hand
36
+ import { bench } from 'vitest';
37
+
38
+ bench('${cap.name}', () => {
39
+ // state-machine step with a canonical event
40
+ }, { time: 500 });
41
+ `;
42
+ return { testFile, benchFile };
43
+ }
44
+ //# sourceMappingURL=state-machine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state-machine.js","sourceRoot":"","sources":["../../src/harness/state-machine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,GAA0D;IAC7F,MAAM,QAAQ,GAAG;;;YAGP,GAAG,CAAC,IAAI;;;;;;;;;;;;;;CAcnB,CAAC;IAEA,MAAM,SAAS,GAAG;;;SAGX,GAAG,CAAC,IAAI;;;CAGhB,CAAC;IAEA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;AACjC,CAAC"}
package/dist/hlc.d.ts ADDED
@@ -0,0 +1,99 @@
1
+ /**
2
+ * HLC -- Hybrid Logical Clock.
3
+ *
4
+ * Pure functions + Effect-based managed clock.
5
+ *
6
+ * @module
7
+ */
8
+ import type { Effect } from 'effect';
9
+ import { Ref } from 'effect';
10
+ interface HLCShape {
11
+ readonly wall_ms: number;
12
+ readonly counter: number;
13
+ readonly node_id: string;
14
+ }
15
+ /**
16
+ * Compare two HLC timestamps. Returns -1, 0, or 1.
17
+ *
18
+ * Compares wall_ms first, then counter, then node_id lexicographically.
19
+ *
20
+ * @example
21
+ * ```ts
22
+ * const a = HLC.create('node-1');
23
+ * const b = HLC.increment(a, 1000);
24
+ * const cmp = HLC.compare(a, b);
25
+ * // cmp === -1 (a is before b)
26
+ * ```
27
+ */
28
+ export declare const compare: (a: HLCShape, b: HLCShape) => -1 | 0 | 1;
29
+ /**
30
+ * Create a managed HLC clock as an Effect Ref.
31
+ *
32
+ * @example
33
+ * ```ts
34
+ * import { Effect } from 'effect';
35
+ *
36
+ * const program = Effect.gen(function* () {
37
+ * const clock = yield* HLC.makeClock('node-1');
38
+ * const ts = yield* HLC.tick(clock);
39
+ * // ts.wall_ms === Date.now() (approximately)
40
+ * });
41
+ * ```
42
+ */
43
+ export declare const makeClock: (nodeId: string) => Effect.Effect<Ref.Ref<HLCShape>>;
44
+ /**
45
+ * Tick a managed clock forward, returning the new HLC timestamp.
46
+ *
47
+ * @example
48
+ * ```ts
49
+ * const ts = yield* HLC.tick(clock);
50
+ * // ts.wall_ms >= previous wall_ms
51
+ * ```
52
+ */
53
+ export declare const tick: (clock: Ref.Ref<HLCShape>) => Effect.Effect<HLCShape>;
54
+ /**
55
+ * Receive a remote HLC timestamp and merge it into the managed clock.
56
+ *
57
+ * @example
58
+ * ```ts
59
+ * const remoteTs = HLC.decode(remoteEncoded);
60
+ * const merged = yield* HLC.receive(clock, remoteTs);
61
+ * // merged.wall_ms >= remoteTs.wall_ms
62
+ * ```
63
+ */
64
+ export declare const receive: (clock: Ref.Ref<HLCShape>, remote: HLCShape) => Effect.Effect<HLCShape>;
65
+ /**
66
+ * HLC namespace -- Hybrid Logical Clock.
67
+ *
68
+ * Pure functions for creating, comparing, incrementing, and merging HLC
69
+ * timestamps, plus Effect-based managed clock helpers. Encodes to/from
70
+ * a deterministic colon-separated hex string format.
71
+ *
72
+ * @example
73
+ * ```ts
74
+ * import { HLC } from '@czap/core';
75
+ *
76
+ * const a = HLC.increment(HLC.create('A'), Date.now());
77
+ * const b = HLC.increment(HLC.create('B'), Date.now());
78
+ * const merged = HLC.merge(a, b, Date.now());
79
+ * const encoded = HLC.encode(merged);
80
+ * const decoded = HLC.decode(encoded);
81
+ * ```
82
+ */
83
+ export declare const HLC: {
84
+ create: (nodeId: string) => HLCShape;
85
+ compare: (a: HLCShape, b: HLCShape) => -1 | 0 | 1;
86
+ increment: (hlc: HLCShape, now?: number) => HLCShape;
87
+ merge: (local: HLCShape, remote: HLCShape, now?: number) => HLCShape;
88
+ encode: (hlc: HLCShape) => string;
89
+ decode: (s: string) => HLCShape;
90
+ makeClock: (nodeId: string) => Effect.Effect<Ref.Ref<HLCShape>>;
91
+ tick: (clock: Ref.Ref<HLCShape>) => Effect.Effect<HLCShape>;
92
+ receive: (clock: Ref.Ref<HLCShape>, remote: HLCShape) => Effect.Effect<HLCShape>;
93
+ };
94
+ export declare namespace HLC {
95
+ /** Structural shape of a hybrid logical clock timestamp: `{ wall_ms, counter, node_id }`. */
96
+ type Shape = HLCShape;
97
+ }
98
+ export {};
99
+ //# sourceMappingURL=hlc.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hlc.d.ts","sourceRoot":"","sources":["../src/hlc.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAI7B,UAAU,QAAQ;IAChB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAiBD;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,OAAO,GAAI,GAAG,QAAQ,EAAE,GAAG,QAAQ,KAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAQ3D,CAAC;AA4GF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,SAAS,GAAI,QAAQ,MAAM,KAAG,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,CAA8B,CAAC;AAEzG;;;;;;;;GAQG;AACH,eAAO,MAAM,IAAI,GAAI,OAAO,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,CACC,CAAC;AAExE;;;;;;;;;GASG;AACH,eAAO,MAAM,OAAO,GAAI,OAAO,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,QAAQ,QAAQ,KAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,CAChB,CAAC;AAE5E;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,GAAG;qBAlMS,MAAM,KAAG,QAAQ;iBAmBf,QAAQ,KAAK,QAAQ,KAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC;qBA0BpC,QAAQ,QAAO,MAAM,KAAO,QAAQ;mBA8BtC,QAAQ,UAAU,QAAQ,QAAO,MAAM,KAAO,QAAQ;kBA+BvD,QAAQ,KAAG,MAAM;gBAkBnB,MAAM,KAAG,QAAQ;wBAyBH,MAAM,KAAG,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;kBAW/C,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC;qBAaxC,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,UAAU,QAAQ,KAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC;CA+B3F,CAAC;AAEF,MAAM,CAAC,OAAO,WAAW,GAAG,CAAC;IAC3B,6FAA6F;IAC7F,KAAY,KAAK,GAAG,QAAQ,CAAC;CAC9B"}