@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.
- package/LICENSE +21 -0
- package/README.md +19 -0
- package/dist/addressed-digest.d.ts +15 -0
- package/dist/addressed-digest.d.ts.map +1 -0
- package/dist/addressed-digest.js +35 -0
- package/dist/addressed-digest.js.map +1 -0
- package/dist/animation.d.ts +46 -0
- package/dist/animation.d.ts.map +1 -0
- package/dist/animation.js +70 -0
- package/dist/animation.js.map +1 -0
- package/dist/assembly.d.ts +25 -0
- package/dist/assembly.d.ts.map +1 -0
- package/dist/assembly.js +58 -0
- package/dist/assembly.js.map +1 -0
- package/dist/av-bridge.d.ts +74 -0
- package/dist/av-bridge.d.ts.map +1 -0
- package/dist/av-bridge.js +107 -0
- package/dist/av-bridge.js.map +1 -0
- package/dist/av-renderer.d.ts +56 -0
- package/dist/av-renderer.d.ts.map +1 -0
- package/dist/av-renderer.js +65 -0
- package/dist/av-renderer.js.map +1 -0
- package/dist/blend.d.ts +61 -0
- package/dist/blend.d.ts.map +1 -0
- package/dist/blend.js +100 -0
- package/dist/blend.js.map +1 -0
- package/dist/boundary.d.ts +154 -0
- package/dist/boundary.d.ts.map +1 -0
- package/dist/boundary.js +269 -0
- package/dist/boundary.js.map +1 -0
- package/dist/brands.d.ts +63 -0
- package/dist/brands.d.ts.map +1 -0
- package/dist/brands.js +31 -0
- package/dist/brands.js.map +1 -0
- package/dist/caps.d.ts +49 -0
- package/dist/caps.d.ts.map +1 -0
- package/dist/caps.js +73 -0
- package/dist/caps.js.map +1 -0
- package/dist/capsule.d.ts +77 -0
- package/dist/capsule.d.ts.map +1 -0
- package/dist/capsule.js +18 -0
- package/dist/capsule.js.map +1 -0
- package/dist/capsules/boundary-evaluate.d.ts +28 -0
- package/dist/capsules/boundary-evaluate.d.ts.map +1 -0
- package/dist/capsules/boundary-evaluate.js +117 -0
- package/dist/capsules/boundary-evaluate.js.map +1 -0
- package/dist/capsules/canonical-cbor.d.ts +13 -0
- package/dist/capsules/canonical-cbor.d.ts.map +1 -0
- package/dist/capsules/canonical-cbor.js +60 -0
- package/dist/capsules/canonical-cbor.js.map +1 -0
- package/dist/capsules/token-buffer.d.ts +24 -0
- package/dist/capsules/token-buffer.d.ts.map +1 -0
- package/dist/capsules/token-buffer.js +53 -0
- package/dist/capsules/token-buffer.js.map +1 -0
- package/dist/capture.d.ts +40 -0
- package/dist/capture.d.ts.map +1 -0
- package/dist/capture.js +10 -0
- package/dist/capture.js.map +1 -0
- package/dist/cbor.d.ts +33 -0
- package/dist/cbor.d.ts.map +1 -0
- package/dist/cbor.js +179 -0
- package/dist/cbor.js.map +1 -0
- package/dist/cell.d.ts +53 -0
- package/dist/cell.d.ts.map +1 -0
- package/dist/cell.js +83 -0
- package/dist/cell.js.map +1 -0
- package/dist/codec.d.ts +30 -0
- package/dist/codec.d.ts.map +1 -0
- package/dist/codec.js +25 -0
- package/dist/codec.js.map +1 -0
- package/dist/component.d.ts +52 -0
- package/dist/component.d.ts.map +1 -0
- package/dist/component.js +44 -0
- package/dist/component.js.map +1 -0
- package/dist/composable.d.ts +76 -0
- package/dist/composable.d.ts.map +1 -0
- package/dist/composable.js +221 -0
- package/dist/composable.js.map +1 -0
- package/dist/compositor-pool.d.ts +74 -0
- package/dist/compositor-pool.d.ts.map +1 -0
- package/dist/compositor-pool.js +119 -0
- package/dist/compositor-pool.js.map +1 -0
- package/dist/compositor.d.ts +90 -0
- package/dist/compositor.d.ts.map +1 -0
- package/dist/compositor.js +278 -0
- package/dist/compositor.js.map +1 -0
- package/dist/config.d.ts +72 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +97 -0
- package/dist/config.js.map +1 -0
- package/dist/dag.d.ts +251 -0
- package/dist/dag.d.ts.map +1 -0
- package/dist/dag.js +450 -0
- package/dist/dag.js.map +1 -0
- package/dist/defaults.d.ts +45 -0
- package/dist/defaults.d.ts.map +1 -0
- package/dist/defaults.js +45 -0
- package/dist/defaults.js.map +1 -0
- package/dist/derived.d.ts +34 -0
- package/dist/derived.d.ts.map +1 -0
- package/dist/derived.js +101 -0
- package/dist/derived.js.map +1 -0
- package/dist/diagnostics.d.ts +77 -0
- package/dist/diagnostics.d.ts.map +1 -0
- package/dist/diagnostics.js +122 -0
- package/dist/diagnostics.js.map +1 -0
- package/dist/dirty.d.ts +55 -0
- package/dist/dirty.d.ts.map +1 -0
- package/dist/dirty.js +80 -0
- package/dist/dirty.js.map +1 -0
- package/dist/easing.d.ts +55 -0
- package/dist/easing.d.ts.map +1 -0
- package/dist/easing.js +291 -0
- package/dist/easing.js.map +1 -0
- package/dist/ecs.d.ts +105 -0
- package/dist/ecs.d.ts.map +1 -0
- package/dist/ecs.js +245 -0
- package/dist/ecs.js.map +1 -0
- package/dist/fnv.d.ts +14 -0
- package/dist/fnv.d.ts.map +1 -0
- package/dist/fnv.js +28 -0
- package/dist/fnv.js.map +1 -0
- package/dist/frame-budget.d.ts +73 -0
- package/dist/frame-budget.d.ts.map +1 -0
- package/dist/frame-budget.js +114 -0
- package/dist/frame-budget.js.map +1 -0
- package/dist/gen-frame.d.ts +102 -0
- package/dist/gen-frame.d.ts.map +1 -0
- package/dist/gen-frame.js +121 -0
- package/dist/gen-frame.js.map +1 -0
- package/dist/harness/arbitrary-from-schema.d.ts +28 -0
- package/dist/harness/arbitrary-from-schema.d.ts.map +1 -0
- package/dist/harness/arbitrary-from-schema.js +262 -0
- package/dist/harness/arbitrary-from-schema.js.map +1 -0
- package/dist/harness/cached-projection.d.ts +19 -0
- package/dist/harness/cached-projection.d.ts.map +1 -0
- package/dist/harness/cached-projection.js +39 -0
- package/dist/harness/cached-projection.js.map +1 -0
- package/dist/harness/index.d.ts +16 -0
- package/dist/harness/index.d.ts.map +1 -0
- package/dist/harness/index.js +15 -0
- package/dist/harness/index.js.map +1 -0
- package/dist/harness/policy-gate.d.ts +18 -0
- package/dist/harness/policy-gate.d.ts.map +1 -0
- package/dist/harness/policy-gate.js +46 -0
- package/dist/harness/policy-gate.js.map +1 -0
- package/dist/harness/pure-transform.d.ts +42 -0
- package/dist/harness/pure-transform.d.ts.map +1 -0
- package/dist/harness/pure-transform.js +76 -0
- package/dist/harness/pure-transform.js.map +1 -0
- package/dist/harness/receipted-mutation.d.ts +23 -0
- package/dist/harness/receipted-mutation.d.ts.map +1 -0
- package/dist/harness/receipted-mutation.js +52 -0
- package/dist/harness/receipted-mutation.js.map +1 -0
- package/dist/harness/scene-composition.d.ts +19 -0
- package/dist/harness/scene-composition.d.ts.map +1 -0
- package/dist/harness/scene-composition.js +47 -0
- package/dist/harness/scene-composition.js.map +1 -0
- package/dist/harness/site-adapter.d.ts +18 -0
- package/dist/harness/site-adapter.d.ts.map +1 -0
- package/dist/harness/site-adapter.js +38 -0
- package/dist/harness/site-adapter.js.map +1 -0
- package/dist/harness/state-machine.d.ts +19 -0
- package/dist/harness/state-machine.d.ts.map +1 -0
- package/dist/harness/state-machine.js +44 -0
- package/dist/harness/state-machine.js.map +1 -0
- package/dist/hlc.d.ts +99 -0
- package/dist/hlc.d.ts.map +1 -0
- package/dist/hlc.js +219 -0
- package/dist/hlc.js.map +1 -0
- package/dist/index.d.ts +104 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +137 -0
- package/dist/index.js.map +1 -0
- package/dist/interpolate.d.ts +14 -0
- package/dist/interpolate.d.ts.map +1 -0
- package/dist/interpolate.js +31 -0
- package/dist/interpolate.js.map +1 -0
- package/dist/live-cell.d.ts +46 -0
- package/dist/live-cell.d.ts.map +1 -0
- package/dist/live-cell.js +154 -0
- package/dist/live-cell.js.map +1 -0
- package/dist/op.d.ts +58 -0
- package/dist/op.d.ts.map +1 -0
- package/dist/op.js +171 -0
- package/dist/op.js.map +1 -0
- package/dist/plan.d.ts +195 -0
- package/dist/plan.d.ts.map +1 -0
- package/dist/plan.js +211 -0
- package/dist/plan.js.map +1 -0
- package/dist/protocol.d.ts +33 -0
- package/dist/protocol.d.ts.map +1 -0
- package/dist/protocol.js +10 -0
- package/dist/protocol.js.map +1 -0
- package/dist/quantizer-types.d.ts +28 -0
- package/dist/quantizer-types.d.ts.map +1 -0
- package/dist/quantizer-types.js +9 -0
- package/dist/quantizer-types.js.map +1 -0
- package/dist/receipt.d.ts +294 -0
- package/dist/receipt.d.ts.map +1 -0
- package/dist/receipt.js +352 -0
- package/dist/receipt.js.map +1 -0
- package/dist/runtime-coordinator.d.ts +75 -0
- package/dist/runtime-coordinator.d.ts.map +1 -0
- package/dist/runtime-coordinator.js +149 -0
- package/dist/runtime-coordinator.js.map +1 -0
- package/dist/scheduler.d.ts +58 -0
- package/dist/scheduler.d.ts.map +1 -0
- package/dist/scheduler.js +109 -0
- package/dist/scheduler.js.map +1 -0
- package/dist/ship-capsule.d.ts +54 -0
- package/dist/ship-capsule.d.ts.map +1 -0
- package/dist/ship-capsule.js +142 -0
- package/dist/ship-capsule.js.map +1 -0
- package/dist/ship-manifest.d.ts +45 -0
- package/dist/ship-manifest.d.ts.map +1 -0
- package/dist/ship-manifest.js +175 -0
- package/dist/ship-manifest.js.map +1 -0
- package/dist/signal.d.ts +149 -0
- package/dist/signal.d.ts.map +1 -0
- package/dist/signal.js +277 -0
- package/dist/signal.js.map +1 -0
- package/dist/speculative.d.ts +67 -0
- package/dist/speculative.d.ts.map +1 -0
- package/dist/speculative.js +139 -0
- package/dist/speculative.js.map +1 -0
- package/dist/store.d.ts +39 -0
- package/dist/store.d.ts.map +1 -0
- package/dist/store.js +42 -0
- package/dist/store.js.map +1 -0
- package/dist/style.d.ts +119 -0
- package/dist/style.d.ts.map +1 -0
- package/dist/style.js +168 -0
- package/dist/style.js.map +1 -0
- package/dist/testing.d.ts +14 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +14 -0
- package/dist/testing.js.map +1 -0
- package/dist/theme.d.ts +78 -0
- package/dist/theme.d.ts.map +1 -0
- package/dist/theme.js +109 -0
- package/dist/theme.js.map +1 -0
- package/dist/timeline.d.ts +45 -0
- package/dist/timeline.d.ts.map +1 -0
- package/dist/timeline.js +101 -0
- package/dist/timeline.js.map +1 -0
- package/dist/token-buffer.d.ts +43 -0
- package/dist/token-buffer.d.ts.map +1 -0
- package/dist/token-buffer.js +112 -0
- package/dist/token-buffer.js.map +1 -0
- package/dist/token.d.ts +107 -0
- package/dist/token.d.ts.map +1 -0
- package/dist/token.js +143 -0
- package/dist/token.js.map +1 -0
- package/dist/tuple.d.ts +16 -0
- package/dist/tuple.d.ts.map +1 -0
- package/dist/tuple.js +16 -0
- package/dist/tuple.js.map +1 -0
- package/dist/type-utils.d.ts +41 -0
- package/dist/type-utils.d.ts.map +1 -0
- package/dist/type-utils.js +10 -0
- package/dist/type-utils.js.map +1 -0
- package/dist/typed-ref.d.ts +50 -0
- package/dist/typed-ref.d.ts.map +1 -0
- package/dist/typed-ref.js +59 -0
- package/dist/typed-ref.js.map +1 -0
- package/dist/ui-quality.d.ts +50 -0
- package/dist/ui-quality.d.ts.map +1 -0
- package/dist/ui-quality.js +64 -0
- package/dist/ui-quality.js.map +1 -0
- package/dist/validation-error.d.ts +25 -0
- package/dist/validation-error.d.ts.map +1 -0
- package/dist/validation-error.js +32 -0
- package/dist/validation-error.js.map +1 -0
- package/dist/vector-clock.d.ts +46 -0
- package/dist/vector-clock.d.ts.map +1 -0
- package/dist/vector-clock.js +91 -0
- package/dist/vector-clock.js.map +1 -0
- package/dist/video.d.ts +62 -0
- package/dist/video.d.ts.map +1 -0
- package/dist/video.js +59 -0
- package/dist/video.js.map +1 -0
- package/dist/wasm-dispatch.d.ts +52 -0
- package/dist/wasm-dispatch.d.ts.map +1 -0
- package/dist/wasm-dispatch.js +204 -0
- package/dist/wasm-dispatch.js.map +1 -0
- package/dist/wasm-fallback.d.ts +19 -0
- package/dist/wasm-fallback.d.ts.map +1 -0
- package/dist/wasm-fallback.js +93 -0
- package/dist/wasm-fallback.js.map +1 -0
- package/dist/wire.d.ts +49 -0
- package/dist/wire.d.ts.map +1 -0
- package/dist/wire.js +201 -0
- package/dist/wire.js.map +1 -0
- package/dist/zap.d.ts +42 -0
- package/dist/zap.d.ts.map +1 -0
- package/dist/zap.js +172 -0
- package/dist/zap.js.map +1 -0
- package/package.json +71 -0
- package/src/addressed-digest.ts +48 -0
- package/src/animation.ts +103 -0
- package/src/assembly.ts +76 -0
- package/src/av-bridge.ts +161 -0
- package/src/av-renderer.ts +118 -0
- package/src/blend.ts +135 -0
- package/src/boundary.ts +363 -0
- package/src/brands.ts +86 -0
- package/src/caps.ts +100 -0
- package/src/capsule.ts +95 -0
- package/src/capsules/boundary-evaluate.ts +128 -0
- package/src/capsules/canonical-cbor.ts +60 -0
- package/src/capsules/token-buffer.ts +57 -0
- package/src/capture.ts +48 -0
- package/src/cbor.ts +199 -0
- package/src/cell.ts +130 -0
- package/src/codec.ts +39 -0
- package/src/component.ts +102 -0
- package/src/composable.ts +328 -0
- package/src/compositor-pool.ts +162 -0
- package/src/compositor.ts +387 -0
- package/src/config.ts +157 -0
- package/src/dag.ts +527 -0
- package/src/defaults.ts +60 -0
- package/src/derived.ts +164 -0
- package/src/diagnostics.ts +186 -0
- package/src/dirty.ts +101 -0
- package/src/easing.ts +334 -0
- package/src/ecs.ts +382 -0
- package/src/fnv.ts +31 -0
- package/src/frame-budget.ts +149 -0
- package/src/gen-frame.ts +229 -0
- package/src/harness/arbitrary-from-schema.ts +270 -0
- package/src/harness/cached-projection.ts +46 -0
- package/src/harness/index.ts +16 -0
- package/src/harness/policy-gate.ts +51 -0
- package/src/harness/pure-transform.ts +121 -0
- package/src/harness/receipted-mutation.ts +59 -0
- package/src/harness/scene-composition.ts +54 -0
- package/src/harness/site-adapter.ts +43 -0
- package/src/harness/state-machine.ts +49 -0
- package/src/hlc.ts +238 -0
- package/src/index.ts +274 -0
- package/src/interpolate.ts +37 -0
- package/src/live-cell.ts +199 -0
- package/src/op.ts +233 -0
- package/src/plan.ts +317 -0
- package/src/protocol.ts +49 -0
- package/src/quantizer-types.ts +29 -0
- package/src/receipt.ts +444 -0
- package/src/runtime-coordinator.ts +230 -0
- package/src/scheduler.ts +161 -0
- package/src/ship-capsule.ts +191 -0
- package/src/signal.ts +345 -0
- package/src/speculative.ts +186 -0
- package/src/store.ts +77 -0
- package/src/style.ts +249 -0
- package/src/testing.ts +14 -0
- package/src/theme.ts +153 -0
- package/src/timeline.ts +146 -0
- package/src/token-buffer.ts +151 -0
- package/src/token.ts +197 -0
- package/src/tuple.ts +19 -0
- package/src/type-utils.ts +48 -0
- package/src/typed-ref.ts +79 -0
- package/src/ui-quality.ts +105 -0
- package/src/validation-error.ts +34 -0
- package/src/vector-clock.ts +111 -0
- package/src/video.ts +106 -0
- package/src/wasm-dispatch.ts +300 -0
- package/src/wasm-fallback.ts +102 -0
- package/src/wire.ts +274 -0
- package/src/zap.ts +241 -0
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GenFrame -- generative UI frame scheduler.
|
|
3
|
+
*
|
|
4
|
+
* Fixed-step scheduler producing "UI frames" at configurable fps
|
|
5
|
+
* from token buffer. Each frame classified as keyframe (I-frame),
|
|
6
|
+
* delta (P-frame), or interpolated (B-frame).
|
|
7
|
+
*
|
|
8
|
+
* Integrates with FrameBudget for priority scheduling and receipt
|
|
9
|
+
* chain for disconnect-resilient generative UI state.
|
|
10
|
+
*
|
|
11
|
+
* @module
|
|
12
|
+
*/
|
|
13
|
+
import { fnv1a } from './fnv.js';
|
|
14
|
+
function resolveGap(lastAckReceiptId, currentStreamPosition, receiptChain, resumptionState) {
|
|
15
|
+
// 1. Can the stream resume?
|
|
16
|
+
if (resumptionState.canResume) {
|
|
17
|
+
return { type: 'resume', bufferPosition: currentStreamPosition };
|
|
18
|
+
}
|
|
19
|
+
// 2. Do we have cached frames in the receipt chain?
|
|
20
|
+
if (receiptChain.hasFramesAfter(lastAckReceiptId)) {
|
|
21
|
+
const frames = receiptChain.getFramesAfter(lastAckReceiptId);
|
|
22
|
+
if (frames.length > 0) {
|
|
23
|
+
return { type: 'replay', frames };
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
// 3. Neither available — full re-request
|
|
27
|
+
return { type: 're-request', fromScratch: true };
|
|
28
|
+
}
|
|
29
|
+
// FNV-1a for receipt IDs — delegated to shared fnv.ts (see fnv.ts)
|
|
30
|
+
function _make(config) {
|
|
31
|
+
const { tokenBuffer, getQualityTier } = config;
|
|
32
|
+
let frameCount = 0;
|
|
33
|
+
let lastFrame = null;
|
|
34
|
+
let lastQualityTier = null;
|
|
35
|
+
let forceKeyframe = true; // First frame is always a keyframe
|
|
36
|
+
let totalTokensDrained = 0;
|
|
37
|
+
return {
|
|
38
|
+
tick() {
|
|
39
|
+
const tier = getQualityTier();
|
|
40
|
+
const tokens = tokenBuffer.drain(32); // Drain up to 32 tokens per frame
|
|
41
|
+
// Determine frame type
|
|
42
|
+
let type;
|
|
43
|
+
if (forceKeyframe || lastQualityTier !== tier) {
|
|
44
|
+
type = 'keyframe';
|
|
45
|
+
forceKeyframe = false;
|
|
46
|
+
}
|
|
47
|
+
else if (tokens.length === 0) {
|
|
48
|
+
// Stall — produce interpolated frame (CSS-only, no DOM mutation)
|
|
49
|
+
if (tokenBuffer.isStalled) {
|
|
50
|
+
type = 'interpolated';
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
// No tokens but not stalled — skip frame
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
type = 'delta';
|
|
59
|
+
}
|
|
60
|
+
// Determine morph strategy
|
|
61
|
+
let morphStrategy;
|
|
62
|
+
switch (type) {
|
|
63
|
+
case 'keyframe':
|
|
64
|
+
morphStrategy = 'replace';
|
|
65
|
+
break;
|
|
66
|
+
case 'interpolated':
|
|
67
|
+
morphStrategy = 'css-only';
|
|
68
|
+
break;
|
|
69
|
+
default:
|
|
70
|
+
morphStrategy = 'patch';
|
|
71
|
+
}
|
|
72
|
+
totalTokensDrained += tokens.length;
|
|
73
|
+
const now = typeof performance !== 'undefined' ? performance.now() : Date.now();
|
|
74
|
+
// Generate receipt ID from frame content
|
|
75
|
+
const receiptId = fnv1a(`${frameCount}:${now}:${tokens.join('')}`);
|
|
76
|
+
const frame = {
|
|
77
|
+
type,
|
|
78
|
+
tokens,
|
|
79
|
+
qualityTier: tier,
|
|
80
|
+
morphStrategy,
|
|
81
|
+
timestamp: now,
|
|
82
|
+
receiptId,
|
|
83
|
+
bufferPosition: totalTokensDrained,
|
|
84
|
+
};
|
|
85
|
+
lastFrame = frame;
|
|
86
|
+
lastQualityTier = tier;
|
|
87
|
+
frameCount++;
|
|
88
|
+
return frame;
|
|
89
|
+
},
|
|
90
|
+
get frameCount() {
|
|
91
|
+
return frameCount;
|
|
92
|
+
},
|
|
93
|
+
get lastFrame() {
|
|
94
|
+
return lastFrame;
|
|
95
|
+
},
|
|
96
|
+
markKeyframe() {
|
|
97
|
+
forceKeyframe = true;
|
|
98
|
+
},
|
|
99
|
+
reset() {
|
|
100
|
+
frameCount = 0;
|
|
101
|
+
lastFrame = null;
|
|
102
|
+
lastQualityTier = null;
|
|
103
|
+
forceKeyframe = true;
|
|
104
|
+
totalTokensDrained = 0;
|
|
105
|
+
},
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Generative-UI frame scheduler namespace.
|
|
110
|
+
*
|
|
111
|
+
* Turns a bursty LLM token stream into evenly-paced frames the DOM runtime
|
|
112
|
+
* can apply without stalling, and resolves disconnect gaps using the receipt
|
|
113
|
+
* chain or transport resumption.
|
|
114
|
+
*/
|
|
115
|
+
export const GenFrame = {
|
|
116
|
+
/** Create a new fixed-step scheduler bound to a {@link TokenBuffer} and quality-tier probe. */
|
|
117
|
+
make: _make,
|
|
118
|
+
/** Pick a recovery {@link GapStrategy} after a stream disconnect. */
|
|
119
|
+
resolveGap,
|
|
120
|
+
};
|
|
121
|
+
//# sourceMappingURL=gen-frame.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gen-frame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OAAO,KAAK,CAAC;QACf,CAAC;QAED,IAAI,UAAU;YACZ,OAAO,UAAU,CAAC;QACpB,CAAC;QAED,IAAI,SAAS;YACX,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,YAAY;YACV,aAAa,GAAG,IAAI,CAAC;QACvB,CAAC;QAED,KAAK;YACH,UAAU,GAAG,CAAC,CAAC;YACf,SAAS,GAAG,IAAI,CAAC;YACjB,eAAe,GAAG,IAAI,CAAC;YACvB,aAAa,GAAG,IAAI,CAAC;YACrB,kBAAkB,GAAG,CAAC,CAAC;QACzB,CAAC;KACF,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,+FAA+F;IAC/F,IAAI,EAAE,KAAK;IACX,qEAAqE;IACrE,UAAU;CACX,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Schema } from 'effect';
|
|
2
|
+
import * as fc from 'fast-check';
|
|
3
|
+
/** Error thrown when an AST node has no supported arbitrary mapping. */
|
|
4
|
+
export declare class UnsupportedSchemaError extends Error {
|
|
5
|
+
readonly _tag = "UnsupportedSchemaError";
|
|
6
|
+
readonly nodeTag: string;
|
|
7
|
+
constructor(nodeTag: string, hint?: string);
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Walk a `Schema` AST and return a `fc.Arbitrary` that produces values
|
|
11
|
+
* structurally conforming to the schema. Throws
|
|
12
|
+
* {@link UnsupportedSchemaError} on AST nodes with no supported mapping.
|
|
13
|
+
*
|
|
14
|
+
* Accepts any `Schema.Schema<T>` (or `Codec`) — only `.ast` is read.
|
|
15
|
+
*/
|
|
16
|
+
declare function _schemaToArbitrary<T>(schema: Schema.Schema<T>): fc.Arbitrary<T>;
|
|
17
|
+
/** Public namespace for the arbitrary-from-schema walker. */
|
|
18
|
+
export declare const ArbitraryFromSchema: {
|
|
19
|
+
readonly fromSchema: typeof _schemaToArbitrary;
|
|
20
|
+
};
|
|
21
|
+
/** Convenience top-level export — most call sites use this directly. */
|
|
22
|
+
export declare const schemaToArbitrary: typeof _schemaToArbitrary;
|
|
23
|
+
export declare namespace ArbitraryFromSchema {
|
|
24
|
+
/** The result type returned by {@link ArbitraryFromSchema.fromSchema}. */
|
|
25
|
+
type Result<T> = fc.Arbitrary<T>;
|
|
26
|
+
}
|
|
27
|
+
export {};
|
|
28
|
+
//# sourceMappingURL=arbitrary-from-schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arbitrary-from-schema.d.ts","sourceRoot":"","sources":["../../src/harness/arbitrary-from-schema.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,MAAM,EAAa,MAAM,QAAQ,CAAC;AAChD,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAEjC,wEAAwE;AACxE,qBAAa,sBAAuB,SAAQ,KAAK;IAC/C,QAAQ,CAAC,IAAI,4BAA4B;IACzC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;gBACb,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM;CAI3C;AAoND;;;;;;GAMG;AACH,iBAAS,kBAAkB,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,CAExE;AAED,6DAA6D;AAC7D,eAAO,MAAM,mBAAmB;;CAEtB,CAAC;AAEX,wEAAwE;AACxE,eAAO,MAAM,iBAAiB,2BAAqB,CAAC;AAEpD,MAAM,CAAC,OAAO,WAAW,mBAAmB,CAAC;IAC3C,0EAA0E;IAC1E,KAAY,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;CACzC"}
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* arbitrary-from-schema — derive a `fast-check` arbitrary from an Effect
|
|
3
|
+
* `Schema.Codec<T>`. Used by the harness templates so generated property
|
|
4
|
+
* tests feed real, schema-conformant inputs into capsule run handlers.
|
|
5
|
+
*
|
|
6
|
+
* Coverage: scalars (String, Number, Boolean, BigInt), Literal,
|
|
7
|
+
* Null/Undefined/Void, Unknown/Any, ObjectKeyword, Enum, Union, Array
|
|
8
|
+
* (Schema.Array + fixed Tuple + NonEmptyArray-style elements+rest),
|
|
9
|
+
* TypeLiteral (Struct with optional property signatures), Suspend,
|
|
10
|
+
* Declaration (Date specifically; throws for other declarations), and
|
|
11
|
+
* AST-level `checks` (Filter / FilterGroup) which model refinements
|
|
12
|
+
* such as `Schema.NonEmptyString` and `Schema.minLength(n)` — these
|
|
13
|
+
* post-filter the underlying arbitrary by running each Filter's
|
|
14
|
+
* predicate.
|
|
15
|
+
*
|
|
16
|
+
* KNOWN GAPS — these AST nodes throw `UnsupportedSchemaError` and the
|
|
17
|
+
* harness falls back to `it.skip` rather than a vacuous test:
|
|
18
|
+
* - Transformation (Schema.transform, Schema.compose chains)
|
|
19
|
+
* - TemplateLiteral (Schema.TemplateLiteral)
|
|
20
|
+
* - Declaration for non-Date opaque types (e.g. Uint8Array)
|
|
21
|
+
*
|
|
22
|
+
* @module
|
|
23
|
+
*/
|
|
24
|
+
import { Effect } from 'effect';
|
|
25
|
+
import * as fc from 'fast-check';
|
|
26
|
+
/** Error thrown when an AST node has no supported arbitrary mapping. */
|
|
27
|
+
export class UnsupportedSchemaError extends Error {
|
|
28
|
+
_tag = 'UnsupportedSchemaError';
|
|
29
|
+
nodeTag;
|
|
30
|
+
constructor(nodeTag, hint) {
|
|
31
|
+
super(`arbitrary-from-schema: AST node "${nodeTag}" is not supported${hint ? ` (${hint})` : ''}`);
|
|
32
|
+
this.nodeTag = nodeTag;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Apply post-type-match `checks` (Filter / FilterGroup) declared on the
|
|
37
|
+
* AST node to the produced arbitrary. Each Filter's `run` returns
|
|
38
|
+
* `Issue | undefined`; `undefined` means the input passed. We compose all
|
|
39
|
+
* checks and `.filter` the arbitrary so only conforming samples survive.
|
|
40
|
+
*
|
|
41
|
+
* fast-check throws if the filter rejection rate exceeds ~10%. For
|
|
42
|
+
* common refinements (NonEmptyString, minLength) the underlying
|
|
43
|
+
* arbitrary already biases toward populated values so rejection stays
|
|
44
|
+
* well below the threshold.
|
|
45
|
+
*/
|
|
46
|
+
function _applyChecks(ast, arb) {
|
|
47
|
+
const checks = ast.checks;
|
|
48
|
+
if (checks === undefined || checks.length === 0)
|
|
49
|
+
return arb;
|
|
50
|
+
return arb.filter((sample) => {
|
|
51
|
+
for (const check of checks) {
|
|
52
|
+
if (check._tag === 'Filter') {
|
|
53
|
+
// ParseOptions is opaque — pass an empty object; the runtime
|
|
54
|
+
// tolerates missing fields for filter execution.
|
|
55
|
+
const issue = check.run(sample, ast, {});
|
|
56
|
+
if (issue !== undefined)
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
else if (check._tag === 'FilterGroup') {
|
|
60
|
+
const group = check;
|
|
61
|
+
for (const inner of group.checks) {
|
|
62
|
+
if (inner._tag === 'Filter') {
|
|
63
|
+
const issue = inner.run(sample, ast, {});
|
|
64
|
+
if (issue !== undefined)
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
// Nested FilterGroup is theoretically possible but rare;
|
|
68
|
+
// ignore for now and let the outer test catch failures.
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return true;
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Probe a `Declaration` node to determine the JavaScript class it accepts.
|
|
77
|
+
* We attempt to construct a sentinel value and see whether the node's
|
|
78
|
+
* `run` parser accepts it. If yes, return a fast-check arbitrary that
|
|
79
|
+
* produces values of that shape. Otherwise throw.
|
|
80
|
+
*
|
|
81
|
+
* Currently supports `Date`. Add new probes here when production
|
|
82
|
+
* capsules require them.
|
|
83
|
+
*/
|
|
84
|
+
function _arbitraryForDeclaration(ast) {
|
|
85
|
+
const parser = ast.run(ast.typeParameters);
|
|
86
|
+
// Probe with `new Date()` — the most common Declaration in production.
|
|
87
|
+
const probeDate = new Date();
|
|
88
|
+
// The parser returns an Effect; we synchronously inspect via the
|
|
89
|
+
// runtime sync path. If it succeeds, the Declaration accepts Date.
|
|
90
|
+
// We avoid pulling in the full Effect runtime here — a try/catch
|
|
91
|
+
// around the parser's first sync step is enough for the probe.
|
|
92
|
+
let acceptsDate = false;
|
|
93
|
+
try {
|
|
94
|
+
const out = parser(probeDate, ast, {});
|
|
95
|
+
// The Effect returned by `out` succeeds synchronously when the
|
|
96
|
+
// input matches; failure surfaces as an Issue. We use Effect's
|
|
97
|
+
// `runSyncExit` to inspect the success/failure tag without
|
|
98
|
+
// throwing on parse failures.
|
|
99
|
+
const exit = Effect.runSyncExit(out);
|
|
100
|
+
acceptsDate = exit._tag === 'Success';
|
|
101
|
+
}
|
|
102
|
+
catch {
|
|
103
|
+
acceptsDate = false;
|
|
104
|
+
}
|
|
105
|
+
if (acceptsDate)
|
|
106
|
+
return fc.date();
|
|
107
|
+
throw new UnsupportedSchemaError('Declaration', 'opaque user-defined type — only Date is currently probed');
|
|
108
|
+
}
|
|
109
|
+
function walk(ast) {
|
|
110
|
+
let arb;
|
|
111
|
+
switch (ast._tag) {
|
|
112
|
+
case 'String':
|
|
113
|
+
arb = fc.string();
|
|
114
|
+
break;
|
|
115
|
+
case 'Number':
|
|
116
|
+
// Integer is safer than float — avoids NaN/Infinity which trip
|
|
117
|
+
// most user-defined invariants. Capsules that need floats can
|
|
118
|
+
// refine via filter checks (not yet handled here).
|
|
119
|
+
arb = fc.integer();
|
|
120
|
+
break;
|
|
121
|
+
case 'Boolean':
|
|
122
|
+
arb = fc.boolean();
|
|
123
|
+
break;
|
|
124
|
+
case 'BigInt':
|
|
125
|
+
arb = fc.bigInt();
|
|
126
|
+
break;
|
|
127
|
+
case 'Literal':
|
|
128
|
+
arb = fc.constant(ast.literal);
|
|
129
|
+
break;
|
|
130
|
+
case 'Null':
|
|
131
|
+
arb = fc.constant(null);
|
|
132
|
+
break;
|
|
133
|
+
case 'Undefined':
|
|
134
|
+
case 'Void':
|
|
135
|
+
arb = fc.constant(undefined);
|
|
136
|
+
break;
|
|
137
|
+
case 'Unknown':
|
|
138
|
+
case 'Any':
|
|
139
|
+
arb = fc.anything();
|
|
140
|
+
break;
|
|
141
|
+
case 'ObjectKeyword':
|
|
142
|
+
arb = fc.object();
|
|
143
|
+
break;
|
|
144
|
+
case 'Enum': {
|
|
145
|
+
const enums = ast.enums;
|
|
146
|
+
if (enums.length === 0) {
|
|
147
|
+
throw new UnsupportedSchemaError('Enum', 'empty enum');
|
|
148
|
+
}
|
|
149
|
+
arb = fc.constantFrom(...enums.map(([, v]) => v));
|
|
150
|
+
break;
|
|
151
|
+
}
|
|
152
|
+
case 'Union': {
|
|
153
|
+
const u = ast;
|
|
154
|
+
if (u.types.length === 0) {
|
|
155
|
+
throw new UnsupportedSchemaError('Union', 'empty union');
|
|
156
|
+
}
|
|
157
|
+
const arbs = u.types.map(walk);
|
|
158
|
+
// fc.oneof accepts an arbitraries-array as variadic args
|
|
159
|
+
arb = fc.oneof(...arbs);
|
|
160
|
+
break;
|
|
161
|
+
}
|
|
162
|
+
case 'Arrays': {
|
|
163
|
+
const a = ast;
|
|
164
|
+
// Common case: Schema.Array(T) yields elements=[], rest=[T]
|
|
165
|
+
if (a.elements.length === 0 && a.rest.length === 1) {
|
|
166
|
+
const elem = a.rest[0];
|
|
167
|
+
if (elem === undefined) {
|
|
168
|
+
throw new UnsupportedSchemaError('Arrays', 'rest[0] missing');
|
|
169
|
+
}
|
|
170
|
+
arb = fc.array(walk(elem), { maxLength: 8 });
|
|
171
|
+
break;
|
|
172
|
+
}
|
|
173
|
+
// Fixed tuple
|
|
174
|
+
if (a.rest.length === 0 && a.elements.length > 0) {
|
|
175
|
+
const elemArbs = a.elements.map(walk);
|
|
176
|
+
arb = fc.tuple(...elemArbs);
|
|
177
|
+
break;
|
|
178
|
+
}
|
|
179
|
+
// Mixed: required leading element(s) + rest tail. NonEmptyArray
|
|
180
|
+
// surfaces here as elements=[T], rest=[T] — generate the leading
|
|
181
|
+
// tuple and append a variable-length tail of the same elem type.
|
|
182
|
+
if (a.elements.length > 0 && a.rest.length === 1) {
|
|
183
|
+
const headArbs = a.elements.map(walk);
|
|
184
|
+
const tailElem = a.rest[0];
|
|
185
|
+
if (tailElem === undefined) {
|
|
186
|
+
throw new UnsupportedSchemaError('Arrays', 'rest[0] missing');
|
|
187
|
+
}
|
|
188
|
+
const tailArb = fc.array(walk(tailElem), { maxLength: 7 });
|
|
189
|
+
arb = fc.tuple(fc.tuple(...headArbs), tailArb).map(([head, tail]) => [...head, ...tail]);
|
|
190
|
+
break;
|
|
191
|
+
}
|
|
192
|
+
throw new UnsupportedSchemaError('Arrays', `unsupported tuple+rest shape (elements=${a.elements.length}, rest=${a.rest.length})`);
|
|
193
|
+
}
|
|
194
|
+
case 'Objects': {
|
|
195
|
+
const o = ast;
|
|
196
|
+
if (o.indexSignatures.length > 0) {
|
|
197
|
+
throw new UnsupportedSchemaError('Objects', 'index signatures');
|
|
198
|
+
}
|
|
199
|
+
const required = {};
|
|
200
|
+
const optional = {};
|
|
201
|
+
for (const ps of o.propertySignatures) {
|
|
202
|
+
const key = String(ps.name);
|
|
203
|
+
const fieldArb = walk(ps.type);
|
|
204
|
+
const isOptional = ps.type.context?.isOptional === true;
|
|
205
|
+
if (isOptional)
|
|
206
|
+
optional[key] = fieldArb;
|
|
207
|
+
else
|
|
208
|
+
required[key] = fieldArb;
|
|
209
|
+
}
|
|
210
|
+
if (Object.keys(optional).length === 0) {
|
|
211
|
+
arb = fc.record(required);
|
|
212
|
+
break;
|
|
213
|
+
}
|
|
214
|
+
// fast-check supports `requiredKeys` to mark a subset as required —
|
|
215
|
+
// but the simpler, version-stable approach is to merge all keys and
|
|
216
|
+
// post-process: for each optional key, randomly drop it.
|
|
217
|
+
const allKeys = { ...required, ...optional };
|
|
218
|
+
arb = fc.record(allKeys).chain((rec) => fc.tuple(...Object.keys(optional).map(() => fc.boolean())).map((dropFlags) => {
|
|
219
|
+
const out = { ...rec };
|
|
220
|
+
const optKeys = Object.keys(optional);
|
|
221
|
+
for (let i = 0; i < optKeys.length; i++) {
|
|
222
|
+
if (dropFlags[i] === true) {
|
|
223
|
+
const k = optKeys[i];
|
|
224
|
+
if (k !== undefined)
|
|
225
|
+
delete out[k];
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
return out;
|
|
229
|
+
}));
|
|
230
|
+
break;
|
|
231
|
+
}
|
|
232
|
+
case 'Suspend': {
|
|
233
|
+
const s = ast;
|
|
234
|
+
// Resolve once; arbitrary depth control is left to fast-check defaults.
|
|
235
|
+
arb = walk(s.thunk());
|
|
236
|
+
break;
|
|
237
|
+
}
|
|
238
|
+
case 'Declaration':
|
|
239
|
+
arb = _arbitraryForDeclaration(ast);
|
|
240
|
+
break;
|
|
241
|
+
default:
|
|
242
|
+
throw new UnsupportedSchemaError(ast._tag);
|
|
243
|
+
}
|
|
244
|
+
return _applyChecks(ast, arb);
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Walk a `Schema` AST and return a `fc.Arbitrary` that produces values
|
|
248
|
+
* structurally conforming to the schema. Throws
|
|
249
|
+
* {@link UnsupportedSchemaError} on AST nodes with no supported mapping.
|
|
250
|
+
*
|
|
251
|
+
* Accepts any `Schema.Schema<T>` (or `Codec`) — only `.ast` is read.
|
|
252
|
+
*/
|
|
253
|
+
function _schemaToArbitrary(schema) {
|
|
254
|
+
return walk(schema.ast);
|
|
255
|
+
}
|
|
256
|
+
/** Public namespace for the arbitrary-from-schema walker. */
|
|
257
|
+
export const ArbitraryFromSchema = {
|
|
258
|
+
fromSchema: _schemaToArbitrary,
|
|
259
|
+
};
|
|
260
|
+
/** Convenience top-level export — most call sites use this directly. */
|
|
261
|
+
export const schemaToArbitrary = _schemaToArbitrary;
|
|
262
|
+
//# sourceMappingURL=arbitrary-from-schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arbitrary-from-schema.js","sourceRoot":"","sources":["../../src/harness/arbitrary-from-schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAEjC,wEAAwE;AACxE,MAAM,OAAO,sBAAuB,SAAQ,KAAK;IACtC,IAAI,GAAG,wBAAwB,CAAC;IAChC,OAAO,CAAS;IACzB,YAAY,OAAe,EAAE,IAAa;QACxC,KAAK,CAAC,oCAAoC,OAAO,qBAAqB,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QAClG,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;CACF;AAED;;;;;;;;;;GAUG;AACH,SAAS,YAAY,CAAC,GAAkB,EAAE,GAA0B;IAClE,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC;IAC1B,IAAI,MAAM,KAAK,SAAS,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,GAAG,CAAC;IAC5D,OAAO,GAAG,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE;QAC3B,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;YAC3B,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;gBAC5B,6DAA6D;gBAC7D,iDAAiD;gBACjD,MAAM,KAAK,GAAI,KAAmC,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,EAAE,EAA4B,CAAC,CAAC;gBAClG,IAAI,KAAK,KAAK,SAAS;oBAAE,OAAO,KAAK,CAAC;YACxC,CAAC;iBAAM,IAAI,KAAK,CAAC,IAAI,KAAK,aAAa,EAAE,CAAC;gBACxC,MA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AAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;oBACxC,IAAI,SAAS,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;wBAC1B,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;wBACrB,IAAI,CAAC,KAAK,SAAS;4BAAE,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC;oBACrC,CAAC;gBACH,CAAC;gBACD,OAAO,GAAG,CAAC;YACb,CAAC,CAAC,CACH,CAAC;YACF,MAAM;QACR,CAAC;QACD,KAAK,SAAS,CAAC,CAAC,CAAC;YACf,MAAM,CAAC,GAAG,GAAwB,CAAC;YACnC,wEAAwE;YACxE,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC;YACtB,MAAM;QACR,CAAC;QACD,KAAK,aAAa;YAChB,GAAG,GAAG,wBAAwB,CAAC,GAA4B,CAAC,CAAC;YAC7D,MAAM;QACR;YACE,MAAM,IAAI,sBAAsB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC/C,CAAC;IACD,OAAO,YAAY,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AAChC,CAAC;AAED;;;;;;GAMG;AACH,SAAS,kBAAkB,CAAI,MAAwB;IACrD,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAoB,CAAC;AAC7C,CAAC;AAED,6DAA6D;AAC7D,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,UAAU,EAAE,kBAAkB;CACtB,CAAC;AAEX,wEAAwE;AACxE,MAAM,CAAC,MAAM,iBAAiB,GAAG,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Harness template for the `cachedProjection` assembly arm.
|
|
3
|
+
*
|
|
4
|
+
* Cached projections derive an output from a source via a deterministic
|
|
5
|
+
* pipeline with cache invalidation tied to source content addresses.
|
|
6
|
+
* Without a `derive(source)` channel on the contract the harness can't
|
|
7
|
+
* exercise cache-hit equality or invalidation, so each case is emitted
|
|
8
|
+
* as `it.skip` rather than a vacuous placeholder.
|
|
9
|
+
*
|
|
10
|
+
* @module
|
|
11
|
+
*/
|
|
12
|
+
import type { CapsuleDef } from '../assembly.js';
|
|
13
|
+
import type { HarnessOutput } from './pure-transform.js';
|
|
14
|
+
/**
|
|
15
|
+
* Generate the test + bench file contents for a `cachedProjection` capsule.
|
|
16
|
+
* Emits `it.skip` placeholders for cache-hit and invalidation tests.
|
|
17
|
+
*/
|
|
18
|
+
export declare function generateCachedProjection(cap: CapsuleDef<'cachedProjection', unknown, unknown, unknown>): HarnessOutput;
|
|
19
|
+
//# sourceMappingURL=cached-projection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cached-projection.d.ts","sourceRoot":"","sources":["../../src/harness/cached-projection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD;;;GAGG;AACH,wBAAgB,wBAAwB,CACtC,GAAG,EAAE,UAAU,CAAC,kBAAkB,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,GAC7D,aAAa,CAwBf"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Harness template for the `cachedProjection` assembly arm.
|
|
3
|
+
*
|
|
4
|
+
* Cached projections derive an output from a source via a deterministic
|
|
5
|
+
* pipeline with cache invalidation tied to source content addresses.
|
|
6
|
+
* Without a `derive(source)` channel on the contract the harness can't
|
|
7
|
+
* exercise cache-hit equality or invalidation, so each case is emitted
|
|
8
|
+
* as `it.skip` rather than a vacuous placeholder.
|
|
9
|
+
*
|
|
10
|
+
* @module
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Generate the test + bench file contents for a `cachedProjection` capsule.
|
|
14
|
+
* Emits `it.skip` placeholders for cache-hit and invalidation tests.
|
|
15
|
+
*/
|
|
16
|
+
export function generateCachedProjection(cap) {
|
|
17
|
+
const testFile = `// GENERATED — do not edit by hand
|
|
18
|
+
import { describe, it } from 'vitest';
|
|
19
|
+
|
|
20
|
+
describe('${cap.name}', () => {
|
|
21
|
+
it.skip('cache hit: identical source yields the same derived output', () => {
|
|
22
|
+
// TODO(harness): needs cap.derive handler + content-addressed source.
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it.skip('invalidation: source change produces new cache entry', () => {
|
|
26
|
+
// TODO(harness): same — needs cap.derive.
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
`;
|
|
30
|
+
const benchFile = `// GENERATED — do not edit by hand
|
|
31
|
+
import { bench } from 'vitest';
|
|
32
|
+
|
|
33
|
+
bench('${cap.name} — decode throughput', () => {
|
|
34
|
+
// decode a canonical source, measure p95 vs budget (${cap.budgets.p95Ms ?? 'n/a'}ms)
|
|
35
|
+
}, { time: 500 });
|
|
36
|
+
`;
|
|
37
|
+
return { testFile, benchFile };
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=cached-projection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cached-projection.js","sourceRoot":"","sources":["../../src/harness/cached-projection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAKH;;;GAGG;AACH,MAAM,UAAU,wBAAwB,CACtC,GAA8D;IAE9D,MAAM,QAAQ,GAAG;;;YAGP,GAAG,CAAC,IAAI;;;;;;;;;CASnB,CAAC;IAEA,MAAM,SAAS,GAAG;;;SAGX,GAAG,CAAC,IAAI;yDACwC,GAAG,CAAC,OAAO,CAAC,KAAK,IAAI,KAAK;;CAElF,CAAC;IAEA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;AACjC,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Harness — per-arm templates that emit test + bench + audit files
|
|
3
|
+
* from a capsule declaration. Each arm has its own generator.
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
export { generatePureTransform } from './pure-transform.js';
|
|
8
|
+
export type { HarnessOutput, HarnessContext } from './pure-transform.js';
|
|
9
|
+
export { ArbitraryFromSchema, schemaToArbitrary, UnsupportedSchemaError } from './arbitrary-from-schema.js';
|
|
10
|
+
export { generateReceiptedMutation } from './receipted-mutation.js';
|
|
11
|
+
export { generateStateMachine } from './state-machine.js';
|
|
12
|
+
export { generateSiteAdapter } from './site-adapter.js';
|
|
13
|
+
export { generatePolicyGate } from './policy-gate.js';
|
|
14
|
+
export { generateCachedProjection } from './cached-projection.js';
|
|
15
|
+
export { generateSceneComposition } from './scene-composition.js';
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/harness/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACzE,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAC5G,OAAO,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAClE,OAAO,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Harness — per-arm templates that emit test + bench + audit files
|
|
3
|
+
* from a capsule declaration. Each arm has its own generator.
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
export { generatePureTransform } from './pure-transform.js';
|
|
8
|
+
export { ArbitraryFromSchema, schemaToArbitrary, UnsupportedSchemaError } from './arbitrary-from-schema.js';
|
|
9
|
+
export { generateReceiptedMutation } from './receipted-mutation.js';
|
|
10
|
+
export { generateStateMachine } from './state-machine.js';
|
|
11
|
+
export { generateSiteAdapter } from './site-adapter.js';
|
|
12
|
+
export { generatePolicyGate } from './policy-gate.js';
|
|
13
|
+
export { generateCachedProjection } from './cached-projection.js';
|
|
14
|
+
export { generateSceneComposition } from './scene-composition.js';
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/harness/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAE5D,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAC5G,OAAO,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAClE,OAAO,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Harness template for the `policyGate` assembly arm.
|
|
3
|
+
*
|
|
4
|
+
* Policy gates resolve allow/deny against typed subjects. Without a
|
|
5
|
+
* `decide(subject)` channel on the capsule contract the harness can't
|
|
6
|
+
* exercise allow/deny branches or check reason chains, so each case is
|
|
7
|
+
* emitted as `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 `policyGate` capsule.
|
|
15
|
+
* Emits `it.skip` placeholders for allow / deny / reason-chain coverage.
|
|
16
|
+
*/
|
|
17
|
+
export declare function generatePolicyGate(cap: CapsuleDef<'policyGate', unknown, unknown, unknown>): HarnessOutput;
|
|
18
|
+
//# sourceMappingURL=policy-gate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"policy-gate.d.ts","sourceRoot":"","sources":["../../src/harness/policy-gate.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,kBAAkB,CAAC,GAAG,EAAE,UAAU,CAAC,YAAY,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,GAAG,aAAa,CAgC1G"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Harness template for the `policyGate` assembly arm.
|
|
3
|
+
*
|
|
4
|
+
* Policy gates resolve allow/deny against typed subjects. Without a
|
|
5
|
+
* `decide(subject)` channel on the capsule contract the harness can't
|
|
6
|
+
* exercise allow/deny branches or check reason chains, so each case is
|
|
7
|
+
* emitted as `it.skip` rather than a vacuous placeholder.
|
|
8
|
+
*
|
|
9
|
+
* @module
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Generate the test + bench file contents for a `policyGate` capsule.
|
|
13
|
+
* Emits `it.skip` placeholders for allow / deny / reason-chain coverage.
|
|
14
|
+
*/
|
|
15
|
+
export function generatePolicyGate(cap) {
|
|
16
|
+
const testFile = `// GENERATED — do not edit by hand
|
|
17
|
+
import { describe, it } from 'vitest';
|
|
18
|
+
|
|
19
|
+
describe('${cap.name}', () => {
|
|
20
|
+
it.skip('allow branch: a subject meeting the policy resolves to allow', () => {
|
|
21
|
+
// TODO(harness): needs cap.decide handler to drive subject -> outcome.
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it.skip('deny branch: a subject failing the policy resolves to deny', () => {
|
|
25
|
+
// TODO(harness): same — needs cap.decide.
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it.skip('reason chain present on every decision', () => {
|
|
29
|
+
// TODO(harness): same — needs cap.decide and a typed reasons schema.
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it.skip('no silent deny: every deny has a typed reason code', () => {
|
|
33
|
+
// TODO(harness): same — needs reasons enum on the contract.
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
`;
|
|
37
|
+
const benchFile = `// GENERATED — do not edit by hand
|
|
38
|
+
import { bench } from 'vitest';
|
|
39
|
+
|
|
40
|
+
bench('${cap.name}', () => {
|
|
41
|
+
// policy decision with a canonical fixture
|
|
42
|
+
}, { time: 500 });
|
|
43
|
+
`;
|
|
44
|
+
return { testFile, benchFile };
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=policy-gate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"policy-gate.js","sourceRoot":"","sources":["../../src/harness/policy-gate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAC,GAAwD;IACzF,MAAM,QAAQ,GAAG;;;YAGP,GAAG,CAAC,IAAI;;;;;;;;;;;;;;;;;CAiBnB,CAAC;IAEA,MAAM,SAAS,GAAG;;;SAGX,GAAG,CAAC,IAAI;;;CAGhB,CAAC;IAEA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;AACjC,CAAC"}
|