foldkit-surface 0.13.0 → 0.15.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/README.md +277 -30
- package/dist/closure.d.ts +75 -0
- package/dist/closure.d.ts.map +1 -0
- package/dist/closure.js +95 -0
- package/dist/closure.js.map +1 -0
- package/dist/edgeCache.d.ts +75 -5
- package/dist/edgeCache.d.ts.map +1 -1
- package/dist/edgeCache.js +42 -1
- package/dist/edgeCache.js.map +1 -1
- package/dist/graph.d.ts +238 -0
- package/dist/graph.d.ts.map +1 -0
- package/dist/graph.js +350 -0
- package/dist/graph.js.map +1 -0
- package/dist/index.d.ts +64 -14
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +41 -25
- package/dist/index.js.map +1 -1
- package/dist/messageTags.d.ts +9 -0
- package/dist/messageTags.d.ts.map +1 -0
- package/dist/messageTags.js +14 -0
- package/dist/messageTags.js.map +1 -0
- package/dist/text.d.ts +6 -0
- package/dist/text.d.ts.map +1 -0
- package/dist/text.js +8 -0
- package/dist/text.js.map +1 -0
- package/package.json +5 -4
package/dist/graph.js
ADDED
|
@@ -0,0 +1,350 @@
|
|
|
1
|
+
import { Data, Option } from "effect";
|
|
2
|
+
import { lawFactsOf } from "foldkit-entity";
|
|
3
|
+
import { Evidence } from "foldkit-metadata";
|
|
4
|
+
import { labelOf, pathText, tableCell } from "./text.js";
|
|
5
|
+
// src/graph.ts
|
|
6
|
+
/**
|
|
7
|
+
* The law half of the contract graph (#537): which transitions write what
|
|
8
|
+
* which laws read, and what shows each keeps each. A contract declares its
|
|
9
|
+
* laws and transitions as plain data (`Contract.laws`), and `Graph` derives
|
|
10
|
+
* their nodes and edges here, when asked; a closed Surface contributes a
|
|
11
|
+
* level from its flag; tests contribute evidence. `Graph` is its own module
|
|
12
|
+
* so a page that reads `Module` alone carries none of it. `Graph.validate`
|
|
13
|
+
* asks the graph's one question: is every transition that can break a law
|
|
14
|
+
* witnessed keeping it?
|
|
15
|
+
*/
|
|
16
|
+
const GraphNode = /* @__PURE__ */ Data.taggedEnum();
|
|
17
|
+
const GraphEdge = /* @__PURE__ */ Data.taggedEnum();
|
|
18
|
+
const isPrefix = (prefix, path) => prefix.length <= path.length && prefix.every((segment, index) => segment === path[index]);
|
|
19
|
+
/** One path is within the other: writing `['todos']` writes `['todos', 'title']`, and the reverse. */
|
|
20
|
+
const overlaps = (a, b) => a.space === b.space && a.path.length > 0 && b.path.length > 0 && (isPrefix(a.path, b.path) || isPrefix(b.path, a.path));
|
|
21
|
+
const keyOf = (value) => JSON.stringify(value);
|
|
22
|
+
/** A contract's declared laws as nodes and edges. */
|
|
23
|
+
const factsOf = (contract, laws) => {
|
|
24
|
+
const model = (laws.model ?? []).map((id) => `${labelOf(contract)}.${id}`);
|
|
25
|
+
const durable = laws.model === void 0 ? [] : contract.messages.map((tag) => `durable:${tag}`);
|
|
26
|
+
const entities = lawFactsOf(laws.entities ?? []);
|
|
27
|
+
return {
|
|
28
|
+
nodes: [
|
|
29
|
+
...model.map((id) => GraphNode.Law({ id })),
|
|
30
|
+
...durable.map((id) => GraphNode.Transition({
|
|
31
|
+
id,
|
|
32
|
+
kind: "durable"
|
|
33
|
+
})),
|
|
34
|
+
...entities.nodes
|
|
35
|
+
],
|
|
36
|
+
edges: [
|
|
37
|
+
...model.flatMap((law) => contract.owns.map((path) => GraphEdge.Reads({
|
|
38
|
+
law,
|
|
39
|
+
space: "model",
|
|
40
|
+
path
|
|
41
|
+
}))),
|
|
42
|
+
...durable.flatMap((transition) => contract.owns.map((path) => GraphEdge.Writes({
|
|
43
|
+
transition,
|
|
44
|
+
space: "model",
|
|
45
|
+
path
|
|
46
|
+
}))),
|
|
47
|
+
...entities.edges
|
|
48
|
+
]
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
/** The contracts' declared laws, their closed Surfaces as levels, and the evidence that joins a pair. */
|
|
52
|
+
const assemble = (contracts, options) => {
|
|
53
|
+
const nodes = /* @__PURE__ */ new Map();
|
|
54
|
+
const edges = /* @__PURE__ */ new Map();
|
|
55
|
+
const contributors = /* @__PURE__ */ new Map();
|
|
56
|
+
const reads = /* @__PURE__ */ new Map();
|
|
57
|
+
const writes = /* @__PURE__ */ new Map();
|
|
58
|
+
const levels = [];
|
|
59
|
+
const node = (made) => nodes.set(keyOf(made), made);
|
|
60
|
+
const contributed = (key, label) => {
|
|
61
|
+
const known = contributors.get(key) ?? [];
|
|
62
|
+
if (!known.includes(label)) contributors.set(key, [...known, label]);
|
|
63
|
+
};
|
|
64
|
+
const located = (into, id, at) => {
|
|
65
|
+
const known = into.get(id) ?? [];
|
|
66
|
+
if (!known.some((each) => each.space === at.space && keyOf(each.path) === keyOf(at.path))) into.set(id, [...known, at]);
|
|
67
|
+
node(GraphNode.Path({
|
|
68
|
+
space: at.space,
|
|
69
|
+
path: at.path
|
|
70
|
+
}));
|
|
71
|
+
};
|
|
72
|
+
const edge = (made) => {
|
|
73
|
+
if (GraphEdge.$match(made, {
|
|
74
|
+
Owns: ({ path }) => {
|
|
75
|
+
node(GraphNode.Path({
|
|
76
|
+
space: "model",
|
|
77
|
+
path
|
|
78
|
+
}));
|
|
79
|
+
return true;
|
|
80
|
+
},
|
|
81
|
+
Reads: ({ law, space, path }) => {
|
|
82
|
+
located(reads, law, {
|
|
83
|
+
space,
|
|
84
|
+
path
|
|
85
|
+
});
|
|
86
|
+
return true;
|
|
87
|
+
},
|
|
88
|
+
Writes: ({ transition, space, path }) => {
|
|
89
|
+
located(writes, transition, {
|
|
90
|
+
space,
|
|
91
|
+
path
|
|
92
|
+
});
|
|
93
|
+
return true;
|
|
94
|
+
},
|
|
95
|
+
Observes: ({ path }) => {
|
|
96
|
+
node(GraphNode.Path({
|
|
97
|
+
space: "model",
|
|
98
|
+
path
|
|
99
|
+
}));
|
|
100
|
+
return true;
|
|
101
|
+
},
|
|
102
|
+
From: () => true,
|
|
103
|
+
To: () => true,
|
|
104
|
+
Keeps: () => false,
|
|
105
|
+
Refines: () => true
|
|
106
|
+
})) edges.set(keyOf(made), made);
|
|
107
|
+
};
|
|
108
|
+
for (const contract of new Set(contracts)) {
|
|
109
|
+
const label = labelOf(contract);
|
|
110
|
+
if (contract.owns.length > 0) {
|
|
111
|
+
node(GraphNode.Owner({
|
|
112
|
+
kind: contract.kind,
|
|
113
|
+
name: contract.name
|
|
114
|
+
}));
|
|
115
|
+
for (const path of contract.owns) edge(GraphEdge.Owns({
|
|
116
|
+
owner: label,
|
|
117
|
+
path
|
|
118
|
+
}));
|
|
119
|
+
}
|
|
120
|
+
if (contract.closed === true) {
|
|
121
|
+
const law = `closure:${contract.name}`;
|
|
122
|
+
node(GraphNode.Level({ surface: contract.name }));
|
|
123
|
+
node(GraphNode.Law({ id: law }));
|
|
124
|
+
contributed(`law:${law}`, label);
|
|
125
|
+
levels.push(contract);
|
|
126
|
+
for (const path of contract.observes) {
|
|
127
|
+
edge(GraphEdge.Observes({
|
|
128
|
+
level: contract.name,
|
|
129
|
+
path
|
|
130
|
+
}));
|
|
131
|
+
edge(GraphEdge.Reads({
|
|
132
|
+
law,
|
|
133
|
+
space: "model",
|
|
134
|
+
path
|
|
135
|
+
}));
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
if (contract.laws === void 0) continue;
|
|
139
|
+
const facts = factsOf(contract, contract.laws);
|
|
140
|
+
for (const made of facts.nodes) {
|
|
141
|
+
node(made);
|
|
142
|
+
const key = GraphNode.$match(made, {
|
|
143
|
+
Owner: () => Option.none(),
|
|
144
|
+
Path: () => Option.none(),
|
|
145
|
+
Transition: ({ id }) => Option.some(`transition:${id}`),
|
|
146
|
+
Law: ({ id }) => Option.some(`law:${id}`),
|
|
147
|
+
State: () => Option.none(),
|
|
148
|
+
Level: () => Option.none()
|
|
149
|
+
});
|
|
150
|
+
if (Option.isSome(key)) contributed(key.value, label);
|
|
151
|
+
}
|
|
152
|
+
for (const made of facts.edges) edge(made);
|
|
153
|
+
}
|
|
154
|
+
const covers = (wider, narrower) => narrower.observes.every((path) => wider.observes.some((own) => isPrefix(own, path)));
|
|
155
|
+
for (const a of levels) for (const b of levels) if (a !== b && covers(a, b) && !covers(b, a)) edge(GraphEdge.Refines({
|
|
156
|
+
level: a.name,
|
|
157
|
+
of: b.name
|
|
158
|
+
}));
|
|
159
|
+
const laws = new Set([...nodes.values()].filter(GraphNode.$is("Law")).map((law) => law.id));
|
|
160
|
+
const transitions = new Map([...nodes.values()].filter(GraphNode.$is("Transition")).map((transition) => [transition.id, transition.entity]));
|
|
161
|
+
const unmatched = [];
|
|
162
|
+
const kept = /* @__PURE__ */ new Set();
|
|
163
|
+
const admit = (record) => {
|
|
164
|
+
const { transition, law } = record;
|
|
165
|
+
const involved = [...contributors.get(`transition:${transition}`) ?? [], ...contributors.get(`law:${law}`) ?? []];
|
|
166
|
+
const refuse = (why) => {
|
|
167
|
+
unmatched.push({
|
|
168
|
+
record,
|
|
169
|
+
contracts: [...new Set(involved)],
|
|
170
|
+
message: `Evidence that ${transition} keeps ${law} ${why}`
|
|
171
|
+
});
|
|
172
|
+
};
|
|
173
|
+
if (Option.isNone(Evidence.issuedBy(record))) return refuse("was issued by no producer: it was typed by hand or copied");
|
|
174
|
+
if (!transitions.has(transition)) return refuse(`names ${transition}, which no contract declares`);
|
|
175
|
+
if (!laws.has(law)) return refuse(`names ${law}, which no contract declares`);
|
|
176
|
+
const written = writes.get(transition) ?? [];
|
|
177
|
+
const entity = transitions.get(transition);
|
|
178
|
+
const entities = /* @__PURE__ */ new Set([...written.flatMap((at) => at.space === "entity" ? [at.path[0]] : []), ...entity === void 0 ? [] : [entity]]);
|
|
179
|
+
const joins = (at) => at.space === "entity" ? entities.has(at.path[0]) : written.some((each) => overlaps(each, at));
|
|
180
|
+
if (!(reads.get(law) ?? []).some(joins)) return refuse(`names a pair the graph does not join: ${transition} writes nothing beside what ${law} reads`);
|
|
181
|
+
if (kept.has(record)) return;
|
|
182
|
+
kept.add(record);
|
|
183
|
+
edges.set(`keeps:${kept.size}`, GraphEdge.Keeps({
|
|
184
|
+
transition,
|
|
185
|
+
law,
|
|
186
|
+
evidence: record
|
|
187
|
+
}));
|
|
188
|
+
};
|
|
189
|
+
for (const record of options.evidence ?? []) admit(record);
|
|
190
|
+
return {
|
|
191
|
+
graph: {
|
|
192
|
+
nodes: [...nodes.values()],
|
|
193
|
+
edges: [...edges.values()]
|
|
194
|
+
},
|
|
195
|
+
contributors,
|
|
196
|
+
unmatched
|
|
197
|
+
};
|
|
198
|
+
};
|
|
199
|
+
/** The ids of the graph's laws, in the order contracts declared them. */
|
|
200
|
+
const lawsOf = (graph) => graph.nodes.filter(GraphNode.$is("Law")).map((law) => law.id);
|
|
201
|
+
const breakers = (graph, law) => {
|
|
202
|
+
const read = graph.edges.filter(GraphEdge.$is("Reads")).filter((edge) => edge.law === law).map(({ space, path }) => ({
|
|
203
|
+
space,
|
|
204
|
+
path
|
|
205
|
+
}));
|
|
206
|
+
const keeps = graph.edges.filter(GraphEdge.$is("Keeps")).filter((edge) => edge.law === law);
|
|
207
|
+
return graph.nodes.filter(GraphNode.$is("Transition")).flatMap(({ id }) => {
|
|
208
|
+
const paths = graph.edges.filter(GraphEdge.$is("Writes")).filter((edge) => edge.transition === id && read.some((at) => overlaps(at, edge))).map((edge) => edge.path);
|
|
209
|
+
if (paths.length === 0) return [];
|
|
210
|
+
return [{
|
|
211
|
+
transition: id,
|
|
212
|
+
paths,
|
|
213
|
+
evidence: keeps.filter((edge) => edge.transition === id).map((edge) => edge.evidence)
|
|
214
|
+
}];
|
|
215
|
+
});
|
|
216
|
+
};
|
|
217
|
+
const sameSet = (a, b) => a.length === b.length && a.every((each) => b.includes(each)) && b.every((each) => a.includes(each));
|
|
218
|
+
/** The rules over the graph, as `Graph.validate` documents them. */
|
|
219
|
+
const findingsOf = (contracts, { graph, contributors, unmatched }) => {
|
|
220
|
+
const involved = (transition, law) => [.../* @__PURE__ */ new Set([...contributors.get(`transition:${transition}`) ?? [], ...contributors.get(`law:${law}`) ?? []])];
|
|
221
|
+
const findings = lawsOf(graph).flatMap((law) => breakers(graph, law).filter((breaker) => breaker.evidence.length === 0).map(({ transition, paths }) => ({
|
|
222
|
+
rule: "law-unwitnessed",
|
|
223
|
+
contracts: involved(transition, law),
|
|
224
|
+
message: `${transition} writes ${paths.map(pathText).join(", ")}, which ${law} reads, and no evidence shows it keeps ${law}`
|
|
225
|
+
})));
|
|
226
|
+
for (const { contracts: named, message } of unmatched) findings.push({
|
|
227
|
+
rule: "evidence-unmatched",
|
|
228
|
+
contracts: named,
|
|
229
|
+
message
|
|
230
|
+
});
|
|
231
|
+
for (const { id, kind } of graph.nodes.filter(GraphNode.$is("Transition"))) if (kind === "write") {
|
|
232
|
+
const named = contributors.get(`transition:${id}`) ?? [];
|
|
233
|
+
if (named.length > 1) findings.push({
|
|
234
|
+
rule: "transition-declared-twice",
|
|
235
|
+
contracts: named,
|
|
236
|
+
message: `${id} is declared by ${named.join(" and ")}, so evidence naming it cannot say which`
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
const closed = [...new Set(contracts)].filter((contract) => contract.closed === true);
|
|
240
|
+
for (let i = 0; i < closed.length; i += 1) for (let j = i + 1; j < closed.length; j += 1) {
|
|
241
|
+
const [a, b] = [closed[i], closed[j]];
|
|
242
|
+
if (sameSet(a.observes.map(pathText), b.observes.map(pathText)) && sameSet(a.messages, b.messages)) findings.push({
|
|
243
|
+
rule: "level-declared-twice",
|
|
244
|
+
contracts: [labelOf(a), labelOf(b)],
|
|
245
|
+
message: `${labelOf(a)} and ${labelOf(b)} are closed over the same paths and the same Messages`
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
return findings;
|
|
249
|
+
};
|
|
250
|
+
/** One line of a record, for the renderers. */
|
|
251
|
+
const evidenceText = (record) => Evidence.$match(record, {
|
|
252
|
+
Enumerated: () => "enumerated",
|
|
253
|
+
Walked: ({ seeds, steps, starts }) => `walked: ${seeds} seeds of ${steps} steps from ${starts.join(", ")}`,
|
|
254
|
+
Scenario: ({ name, runner }) => `scenario on ${runner}: ${name}`,
|
|
255
|
+
RuntimeOnly: ({ why }) => `runtime only: ${why}`
|
|
256
|
+
});
|
|
257
|
+
/**
|
|
258
|
+
* The laws of a Module's contracts as a graph, the rules over it, and its
|
|
259
|
+
* renderers. `Module` asks who owns what; `Graph` asks which transitions can
|
|
260
|
+
* break which laws and what shows they keep them. A page that imports only
|
|
261
|
+
* `Module` carries none of this.
|
|
262
|
+
*
|
|
263
|
+
* ```ts
|
|
264
|
+
* Graph.validate(Shop, { evidence }) // law-unwitnessed, evidence-unmatched, …
|
|
265
|
+
* Graph.toMarkdown(Shop, { evidence }) // the Laws section
|
|
266
|
+
* ```
|
|
267
|
+
*/
|
|
268
|
+
const Graph = {
|
|
269
|
+
/**
|
|
270
|
+
* The contracts' laws as a graph: what each contract's `laws` declare, a
|
|
271
|
+
* level and a `closure:<name>` law per closed Surface, which level refines
|
|
272
|
+
* which, and a `keeps` edge per record of `evidence` that is issued and
|
|
273
|
+
* joins its pair. Pure, and computed each time it is asked.
|
|
274
|
+
*/
|
|
275
|
+
of: (module, options = {}) => assemble(module.contracts, options).graph,
|
|
276
|
+
/**
|
|
277
|
+
* Each transition that writes a path `law` reads, which is each that could
|
|
278
|
+
* break it, and the evidence admitted that it keeps it. Throws for a law
|
|
279
|
+
* the graph does not hold, which a misspelt id would otherwise answer with
|
|
280
|
+
* nothing.
|
|
281
|
+
*/
|
|
282
|
+
breakersOf: (graph, law) => {
|
|
283
|
+
if (!lawsOf(graph).includes(law)) throw new Error(`Graph.breakersOf: the graph holds no law ${law}`);
|
|
284
|
+
return breakers(graph, law);
|
|
285
|
+
},
|
|
286
|
+
/**
|
|
287
|
+
* The rules over the graph, which `Module.validate` does not ask: each
|
|
288
|
+
* transition that writes what a law reads with no evidence it keeps it
|
|
289
|
+
* (`law-unwitnessed`), each record of `evidence` not admitted
|
|
290
|
+
* (`evidence-unmatched`), each write two contracts declare
|
|
291
|
+
* (`transition-declared-twice`), and each two closed Surfaces with one
|
|
292
|
+
* projection and one Message set (`level-declared-twice`). With no
|
|
293
|
+
* `evidence`, every pair a transition can break is unwitnessed.
|
|
294
|
+
*/
|
|
295
|
+
validate: (module, options = {}) => findingsOf(module.contracts, assemble(module.contracts, options)),
|
|
296
|
+
/**
|
|
297
|
+
* A Laws section in Markdown, to set beside `Module.toMarkdown`'s: each law
|
|
298
|
+
* by each transition that writes what it reads and its evidence, then
|
|
299
|
+
* `Graph.validate`'s findings.
|
|
300
|
+
*/
|
|
301
|
+
toMarkdown: (module, options = {}) => {
|
|
302
|
+
const assembled = assemble(module.contracts, options);
|
|
303
|
+
const { graph } = assembled;
|
|
304
|
+
const laws = lawsOf(graph);
|
|
305
|
+
const lines = ["## Laws", ""];
|
|
306
|
+
if (laws.length === 0) lines.push("No contract declares a law.");
|
|
307
|
+
else {
|
|
308
|
+
lines.push("| Law | Transition | Evidence |", "| --- | --- | --- |");
|
|
309
|
+
for (const law of laws) {
|
|
310
|
+
const found = breakers(graph, law);
|
|
311
|
+
if (found.length === 0) lines.push(`| ${tableCell(law)} | | nothing writes what it reads |`);
|
|
312
|
+
for (const { transition, evidence } of found) lines.push(`| ${tableCell(law)} | ${tableCell(transition)} | ${evidence.length === 0 ? "**none**" : tableCell(evidence.map(evidenceText).join("; "))} |`);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
const findings = findingsOf(module.contracts, assembled);
|
|
316
|
+
if (findings.length > 0) {
|
|
317
|
+
lines.push("", "### Findings", "");
|
|
318
|
+
for (const finding of findings) lines.push(`- **${finding.rule}** ${finding.message}`);
|
|
319
|
+
}
|
|
320
|
+
return lines.join("\n");
|
|
321
|
+
},
|
|
322
|
+
/**
|
|
323
|
+
* The laws as a Mermaid flowchart of their own: a node per law and per
|
|
324
|
+
* transition that writes what one reads, a solid edge from each shown
|
|
325
|
+
* keeping it, labelled with its kinds of evidence, and a dotted one from
|
|
326
|
+
* each with none.
|
|
327
|
+
*/
|
|
328
|
+
toMermaid: (module, options = {}) => {
|
|
329
|
+
const graph = Graph.of(module, options);
|
|
330
|
+
const laws = lawsOf(graph);
|
|
331
|
+
const lines = ["flowchart LR", ...laws.map((law, index) => ` l${index}["${law}"]`)];
|
|
332
|
+
const transitions = [];
|
|
333
|
+
const transitionId = (id) => {
|
|
334
|
+
if (!transitions.includes(id)) {
|
|
335
|
+
transitions.push(id);
|
|
336
|
+
lines.push(` t${transitions.length - 1}["${id}"]`);
|
|
337
|
+
}
|
|
338
|
+
return `t${transitions.indexOf(id)}`;
|
|
339
|
+
};
|
|
340
|
+
const arrows = laws.flatMap((law, index) => breakers(graph, law).map(({ transition, evidence }) => {
|
|
341
|
+
const from = transitionId(transition);
|
|
342
|
+
return evidence.length === 0 ? ` ${from} -.->|unwitnessed| l${index}` : ` ${from} -->|${[...new Set(evidence.map((record) => record._tag))].join(", ")}| l${index}`;
|
|
343
|
+
}));
|
|
344
|
+
lines.push(...arrows);
|
|
345
|
+
return lines.join("\n");
|
|
346
|
+
}
|
|
347
|
+
};
|
|
348
|
+
export { Graph, GraphEdge, GraphNode };
|
|
349
|
+
|
|
350
|
+
//# sourceMappingURL=graph.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graph.js","names":[],"sources":["../src/graph.ts"],"sourcesContent":["/**\n * The law half of the contract graph (#537): which transitions write what\n * which laws read, and what shows each keeps each. A contract declares its\n * laws and transitions as plain data (`Contract.laws`), and `Graph` derives\n * their nodes and edges here, when asked; a closed Surface contributes a\n * level from its flag; tests contribute evidence. `Graph` is its own module\n * so a page that reads `Module` alone carries none of it. `Graph.validate`\n * asks the graph's one question: is every transition that can break a law\n * witnessed keeping it?\n */\nimport { Data, Option } from 'effect'\nimport { lawFactsOf, type LawEntry } from 'foldkit-entity'\nimport { Evidence } from 'foldkit-metadata'\nimport type { Contract, Finding, Module } from './index.js'\nimport { labelOf, pathText, tableCell } from './text.js'\n\n/** Where a path is: a Model field (`['todos']`) or an Entity member (`['Product', 'stock']`). */\nexport type GraphSpace = 'model' | 'entity'\n\nexport type GraphNode = Data.TaggedEnum<{\n /** A contract that owns Model paths: `remote:Shop`, `sync:todos-capped`. */\n Owner: { readonly kind: string; readonly name: string }\n Path: { readonly space: GraphSpace; readonly path: ReadonlyArray<string> }\n /**\n * A declared write (`write:Sell`), with the Entity whose rows it writes, or\n * a durable Message (`durable:CreatedTodo`), with none.\n */\n Transition: {\n readonly id: string\n readonly kind: 'write' | 'durable'\n readonly entity?: string | undefined\n }\n /** An Entity's invariant (`Product.reservedWithinStock`), a document's law, or a closed Surface's closure. */\n Law: { readonly id: string }\n /** A declared state of an Entity. */\n State: { readonly entity: string; readonly name: string }\n /** A Surface declared `closed: true`. */\n Level: { readonly surface: string }\n}>\nexport const GraphNode = /* @__PURE__ */ Data.taggedEnum<GraphNode>()\n\nexport type GraphEdge = Data.TaggedEnum<{\n /** `owner` (`kind:name`) is the authority for a Model path. */\n Owns: { readonly owner: string; readonly path: ReadonlyArray<string> }\n Reads: { readonly law: string; readonly space: GraphSpace; readonly path: ReadonlyArray<string> }\n Writes: {\n readonly transition: string\n readonly space: GraphSpace\n readonly path: ReadonlyArray<string>\n }\n /** A closed Surface's projection reads a Model path. */\n Observes: { readonly level: string; readonly path: ReadonlyArray<string> }\n /** The write starts only from this state. */\n From: { readonly transition: string; readonly entity: string; readonly state: string }\n /** The write leaves its row in this state. */\n To: { readonly transition: string; readonly entity: string; readonly state: string }\n /** The transition keeps the law, and the record that shows it. */\n Keeps: { readonly transition: string; readonly law: string; readonly evidence: Evidence }\n /** `level`'s projection contains every path of `of`'s, and more. */\n Refines: { readonly level: string; readonly of: string }\n}>\nexport const GraphEdge = /* @__PURE__ */ Data.taggedEnum<GraphEdge>()\n\n/** Nodes and edges, as `Graph.of` returns them. */\nexport interface GraphFacts {\n readonly nodes: ReadonlyArray<GraphNode>\n readonly edges: ReadonlyArray<GraphEdge>\n}\n\n/** What a contract declares of its laws, read by `Graph.of` when asked. */\nexport interface ContractLaws {\n /**\n * Laws over the contract's Model slice, by id, as a Sync document declares\n * them: each is `<kind>:<name>.<id>`, taken to read every path the contract\n * owns (a law is a function, so the whole slice), and each of the\n * contract's Messages is a transition `durable:<tag>` writing it. Given,\n * even empty, the transitions are drawn.\n */\n readonly model?: ReadonlyArray<string> | undefined\n /**\n * Transitions over Entities, as `Laws.check` takes them: a declared write\n * (`{ name, write }`, as `Mutation.write` returns), or one known by its\n * footprint. Each is `write:<name>`, beside each invariant of its Entity.\n */\n readonly entities?: ReadonlyArray<LawEntry> | undefined\n}\n\n/** An application's graph: every contract's facts, its closed Surfaces, and the evidence admitted. */\nexport interface Graph extends GraphFacts {}\n\n/** What `Graph` reads beside the contracts. */\nexport interface GraphOptions {\n /**\n * Records that a transition keeps a law: what a test's walks and scenarios\n * returned, `Laws.check`'s `Enumerated` records, and `Evidence.runtimeOnly`\n * lines. One issued by no producer, or naming a pair the graph does not\n * join, is not admitted and is reported as `evidence-unmatched`.\n */\n readonly evidence?: ReadonlyArray<Evidence> | undefined\n}\n\n/** A transition that writes a path a law reads, and what shows it keeps the law (empty: nothing). */\nexport interface Breaker {\n readonly transition: string\n /** The paths it writes that the law reads, in the law's space. */\n readonly paths: ReadonlyArray<ReadonlyArray<string>>\n readonly evidence: ReadonlyArray<Evidence>\n}\n\ninterface Located {\n readonly space: GraphSpace\n readonly path: ReadonlyArray<string>\n}\n\n/** A record not admitted, and why, for `evidence-unmatched`. */\ninterface Unmatched {\n readonly record: Evidence\n readonly contracts: ReadonlyArray<string>\n readonly message: string\n}\n\n/** The graph, with who contributed each law and transition and what evidence was turned away. */\ninterface Assembled {\n readonly graph: Graph\n readonly contributors: ReadonlyMap<string, ReadonlyArray<string>>\n readonly unmatched: ReadonlyArray<Unmatched>\n}\n\nconst isPrefix = (prefix: ReadonlyArray<string>, path: ReadonlyArray<string>): boolean =>\n prefix.length <= path.length && prefix.every((segment, index) => segment === path[index])\n\n/** One path is within the other: writing `['todos']` writes `['todos', 'title']`, and the reverse. */\nconst overlaps = (a: Located, b: Located): boolean =>\n a.space === b.space &&\n a.path.length > 0 &&\n b.path.length > 0 &&\n (isPrefix(a.path, b.path) || isPrefix(b.path, a.path))\n\nconst keyOf = (value: unknown): string => JSON.stringify(value)\n\n/** A contract's declared laws as nodes and edges. */\nconst factsOf = (contract: Contract, laws: ContractLaws): GraphFacts => {\n const model = (laws.model ?? []).map(id => `${labelOf(contract)}.${id}`)\n const durable = laws.model === undefined ? [] : contract.messages.map(tag => `durable:${tag}`)\n // An Entity's laws come out shaped as the graph's own nodes and edges.\n const entities: GraphFacts = lawFactsOf(laws.entities ?? [])\n return {\n nodes: [\n ...model.map(id => GraphNode.Law({ id })),\n ...durable.map(id => GraphNode.Transition({ id, kind: 'durable' })),\n ...entities.nodes,\n ],\n edges: [\n ...model.flatMap(law =>\n contract.owns.map(path => GraphEdge.Reads({ law, space: 'model', path })),\n ),\n ...durable.flatMap(transition =>\n contract.owns.map(path => GraphEdge.Writes({ transition, space: 'model', path })),\n ),\n ...entities.edges,\n ],\n }\n}\n\n/** The contracts' declared laws, their closed Surfaces as levels, and the evidence that joins a pair. */\nconst assemble = (contracts: ReadonlyArray<Contract>, options: GraphOptions): Assembled => {\n const nodes = new Map<string, GraphNode>()\n const edges = new Map<string, GraphEdge>()\n const contributors = new Map<string, Array<string>>()\n const reads = new Map<string, Array<Located>>()\n const writes = new Map<string, Array<Located>>()\n const levels: Array<Contract> = []\n\n const node = (made: GraphNode) => nodes.set(keyOf(made), made)\n const contributed = (key: string, label: string) => {\n const known = contributors.get(key) ?? []\n if (!known.includes(label)) contributors.set(key, [...known, label])\n }\n const located = (into: Map<string, Array<Located>>, id: string, at: Located) => {\n const known = into.get(id) ?? []\n if (!known.some(each => each.space === at.space && keyOf(each.path) === keyOf(at.path)))\n into.set(id, [...known, at])\n node(GraphNode.Path({ space: at.space, path: at.path }))\n }\n const edge = (made: GraphEdge) => {\n const kept = GraphEdge.$match(made, {\n Owns: ({ path }) => {\n node(GraphNode.Path({ space: 'model', path }))\n return true\n },\n Reads: ({ law, space, path }) => {\n located(reads, law, { space, path })\n return true\n },\n Writes: ({ transition, space, path }) => {\n located(writes, transition, { space, path })\n return true\n },\n Observes: ({ path }) => {\n node(GraphNode.Path({ space: 'model', path }))\n return true\n },\n From: () => true,\n To: () => true,\n // Only admitted evidence is a keeps edge, made below.\n Keeps: () => false,\n Refines: () => true,\n })\n if (kept) edges.set(keyOf(made), made)\n }\n\n for (const contract of new Set(contracts)) {\n const label = labelOf(contract)\n if (contract.owns.length > 0) {\n node(GraphNode.Owner({ kind: contract.kind, name: contract.name }))\n for (const path of contract.owns) edge(GraphEdge.Owns({ owner: label, path }))\n }\n if (contract.closed === true) {\n const law = `closure:${contract.name}`\n node(GraphNode.Level({ surface: contract.name }))\n node(GraphNode.Law({ id: law }))\n contributed(`law:${law}`, label)\n levels.push(contract)\n for (const path of contract.observes) {\n edge(GraphEdge.Observes({ level: contract.name, path }))\n edge(GraphEdge.Reads({ law, space: 'model', path }))\n }\n }\n if (contract.laws === undefined) continue\n const facts = factsOf(contract, contract.laws)\n for (const made of facts.nodes) {\n node(made)\n const key = GraphNode.$match(made, {\n Owner: () => Option.none<string>(),\n Path: () => Option.none<string>(),\n Transition: ({ id }) => Option.some(`transition:${id}`),\n Law: ({ id }) => Option.some(`law:${id}`),\n State: () => Option.none<string>(),\n Level: () => Option.none<string>(),\n })\n if (Option.isSome(key)) contributed(key.value, label)\n }\n for (const made of facts.edges) edge(made)\n }\n\n // A level refines another when its paths cover every one of the other's and the reverse fails.\n const covers = (wider: Contract, narrower: Contract) =>\n narrower.observes.every(path => wider.observes.some(own => isPrefix(own, path)))\n for (const a of levels)\n for (const b of levels)\n if (a !== b && covers(a, b) && !covers(b, a))\n edge(GraphEdge.Refines({ level: a.name, of: b.name }))\n\n const laws = new Set([...nodes.values()].filter(GraphNode.$is('Law')).map(law => law.id))\n const transitions = new Map(\n [...nodes.values()]\n .filter(GraphNode.$is('Transition'))\n .map(transition => [transition.id, transition.entity] as const),\n )\n const unmatched: Array<Unmatched> = []\n const kept = new Set<Evidence>()\n const admit = (record: Evidence) => {\n const { transition, law } = record\n const involved = [\n ...(contributors.get(`transition:${transition}`) ?? []),\n ...(contributors.get(`law:${law}`) ?? []),\n ]\n const refuse = (why: string): void => {\n unmatched.push({\n record,\n contracts: [...new Set(involved)],\n message: `Evidence that ${transition} keeps ${law} ${why}`,\n })\n }\n if (Option.isNone(Evidence.issuedBy(record)))\n return refuse('was issued by no producer: it was typed by hand or copied')\n if (!transitions.has(transition))\n return refuse(`names ${transition}, which no contract declares`)\n if (!laws.has(law)) return refuse(`names ${law}, which no contract declares`)\n // What a record's pair must share. Over an Entity, the Entity: a pair within one is joined\n // even when it shares no member, as `Laws.check` records one kept by disjointness, and a\n // transition's own Entity counts where it writes no member (a delete). Over the Model, a\n // path: Model laws read their owner's slice, so a slice is what tells two owners apart.\n const written = writes.get(transition) ?? []\n const entity = transitions.get(transition)\n const entities = new Set([\n ...written.flatMap(at => (at.space === 'entity' ? [at.path[0]] : [])),\n ...(entity === undefined ? [] : [entity]),\n ])\n const joins = (at: Located) =>\n at.space === 'entity' ? entities.has(at.path[0]) : written.some(each => overlaps(each, at))\n if (!(reads.get(law) ?? []).some(joins))\n return refuse(\n `names a pair the graph does not join: ${transition} writes nothing beside what ${law} reads`,\n )\n if (kept.has(record)) return\n kept.add(record)\n // Every admitted record is an edge of its own: a walk and a scenario of one pair are two.\n edges.set(`keeps:${kept.size}`, GraphEdge.Keeps({ transition, law, evidence: record }))\n }\n for (const record of options.evidence ?? []) admit(record)\n\n return {\n graph: { nodes: [...nodes.values()], edges: [...edges.values()] },\n contributors,\n unmatched,\n }\n}\n\n/** The ids of the graph's laws, in the order contracts declared them. */\nconst lawsOf = (graph: Graph): ReadonlyArray<string> =>\n graph.nodes.filter(GraphNode.$is('Law')).map(law => law.id)\n\nconst breakers = (graph: Graph, law: string): ReadonlyArray<Breaker> => {\n const read = graph.edges\n .filter(GraphEdge.$is('Reads'))\n .filter(edge => edge.law === law)\n .map(({ space, path }) => ({ space, path }))\n const keeps = graph.edges.filter(GraphEdge.$is('Keeps')).filter(edge => edge.law === law)\n return graph.nodes.filter(GraphNode.$is('Transition')).flatMap(({ id }) => {\n const paths = graph.edges\n .filter(GraphEdge.$is('Writes'))\n .filter(edge => edge.transition === id && read.some(at => overlaps(at, edge)))\n .map(edge => edge.path)\n if (paths.length === 0) return []\n const evidence = keeps.filter(edge => edge.transition === id).map(edge => edge.evidence)\n return [{ transition: id, paths, evidence }]\n })\n}\n\nconst sameSet = (a: ReadonlyArray<string>, b: ReadonlyArray<string>): boolean =>\n a.length === b.length && a.every(each => b.includes(each)) && b.every(each => a.includes(each))\n\n/** The rules over the graph, as `Graph.validate` documents them. */\nconst findingsOf = (\n contracts: ReadonlyArray<Contract>,\n { graph, contributors, unmatched }: Assembled,\n): readonly Finding[] => {\n const involved = (transition: string, law: string) => [\n ...new Set([\n ...(contributors.get(`transition:${transition}`) ?? []),\n ...(contributors.get(`law:${law}`) ?? []),\n ]),\n ]\n const findings: Array<Finding> = lawsOf(graph).flatMap(law =>\n breakers(graph, law)\n .filter(breaker => breaker.evidence.length === 0)\n .map(({ transition, paths }) => ({\n rule: 'law-unwitnessed' as const,\n contracts: involved(transition, law),\n message: `${transition} writes ${paths.map(pathText).join(', ')}, which ${law} reads, and no evidence shows it keeps ${law}`,\n })),\n )\n for (const { contracts: named, message } of unmatched)\n findings.push({ rule: 'evidence-unmatched', contracts: named, message })\n // A write is named by its name alone, in the graph and in evidence, so two contracts'\n // writes of one name are one node no record can tell apart.\n for (const { id, kind } of graph.nodes.filter(GraphNode.$is('Transition')))\n if (kind === 'write') {\n const named = contributors.get(`transition:${id}`) ?? []\n if (named.length > 1)\n findings.push({\n rule: 'transition-declared-twice',\n contracts: named,\n message: `${id} is declared by ${named.join(' and ')}, so evidence naming it cannot say which`,\n })\n }\n const closed = [...new Set(contracts)].filter(contract => contract.closed === true)\n for (let i = 0; i < closed.length; i += 1)\n for (let j = i + 1; j < closed.length; j += 1) {\n const [a, b] = [closed[i]!, closed[j]!]\n if (\n sameSet(a.observes.map(pathText), b.observes.map(pathText)) &&\n sameSet(a.messages, b.messages)\n )\n findings.push({\n rule: 'level-declared-twice',\n contracts: [labelOf(a), labelOf(b)],\n message: `${labelOf(a)} and ${labelOf(b)} are closed over the same paths and the same Messages`,\n })\n }\n return findings\n}\n\n/** One line of a record, for the renderers. */\nconst evidenceText = (record: Evidence): string =>\n Evidence.$match(record, {\n Enumerated: () => 'enumerated',\n Walked: ({ seeds, steps, starts }) =>\n `walked: ${seeds} seeds of ${steps} steps from ${starts.join(', ')}`,\n Scenario: ({ name, runner }) => `scenario on ${runner}: ${name}`,\n RuntimeOnly: ({ why }) => `runtime only: ${why}`,\n })\n\n/**\n * The laws of a Module's contracts as a graph, the rules over it, and its\n * renderers. `Module` asks who owns what; `Graph` asks which transitions can\n * break which laws and what shows they keep them. A page that imports only\n * `Module` carries none of this.\n *\n * ```ts\n * Graph.validate(Shop, { evidence }) // law-unwitnessed, evidence-unmatched, …\n * Graph.toMarkdown(Shop, { evidence }) // the Laws section\n * ```\n */\nexport const Graph = {\n /**\n * The contracts' laws as a graph: what each contract's `laws` declare, a\n * level and a `closure:<name>` law per closed Surface, which level refines\n * which, and a `keeps` edge per record of `evidence` that is issued and\n * joins its pair. Pure, and computed each time it is asked.\n */\n of: (module: Module<any, any, any>, options: GraphOptions = {}): Graph =>\n assemble(module.contracts, options).graph,\n\n /**\n * Each transition that writes a path `law` reads, which is each that could\n * break it, and the evidence admitted that it keeps it. Throws for a law\n * the graph does not hold, which a misspelt id would otherwise answer with\n * nothing.\n */\n breakersOf: (graph: Graph, law: string): ReadonlyArray<Breaker> => {\n if (!lawsOf(graph).includes(law))\n throw new Error(`Graph.breakersOf: the graph holds no law ${law}`)\n return breakers(graph, law)\n },\n\n /**\n * The rules over the graph, which `Module.validate` does not ask: each\n * transition that writes what a law reads with no evidence it keeps it\n * (`law-unwitnessed`), each record of `evidence` not admitted\n * (`evidence-unmatched`), each write two contracts declare\n * (`transition-declared-twice`), and each two closed Surfaces with one\n * projection and one Message set (`level-declared-twice`). With no\n * `evidence`, every pair a transition can break is unwitnessed.\n */\n validate: (module: Module<any, any, any>, options: GraphOptions = {}): readonly Finding[] =>\n findingsOf(module.contracts, assemble(module.contracts, options)),\n\n /**\n * A Laws section in Markdown, to set beside `Module.toMarkdown`'s: each law\n * by each transition that writes what it reads and its evidence, then\n * `Graph.validate`'s findings.\n */\n toMarkdown: (module: Module<any, any, any>, options: GraphOptions = {}): string => {\n const assembled = assemble(module.contracts, options)\n const { graph } = assembled\n const laws = lawsOf(graph)\n const lines = ['## Laws', '']\n if (laws.length === 0) lines.push('No contract declares a law.')\n else {\n lines.push('| Law | Transition | Evidence |', '| --- | --- | --- |')\n for (const law of laws) {\n const found = breakers(graph, law)\n if (found.length === 0) lines.push(`| ${tableCell(law)} | | nothing writes what it reads |`)\n for (const { transition, evidence } of found)\n lines.push(\n `| ${tableCell(law)} | ${tableCell(transition)} | ${evidence.length === 0 ? '**none**' : tableCell(evidence.map(evidenceText).join('; '))} |`,\n )\n }\n }\n const findings = findingsOf(module.contracts, assembled)\n if (findings.length > 0) {\n lines.push('', '### Findings', '')\n for (const finding of findings) lines.push(`- **${finding.rule}** ${finding.message}`)\n }\n return lines.join('\\n')\n },\n\n /**\n * The laws as a Mermaid flowchart of their own: a node per law and per\n * transition that writes what one reads, a solid edge from each shown\n * keeping it, labelled with its kinds of evidence, and a dotted one from\n * each with none.\n */\n toMermaid: (module: Module<any, any, any>, options: GraphOptions = {}): string => {\n const graph = Graph.of(module, options)\n const laws = lawsOf(graph)\n const lines = ['flowchart LR', ...laws.map((law, index) => ` l${index}[\"${law}\"]`)]\n const transitions: string[] = []\n const transitionId = (id: string): string => {\n if (!transitions.includes(id)) {\n transitions.push(id)\n lines.push(` t${transitions.length - 1}[\"${id}\"]`)\n }\n return `t${transitions.indexOf(id)}`\n }\n const arrows = laws.flatMap((law, index) =>\n breakers(graph, law).map(({ transition, evidence }) => {\n const from = transitionId(transition)\n return evidence.length === 0\n ? ` ${from} -.->|unwitnessed| l${index}`\n : ` ${from} -->|${[...new Set(evidence.map(record => record._tag))].join(', ')}| l${index}`\n }),\n )\n lines.push(...arrows)\n return lines.join('\\n')\n },\n}\n"],"mappings":";;;;;;;;;;;;;;;AAuCA,MAAa,YAA4B,qBAAK,WAAsB;AAsBpE,MAAa,YAA4B,qBAAK,WAAsB;AAmEpE,MAAM,YAAY,QAA+B,SAC/C,OAAO,UAAU,KAAK,UAAU,OAAO,OAAO,SAAS,UAAU,YAAY,KAAK,MAAM;;AAG1F,MAAM,YAAY,GAAY,MAC5B,EAAE,UAAU,EAAE,SACd,EAAE,KAAK,SAAS,KAChB,EAAE,KAAK,SAAS,MACf,SAAS,EAAE,MAAM,EAAE,IAAI,KAAK,SAAS,EAAE,MAAM,EAAE,IAAI;AAEtD,MAAM,SAAS,UAA2B,KAAK,UAAU,KAAK;;AAG9D,MAAM,WAAW,UAAoB,SAAmC;CACtE,MAAM,SAAS,KAAK,SAAS,CAAC,EAAA,CAAG,KAAI,OAAM,GAAG,QAAQ,QAAQ,EAAE,GAAG,IAAI;CACvE,MAAM,UAAU,KAAK,UAAU,KAAA,IAAY,CAAC,IAAI,SAAS,SAAS,KAAI,QAAO,WAAW,KAAK;CAE7F,MAAM,WAAuB,WAAW,KAAK,YAAY,CAAC,CAAC;CAC3D,OAAO;EACL,OAAO;GACL,GAAG,MAAM,KAAI,OAAM,UAAU,IAAI,EAAE,GAAG,CAAC,CAAC;GACxC,GAAG,QAAQ,KAAI,OAAM,UAAU,WAAW;IAAE;IAAI,MAAM;GAAU,CAAC,CAAC;GAClE,GAAG,SAAS;EACd;EACA,OAAO;GACL,GAAG,MAAM,SAAQ,QACf,SAAS,KAAK,KAAI,SAAQ,UAAU,MAAM;IAAE;IAAK,OAAO;IAAS;GAAK,CAAC,CAAC,CAC1E;GACA,GAAG,QAAQ,SAAQ,eACjB,SAAS,KAAK,KA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,WAAW,SAAS;EACvD,IAAI,SAAS,SAAS,GAAG;GACvB,MAAM,KAAK,IAAI,gBAAgB,EAAE;GACjC,KAAK,MAAM,WAAW,UAAU,MAAM,KAAK,OAAO,QAAQ,KAAK,KAAK,QAAQ,SAAS;EACvF;EACA,OAAO,MAAM,KAAK,IAAI;CACxB;;;;;;;CAQA,YAAY,QAA+B,UAAwB,CAAC,MAAc;EAChF,MAAM,QAAQ,MAAM,GAAG,QAAQ,OAAO;EACtC,MAAM,OAAO,OAAO,KAAK;EACzB,MAAM,QAAQ,CAAC,gBAAgB,GAAG,KAAK,KAAK,KAAK,UAAU,MAAM,MAAM,IAAI,IAAI,GAAG,CAAC;EACnF,MAAM,cAAwB,CAAC;EAC/B,MAAM,gBAAgB,OAAuB;GAC3C,IAAI,CAAC,YAAY,SAAS,EAAE,GAAG;IAC7B,YAAY,KAAK,EAAE;IACnB,MAAM,KAAK,MAAM,YAAY,SAAS,EAAE,IAAI,GAAG,GAAG;GACpD;GACA,OAAO,IAAI,YAAY,QAAQ,EAAE;EACnC;EACA,MAAM,SAAS,KAAK,SAAS,KAAK,UAChC,SAAS,OAAO,GAAG,CAAC,CAAC,KAAK,EAAE,YAAY,eAAe;GACrD,MAAM,OAAO,aAAa,UAAU;GACpC,OAAO,SAAS,WAAW,IACvB,KAAK,KAAK,sBAAsB,UAChC,KAAK,KAAK,OAAO,CAAC,GAAG,IAAI,IAAI,SAAS,KAAI,WAAU,OAAO,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE,KAAK;EACzF,CAAC,CACH;EACA,MAAM,KAAK,GAAG,MAAM;EACpB,OAAO,MAAM,KAAK,IAAI;CACxB;AACF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { Optic, Option, Result, Schema } from "effect";
|
|
2
|
-
import { Metadata, Metadata as Metadata$1, MetadataKey, MetadataSummary, MetadataSummary as MetadataSummary$1, MetadataTypeId } from "foldkit-metadata";
|
|
2
|
+
import { Evidence, Metadata, Metadata as Metadata$1, MetadataKey, MetadataSummary, MetadataSummary as MetadataSummary$1, MetadataTypeId } from "foldkit-metadata";
|
|
3
|
+
import { Closure, ClosureProjection, ClosureViolation } from "./closure.js";
|
|
4
|
+
import { Breaker, ContractLaws, ContractLaws as ContractLaws$1, Graph, GraphEdge, GraphFacts, GraphNode, GraphOptions, GraphSpace } from "./graph.js";
|
|
3
5
|
import { Diagnostic, Diagnostics, ReportDiagnostic } from "./diagnostics.js";
|
|
4
|
-
import { CacheOptions, CachePolicy, CacheStore, CachedRead, PageReads, WorkersCache, cachePolicy, maxAgeSeconds, shorterPolicy } from "./edgeCache.js";
|
|
6
|
+
import { CacheOptions, CachePolicy, CacheStore, CachedRead, PageCacheStore, PageReads, WorkersCache, WorkersKv, cachePolicy, maxAgeSeconds, shorterPolicy } from "./edgeCache.js";
|
|
5
7
|
import { Html, HtmlBuilder } from "foldkit/html";
|
|
6
8
|
import { MessageUnion } from "foldkit/message";
|
|
7
9
|
import { Entry } from "foldkit/managedResource";
|
|
@@ -101,7 +103,7 @@ type Selectable<Root, Value, Key extends string, Encoded = unknown> = FieldRef<R
|
|
|
101
103
|
* cannot infer a field name from it.
|
|
102
104
|
*/
|
|
103
105
|
export type OptionalRef<Root, Value> = ModelRef<Root, Value> & Select<Root, Value>;
|
|
104
|
-
type RefNode<Root, S, Key extends string> = S extends Schema.Codec<infer A, infer Encoded, any, any> ? S extends Schema.Struct<infer F> ? Selectable<Root, A, Key, Encoded> & RefTree<Root, F> : A extends ReadonlyArray<infer E> ? Selectable<Root, A, Key, Encoded> & Indexes<Root, E> : A extends Readonly<Record<infer K extends string, infer V>> ? Selectable<Root, A, Key, Encoded> & Entries<Root, K, V> : Selectable<Root, A, Key, Encoded> : never;
|
|
106
|
+
type RefNode<Root, S, Key extends string> = S extends Schema.Codec<infer A, infer Encoded, any, any> ? S extends Schema.Struct<infer F> ? Selectable<Root, A, Key, Encoded> & RefTree<Root, F> : [A] extends [ReadonlyArray<infer E>] ? Selectable<Root, A, Key, Encoded> & Indexes<Root, E> : [A] extends [Readonly<Record<infer K extends string, infer V>>] ? Selectable<Root, A, Key, Encoded> & Entries<Root, K, V> : Selectable<Root, A, Key, Encoded> : never;
|
|
105
107
|
export type DependencyTree = readonly (readonly string[])[];
|
|
106
108
|
export interface Projection<Root, Value> {
|
|
107
109
|
readonly Model: Schema.Codec<Value, unknown>;
|
|
@@ -124,8 +126,8 @@ export interface WritableProjection<Model, Fields extends Schema.Struct.Fields>
|
|
|
124
126
|
}
|
|
125
127
|
type OfSelection<F extends Schema.Struct.Fields> = { readonly [K in keyof F]?: true | Projection<Schema.Schema.Type<F[K]>, unknown>; };
|
|
126
128
|
type OfValue<F extends Schema.Struct.Fields, Sel> = { readonly [K in keyof Sel & keyof F]: Sel[K] extends true ? Schema.Schema.Type<F[K]> : Sel[K] extends Projection<any, infer V> ? V : never; };
|
|
127
|
-
type EntryValue<E> = E extends Projection<any, infer V> ? V : E extends ModelRef<any, infer V> ? V : never;
|
|
128
|
-
type EntryRoot<E> = E extends Projection<infer R, any> ? R : E extends ModelRef<infer R, any> ? R : never;
|
|
129
|
+
type EntryValue<E> = E extends Projection<any, infer V> ? V : E extends ModelRef<any, infer V> ? V : E extends ModeledDerived<any, infer V> ? V : never;
|
|
130
|
+
type EntryRoot<E> = E extends Projection<infer R, any> ? R : E extends ModelRef<infer R, any> ? R : E extends ModeledDerived<infer R, any> ? R : never;
|
|
129
131
|
type EntryRoots<Entries> = { readonly [K in keyof Entries]: EntryRoot<Entries[K]>; };
|
|
130
132
|
/** `true` when the union has more than one member. Used to reject mixed roots. */
|
|
131
133
|
type IsUnion<T, U = T> = [T] extends [never] ? false : T extends unknown ? [U] extends [T] ? false : true : never;
|
|
@@ -135,9 +137,13 @@ export interface Derived<Root, Value> {
|
|
|
135
137
|
readonly dependencies: DependencyTree;
|
|
136
138
|
readonly read: (root: Root) => Value;
|
|
137
139
|
}
|
|
140
|
+
/** A `Derived` that names the Schema of its value (`derive`'s `Model` option), so a `Projection.struct` can hold it. */
|
|
141
|
+
export interface ModeledDerived<Root, Value> extends Derived<Root, Value> {
|
|
142
|
+
readonly Model: Schema.Codec<Value, unknown>;
|
|
143
|
+
}
|
|
138
144
|
export declare const Projection: {
|
|
139
145
|
of: <F extends Schema.Struct.Fields>(schema: Schema.Struct<F>) => <const Sel extends OfSelection<F>>(selection: Sel) => Projection<Schema.Struct.Type<F>, OfValue<F, Sel>>;
|
|
140
|
-
struct: <const Entries extends Record<string, Projection<any, any> | ModelRef<any, any>>>(entries: Entries & (IsUnion<EntryRoots<Entries>[keyof Entries]> extends true ? never : unknown)) => Projection<EntryRoot<Entries[keyof Entries]>, StructValue<Entries>>;
|
|
146
|
+
struct: <const Entries extends Record<string, Projection<any, any> | ModelRef<any, any> | ModeledDerived<any, any>>>(entries: Entries & (IsUnion<EntryRoots<Entries>[keyof Entries]> extends true ? never : unknown)) => Projection<EntryRoot<Entries[keyof Entries]>, StructValue<Entries>>;
|
|
141
147
|
/**
|
|
142
148
|
* Maps a Projection over an array: `array(p): Projection<ReadonlyArray<Root>,
|
|
143
149
|
* ReadonlyArray<Value>>`. Nesting is explicit (an array of arrays stays an
|
|
@@ -168,6 +174,17 @@ export declare const Projection: {
|
|
|
168
174
|
* keyed on it holds. It keeps one result: the one for the last Model it was
|
|
169
175
|
* given.
|
|
170
176
|
*
|
|
177
|
+
* `verify` checks that promise: where the memo would give its last value,
|
|
178
|
+
* `derive` runs again, and a result unequal to it throws, naming the paths
|
|
179
|
+
* `on` reads, since `derive` read something they do not name. Pass
|
|
180
|
+
* `import.meta.env?.DEV === true`, as `Remote.make`'s `verifyPredictions` takes it;
|
|
181
|
+
* it doubles the work, so leave it off in production.
|
|
182
|
+
*
|
|
183
|
+
* `Model`, the Schema of the value, makes the result a `ModeledDerived`, which
|
|
184
|
+
* a `Projection.struct` takes as an entry: the struct reads the memoized
|
|
185
|
+
* value, and the Surface checks it against `Model`. A Derived plans no
|
|
186
|
+
* requirements, whatever `on` holds.
|
|
187
|
+
*
|
|
171
188
|
* @example
|
|
172
189
|
* ```ts
|
|
173
190
|
* const shown = Projection.derive([App.model.todos, App.model.filter], (model: Model) =>
|
|
@@ -176,9 +193,19 @@ export declare const Projection: {
|
|
|
176
193
|
* // In the view: shown.read(model)
|
|
177
194
|
* ```
|
|
178
195
|
*/
|
|
179
|
-
derive:
|
|
180
|
-
|
|
181
|
-
|
|
196
|
+
derive: {
|
|
197
|
+
<Root, Value>(on: ReadonlyArray<ModelRef<Root, any> | {
|
|
198
|
+
readonly dependencies: DependencyTree;
|
|
199
|
+
}>, derive: (root: Root) => Value, options: {
|
|
200
|
+
readonly verify?: boolean | undefined;
|
|
201
|
+
readonly Model: Schema.Codec<Value, unknown>;
|
|
202
|
+
}): ModeledDerived<Root, Value>;
|
|
203
|
+
<Root, Value>(on: ReadonlyArray<ModelRef<Root, any> | {
|
|
204
|
+
readonly dependencies: DependencyTree;
|
|
205
|
+
}>, derive: (root: Root) => Value, options?: {
|
|
206
|
+
readonly verify?: boolean | undefined;
|
|
207
|
+
}): Derived<Root, Value>;
|
|
208
|
+
};
|
|
182
209
|
/**
|
|
183
210
|
* Derives a writable projection from generated Model field references:
|
|
184
211
|
* `Projection.pick(App.model.todos, App.model.selectedTodoId)` infers
|
|
@@ -228,6 +255,8 @@ export interface Surface<Root, Model, Message, Params> {
|
|
|
228
255
|
readonly Params: ParamsSchema<Params>;
|
|
229
256
|
readonly Message: Schema.Schema<Message>;
|
|
230
257
|
readonly messages: readonly unknown[];
|
|
258
|
+
/** Declared `closed: true`: `Closure.violations` tests it in a walk. */
|
|
259
|
+
readonly closed: boolean;
|
|
231
260
|
readonly projection: (params: Params) => Projection<Root, Model>;
|
|
232
261
|
}
|
|
233
262
|
/**
|
|
@@ -393,6 +422,7 @@ export interface Application<Root, F extends Schema.Struct.Fields, Cases extends
|
|
|
393
422
|
readonly params: ParamsOf<Params>;
|
|
394
423
|
}) => Shape;
|
|
395
424
|
readonly messages?: Ms;
|
|
425
|
+
readonly closed?: boolean;
|
|
396
426
|
}) => Surface<Root, ModelOf<Root, Shape>, MsgOf<Ms>, ParamsOf<Params>>;
|
|
397
427
|
/**
|
|
398
428
|
* This application made runnable, once its update exists: the same
|
|
@@ -578,6 +608,11 @@ export declare const Surface: {
|
|
|
578
608
|
readonly params: Params;
|
|
579
609
|
}) => Projection<Root, Model>;
|
|
580
610
|
readonly messages?: Ms;
|
|
611
|
+
/**
|
|
612
|
+
* The projection after a Message in `messages` depends only on the projection before and
|
|
613
|
+
* the Message, and no other Message changes it; `Closure.violations` tests both.
|
|
614
|
+
*/
|
|
615
|
+
readonly closed?: boolean;
|
|
581
616
|
}) => Surface<Root, Model, MsgOf<Ms>, Params>;
|
|
582
617
|
read: <Root, Model, Message, Params>(surface: Surface<Root, Model, Message, Params>, root: Root, ...params: ParamsArgument<Params>) => Model;
|
|
583
618
|
/**
|
|
@@ -626,6 +661,15 @@ export interface Contract {
|
|
|
626
661
|
readonly messages: readonly string[];
|
|
627
662
|
/** What interpreters attached to the contract's reads, as text. */
|
|
628
663
|
readonly metadata: readonly MetadataSummary$1[];
|
|
664
|
+
/** A Surface declared `closed: true`; absent for any other contract. */
|
|
665
|
+
readonly closed?: true;
|
|
666
|
+
/**
|
|
667
|
+
* The laws the contract holds and the transitions that can break them, as
|
|
668
|
+
* the declarations themselves: `Graph.of` derives their nodes and edges
|
|
669
|
+
* when asked, so a page that never imports `Graph` carries none of that code. Absent
|
|
670
|
+
* for a contract with none.
|
|
671
|
+
*/
|
|
672
|
+
readonly laws?: ContractLaws$1 | undefined;
|
|
629
673
|
}
|
|
630
674
|
/**
|
|
631
675
|
* How one integration joins an application, as data and pure functions: the
|
|
@@ -669,7 +713,8 @@ export interface Module<Root, F extends Schema.Struct.Fields, Cases extends Reco
|
|
|
669
713
|
readonly contracts: readonly Contract[];
|
|
670
714
|
}
|
|
671
715
|
export interface Finding {
|
|
672
|
-
|
|
716
|
+
/** The last four are `Graph.validate`'s, over the laws; the rest are `Module.validate`'s. */
|
|
717
|
+
readonly rule: 'foreign-contract' | 'duplicate-name' | 'ownership-overlap' | 'message-claimed-twice' | 'unknown-path' | 'unknown-message' | 'law-unwitnessed' | 'evidence-unmatched' | 'level-declared-twice' | 'transition-declared-twice';
|
|
673
718
|
/** `kind:name` of each contract involved. */
|
|
674
719
|
readonly contracts: readonly string[];
|
|
675
720
|
readonly message: string;
|
|
@@ -686,7 +731,7 @@ export interface ModuleManifest {
|
|
|
686
731
|
readonly fields: readonly string[];
|
|
687
732
|
readonly messages: readonly string[];
|
|
688
733
|
readonly ownership: readonly Ownership[];
|
|
689
|
-
readonly contracts: readonly Omit<Contract, 'owner'>[];
|
|
734
|
+
readonly contracts: readonly Omit<Contract, 'owner' | 'laws'>[];
|
|
690
735
|
readonly findings: readonly Finding[];
|
|
691
736
|
}
|
|
692
737
|
/** A value `Module.make` accepts: a contract, a value carrying one, or a Surface without params. */
|
|
@@ -711,7 +756,8 @@ export declare const Module: {
|
|
|
711
756
|
* Cross-contract invariants the types cannot express: a contract from another
|
|
712
757
|
* application, a duplicate `kind:name`, two owners of overlapping Model paths,
|
|
713
758
|
* a Message recorded by two replication contracts, and a path or Message the
|
|
714
|
-
* application does not declare.
|
|
759
|
+
* application does not declare. The rules over the contracts' laws are
|
|
760
|
+
* `Graph.validate`'s.
|
|
715
761
|
*/
|
|
716
762
|
validate: (module: Module<any, any, any>) => readonly Finding[];
|
|
717
763
|
/**
|
|
@@ -720,13 +766,17 @@ export declare const Module: {
|
|
|
720
766
|
* given Module, so it can be committed and diffed.
|
|
721
767
|
*/
|
|
722
768
|
manifest: (module: Module<any, any, any>) => ModuleManifest;
|
|
723
|
-
/**
|
|
769
|
+
/**
|
|
770
|
+
* The manifest as Markdown: the ownership tree, a table of contracts, and
|
|
771
|
+
* findings. `Graph.toMarkdown` writes the laws.
|
|
772
|
+
*/
|
|
724
773
|
toMarkdown: (module: Module<any, any, any>) => string;
|
|
725
774
|
/**
|
|
726
775
|
* The manifest as a Mermaid flowchart: Model fields in a subgraph, one node
|
|
727
776
|
* per contract, a solid edge for ownership and a dotted edge for observation.
|
|
777
|
+
* `Graph.toMermaid` draws the laws.
|
|
728
778
|
*/
|
|
729
779
|
toMermaid: (module: Module<any, any, any>) => string;
|
|
730
780
|
};
|
|
731
|
-
export { type CacheOptions, type CachePolicy, CacheStore, CachedRead, type Diagnostic, Diagnostics, Metadata, type MetadataKey, type MetadataSummary, MetadataTypeId, PageReads, type ReportDiagnostic, type WorkersCache, cachePolicy, maxAgeSeconds, shorterPolicy };
|
|
781
|
+
export { type Breaker, type CacheOptions, type CachePolicy, CacheStore, CachedRead, Closure, type ClosureProjection, ClosureViolation, type ContractLaws, type Diagnostic, Diagnostics, Evidence, Graph, GraphEdge, type GraphFacts, GraphNode, type GraphOptions, type GraphSpace, Metadata, type MetadataKey, type MetadataSummary, MetadataTypeId, type PageCacheStore, PageReads, type ReportDiagnostic, type WorkersCache, type WorkersKv, cachePolicy, maxAgeSeconds, shorterPolicy };
|
|
732
782
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":["Metadata","MetadataSummary","ManagedResourceEntry"],"sources":["../src/index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":["Metadata","MetadataSummary","ContractLaws","ManagedResourceEntry"],"sources":["../src/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;qBAmEa;;iBAGI,MAAM,MAAM,OAAO;;WAEzB,QAAQ,OAAO,MAAM,OAAO;WAC5B,OAAO,MAAM,SAAS,MAAM;;WAE5B;WACA,MAAM,MAAM,SAAS;WACrB,MAAM,MAAM,MAAM,OAAO,UAAU;;;;;;;WAOnC,SAAS,MAAM,MAAM,KAAK,OAAO,UAAU,UAAU;;;;;;iBAO/C,SAAS,MAAM,OAAO;YAC3B,YAAY,MAAM,MAAM,OAAO;;;;;;;iBA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