gdp-wired 0.46.0 → 0.48.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 (182) hide show
  1. package/README.md +18 -5
  2. package/dist/core/carry.d.ts +15 -0
  3. package/dist/core/carry.js +651 -0
  4. package/dist/core/cli.d.ts +4 -1
  5. package/dist/core/cli.js +31 -11
  6. package/dist/core/count-cases.d.ts +24 -0
  7. package/dist/core/count-cases.js +320 -0
  8. package/dist/core/count-cert-grow.d.ts +4 -0
  9. package/dist/core/count-cert-grow.js +37 -0
  10. package/dist/core/count-cert-transport.d.ts +3 -0
  11. package/dist/core/count-cert-transport.js +58 -0
  12. package/dist/core/count-completion.d.ts +9 -0
  13. package/dist/core/count-completion.js +27 -0
  14. package/dist/core/count-cubes.d.ts +8 -0
  15. package/dist/core/count-cubes.js +69 -0
  16. package/dist/core/count-demand.d.ts +37 -0
  17. package/dist/core/count-demand.js +361 -0
  18. package/dist/core/count-facts.d.ts +52 -0
  19. package/dist/core/count-facts.js +247 -0
  20. package/dist/core/count-focus-proof.d.ts +8 -0
  21. package/dist/core/count-focus-proof.js +140 -0
  22. package/dist/core/count-focused.d.ts +22 -0
  23. package/dist/core/count-focused.js +676 -0
  24. package/dist/core/count-ranges.d.ts +5 -0
  25. package/dist/core/count-ranges.js +65 -0
  26. package/dist/core/count-recovery/action-guard.d.ts +5 -0
  27. package/dist/core/count-recovery/action-guard.js +51 -0
  28. package/dist/core/count-recovery/boolean-core.d.ts +16 -0
  29. package/dist/core/count-recovery/boolean-core.js +258 -0
  30. package/dist/core/count-recovery/carried-case.d.ts +2 -0
  31. package/dist/core/count-recovery/carried-case.js +24 -0
  32. package/dist/core/count-recovery/conditional-check-cache.d.ts +23 -0
  33. package/dist/core/count-recovery/conditional-check-cache.js +130 -0
  34. package/dist/core/count-recovery/conditional-cuts.d.ts +6 -0
  35. package/dist/core/count-recovery/conditional-cuts.js +318 -0
  36. package/dist/core/count-recovery/conditional-proof.d.ts +19 -0
  37. package/dist/core/count-recovery/conditional-proof.js +306 -0
  38. package/dist/core/count-recovery/derivability-closure.d.ts +14 -0
  39. package/dist/core/count-recovery/derivability-closure.js +533 -0
  40. package/dist/core/count-recovery/empty-count-source.d.ts +2 -0
  41. package/dist/core/count-recovery/empty-count-source.js +40 -0
  42. package/dist/core/count-recovery/field-bound-lemmas.d.ts +23 -0
  43. package/dist/core/count-recovery/field-bound-lemmas.js +640 -0
  44. package/dist/core/count-recovery/field-case.d.ts +5 -0
  45. package/dist/core/count-recovery/field-case.js +89 -0
  46. package/dist/core/count-recovery/field-demand.d.ts +46 -0
  47. package/dist/core/count-recovery/field-demand.js +47 -0
  48. package/dist/core/count-recovery/field-only.d.ts +3 -0
  49. package/dist/core/count-recovery/field-only.js +18 -0
  50. package/dist/core/count-recovery/fold-path.d.ts +6 -0
  51. package/dist/core/count-recovery/fold-path.js +35 -0
  52. package/dist/core/count-recovery/frame-lemmas.d.ts +9 -0
  53. package/dist/core/count-recovery/frame-lemmas.js +120 -0
  54. package/dist/core/count-recovery/guard-cases.d.ts +12 -0
  55. package/dist/core/count-recovery/guard-cases.js +138 -0
  56. package/dist/core/count-recovery/key-closure.d.ts +14 -0
  57. package/dist/core/count-recovery/key-closure.js +62 -0
  58. package/dist/core/count-recovery/leaf-allowance.d.ts +4 -0
  59. package/dist/core/count-recovery/leaf-allowance.js +7 -0
  60. package/dist/core/count-recovery/lift-count-proxies.d.ts +6 -0
  61. package/dist/core/count-recovery/lift-count-proxies.js +175 -0
  62. package/dist/core/count-recovery/live-dependencies.d.ts +6 -0
  63. package/dist/core/count-recovery/live-dependencies.js +76 -0
  64. package/dist/core/count-recovery/member-inclusions.d.ts +11 -0
  65. package/dist/core/count-recovery/member-inclusions.js +168 -0
  66. package/dist/core/count-recovery/member-premises.d.ts +29 -0
  67. package/dist/core/count-recovery/member-premises.js +114 -0
  68. package/dist/core/count-recovery/natural-cases.d.ts +6 -0
  69. package/dist/core/count-recovery/natural-cases.js +59 -0
  70. package/dist/core/count-recovery/ops.d.ts +6 -0
  71. package/dist/core/count-recovery/ops.js +8 -0
  72. package/dist/core/count-recovery/pre-state-source.d.ts +8 -0
  73. package/dist/core/count-recovery/pre-state-source.js +18 -0
  74. package/dist/core/count-recovery/rebase-path.d.ts +9 -0
  75. package/dist/core/count-recovery/rebase-path.js +70 -0
  76. package/dist/core/count-recovery/rename-proof.d.ts +2 -0
  77. package/dist/core/count-recovery/rename-proof.js +102 -0
  78. package/dist/core/count-recovery/row-cases.d.ts +16 -0
  79. package/dist/core/count-recovery/row-cases.js +291 -0
  80. package/dist/core/count-recovery/scalar-guards.d.ts +7 -0
  81. package/dist/core/count-recovery/scalar-guards.js +291 -0
  82. package/dist/core/count-recovery/source-memo.d.ts +12 -0
  83. package/dist/core/count-recovery/source-memo.js +67 -0
  84. package/dist/core/count-select.d.ts +16 -0
  85. package/dist/core/count-select.js +24 -0
  86. package/dist/core/count-support.d.ts +598 -0
  87. package/dist/core/count-support.js +2080 -0
  88. package/dist/core/count-unions.d.ts +2 -0
  89. package/dist/core/count-unions.js +139 -0
  90. package/dist/core/count-witness-flags.d.ts +9 -0
  91. package/dist/core/count-witness-flags.js +37 -0
  92. package/dist/core/count-write-frames.d.ts +12 -0
  93. package/dist/core/count-write-frames.js +206 -0
  94. package/dist/core/counts.d.ts +20 -2
  95. package/dist/core/counts.js +807 -156
  96. package/dist/core/dsl.d.ts +50 -6
  97. package/dist/core/dsl.js +307 -65
  98. package/dist/core/effect-schema.d.ts +90 -0
  99. package/dist/core/effect-schema.js +500 -0
  100. package/dist/core/effect.d.ts +3 -7
  101. package/dist/core/effect.js +10 -65
  102. package/dist/core/exists.d.ts +1 -1
  103. package/dist/core/exists.js +80 -15
  104. package/dist/core/extract-check.d.ts +7 -1
  105. package/dist/core/extract-check.js +161 -19
  106. package/dist/core/extract-go-check.js +24 -4
  107. package/dist/core/extract-go.d.ts +7 -0
  108. package/dist/core/extract-go.js +29 -2
  109. package/dist/core/extract-read.d.ts +31 -9
  110. package/dist/core/extract-read.js +36 -11
  111. package/dist/core/extract-rs.js +58 -14
  112. package/dist/core/extract-shapes.d.ts +1 -0
  113. package/dist/core/extract-shapes.js +190 -27
  114. package/dist/core/extract-standalone.d.ts +3 -0
  115. package/dist/core/extract-standalone.js +265 -0
  116. package/dist/core/extract.d.ts +1 -0
  117. package/dist/core/extract.js +25 -5
  118. package/dist/core/field-laws.d.ts +2 -0
  119. package/dist/core/field-laws.js +100 -0
  120. package/dist/core/finite-frontiers.d.ts +5 -0
  121. package/dist/core/finite-frontiers.js +116 -0
  122. package/dist/core/finite-houdini.d.ts +52 -0
  123. package/dist/core/finite-houdini.js +460 -0
  124. package/dist/core/finite-model.d.ts +13 -0
  125. package/dist/core/finite-model.js +68 -0
  126. package/dist/core/finite-tiny.d.ts +72 -0
  127. package/dist/core/finite-tiny.js +1052 -0
  128. package/dist/core/infer.d.ts +1 -1
  129. package/dist/core/infer.js +32 -9
  130. package/dist/core/laws.d.ts +2 -1
  131. package/dist/core/laws.js +76 -19
  132. package/dist/core/lemma-cuts.d.ts +38 -0
  133. package/dist/core/lemma-cuts.js +365 -0
  134. package/dist/core/machine.d.ts +39 -2
  135. package/dist/core/machine.js +240 -35
  136. package/dist/core/mutate.d.ts +55 -0
  137. package/dist/core/mutate.js +210 -0
  138. package/dist/core/native-domain.d.ts +6 -0
  139. package/dist/core/native-domain.js +114 -0
  140. package/dist/core/native-law.d.ts +3 -0
  141. package/dist/core/native-law.js +174 -0
  142. package/dist/core/quorum-laws.d.ts +5 -0
  143. package/dist/core/quorum-laws.js +239 -0
  144. package/dist/core/relational.js +10 -2
  145. package/dist/core/relevance.d.ts +4 -0
  146. package/dist/core/relevance.js +79 -0
  147. package/dist/core/rs/Cargo.toml +1 -1
  148. package/dist/core/rs/src/main.rs +458 -9
  149. package/dist/core/runtime-wall.d.ts +3 -0
  150. package/dist/core/runtime-wall.js +4 -0
  151. package/dist/core/sample-step.d.ts +16 -0
  152. package/dist/core/sample-step.js +28 -0
  153. package/dist/core/source-check.d.ts +44 -0
  154. package/dist/core/source-check.js +126 -0
  155. package/dist/core/source-diagnostic.d.ts +1 -0
  156. package/dist/core/source-diagnostic.js +34 -0
  157. package/dist/core/support-budget.d.ts +2 -0
  158. package/dist/core/support-budget.js +6 -0
  159. package/dist/core/system.js +2 -0
  160. package/dist/core/wall.d.ts +6 -0
  161. package/dist/core/wall.js +23 -0
  162. package/dist/core/watch.js +4 -0
  163. package/dist/kernel/cdcl.d.ts +4 -0
  164. package/dist/kernel/cdcl.js +20 -5
  165. package/dist/kernel/kernel.d.ts +10 -0
  166. package/dist/kernel/kernel.js +56 -3
  167. package/dist/kernel/model-sequence.d.ts +2 -2
  168. package/dist/kernel/model-sequence.js +4 -3
  169. package/dist/kernel/model-values.d.ts +2 -0
  170. package/dist/kernel/model-values.js +60 -0
  171. package/dist/kernel/prove.d.ts +10 -0
  172. package/dist/kernel/prove.js +56 -8
  173. package/dist/kernel/prover-rows.d.ts +29 -0
  174. package/dist/kernel/prover-rows.js +114 -0
  175. package/dist/lean-kernel/emit.d.ts +39 -2
  176. package/dist/lean-kernel/emit.js +136 -24
  177. package/dist/lean-kernel/lean-terms.d.ts +1 -0
  178. package/dist/lean-kernel/lean-terms.js +13 -5
  179. package/dist/lean-kernel/library.js +4 -0
  180. package/dist/lean-kernel/qalpha.d.ts +7 -0
  181. package/dist/lean-kernel/qalpha.js +40 -0
  182. package/package.json +5 -1
@@ -0,0 +1,500 @@
1
+ // Effect Schema's decoded-value domain as an ordinary Kind. No Effect import (including type imports): the
2
+ // optional frontend reads the 3.22.x / 4.0.x AST, never runs a predicate, decoder, encoder, or transformation.
3
+ import { Choice, Cond, Int, Kind, Maybe, Str, Term, any, bool, int, lit, oneOf, str, variant, Variant } from "./dsl.js";
4
+ export class SchemaError extends Error {
5
+ path;
6
+ code;
7
+ constructor(path, code, message) {
8
+ super(`fromSchema: ${path || 'the schema'} is ${message}`);
9
+ this.path = path;
10
+ this.code = code;
11
+ this.name = 'SchemaError';
12
+ }
13
+ }
14
+ /** A regular Kind, with a report that distinguishes runtime conversion from symbolic model precision. */
15
+ export class SchemaKind extends Kind {
16
+ inner;
17
+ report;
18
+ constructor(inner, report) {
19
+ super();
20
+ this.inner = inner;
21
+ this.report = report;
22
+ }
23
+ vars(name) { return this.inner.vars(name); }
24
+ assume(name) { return this.inner.assume(name); }
25
+ build(name, get) { return this.inner.build(name, get); }
26
+ invariant(value) { return this.inner.invariant(value); }
27
+ encode(name, raw) { return this.inner.encode(name, raw); }
28
+ decode(name, vars) { return this.inner.decode(name, vars); }
29
+ store(name, value) { return this.inner.store(name, value); }
30
+ empty() { return this.inner.empty(); }
31
+ random(name, rand, bound) { return this.inner.random(name, rand, bound); }
32
+ sample(rand, bound) { return this.inner.sample(rand, bound); }
33
+ // Unlike Kind.from's historical callback, no implicit any is handed to a schema callback. Annotate params.
34
+ from(init) {
35
+ if (typeof init !== 'function')
36
+ this.encode('initial', init);
37
+ return { kind: this, init };
38
+ }
39
+ /** Build a symbolic value through the same checked store path used by state initialization. */
40
+ make(value) {
41
+ const parts = this.store('$schema', value);
42
+ return this.build('$schema', part => { const t = parts[part]; return typeof t === 'number' ? lit(t) : t; });
43
+ }
44
+ }
45
+ const fail = (path, code, message) => { throw new SchemaError(path, code, message); };
46
+ const badValue = (name, message) => { throw new RangeError(`${name}: ${message}`); };
47
+ const own = (o, key) => Object.prototype.hasOwnProperty.call(o, key);
48
+ const object = (x) => x !== null && typeof x === 'object' ? x : {};
49
+ const node = (x, path) => typeof object(x)._tag === 'string' ? x : fail(path, 'invalid-ast', 'not a supported Effect AST');
50
+ const tags = { NumberKeyword: 'Number', BooleanKeyword: 'Boolean', StringKeyword: 'String', TypeLiteral: 'Objects', UndefinedKeyword: 'Undefined' };
51
+ const tag = (a) => tags[a._tag] ?? a._tag;
52
+ const at = (path, field) => path ? `${path}.${field}` : field;
53
+ const symAnnotation = (a, id) => {
54
+ const annotations = object(a.annotations), key = Object.getOwnPropertySymbols(annotations).find(k => k.description === `effect/annotation/${id}`);
55
+ return key === undefined ? undefined : annotations[key];
56
+ };
57
+ const plainName = (name, path) => {
58
+ if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(name) || name in Object.prototype || name === 'prototype')
59
+ fail(path, 'field-name', 'a field/case name outside the plain, non-reserved identifier subset');
60
+ };
61
+ // The range is part of both input assumptions AND the state invariant. A transition is never trusted to keep it.
62
+ class IntegerKind extends Kind {
63
+ minimum;
64
+ maximum;
65
+ values;
66
+ constructor(minimum, maximum, values) {
67
+ super();
68
+ this.minimum = minimum;
69
+ this.maximum = maximum;
70
+ this.values = values;
71
+ }
72
+ vars(name) { return int.vars(name); }
73
+ build(name, get) { return int.build(name, get); }
74
+ invariant(x) { return [x.atLeast(this.minimum), x.atMost(this.maximum), ...(this.values ? [any(...this.values.map(n => x.eq(n)))] : [])]; }
75
+ assume(name) { return this.invariant(this.value(name)); }
76
+ check(name, raw) {
77
+ if (typeof raw !== 'number' || !Number.isSafeInteger(raw) || raw < this.minimum || raw > this.maximum || (this.values && !this.values.includes(raw)))
78
+ badValue(name, 'outside the schema integer domain');
79
+ return raw;
80
+ }
81
+ encode(name, raw) { return int.encode(name, this.check(name, raw)); }
82
+ store(name, value) {
83
+ if (!(value instanceof Int) && !(value instanceof Term))
84
+ this.check(name, value);
85
+ return int.store(name, value);
86
+ }
87
+ decode(name, vars) {
88
+ for (const part of this.vars(name))
89
+ if (!Number.isSafeInteger(vars[part]) || vars[part] < 0)
90
+ badValue(name, 'invalid natural part of an integer');
91
+ return this.check(name, int.decode(name, vars));
92
+ }
93
+ empty() { return this.values?.[0] ?? Math.min(this.maximum, Math.max(this.minimum, 0)); }
94
+ sample(rand, bound) {
95
+ if (this.values)
96
+ return this.values[rand(this.values.length)];
97
+ const near = this.empty(), span = Math.max(0, Math.min(1_000_000, Math.floor(bound)));
98
+ const lo = Math.max(this.minimum, near - span), hi = Math.min(this.maximum, near + span);
99
+ const edges = [this.minimum, this.maximum, near];
100
+ return rand(4) === 0 ? edges[rand(edges.length)] : lo + rand(hi - lo + 1);
101
+ }
102
+ random(name, rand, bound) { return this.encode(name, this.sample(rand, bound)); }
103
+ }
104
+ class BooleanKind extends Kind {
105
+ literal;
106
+ constructor(literal) {
107
+ super();
108
+ this.literal = literal;
109
+ }
110
+ vars(name) { return bool.vars(name); }
111
+ build(name, get) { return bool.build(name, get); }
112
+ invariant(b) { return [...bool.invariant(b), ...(this.literal === undefined ? [] : [b.n.eq(Number(this.literal))])]; }
113
+ assume(name) { return this.invariant(this.value(name)); }
114
+ encode(name, raw) {
115
+ if (typeof raw !== 'boolean' || (this.literal !== undefined && raw !== this.literal))
116
+ badValue(name, 'outside the schema boolean domain');
117
+ return bool.encode(name, raw);
118
+ }
119
+ store(name, value) { return value instanceof Cond ? bool.store(name, value) : this.encode(name, value); }
120
+ decode(name, vars) {
121
+ if (vars[name] !== 0 && vars[name] !== 1)
122
+ badValue(name, 'invalid boolean encoding');
123
+ const raw = vars[name] === 1;
124
+ this.encode(name, raw);
125
+ return raw;
126
+ }
127
+ empty() { return this.literal ?? false; }
128
+ sample(rand) { return this.literal ?? rand(2) === 1; }
129
+ random(name, rand) { return this.encode(name, this.sample(rand)); }
130
+ }
131
+ class ChoiceKind extends Kind {
132
+ values;
133
+ inner;
134
+ constructor(values) {
135
+ super();
136
+ this.values = values;
137
+ this.inner = oneOf(...values);
138
+ }
139
+ vars(name) { return this.inner.vars(name); }
140
+ build(name, get) { return this.inner.build(name, get); }
141
+ invariant(x) { return this.inner.invariant(x); }
142
+ assume(name) { return this.inner.assume(name); }
143
+ encode(name, raw) { return this.inner.encode(name, raw); }
144
+ store(name, value) {
145
+ if (value instanceof Choice && (value.values.length !== this.values.length || value.values.some((v, i) => v !== this.values[i])))
146
+ badValue(name, 'a choice from another schema');
147
+ return this.inner.store(name, value);
148
+ }
149
+ decode(name, vars) {
150
+ if (!Number.isInteger(vars[name]) || vars[name] < 0 || vars[name] >= this.values.length)
151
+ badValue(name, 'invalid choice encoding');
152
+ return this.inner.decode(name, vars);
153
+ }
154
+ empty() { return this.inner.empty(); }
155
+ sample(rand, bound) { return this.inner.sample(rand, bound); }
156
+ random(name, rand, bound) { return this.inner.random(name, rand, bound); }
157
+ }
158
+ class StringKind extends Kind {
159
+ inner = str();
160
+ vars(name) { return this.inner.vars(name); }
161
+ assume(name) { return this.inner.assume(name); }
162
+ build(name, get) { return this.inner.build(name, get); }
163
+ invariant(s) { return [s.id.eq(0).iff(s.length.eq(0))]; }
164
+ encode(name, raw) { return this.inner.encode(name, raw); }
165
+ store(name, value) {
166
+ if (typeof value !== 'string' && !(value instanceof Str))
167
+ badValue(name, 'a schema string is expected');
168
+ return this.inner.store(name, value);
169
+ }
170
+ decode(name, vars) {
171
+ const text = this.inner.decode(name, vars);
172
+ if (typeof text !== 'string')
173
+ return badValue(name, 'invalid string encoding');
174
+ if (vars[`${name}$len`] !== text.length)
175
+ badValue(name, 'string id and length disagree (validate symbolic counterexamples)');
176
+ return text;
177
+ }
178
+ empty() { return ''; }
179
+ sample(rand, bound) { return this.inner.sample(rand, bound); }
180
+ random(name, rand, bound) { return this.inner.random(name, rand, bound); }
181
+ }
182
+ class NullableKind extends Kind {
183
+ inner;
184
+ normalizeUndefined;
185
+ constructor(inner, normalizeUndefined = false) {
186
+ super();
187
+ this.inner = inner;
188
+ this.normalizeUndefined = normalizeUndefined;
189
+ }
190
+ has(name) { return `${name}$some`; }
191
+ vars(name) { return [this.has(name), ...this.inner.vars(name)]; }
192
+ build(name, get) { return new Maybe(get(this.has(name)), this.inner.build(name, get)); }
193
+ invariant(m) { return [m.present.atMost(1), ...this.inner.invariant(m.inner).map(c => m.isSome.implies(c))]; }
194
+ assume(name) { const m = this.value(name); return [m.present.atMost(1), ...this.inner.assume(name).map(c => m.isSome.implies(c))]; }
195
+ encode(name, raw) {
196
+ if (raw === undefined && !this.normalizeUndefined)
197
+ badValue(name, 'undefined is not null');
198
+ return raw === null || raw === undefined ? { [this.has(name)]: 0, ...this.inner.encode(name, this.inner.empty()) } : { [this.has(name)]: 1, ...this.inner.encode(name, raw) };
199
+ }
200
+ store(name, value) {
201
+ if (value instanceof Maybe)
202
+ return { [this.has(name)]: value.present, ...this.inner.store(name, value.inner) };
203
+ if (value === null || value === undefined)
204
+ return this.encode(name, value);
205
+ return { [this.has(name)]: 1, ...this.inner.store(name, value) };
206
+ }
207
+ decode(name, vars) {
208
+ if (vars[this.has(name)] !== 0 && vars[this.has(name)] !== 1)
209
+ badValue(name, 'invalid presence bit');
210
+ return vars[this.has(name)] === 0 ? null : this.inner.decode(name, vars);
211
+ }
212
+ empty() { return null; }
213
+ sample(rand, bound) { return rand(4) === 0 ? null : this.inner.sample(rand, bound); }
214
+ random(name, rand, bound) { return this.encode(name, this.sample(rand, bound)); }
215
+ }
216
+ class StructKind extends Kind {
217
+ fields;
218
+ optional;
219
+ constructor(fields, optional = new Set()) {
220
+ super();
221
+ this.fields = fields;
222
+ this.optional = optional;
223
+ }
224
+ each(name, f) { return Object.entries(this.fields).map(([key, k]) => f(k, at(name, key), key)); }
225
+ vars(name) { return this.each(name, (k, p) => k.vars(p)).flat(); }
226
+ assume(name) { return this.each(name, (k, p) => k.assume(p)).flat(); }
227
+ build(name, get) { return Object.fromEntries(this.each(name, (k, p, key) => [key, k.build(p, get)])); }
228
+ invariant(value) { return this.each('', (k, _, key) => k.invariant(value[key])).flat(); }
229
+ check(name, value) {
230
+ if (value === null || typeof value !== 'object' || Array.isArray(value))
231
+ return badValue(name, 'a closed structural object is expected');
232
+ const o = value;
233
+ for (const key of Reflect.ownKeys(o))
234
+ if (typeof key !== 'string' || !own(this.fields, key))
235
+ badValue(name, 'an object has an undeclared field');
236
+ for (const key of Object.keys(this.fields))
237
+ if (!own(o, key) && !this.optional.has(key))
238
+ badValue(at(name, key), 'a required field is absent');
239
+ return o;
240
+ }
241
+ encode(name, raw) { const o = this.check(name, raw); return Object.assign({}, ...this.each(name, (k, p, key) => k.encode(p, o[key]))); }
242
+ store(name, value) { const o = this.check(name, value); return Object.assign({}, ...this.each(name, (k, p, key) => k.store(p, o[key]))); }
243
+ decode(name, vars) { return Object.fromEntries(this.each(name, (k, p, key) => [key, k.decode(p, vars)])); }
244
+ empty() { return Object.fromEntries(this.each('', (k, _, key) => [key, k.empty()])); }
245
+ sample(rand, bound) { return Object.fromEntries(this.each('', (k, _, key) => [key, k.sample(rand, bound)])); }
246
+ random(name, rand, bound) { return this.encode(name, this.sample(rand, bound)); }
247
+ }
248
+ class TaggedKind extends Kind {
249
+ cases;
250
+ inner;
251
+ names;
252
+ constructor(cases) {
253
+ super();
254
+ this.cases = cases;
255
+ this.inner = variant(cases, { tag: '_tag' });
256
+ this.names = Object.keys(cases);
257
+ }
258
+ vars(name) { return this.inner.vars(name); }
259
+ build(name, get) { return this.inner.build(name, get); }
260
+ assume(name) { const x = this.value(name); return [x.tag.lt(this.names.length), ...this.names.flatMap(k => new StructKind(this.cases[k]).assume(at(name, k)).map(c => x.is(k).implies(c)))]; }
261
+ invariant(x) { return [x.tag.lt(this.names.length), ...this.names.flatMap(k => new StructKind(this.cases[k]).invariant(x.cases[k]).map(c => x.is(k).implies(c)))]; }
262
+ raw(name, value) {
263
+ if (value === null || typeof value !== 'object' || Array.isArray(value))
264
+ return badValue(name, 'a closed tagged object is expected');
265
+ const o = value, tag = own(o, '_tag') ? o._tag : undefined;
266
+ if (typeof tag !== 'string' || !own(this.cases, tag))
267
+ return badValue(name, 'a required known _tag is expected');
268
+ const fields = this.cases[tag];
269
+ for (const key of Reflect.ownKeys(o))
270
+ if (typeof key !== 'string' || (key !== '_tag' && !own(fields, key)))
271
+ badValue(name, 'a tagged object has an undeclared field');
272
+ for (const key of Object.keys(fields))
273
+ if (!own(o, key))
274
+ badValue(at(name, key), 'a required field is absent');
275
+ }
276
+ encode(name, raw) { this.raw(name, raw); return this.inner.encode(name, raw); }
277
+ store(name, value) {
278
+ if (!(value instanceof Variant))
279
+ this.raw(name, value);
280
+ return this.inner.store(name, value);
281
+ }
282
+ decode(name, vars) {
283
+ if (!Number.isInteger(vars[name]) || !this.names[vars[name]])
284
+ badValue(name, 'invalid schema tag');
285
+ return this.inner.decode(name, vars);
286
+ }
287
+ empty() { return this.inner.empty(); }
288
+ sample(rand, bound) { return this.inner.sample(rand, bound); }
289
+ random(name, rand, bound) { return this.encode(name, this.sample(rand, bound)); }
290
+ }
291
+ export function fromSchema(schema, options = {}) {
292
+ const mode = options.mode ?? 'exact', losses = [], constraints = [];
293
+ if (mode !== 'exact' && mode !== 'approximate')
294
+ fail('', 'invalid-mode', 'given an invalid mode (expected exact or approximate)');
295
+ let abstractStrings = false;
296
+ const lose = (path, code, message, effect = 'overapproximation') => {
297
+ if (mode === 'exact')
298
+ fail(path, code, message);
299
+ losses.push({ path, code, message, effect });
300
+ };
301
+ const transformed = (a) => a._tag === 'Transformation' || (Array.isArray(a.encoding) && a.encoding.length > 0);
302
+ const filtersOf = (a, path) => {
303
+ if (transformed(a))
304
+ fail(path, 'transformation', 'a transform/encoding (only decoded domains without transforms are read)');
305
+ const filters = [];
306
+ while (a._tag === 'Refinement') {
307
+ const id = symAnnotation(a, 'SchemaId');
308
+ filters.push({ id: typeof id === 'symbol' ? id.description ?? '' : '', payload: object(symAnnotation(a, 'JSONSchema')) });
309
+ a = node(a.from, path);
310
+ if (transformed(a))
311
+ fail(path, 'transformation', 'a transform under a refinement');
312
+ }
313
+ if (Array.isArray(a.checks))
314
+ for (const x of a.checks) {
315
+ const c = object(x), r = object(object(c.annotations).representation);
316
+ filters.push({ id: c._tag === 'Filter' && typeof r.id === 'string' ? r.id : '', payload: object(r.payload) });
317
+ }
318
+ return { base: a, filters };
319
+ };
320
+ const integers = (fs, path, literals) => {
321
+ let integral = !!literals, minimum = Number.MIN_SAFE_INTEGER, maximum = Number.MAX_SAFE_INTEGER;
322
+ const bound = (payload, key) => typeof payload[key] === 'number' && Number.isFinite(payload[key]) ? payload[key] : fail(path, 'invalid-bound', 'an unrecognized or non-finite integer bound');
323
+ for (const f of fs) {
324
+ switch (f.id) {
325
+ case 'effect/SchemaId/Int':
326
+ case 'effect/schema/isInt':
327
+ integral = true;
328
+ break;
329
+ case 'effect/SchemaId/GreaterThan':
330
+ case 'effect/schema/isGreaterThan':
331
+ minimum = Math.max(minimum, Math.floor(bound(f.payload, 'exclusiveMinimum')) + 1);
332
+ break;
333
+ case 'effect/SchemaId/GreaterThanOrEqualTo':
334
+ case 'effect/schema/isGreaterThanOrEqualTo':
335
+ minimum = Math.max(minimum, Math.ceil(bound(f.payload, 'minimum')));
336
+ break;
337
+ case 'effect/SchemaId/LessThan':
338
+ case 'effect/schema/isLessThan':
339
+ maximum = Math.min(maximum, Math.ceil(bound(f.payload, 'exclusiveMaximum')) - 1);
340
+ break;
341
+ case 'effect/SchemaId/LessThanOrEqualTo':
342
+ case 'effect/schema/isLessThanOrEqualTo':
343
+ maximum = Math.min(maximum, Math.floor(bound(f.payload, 'maximum')));
344
+ break;
345
+ case 'effect/SchemaId/Between':
346
+ case 'effect/schema/isBetween':
347
+ minimum = Math.max(minimum, Math.ceil(bound(f.payload, 'minimum')));
348
+ maximum = Math.min(maximum, Math.floor(bound(f.payload, 'maximum')));
349
+ break;
350
+ case 'effect/SchemaId/Finite':
351
+ case 'effect/schema/isFinite':
352
+ case 'effect/SchemaId/NonNaN': break; // implied by safe integer, checked below
353
+ default: lose(path, 'unsupported-refinement', `an unsupported numeric refinement (${f.id || 'custom predicate'}); no predicate is executed`);
354
+ }
355
+ }
356
+ if (!integral)
357
+ fail(path, 'fractional-number', 'a number that may be fractional (use Schema.Int)');
358
+ if (minimum > maximum || (literals && (!literals.length || literals.some(n => !Number.isSafeInteger(n)))))
359
+ fail(path, 'empty-integer-domain', 'an empty or non-safe integer domain');
360
+ const values = literals?.filter(n => n >= minimum && n <= maximum);
361
+ if (values?.length === 0)
362
+ fail(path, 'empty-integer-domain', 'an empty integer domain');
363
+ constraints.push({ path, kind: 'integer', minimum, maximum, ...(values ? { values } : {}) });
364
+ return new IntegerKind(minimum, maximum, values);
365
+ };
366
+ const fieldsOf = (a, path, tagged = false) => {
367
+ if (!Array.isArray(a.propertySignatures) || (Array.isArray(a.indexSignatures) && a.indexSignatures.length))
368
+ fail(path, 'index-signature', 'an object with an index signature or unknown fields');
369
+ const fields = {}, optional = new Set();
370
+ for (const raw of a.propertySignatures) {
371
+ const p = object(raw), name = p.name;
372
+ if (typeof name !== 'string')
373
+ fail(path, 'field-name', 'a symbol/numeric property (plain named fields are read)');
374
+ plainName(name, path);
375
+ if (tagged && name === '_tag')
376
+ continue;
377
+ const field = name, location = at(path, field), child = node(p.type, location);
378
+ const absent = p.isOptional === true || object(p.context).isOptional === true || object(child.context).isOptional === true;
379
+ if (absent) {
380
+ lose(location, 'optional-to-null', 'an optional property; missing and undefined would normalize to null', 'normalization');
381
+ optional.add(field);
382
+ }
383
+ let k = go(child, location);
384
+ if (absent && !(k instanceof NullableKind))
385
+ k = new NullableKind(k, true);
386
+ if (absent && k instanceof NullableKind && !k.normalizeUndefined)
387
+ k = new NullableKind(k.inner, true);
388
+ if (own(fields, field))
389
+ fail(location, 'duplicate-field', 'a duplicate field');
390
+ fields[field] = k;
391
+ }
392
+ return { fields, optional };
393
+ };
394
+ const go = (source, path) => {
395
+ const { base: a, filters } = filtersOf(source, path), t = tag(a);
396
+ if (t === 'Number')
397
+ return integers(filters, path);
398
+ if (t === 'Literal' && typeof a.literal === 'number')
399
+ return integers(filters, path, [a.literal]);
400
+ for (const f of filters)
401
+ lose(path, 'unsupported-refinement', `an unsupported ${t} refinement (${f.id || 'custom predicate'}); no predicate is executed`);
402
+ if (t === 'Boolean')
403
+ return new BooleanKind();
404
+ if (t === 'String') {
405
+ abstractStrings = true;
406
+ return new StringKind();
407
+ }
408
+ if (t === 'Literal') {
409
+ if (typeof a.literal === 'string') {
410
+ constraints.push({ path, kind: 'literals', values: [a.literal] });
411
+ return new ChoiceKind([a.literal]);
412
+ }
413
+ if (typeof a.literal === 'boolean')
414
+ return new BooleanKind(a.literal);
415
+ }
416
+ if (t === 'Objects') {
417
+ const { fields, optional } = fieldsOf(a, path);
418
+ return new StructKind(fields, optional);
419
+ }
420
+ if (t !== 'Union')
421
+ return fail(path, 'unsupported-schema', `a ${a._tag} schema (arrays, dynamic collections, standalone null/undefined and declarations are not ordinary Kinds)`);
422
+ if (!Array.isArray(a.types) || !a.types.length)
423
+ return fail(path, 'empty-union', 'an empty union');
424
+ const types = a.types.map(x => node(x, path));
425
+ if (types.length === 1)
426
+ return go(types[0], path);
427
+ for (const member of types) {
428
+ const inspected = filtersOf(member, path);
429
+ if (['Literal', 'Null', 'Undefined'].includes(tag(inspected.base)))
430
+ for (const f of inspected.filters)
431
+ lose(path, 'unsupported-refinement', `a refined union alternative (${f.id || 'custom predicate'})`);
432
+ }
433
+ const missing = types.filter(x => tag(x) === 'Null' || tag(x) === 'Undefined' || (x._tag === 'Literal' && x.literal === null));
434
+ const rest = types.filter(x => !missing.includes(x));
435
+ if (missing.length) {
436
+ const hasUndefined = missing.some(x => tag(x) === 'Undefined');
437
+ if (hasUndefined)
438
+ lose(path, 'undefined-to-null', 'a union with undefined; undefined would normalize to null', 'normalization');
439
+ if (rest.length !== 1)
440
+ fail(path, 'unsupported-union', 'a nullable union without exactly one value domain');
441
+ const inner = go(rest[0], path);
442
+ return inner instanceof NullableKind ? new NullableKind(inner.inner, hasUndefined || inner.normalizeUndefined) : new NullableKind(inner, hasUndefined);
443
+ }
444
+ if (types.every(x => x._tag === 'Literal' && typeof x.literal === 'string')) {
445
+ const values = [...new Set(types.map(x => x.literal))];
446
+ constraints.push({ path, kind: 'literals', values });
447
+ return new ChoiceKind(values);
448
+ }
449
+ if (types.every(x => x._tag === 'Literal' && typeof x.literal === 'number'))
450
+ return integers([], path, [...new Set(types.map(x => x.literal))]);
451
+ if (types.every(x => x._tag === 'Literal' && typeof x.literal === 'boolean'))
452
+ return new BooleanKind(types.every(x => x.literal === types[0].literal) ? types[0].literal : undefined);
453
+ const cases = {};
454
+ for (const x of types) {
455
+ // Do not discard checks/transformations attached to a union member while reading its fields.
456
+ const member = filtersOf(x, path);
457
+ if (tag(member.base) !== 'Objects')
458
+ fail(path, 'unsupported-union', 'a union other than literals, NullOr, or distinct _tag structs');
459
+ for (const f of member.filters)
460
+ lose(path, 'unsupported-refinement', `a refined union member (${f.id || 'custom predicate'})`);
461
+ const props = member.base.propertySignatures;
462
+ if (!Array.isArray(props))
463
+ fail(path, 'unsupported-union', 'a tagged member without declared fields');
464
+ const p = props.map(object).find(p => p.name === '_tag'), litTag = p && node(p.type, path);
465
+ if (!litTag || litTag._tag !== 'Literal' || typeof litTag.literal !== 'string' || p?.isOptional || object(p?.context).isOptional || object(litTag.context).isOptional)
466
+ return fail(path, 'unsupported-union', 'a member without a required literal _tag');
467
+ const name = litTag.literal;
468
+ plainName(name, path);
469
+ if (own(cases, name))
470
+ fail(path, 'duplicate-tag', 'a union with duplicate _tag values');
471
+ // Tag predicates are not field metadata.
472
+ go(litTag, at(path, '_tag'));
473
+ const fields = fieldsOf(member.base, at(path, name), true);
474
+ if (fields.optional.size)
475
+ fail(path, 'optional-variant', 'an optional field in a variant (normalization is supported only for records)');
476
+ cases[name] = fields.fields;
477
+ }
478
+ return new TaggedKind(cases);
479
+ };
480
+ let ast = node(schema.ast, '');
481
+ const fields = schema.fields;
482
+ if (fields && tag(ast) !== 'Objects') {
483
+ lose('', 'class-fields', 'a Schema.Class/declaration: only declared fields, not instances, methods or prototype, are projected', 'projection');
484
+ // A class can carry additional predicates; projection does not silently discard those either.
485
+ let outer = ast;
486
+ while (outer._tag === 'Refinement') {
487
+ lose('', 'unsupported-refinement', 'an additional class refinement is not modeled');
488
+ outer = node(outer.from, '');
489
+ }
490
+ if (Array.isArray(outer.checks))
491
+ for (const _check of outer.checks)
492
+ lose('', 'unsupported-refinement', 'an additional class check is not modeled');
493
+ ast = { _tag: 'Objects', propertySignatures: Object.entries(fields).map(([name, f]) => ({ name, type: f.ast })), indexSignatures: [] };
494
+ }
495
+ const inner = go(ast, '');
496
+ const runtime = losses.some(l => l.effect === 'projection') ? 'projection' : losses.some(l => l.effect === 'normalization') ? 'normalized' : losses.length ? 'overapproximation' : 'exact-on-decoded-closed-values';
497
+ const report = Object.freeze({ mode, domain: 'decoded-closed-values', runtime, model: abstractStrings || losses.length ? 'overapproximation' : 'exact', counterexamples: 'validate-with-schema', losses: Object.freeze(losses.map(l => Object.freeze(l))), constraints: Object.freeze(constraints.map(c => Object.freeze({ ...c, ...(c.values ? { values: Object.freeze([...c.values]) } : {}) }))) });
498
+ // The exact overload follows the supported structural shape. Approximation never promises a narrowed Type.
499
+ return new SchemaKind(inner, report);
500
+ }
@@ -1,4 +1,4 @@
1
- import type { Kind, Rule } from './dsl.js';
1
+ import type { Rule } from './dsl.js';
2
2
  import { type Law, type Rand } from './machine.js';
3
3
  import { type Source } from './extract-read.js';
4
4
  import { type ExtractOptions, type Extraction } from './extract.js';
@@ -73,9 +73,5 @@ export declare function conforms<S>(r: Rule, svc: Service<S>, opts: {
73
73
  checked: number;
74
74
  failure?: string;
75
75
  };
76
- export declare function fromSchema(schema: {
77
- ast: unknown;
78
- fields?: Record<string, {
79
- ast: unknown;
80
- }>;
81
- }): Kind<any>;
76
+ export { fromSchema, SchemaError, SchemaKind } from './effect-schema.js';
77
+ export type { SchemaConstraint, SchemaDiagnostic, SchemaLike, SchemaOptions, SchemaReport, SchemaSymbolic, SchemaValue } from './effect-schema.js';
@@ -25,6 +25,7 @@ import { fromModel, namesOf } from "./extract.js";
25
25
  import { check, sandbox } from "./extract-check.js";
26
26
  import { Parts, readSchedule, replaySchedule, scheduleConforms, scheduleRule } from "./effect-schedule.js";
27
27
  import { asRule, lift } from "./system.js";
28
+ import { attachSource, inheritSource } from "./source-check.js";
28
29
  import { rewritePrims } from "./effect-prims.js";
29
30
  export { proveRule, proveSteps } from "./dsl.js";
30
31
  export { jitterRun, replaySchedule, scheduleConforms, stepper } from "./effect-schedule.js";
@@ -686,7 +687,9 @@ export function withLemmas(x, opts = {}) {
686
687
  catch {
687
688
  v = undefined;
688
689
  }
689
- if (v?.proven && v.checked) {
690
+ // These are mathematical supports, not source claims. The caller's marked
691
+ // rule still requires native finalization; a native translation error is not admitted.
692
+ if (v && ((v.proven && v.checked) || (v.kernelProven === true && v.translation === 'unchecked'))) {
690
693
  inv.push(l, ...(v.found?.laws ?? []).map(f => f.law));
691
694
  proven.push(l.name);
692
695
  }
@@ -901,6 +904,8 @@ function fibered(code, file, entry, E, opts) {
901
904
  const one2 = one.rule;
902
905
  const ints = [...one2.kindsOfState().filter(([n]) => shared.includes(n) && shared.includes(`${n}$neg`)), ...one2.kindsOfCells().filter(([n, k]) => k.vars(n).every(p => !local(p)))];
903
906
  const rule = asRule({ ...lifted, name: `${m0.name}, every fiber` }, Object.fromEntries([...parts.params, ...parts.inputs].filter(whole).concat(ints)));
907
+ // Lifting is not transparent native replay: retain provenance, not the old journal.
908
+ inheritSource(one.rule, rule);
904
909
  const names = (one.names ?? []).filter(n => !(n.role === 'state' && local(n.rule)) && n.role !== 'result' && !made.has(n.code));
905
910
  const inv = (one.invariants ?? []).filter(l => ![...JSON.stringify(l.holds).matchAll(/"name":"([^"]*)"/g)].some(m => local(m[1])));
906
911
  const steps = split.map((mt, mi) => ({ name: mt.name, steps: mt.units.length, base: (mi + 1) * 100 }));
@@ -981,6 +986,8 @@ function fromScheduleEntry(code, file, e, E, opts) {
981
986
  const runs = opts.check?.runs ?? 60, c = scheduleConforms(sr, make, E, { runs, depth: 14 });
982
987
  const evidence = { runs, requests: c.checked, fromStates: 0, probes: { conditions: 0, witnesses: 0, steps: 0 }, refusedBoth: 0, outside: 0, edge: 0, compiledAgreed: c.checked, coverage: { arms: 0, hit: 0, missed: [] }, ms: Date.now() - t0, ...(c.failure ? { mismatch: c.failure } : {}) };
983
988
  const source = `// ${e.name}: ${e.expr.getText().replace(/\s+/g, ' ')}\n${sr.rule.machine.name}: state ${Object.keys(sr.rule.machine.state).join(', ')}; inputs ${sr.rule.machine.inputs.join(', ')}${sr.rule.machine.params.length ? `; params ${sr.rule.machine.params.join(', ')}` : ''}`;
989
+ // Schedule conformance checks transitions, not native source-law semantics.
990
+ attachSource(sr.rule, evidence, []);
984
991
  if (c.failure)
985
992
  return { ok: false, rule: sr.rule, source, refusals: [{ where: file, what: `the rule and Effect's own schedule part: ${c.failure}` }], notes, names: sr.names, evidence };
986
993
  return { ok: true, rule: sr.rule, source, refusals: [], notes, names: sr.names, evidence, schedule: sr, replay: run => replaySchedule(sr, make(run.params), E, run) };
@@ -1066,67 +1073,5 @@ export function conforms(r, svc, opts) {
1066
1073
  }
1067
1074
  return { checked };
1068
1075
  }
1069
- // A Schema's kind (its type side, 3.x or 4.x): a struct a record, string literals a choice, a tagged union of structs a
1070
- // variant on `_tag`, integers int (nat where at least 0), Boolean, String, `X | null` and optional fields a maybe, a
1071
- // Schema.Class its fields. A number that may be fractional, and any other Schema, is refused with the path to it.
1072
- // 3.x's AST nodes by 4.x's names:
1073
- const TAGS = { NumberKeyword: 'Number', BooleanKeyword: 'Boolean', StringKeyword: 'String', TypeLiteral: 'Objects', UndefinedKeyword: 'Undefined' };
1074
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1075
- export function fromSchema(schema) {
1076
- const fail = (path, what) => { throw new Error(`fromSchema: ${path || 'the schema'} is ${what}`); };
1077
- const tagOf = (a) => TAGS[a?._tag] ?? a?._tag;
1078
- const ann = (a, id) => { const k = Object.getOwnPropertySymbols(a.annotations ?? {}).find(x => x.description === id); return k ? a.annotations[k] : undefined; };
1079
- const base = (a) => (a._tag === 'Refinement' ? base(a.from) : a);
1080
- // An integer: 4.x's checks on Number (isInt, a minimum), 3.x's Refinements down to NumberKeyword (Int, a JSON Schema minimum).
1081
- const num = (a, path) => {
1082
- let int = false, min = -Infinity;
1083
- for (let x = a; x; x = x._tag === 'Refinement' ? x.from : undefined) {
1084
- const js = ann(x, 'effect/annotation/JSONSchema');
1085
- for (const c of [...(x.checks ?? []).map((c) => c.annotations ?? {}).map((an) => ({ int: an.representation?.id === 'effect/schema/isInt' || an.arbitraryConstraint?.number?.isInteger, min: an.arbitraryConstraint?.minimum })),
1086
- { int: js?.type === 'integer' || ann(x, 'effect/annotation/SchemaId')?.description === 'effect/SchemaId/Int', min: js?.minimum }]) {
1087
- int ||= !!c.int;
1088
- if (typeof c.min === 'number')
1089
- min = Math.max(min, c.min);
1090
- }
1091
- }
1092
- return int ? (min >= 0 ? dsl.nat : dsl.int) : fail(path, 'a number that may be fractional (an integer schema, Schema.Int, is read)');
1093
- };
1094
- const props = (a) => a.propertySignatures;
1095
- const go = (a, path) => {
1096
- const tag = tagOf(a);
1097
- if (tag === 'Transformation')
1098
- return go(a.to, path);
1099
- if (tag === 'Number' || (tag === 'Refinement' && tagOf(base(a)) === 'Number'))
1100
- return num(a, path);
1101
- if (tag === 'Refinement')
1102
- return go(a.from, path);
1103
- if (tag === 'Boolean')
1104
- return dsl.bool;
1105
- if (tag === 'String')
1106
- return dsl.str();
1107
- if (tag === 'Literal')
1108
- return typeof a.literal === 'string' ? dsl.oneOf(a.literal) : fail(path, `the literal ${String(a.literal)} (string literals are read)`);
1109
- if (tag === 'Objects') {
1110
- if (a.indexSignatures?.length)
1111
- fail(path, 'a record with an index signature');
1112
- return dsl.record(fieldsOf(a, path, false));
1113
- }
1114
- if (tag !== 'Union')
1115
- return fail(path, `a ${a?._tag} schema (structs, literals, tagged unions, integers, booleans and strings are read)`);
1116
- const types = a.types, missing = types.filter(t => ['Null', 'Undefined'].includes(tagOf(t)) || (t._tag === 'Literal' && t.literal === null)), rest = types.filter(t => !missing.includes(t));
1117
- const caseOf = (t) => { const p = tagOf(t) === 'Objects' ? props(t).find(x => x.name === '_tag') : undefined; return p?.type._tag === 'Literal' && typeof p.type.literal === 'string' ? p.type.literal : undefined; };
1118
- if (missing.length && rest.length === 1)
1119
- return dsl.maybe(go(rest[0], path));
1120
- if (rest.every(t => t._tag === 'Literal' && typeof t.literal === 'string'))
1121
- return dsl.oneOf(...rest.map(t => t.literal));
1122
- if (!missing.length && rest.every(caseOf))
1123
- return dsl.variant(Object.fromEntries(rest.map(t => [caseOf(t), fieldsOf(t, path, true)])), { tag: '_tag' });
1124
- return fail(path, 'a union other than of string literals, of structs tagged by _tag, or with null');
1125
- };
1126
- const fieldsOf = (a, path, tagged) => Object.fromEntries(props(a).filter(p => !(tagged && p.name === '_tag')).map(p => {
1127
- const k = go(p.type, `${path ? `${path}.` : ''}${String(p.name)}`);
1128
- return [String(p.name), (p.isOptional || p.context?.isOptional) && !('of' in k) ? dsl.maybe(k) : k];
1129
- }));
1130
- const ast = schema.ast;
1131
- return schema.fields && tagOf(ast) !== 'Objects' ? dsl.record(Object.fromEntries(Object.entries(schema.fields).map(([f, x]) => [f, go(x.ast, f)]))) : go(ast, '');
1132
- }
1076
+ // The decoded Schema frontend is independent of service extraction and keeps Effect optional.
1077
+ export { fromSchema, SchemaError, SchemaKind } from "./effect-schema.js";
@@ -9,7 +9,7 @@ export declare function substVarsE(e: E, s: Record<string, E>): E;
9
9
  export declare function substVars(c: C, s: Record<string, E>): C;
10
10
  export declare function small(m: Machine, p: Env, b: number, cap?: number, work?: number, walks?: number): State[];
11
11
  export declare function ghostOf(m: Machine, law: Law): SomeWitness | undefined;
12
- export declare function smallOf(m: Machine): {
12
+ export declare function smallOf(m: Machine, source?: Machine): {
13
13
  p: Env;
14
14
  sts: State[];
15
15
  }[];