@biolibs/bionet 1.0.0 → 1.2.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 +148 -0
- package/dist/discover.d.ts +121 -0
- package/dist/discover.d.ts.map +1 -0
- package/dist/discover.js +143 -0
- package/dist/discover.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -1
- package/dist/inventory.d.ts +23 -1
- package/dist/inventory.d.ts.map +1 -1
- package/dist/inventory.js +32 -0
- package/dist/inventory.js.map +1 -1
- package/dist/log.d.ts +196 -0
- package/dist/log.d.ts.map +1 -0
- package/dist/log.js +246 -0
- package/dist/log.js.map +1 -0
- package/dist/merge.d.ts +171 -0
- package/dist/merge.d.ts.map +1 -0
- package/dist/merge.js +520 -0
- package/dist/merge.js.map +1 -0
- package/dist/model.d.ts +40 -0
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +3 -0
- package/dist/model.js.map +1 -1
- package/dist/sync.d.ts +157 -0
- package/dist/sync.d.ts.map +1 -0
- package/dist/sync.js +203 -0
- package/dist/sync.js.map +1 -0
- package/package.json +1 -1
- package/src/discover.ts +214 -0
- package/src/index.ts +8 -0
- package/src/inventory.ts +40 -1
- package/src/log.ts +325 -0
- package/src/merge.ts +605 -0
- package/src/model.ts +41 -0
- package/src/sync.ts +210 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"merge.d.ts","sourceRoot":"","sources":["../src/merge.ts"],"names":[],"mappings":"AA2BA,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAA+C,KAAK,SAAS,EAAE,KAAK,IAAI,EACtE,KAAK,WAAW,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAqB,KAAK,iBAAiB,EAAsB,KAAK,QAAQ,EAC5E,KAAK,SAAS,EAAE,MAAM,Y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E,CAAC;IACtB,+BAA+B;IAC/B,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,iDAAiD;IACjD,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACnD,sEAAsE;IACtE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CAC/C;AA2BD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,QAAQ,CAAC,OAAO,EAAE,SAAS,OAAO,EAAE,EAAE,OAAO,GAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CA0G7G;AAsPD;;;;;;;;;;;;GAYG;AACH,wBAAsB,SAAS,CAAC,KAAK,EAAE,QAAQ,EAAE,GAAG,EAAE,UAAU,EAAE,EAAE,EAAE,SAAS,EAC/C,OAAO,GAAE,WAAgB,GAAG,OAAO,CAAC,WAAW,CAAC,CAU/E;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,QAAQ,EAAE,GAAG,EAAE,QAAQ,EAC9B,OAAO,GAAE;IAAE,KAAK,CAAC,EAAE,SAAS,SAAS,EAAE,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAO,GAAG,iBAAiB,CAkBvH"}
|
package/dist/merge.js
ADDED
|
@@ -0,0 +1,520 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a lab holds, worked out from every key's log together.
|
|
3
|
+
*
|
|
4
|
+
* Nothing here is stored state. Give `mergeLog` the entries and it returns the lab: who is on the
|
|
5
|
+
* roster, which parts and items there are, how much of each. Give it the same entries in any order,
|
|
6
|
+
* on any machine, and it returns the same lab — that is the whole point, because two people who have
|
|
7
|
+
* been offline for a week have to agree the moment their laptops meet, without either being in charge.
|
|
8
|
+
*
|
|
9
|
+
* The rules it applies were each chosen for what goes wrong without them:
|
|
10
|
+
*
|
|
11
|
+
* - **Order comes from what an entry had seen**, never from a clock. A change counts as later than
|
|
12
|
+
* another only if its author held the other when they made it.
|
|
13
|
+
* - **Amounts are differences.** Two people each using a tube while offline are two uses, not one
|
|
14
|
+
* overwriting the other. A recount says what is physically there and replaces only the adjustments
|
|
15
|
+
* its author had seen. Amounts are whole numbers of the item's unit, so that they have one spelling
|
|
16
|
+
* to sign and add up exactly; a lab that needs finer than a microlitre counts in something smaller.
|
|
17
|
+
* - **A removal names a cutoff.** The entry that removes a key says the last entry of that key's log
|
|
18
|
+
* the lab accepts, so somebody removed cannot add to the lab afterwards by claiming not to have
|
|
19
|
+
* heard. What they wrote past the cutoff is kept, set aside, and shown.
|
|
20
|
+
* - **When two changes truly overlap, the lower entry ID wins**, and the overlap is reported. It is
|
|
21
|
+
* the same choice on every machine and nobody can arrange it in advance.
|
|
22
|
+
* - **Between keepers, the one who has been a keeper longer is heard first.**
|
|
23
|
+
*
|
|
24
|
+
* It refuses quietly. An entry that is not allowed is still placed, with its status and the reason,
|
|
25
|
+
* because the people in the lab need to see what was turned away and why.
|
|
26
|
+
*/
|
|
27
|
+
import { Dseqrecord } from "@biolibs/dseqrecord";
|
|
28
|
+
import { entryId, readEntry, verifyEntry, writeEntry } from "./log.js";
|
|
29
|
+
import { INVENTORY_VERSION } from "./model.js";
|
|
30
|
+
/** The longest sequence one part may have. */
|
|
31
|
+
export const LONGEST_SEQUENCE = 500_000;
|
|
32
|
+
const KEY = /^[A-Za-z0-9_-]{43}$/;
|
|
33
|
+
const ITEM_ID = /^[A-Za-z0-9_-]{1,80}$/;
|
|
34
|
+
const FIELD = /^[a-z][a-z0-9_]{0,59}$/;
|
|
35
|
+
const RESERVED = new Set(["amount", "part", "item", "checksum", "sequence", "circular", "length", "offered", "retired"]);
|
|
36
|
+
const text = (value, most) => typeof value === "string" && value.length > 0 && value.length <= most;
|
|
37
|
+
/** An amount is a whole number of the item's unit: only whole numbers have one agreed spelling to sign. */
|
|
38
|
+
const amountOf = (value) => typeof value === "number" && Number.isSafeInteger(value);
|
|
39
|
+
const role = (value) => value === "member" || value === "keeper";
|
|
40
|
+
/** Whether `later` was written by somebody who held `earlier`. */
|
|
41
|
+
const hadSeen = (later, earlier) => (later.vc.get(earlier.author) ?? -1) >= earlier.seq;
|
|
42
|
+
/**
|
|
43
|
+
* Work a lab out from its entries.
|
|
44
|
+
*
|
|
45
|
+
* @param entries - Every entry held, from every key, in any order. Duplicates are harmless.
|
|
46
|
+
* @param options - `lab` says which lab to build, when entries from more than one may be present.
|
|
47
|
+
* @returns The lab. It is the same for the same set of entries, whatever order they came in.
|
|
48
|
+
* @throws If the entries found more than one lab and `options.lab` does not say which is meant.
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```ts
|
|
52
|
+
* import { adjustItem, mergeLog, nextEntry } from "@biolibs/bionet";
|
|
53
|
+
*
|
|
54
|
+
* const lab = await mergeLog(everyEntryHeld);
|
|
55
|
+
* lab.items.find((one) => one.item === tube)?.amount; // 9
|
|
56
|
+
*
|
|
57
|
+
* const used = await nextEntry(lab, key, adjustItem(tube, -1));
|
|
58
|
+
* (await mergeLog([...everyEntryHeld, used])).items.find((one) => one.item === tube)?.amount; // 8
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
export async function mergeLog(entries, options = {}) {
|
|
62
|
+
const state = { lab: options.lab ?? null, name: null, roster: [], parts: [], items: [], entries: [],
|
|
63
|
+
waiting: [], discarded: [], overlaps: [], heads: {}, knows: {} };
|
|
64
|
+
// Read and check every entry on its own, before any of them is believed about the others.
|
|
65
|
+
const nodes = new Map();
|
|
66
|
+
for (const value of entries) {
|
|
67
|
+
let signed;
|
|
68
|
+
try {
|
|
69
|
+
signed = readEntry(value);
|
|
70
|
+
}
|
|
71
|
+
catch (cause) {
|
|
72
|
+
state.discarded.push({ signed: value, reason: cause instanceof Error ? cause.message : String(cause) });
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
const id = await entryId(signed.entry);
|
|
76
|
+
if (nodes.has(id))
|
|
77
|
+
continue;
|
|
78
|
+
const check = await verifyEntry(signed);
|
|
79
|
+
if (!check.ok) {
|
|
80
|
+
state.discarded.push({ signed, reason: check.problem ?? "Its signature does not hold." });
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
nodes.set(id, { id, signed, author: signed.entry.author, seq: signed.entry.seq, op: signed.entry.op, vc: new Map() });
|
|
84
|
+
}
|
|
85
|
+
// Which lab. A founding entry is the only kind with no lab, and its ID is the lab's.
|
|
86
|
+
const foundings = [...nodes.values()].filter((node) => node.signed.entry.lab === null);
|
|
87
|
+
if (options.lab === undefined && foundings.length > 1) {
|
|
88
|
+
throw new Error("These entries found more than one lab. Say which lab is meant.");
|
|
89
|
+
}
|
|
90
|
+
const founding = options.lab === undefined ? foundings[0] : foundings.find((node) => node.id === options.lab);
|
|
91
|
+
if (founding === undefined) {
|
|
92
|
+
for (const node of nodes.values())
|
|
93
|
+
state.waiting.push({ signed: node.signed, reason: "The lab's founding entry has not arrived." });
|
|
94
|
+
return state;
|
|
95
|
+
}
|
|
96
|
+
state.lab = founding.id;
|
|
97
|
+
// One chain per key: each entry must follow the one before it, and a key may say only one thing
|
|
98
|
+
// at each place in its log.
|
|
99
|
+
const byAuthor = new Map();
|
|
100
|
+
for (const node of nodes.values()) {
|
|
101
|
+
if (node !== founding && node.signed.entry.lab !== state.lab) {
|
|
102
|
+
state.discarded.push({ signed: node.signed, reason: "It was written for another lab." });
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
const log = byAuthor.get(node.author) ?? new Map();
|
|
106
|
+
log.set(node.seq, [...(log.get(node.seq) ?? []), node]);
|
|
107
|
+
byAuthor.set(node.author, log);
|
|
108
|
+
}
|
|
109
|
+
const chains = new Map();
|
|
110
|
+
const chained = new Map();
|
|
111
|
+
for (const [author, log] of byAuthor) {
|
|
112
|
+
const chain = [];
|
|
113
|
+
for (let seq = 0; log.has(seq); seq++) {
|
|
114
|
+
const before = chain[seq - 1];
|
|
115
|
+
const here = log.get(seq);
|
|
116
|
+
const follows = here.filter((node) => node.signed.entry.prev === (before?.id ?? null))
|
|
117
|
+
.sort((a, b) => (a === founding ? -1 : b === founding ? 1 : a.id < b.id ? -1 : 1));
|
|
118
|
+
for (const node of here) {
|
|
119
|
+
if (!follows.includes(node))
|
|
120
|
+
state.discarded.push({ signed: node.signed, reason: "It does not follow the entry before it in its own log." });
|
|
121
|
+
}
|
|
122
|
+
for (const node of follows.slice(1)) {
|
|
123
|
+
state.discarded.push({ signed: node.signed, reason: "It is a second entry at the same place in its key's log." });
|
|
124
|
+
}
|
|
125
|
+
if (follows.length === 0)
|
|
126
|
+
break;
|
|
127
|
+
chain.push(follows[0]);
|
|
128
|
+
chained.set(follows[0].id, follows[0]);
|
|
129
|
+
}
|
|
130
|
+
for (const [seq, here] of log) {
|
|
131
|
+
if (seq >= chain.length) {
|
|
132
|
+
for (const node of here) {
|
|
133
|
+
if (!state.discarded.some((one) => one.signed === node.signed)) {
|
|
134
|
+
state.waiting.push({ signed: node.signed, reason: "An earlier entry in the same log has not arrived." });
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
chains.set(author, chain);
|
|
140
|
+
}
|
|
141
|
+
// Place the entries, and settle the roster while doing it. Whether an entry counts can depend on
|
|
142
|
+
// a removal placed after it, so this is repeated with the cutoffs it found until they stop changing.
|
|
143
|
+
let cuts = new Map();
|
|
144
|
+
let walked = walk(founding, chains, chained, cuts);
|
|
145
|
+
for (let round = 0; round < 8 && !sameCuts(cuts, walked.cuts); round++) {
|
|
146
|
+
cuts = walked.cuts;
|
|
147
|
+
walked = walk(founding, chains, chained, cuts);
|
|
148
|
+
}
|
|
149
|
+
state.name = text(founding.op["name"], 200) ? founding.op["name"] : null;
|
|
150
|
+
state.roster = [...walked.roster.values()];
|
|
151
|
+
state.entries = walked.placed;
|
|
152
|
+
for (const [author, chain] of chains) {
|
|
153
|
+
const last = chain.filter((node) => walked.reached.has(node.id)).at(-1);
|
|
154
|
+
if (last !== undefined) {
|
|
155
|
+
state.heads[author] = { seq: last.seq, id: last.id };
|
|
156
|
+
state.knows[author] = Object.fromEntries(last.vc);
|
|
157
|
+
}
|
|
158
|
+
for (const node of chain) {
|
|
159
|
+
if (!walked.reached.has(node.id)) {
|
|
160
|
+
state.waiting.push({ signed: node.signed, reason: "It had seen an entry that has not arrived." });
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
fold(state, walked.placed, chained);
|
|
165
|
+
return state;
|
|
166
|
+
}
|
|
167
|
+
/** Whether two sets of cutoffs are the same. */
|
|
168
|
+
function sameCuts(a, b) {
|
|
169
|
+
return a.size === b.size && [...a].every(([key, cutoff]) => b.get(key) === cutoff);
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Put the chained entries in an order every machine agrees on, and settle the roster on the way.
|
|
173
|
+
*
|
|
174
|
+
* An entry is ready once the entry before it and everything it had seen are placed. Of the ready
|
|
175
|
+
* ones, a roster change by a keeper goes first, the longest-standing keeper before the others; after
|
|
176
|
+
* those, the lowest entry ID.
|
|
177
|
+
*/
|
|
178
|
+
function walk(founding, chains, chained, cuts) {
|
|
179
|
+
const placed = [];
|
|
180
|
+
const roster = new Map();
|
|
181
|
+
const found = new Map();
|
|
182
|
+
const reached = new Set();
|
|
183
|
+
const at = new Map();
|
|
184
|
+
const since = new Map(); // when each key became a keeper, as a count
|
|
185
|
+
const isKeeper = (key) => roster.get(key)?.role === "keeper";
|
|
186
|
+
const liveKeepers = () => [...roster.values()].filter((one) => one.role === "keeper" && one.removed === null).length;
|
|
187
|
+
const ready = () => {
|
|
188
|
+
const out = [];
|
|
189
|
+
for (const [author, chain] of chains) {
|
|
190
|
+
const node = chain[at.get(author) ?? 0];
|
|
191
|
+
if (node === undefined)
|
|
192
|
+
continue;
|
|
193
|
+
const seen = Object.entries(node.signed.entry.seen);
|
|
194
|
+
if (seen.every(([key, id]) => reached.has(id) && chained.get(id)?.author === key))
|
|
195
|
+
out.push(node);
|
|
196
|
+
}
|
|
197
|
+
return out;
|
|
198
|
+
};
|
|
199
|
+
const rank = (node) => node.op.type.startsWith("roster.") && isKeeper(node.author) ? (since.get(node.author) ?? 0) : Number.MAX_SAFE_INTEGER;
|
|
200
|
+
for (let next = ready(); next.length > 0; next = ready()) {
|
|
201
|
+
next.sort((a, b) => rank(a) - rank(b) || (a.id < b.id ? -1 : 1));
|
|
202
|
+
const node = next[0];
|
|
203
|
+
at.set(node.author, (at.get(node.author) ?? 0) + 1);
|
|
204
|
+
reached.add(node.id);
|
|
205
|
+
// What this entry had seen: what the one before it had, what it names, and itself.
|
|
206
|
+
const before = chains.get(node.author)[node.seq - 1];
|
|
207
|
+
node.vc = new Map(before?.vc ?? []);
|
|
208
|
+
for (const id of Object.values(node.signed.entry.seen)) {
|
|
209
|
+
for (const [key, seq] of chained.get(id).vc)
|
|
210
|
+
node.vc.set(key, Math.max(node.vc.get(key) ?? -1, seq));
|
|
211
|
+
}
|
|
212
|
+
node.vc.set(node.author, node.seq);
|
|
213
|
+
const say = (status, reason = null) => {
|
|
214
|
+
placed.push({ id: node.id, signed: node.signed, status, reason });
|
|
215
|
+
};
|
|
216
|
+
const op = node.op;
|
|
217
|
+
if (node === founding) {
|
|
218
|
+
roster.set(node.author, { key: node.author, person: text(op["person"], 200) ? op["person"] : "",
|
|
219
|
+
role: "keeper", founder: true, added: node.id, removed: null });
|
|
220
|
+
since.set(node.author, since.size);
|
|
221
|
+
say("applied");
|
|
222
|
+
continue;
|
|
223
|
+
}
|
|
224
|
+
const author = roster.get(node.author);
|
|
225
|
+
if (author === undefined) {
|
|
226
|
+
say("refused", "Its key is not on the lab's roster.");
|
|
227
|
+
continue;
|
|
228
|
+
}
|
|
229
|
+
if (!hadSeen(node, chained.get(author.added))) {
|
|
230
|
+
say("refused", "It was written before its key had seen itself added to the roster.");
|
|
231
|
+
continue;
|
|
232
|
+
}
|
|
233
|
+
const cut = cuts.get(node.author);
|
|
234
|
+
if (cut !== undefined && node.seq > cut) {
|
|
235
|
+
say("set aside", "It comes after the point at which its key was removed.");
|
|
236
|
+
continue;
|
|
237
|
+
}
|
|
238
|
+
if (!op.type.startsWith("roster.")) {
|
|
239
|
+
say("applied"); // whether the change itself makes sense is settled when the inventory is folded
|
|
240
|
+
continue;
|
|
241
|
+
}
|
|
242
|
+
if (author.role !== "keeper") {
|
|
243
|
+
say("refused", "Only a keeper may change the roster.");
|
|
244
|
+
continue;
|
|
245
|
+
}
|
|
246
|
+
if (op.type === "roster.add") {
|
|
247
|
+
if (!(typeof op["key"] === "string" && KEY.test(op["key"])) || !text(op["person"], 200) || !role(op["role"])) {
|
|
248
|
+
say("refused", "It does not say which key to add, whose it is, or as what.");
|
|
249
|
+
}
|
|
250
|
+
else if (roster.has(op["key"])) {
|
|
251
|
+
say("refused", "That key is already on the roster, or was removed from it.");
|
|
252
|
+
}
|
|
253
|
+
else {
|
|
254
|
+
roster.set(op["key"], { key: op["key"], person: op["person"], role: op["role"], founder: false, added: node.id, removed: null });
|
|
255
|
+
if (op["role"] === "keeper")
|
|
256
|
+
since.set(op["key"], since.size);
|
|
257
|
+
say("applied");
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
else if (op.type === "roster.remove") {
|
|
261
|
+
const target = typeof op["key"] === "string" ? roster.get(op["key"]) : undefined;
|
|
262
|
+
const cutoff = op["cutoff"];
|
|
263
|
+
if (target === undefined) {
|
|
264
|
+
say("refused", "The key it removes is not on the roster.");
|
|
265
|
+
}
|
|
266
|
+
else if (typeof cutoff !== "number" || !Number.isInteger(cutoff) || cutoff < -1) {
|
|
267
|
+
say("refused", "It does not say where in that key's log to stop.");
|
|
268
|
+
}
|
|
269
|
+
else if (cutoff > (node.vc.get(target.key) ?? -1)) {
|
|
270
|
+
say("refused", "Its cutoff is past what its author had seen of that key's log.");
|
|
271
|
+
}
|
|
272
|
+
else if (target.removed === null && target.role === "keeper" && liveKeepers() === 1) {
|
|
273
|
+
say("refused", "A lab cannot be left without a keeper.");
|
|
274
|
+
}
|
|
275
|
+
else {
|
|
276
|
+
const stop = Math.min(cutoff, found.get(target.key) ?? cutoff);
|
|
277
|
+
found.set(target.key, stop);
|
|
278
|
+
target.removed = { by: target.removed?.by ?? node.id, cutoff: stop };
|
|
279
|
+
say("applied");
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
else if (op.type === "roster.role") {
|
|
283
|
+
const target = typeof op["key"] === "string" ? roster.get(op["key"]) : undefined;
|
|
284
|
+
if (target === undefined || target.removed !== null || !role(op["role"])) {
|
|
285
|
+
say("refused", "It does not name a key on the roster and a role to give it.");
|
|
286
|
+
}
|
|
287
|
+
else if (target.role === "keeper" && op["role"] === "member" && liveKeepers() === 1) {
|
|
288
|
+
say("refused", "A lab cannot be left without a keeper.");
|
|
289
|
+
}
|
|
290
|
+
else {
|
|
291
|
+
if (op["role"] === "keeper" && target.role !== "keeper")
|
|
292
|
+
since.set(target.key, since.size);
|
|
293
|
+
target.role = op["role"];
|
|
294
|
+
say("applied");
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
else {
|
|
298
|
+
say("not understood", "This version does not know that kind of roster change.");
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
return { placed, roster, cuts: found, reached };
|
|
302
|
+
}
|
|
303
|
+
/** Apply the inventory changes, in the order the walk settled on. */
|
|
304
|
+
function fold(state, placed, chained) {
|
|
305
|
+
const parts = new Map();
|
|
306
|
+
const items = new Map();
|
|
307
|
+
/** Set a value, unless a change that had not been seen and has a lower ID already set it. */
|
|
308
|
+
const write = (set, field, node, value, what) => {
|
|
309
|
+
const held = set.get(field);
|
|
310
|
+
if (held === undefined || hadSeen(node, held.node)) {
|
|
311
|
+
set.set(field, { node, value });
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
314
|
+
const wins = node.id < held.node.id;
|
|
315
|
+
state.overlaps.push({ what, kept: wins ? node.id : held.node.id, dropped: wins ? held.node.id : node.id });
|
|
316
|
+
if (wins)
|
|
317
|
+
set.set(field, { node, value });
|
|
318
|
+
};
|
|
319
|
+
for (const one of placed) {
|
|
320
|
+
if (one.status !== "applied")
|
|
321
|
+
continue;
|
|
322
|
+
const node = chained.get(one.id);
|
|
323
|
+
const op = node.op;
|
|
324
|
+
if (op.type.startsWith("roster."))
|
|
325
|
+
continue;
|
|
326
|
+
const refuse = (reason) => { one.status = "refused"; one.reason = reason; };
|
|
327
|
+
if (op.type === "part.add") {
|
|
328
|
+
if (!text(op["sequence"], LONGEST_SEQUENCE) || !text(op["name"], 200) || typeof op["circular"] !== "boolean") {
|
|
329
|
+
refuse("It does not carry a sequence, a name and whether the part is a circle.");
|
|
330
|
+
continue;
|
|
331
|
+
}
|
|
332
|
+
// Both the molecule and its checksum are worked out inside the guard: an entry from another
|
|
333
|
+
// machine must never be able to stop the merge, only to be refused by it.
|
|
334
|
+
let record;
|
|
335
|
+
let checksum;
|
|
336
|
+
try {
|
|
337
|
+
record = new Dseqrecord(op["sequence"], op["circular"]);
|
|
338
|
+
checksum = record.seguid();
|
|
339
|
+
}
|
|
340
|
+
catch {
|
|
341
|
+
refuse("What it carries is not a sequence.");
|
|
342
|
+
continue;
|
|
343
|
+
}
|
|
344
|
+
if (!parts.has(checksum)) {
|
|
345
|
+
parts.set(checksum, {
|
|
346
|
+
part: { checksum, sequence: op["sequence"], circular: op["circular"], length: record.length,
|
|
347
|
+
name: op["name"], offered: false, fields: {}, added: node.id },
|
|
348
|
+
set: new Map([["name", { node, value: op["name"] }]]),
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
else if (op.type === "part.offer") {
|
|
353
|
+
const held = typeof op["part"] === "string" ? parts.get(op["part"]) : undefined;
|
|
354
|
+
if (held === undefined || typeof op["available"] !== "boolean") {
|
|
355
|
+
refuse("It does not name a part the lab has, and whether to offer it.");
|
|
356
|
+
continue;
|
|
357
|
+
}
|
|
358
|
+
write(held.set, "offered", node, op["available"], `whether ${held.part.name} is on offer`);
|
|
359
|
+
}
|
|
360
|
+
else if (op.type === "item.add") {
|
|
361
|
+
if (!(typeof op["item"] === "string" && ITEM_ID.test(op["item"])) || !amountOf(op["amount"]) || op["amount"] < 0
|
|
362
|
+
|| !(op["unit"] === null || text(op["unit"], 20))) {
|
|
363
|
+
refuse("It does not carry an item ID, a whole starting amount and a unit.");
|
|
364
|
+
}
|
|
365
|
+
else if (items.has(op["item"])) {
|
|
366
|
+
refuse("An item with that ID already exists.");
|
|
367
|
+
}
|
|
368
|
+
else if (typeof op["part"] !== "string" || !parts.has(op["part"])) {
|
|
369
|
+
refuse("The part it is an item of is not one the lab has.");
|
|
370
|
+
}
|
|
371
|
+
else {
|
|
372
|
+
items.set(op["item"], {
|
|
373
|
+
item: { item: op["item"], part: op["part"], unit: op["unit"], amount: 0, retired: false, needsRecount: false, fields: {}, added: node.id },
|
|
374
|
+
set: new Map(), base: { node, amount: op["amount"], recount: false }, adjusted: [], overlapped: false,
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
else if (op.type === "item.adjust" || op.type === "item.recount" || op.type === "item.retire") {
|
|
379
|
+
const held = typeof op["item"] === "string" ? items.get(op["item"]) : undefined;
|
|
380
|
+
if (held === undefined) {
|
|
381
|
+
refuse("The item it changes is not one the lab has.");
|
|
382
|
+
continue;
|
|
383
|
+
}
|
|
384
|
+
if (op.type === "item.adjust") {
|
|
385
|
+
if (!amountOf(op["by"]) || op["by"] === 0) {
|
|
386
|
+
refuse("It does not say by how many whole units.");
|
|
387
|
+
continue;
|
|
388
|
+
}
|
|
389
|
+
held.adjusted.push({ node, by: op["by"] });
|
|
390
|
+
}
|
|
391
|
+
else if (op.type === "item.recount") {
|
|
392
|
+
if (!amountOf(op["amount"]) || op["amount"] < 0) {
|
|
393
|
+
refuse("It does not say how many whole units are there.");
|
|
394
|
+
continue;
|
|
395
|
+
}
|
|
396
|
+
if (!held.base.recount || hadSeen(node, held.base.node)) {
|
|
397
|
+
held.base = { node, amount: op["amount"], recount: true };
|
|
398
|
+
held.overlapped = false;
|
|
399
|
+
}
|
|
400
|
+
else {
|
|
401
|
+
// Two people counted without knowing of each other. One count stands, and the item is flagged.
|
|
402
|
+
const wins = node.id < held.base.node.id;
|
|
403
|
+
state.overlaps.push({ what: `the count of item ${held.item.item}`, kept: wins ? node.id : held.base.node.id,
|
|
404
|
+
dropped: wins ? held.base.node.id : node.id });
|
|
405
|
+
if (wins)
|
|
406
|
+
held.base = { node, amount: op["amount"], recount: true };
|
|
407
|
+
held.overlapped = true;
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
else {
|
|
411
|
+
held.item.retired = true;
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
else if (op.type === "field.set") {
|
|
415
|
+
const field = op["field"];
|
|
416
|
+
const value = op["value"];
|
|
417
|
+
const target = op["on"] === "part" && typeof op["id"] === "string" ? parts.get(op["id"])
|
|
418
|
+
: op["on"] === "item" && typeof op["id"] === "string" ? items.get(op["id"]) : undefined;
|
|
419
|
+
if (target === undefined) {
|
|
420
|
+
refuse("It does not name a part or an item the lab has.");
|
|
421
|
+
continue;
|
|
422
|
+
}
|
|
423
|
+
if (typeof field !== "string" || !FIELD.test(field) || RESERVED.has(field)) {
|
|
424
|
+
refuse("It does not name a field that can be set.");
|
|
425
|
+
continue;
|
|
426
|
+
}
|
|
427
|
+
if (!(value === null || amountOf(value) || (typeof value === "string" && value.length <= 2_000))) {
|
|
428
|
+
refuse("Its value is not text, a whole number or nothing.");
|
|
429
|
+
continue;
|
|
430
|
+
}
|
|
431
|
+
if (field === "name" && op["on"] === "part" && !text(value, 200)) {
|
|
432
|
+
refuse("A part's name has to be some text.");
|
|
433
|
+
continue;
|
|
434
|
+
}
|
|
435
|
+
write(target.set, field, node, value, `${field} of ${op["on"]} ${String(op["id"]).slice(0, 12)}`);
|
|
436
|
+
}
|
|
437
|
+
else {
|
|
438
|
+
one.status = "not understood";
|
|
439
|
+
one.reason = "This version does not know that kind of change.";
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
for (const { part, set } of parts.values()) {
|
|
443
|
+
for (const [field, held] of set) {
|
|
444
|
+
if (field === "name")
|
|
445
|
+
part.name = held.value;
|
|
446
|
+
else if (field === "offered")
|
|
447
|
+
part.offered = held.value;
|
|
448
|
+
else
|
|
449
|
+
part.fields[field] = held.value;
|
|
450
|
+
}
|
|
451
|
+
state.parts.push(part);
|
|
452
|
+
}
|
|
453
|
+
for (const { item, set, base, adjusted, overlapped } of items.values()) {
|
|
454
|
+
// A recount replaces the adjustments its author had seen. Everything else still counts.
|
|
455
|
+
const since = adjusted.filter((one) => !hadSeen(base.node, one.node)).reduce((sum, one) => sum + one.by, 0);
|
|
456
|
+
item.amount = base.amount + since;
|
|
457
|
+
item.needsRecount = item.amount < 0 || overlapped;
|
|
458
|
+
for (const [field, held] of set)
|
|
459
|
+
item.fields[field] = held.value;
|
|
460
|
+
state.items.push(item);
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
/**
|
|
464
|
+
* Write the next entry in a key's log, given the lab as it stands.
|
|
465
|
+
*
|
|
466
|
+
* It works out the three things an entry has to say about its place: which lab, what came before it
|
|
467
|
+
* in this key's log, and which other logs have moved on since this key last wrote.
|
|
468
|
+
*
|
|
469
|
+
* @param state - The lab, from `mergeLog` over everything held.
|
|
470
|
+
* @param key - The device's key.
|
|
471
|
+
* @param op - The change.
|
|
472
|
+
* @param options - A name to sign under, and when.
|
|
473
|
+
* @returns The signed entry, to be added to what is held and sent to the others.
|
|
474
|
+
* @throws If `state` has no lab.
|
|
475
|
+
*/
|
|
476
|
+
export async function nextEntry(state, key, op, options = {}) {
|
|
477
|
+
if (state.lab === null)
|
|
478
|
+
throw new Error("There is no lab here to write to.");
|
|
479
|
+
const head = state.heads[key.publicKey];
|
|
480
|
+
const prev = head === undefined ? null : state.entries.find((one) => one.id === head.id).signed;
|
|
481
|
+
const known = state.knows[key.publicKey] ?? {};
|
|
482
|
+
const seen = {};
|
|
483
|
+
for (const [author, theirs] of Object.entries(state.heads)) {
|
|
484
|
+
if (author !== key.publicKey && (known[author] ?? -1) < theirs.seq)
|
|
485
|
+
seen[author] = theirs.id;
|
|
486
|
+
}
|
|
487
|
+
return writeEntry(key, { lab: state.lab, prev, seen }, op, options);
|
|
488
|
+
}
|
|
489
|
+
/**
|
|
490
|
+
* What a lab shows the world: the parts it has in stock, and whether each is on offer.
|
|
491
|
+
*
|
|
492
|
+
* The logs hold everything — every tube, every amount, who took what. None of that leaves. A part is
|
|
493
|
+
* listed if some item of it that has not been retired has anything left, it is on offer only if a
|
|
494
|
+
* member said so, and the only note that travels is one written to be public (`public_note`).
|
|
495
|
+
*
|
|
496
|
+
* @param state - The lab.
|
|
497
|
+
* @param lab - Who is publishing, and from where.
|
|
498
|
+
* @param options - Other labs to point at, and when to say it was published.
|
|
499
|
+
* @returns An inventory, ready for a member to sign with `signInventory`.
|
|
500
|
+
*/
|
|
501
|
+
export function publicInventory(state, lab, options = {}) {
|
|
502
|
+
const inStock = new Set(state.items.filter((item) => !item.retired && item.amount > 0).map((item) => item.part));
|
|
503
|
+
const parts = state.parts.filter((part) => inStock.has(part.checksum)).map((part, at) => ({
|
|
504
|
+
id: String(at + 1),
|
|
505
|
+
name: part.name,
|
|
506
|
+
checksum: part.checksum,
|
|
507
|
+
length: part.length,
|
|
508
|
+
circular: part.circular,
|
|
509
|
+
available: part.offered,
|
|
510
|
+
note: typeof part.fields["public_note"] === "string" ? part.fields["public_note"] : null,
|
|
511
|
+
}));
|
|
512
|
+
return {
|
|
513
|
+
bionet_inventory_version: INVENTORY_VERSION,
|
|
514
|
+
lab,
|
|
515
|
+
parts,
|
|
516
|
+
...(options.peers === undefined ? {} : { peers: [...options.peers] }),
|
|
517
|
+
published_at: options.publishedAt ?? new Date().toISOString(),
|
|
518
|
+
};
|
|
519
|
+
}
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IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;QACzG,EAAE,EAAE,MAAM,CAAC,EAAE,GAAG,CAAC,CAAC;QAClB,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,SAAS,EAAE,IAAI,CAAC,OAAO;QACvB,IAAI,EAAE,OAAO,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,IAAI;KACzF,CAAC,CAAC,CAAC;IACJ,OAAO;QACL,wBAAwB,EAAE,iBAAiB;QAC3C,GAAG;QACH,KAAK;QACL,GAAG,CAAC,OAAO,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACrE,YAAY,EAAE,OAAO,CAAC,WAAW,IAAI,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;KAC9D,CAAC;AACJ,CAAC"}
|
package/dist/model.d.ts
CHANGED
|
@@ -14,6 +14,9 @@
|
|
|
14
14
|
* that key to `endylab.example` and to nothing else. There is no registry, no authority and nobody to
|
|
15
15
|
* ask: you get a lab's key the way you got its web address, and what you can catch afterwards is the
|
|
16
16
|
* key *changing*.
|
|
17
|
+
*
|
|
18
|
+
* An inventory may also point at other labs, which is the only way anyone is found without being told
|
|
19
|
+
* an address by a person. See `PeerModel` and `discover.ts`.
|
|
17
20
|
*/
|
|
18
21
|
/** The version of this document these are written in. */
|
|
19
22
|
export declare const INVENTORY_VERSION = 1;
|
|
@@ -53,6 +56,35 @@ export interface InventoryPart {
|
|
|
53
56
|
/** Anything worth saying about it. */
|
|
54
57
|
note: string | null;
|
|
55
58
|
}
|
|
59
|
+
/**
|
|
60
|
+
* Another lab, pointed at by this one.
|
|
61
|
+
*
|
|
62
|
+
* This is how labs are found at all. There is no index to look a lab up in, so the only way to reach
|
|
63
|
+
* one you have not been told about is to start from a lab you already know and follow what it points
|
|
64
|
+
* at — which is what `discover.ts` does.
|
|
65
|
+
*
|
|
66
|
+
* Pointing at a lab is **not** vouching for what that lab holds, and nothing here treats it as such.
|
|
67
|
+
* It says only: this address exists and publishes an inventory. A pointer does carry one useful
|
|
68
|
+
* thing, though. If the referring lab records the key it saw there, a crawler can compare that with
|
|
69
|
+
* the key actually answering, and a disagreement is worth a person's attention — without anyone
|
|
70
|
+
* having to be in charge.
|
|
71
|
+
*/
|
|
72
|
+
export interface PeerModel {
|
|
73
|
+
/** The peer's address, as an origin like `https://otherlab.example`. */
|
|
74
|
+
origin: string;
|
|
75
|
+
/** What the referring lab calls them. A label, not a verified name. */
|
|
76
|
+
name: string | null;
|
|
77
|
+
/**
|
|
78
|
+
* The fingerprint of the key the referring lab saw answering there, if they recorded one.
|
|
79
|
+
*
|
|
80
|
+
* A crawler compares this with the key it finds. Agreement is weak corroboration from somebody
|
|
81
|
+
* other than the lab itself; disagreement means one of them is looking at something the other is
|
|
82
|
+
* not, and only the labs can say which.
|
|
83
|
+
*/
|
|
84
|
+
key: string | null;
|
|
85
|
+
/** Why they are pointed at, if the referring lab said. */
|
|
86
|
+
note: string | null;
|
|
87
|
+
}
|
|
56
88
|
/** A lab's inventory. */
|
|
57
89
|
export interface InventoryDocument {
|
|
58
90
|
/** Always `1`. */
|
|
@@ -61,6 +93,14 @@ export interface InventoryDocument {
|
|
|
61
93
|
lab: LabModel;
|
|
62
94
|
/** What they hold. */
|
|
63
95
|
parts: InventoryPart[];
|
|
96
|
+
/**
|
|
97
|
+
* Other labs this one points at, if it points at any.
|
|
98
|
+
*
|
|
99
|
+
* Absent in inventories written before there was such a thing, which stay perfectly valid: a
|
|
100
|
+
* reader treats a missing list as an empty one and must not add the field, since the signature
|
|
101
|
+
* covers the document as it was written.
|
|
102
|
+
*/
|
|
103
|
+
peers?: PeerModel[];
|
|
64
104
|
/** When they say they published it, as an ISO 8601 instant. */
|
|
65
105
|
published_at: string;
|
|
66
106
|
}
|
package/dist/model.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,yDAAyD;AACzD,eAAO,MAAM,iBAAiB,IAAI,CAAC;AAEnC,kCAAkC;AAClC,MAAM,WAAW,QAAQ;IACvB,+DAA+D;IAC/D,IAAI,EAAE,MAAM,CAAC;IACb;;;;;OAKG;IACH,MAAM,EAAE,MAAM,CAAC;IACf,oDAAoD;IACpD,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,wCAAwC;IACxC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CACrB;AAED,4BAA4B;AAC5B,MAAM,WAAW,aAAa;IAC5B,2DAA2D;IAC3D,EAAE,EAAE,MAAM,CAAC;IACX,yBAAyB;IACzB,IAAI,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB,2BAA2B;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,8BAA8B;IAC9B,QAAQ,EAAE,OAAO,CAAC;IAClB,6FAA6F;IAC7F,SAAS,EAAE,OAAO,CAAC;IACnB,sCAAsC;IACtC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CACrB;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,SAAS;IACxB,wEAAwE;IACxE,MAAM,EAAE,M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