@yaks/effects 0.0.0-stage → 0.2.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/README.md +979 -2
- package/_dist/docs.d.ts +10 -0
- package/_dist/docs.d.ts.map +1 -0
- package/_dist/enqueue.d.ts +12 -0
- package/_dist/enqueue.d.ts.map +1 -0
- package/_dist/expire.d.ts +31 -0
- package/_dist/expire.d.ts.map +1 -0
- package/_dist/invocation.d.ts +36 -0
- package/_dist/invocation.d.ts.map +1 -0
- package/_dist/lease.d.ts +98 -0
- package/_dist/lease.d.ts.map +1 -0
- package/_dist/mod.d.ts +89 -0
- package/_dist/mod.d.ts.map +1 -0
- package/_dist/outage.d.ts +48 -0
- package/_dist/outage.d.ts.map +1 -0
- package/_dist/pool.d.ts +148 -0
- package/_dist/pool.d.ts.map +1 -0
- package/_dist/provisional.d.ts +8 -0
- package/_dist/provisional.d.ts.map +1 -0
- package/_dist/ready.d.ts +3 -0
- package/_dist/ready.d.ts.map +1 -0
- package/_dist/registration.d.ts +17 -0
- package/_dist/registration.d.ts.map +1 -0
- package/_dist/registry.d.ts +153 -0
- package/_dist/registry.d.ts.map +1 -0
- package/_dist/tools.d.ts +21 -0
- package/_dist/tools.d.ts.map +1 -0
- package/_dist/trace.d.ts +63 -0
- package/_dist/trace.d.ts.map +1 -0
- package/_dist/views.d.ts +15 -0
- package/_dist/views.d.ts.map +1 -0
- package/_dist/vocab.d.ts +11 -0
- package/_dist/vocab.d.ts.map +1 -0
- package/_dist/worker.d.ts +19 -0
- package/_dist/worker.d.ts.map +1 -0
- package/_dist/write.d.ts +25 -0
- package/_dist/write.d.ts.map +1 -0
- package/cleanup.js +75 -0
- package/cleanup.js.map +1 -0
- package/cleanup.ts +83 -0
- package/deno.json +1 -0
- package/docs.js +13 -0
- package/docs.js.map +1 -0
- package/docs.ts +13 -0
- package/enqueue.js +71 -0
- package/enqueue.js.map +1 -0
- package/enqueue.ts +86 -0
- package/expire.js +225 -0
- package/expire.js.map +1 -0
- package/expire.ts +244 -0
- package/invocation.js +245 -0
- package/invocation.js.map +1 -0
- package/invocation.ts +250 -0
- package/lease.js +343 -0
- package/lease.js.map +1 -0
- package/lease.ts +444 -0
- package/mod.js +89 -0
- package/mod.js.map +1 -0
- package/mod.ts +92 -0
- package/outage.js +77 -0
- package/outage.js.map +1 -0
- package/outage.ts +84 -0
- package/package.json +52 -4
- package/page.js +315 -0
- package/page.js.map +1 -0
- package/page.ts +524 -0
- package/pool.js +1474 -0
- package/pool.js.map +1 -0
- package/pool.ts +1635 -0
- package/provisional.js +20 -0
- package/provisional.js.map +1 -0
- package/provisional.ts +26 -0
- package/ready.js +48 -0
- package/ready.js.map +1 -0
- package/ready.ts +93 -0
- package/registration.js +21 -0
- package/registration.js.map +1 -0
- package/registration.ts +43 -0
- package/registry.js +872 -0
- package/registry.js.map +1 -0
- package/registry.ts +1196 -0
- package/tools.js +182 -0
- package/tools.js.map +1 -0
- package/tools.ts +229 -0
- package/trace.js +167 -0
- package/trace.js.map +1 -0
- package/trace.ts +217 -0
- package/views.js +18 -0
- package/views.js.map +1 -0
- package/views.ts +18 -0
- package/vocab.js +18 -0
- package/vocab.js.map +1 -0
- package/vocab.json +364 -0
- package/vocab.ts +20 -0
- package/worker.js +114 -0
- package/worker.js.map +1 -0
- package/worker.ts +146 -0
- package/write.js +38 -0
- package/write.js.map +1 -0
- package/write.ts +60 -0
package/lease.js
ADDED
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
// A duty, and the one process running it.
|
|
2
|
+
//
|
|
3
|
+
// Some work is not about a batch at all: picking back up the agents a restart
|
|
4
|
+
// left running, freeing the locks a dead session held, firing the wakes that
|
|
5
|
+
// came due while nobody was looking. Every process that opens the graph could
|
|
6
|
+
// do it, and if they all did, an agent would be tailed twice and a wake fired
|
|
7
|
+
// twice. So each such duty is a row, and taking it is a contest:
|
|
8
|
+
//
|
|
9
|
+
// lease{name, holder, until}
|
|
10
|
+
//
|
|
11
|
+
// The eid is derived from the name, the way an edge's eid is derived from its
|
|
12
|
+
// endpoints and relation, so one duty is one row in every graph and two
|
|
13
|
+
// processes reaching for it address the same row. Taking it is a write with a
|
|
14
|
+
// `$was` precondition — the holder and the expiry as the taker read them — so
|
|
15
|
+
// the loser is refused inside the transaction rather than overwriting the
|
|
16
|
+
// winner a moment later. Nothing here polls a lock table; the graph's own
|
|
17
|
+
// precondition is the lock.
|
|
18
|
+
//
|
|
19
|
+
// `until` is what makes a lease a lease. A holder that is still doing the work
|
|
20
|
+
// takes it again on a timer and pushes the expiry out; one that was killed
|
|
21
|
+
// leaves a row that expires, and the next process to ask gets it. Nothing has
|
|
22
|
+
// to clean up after it, which is the whole reason the duty is held under a
|
|
23
|
+
// lease rather than a claim. An asker that can tell the holder is gone (`gone`:
|
|
24
|
+
// its pid no longer running, or its row saying it is over) does not wait for
|
|
25
|
+
// the expiry at all.
|
|
26
|
+
//
|
|
27
|
+
// A graph whose vocabulary does not declare `lease` has no other process to
|
|
28
|
+
// contend with — one process, one graph — so every take succeeds and nothing
|
|
29
|
+
// is written.
|
|
30
|
+
import { after } from "@yaks/fp";
|
|
31
|
+
import { derivedEid } from "@yaks/graph/identity";
|
|
32
|
+
import { Stale } from "@yaks/graph/errors";
|
|
33
|
+
import { token } from "@yaks/graph/sha256";
|
|
34
|
+
import { and, eq, every, line, or } from "@yaks/query";
|
|
35
|
+
import { finishedRun } from "./cleanup.js";
|
|
36
|
+
/** The name of the component a lease is stored as. */ export let LEASE = 'lease';
|
|
37
|
+
/** How long a take stands before another process may have it (ms). */ export let HOLD = 30_000;
|
|
38
|
+
/**
|
|
39
|
+
* The eid a lease is stored at: `sha256("lease|<name>")` formatted as a uuid,
|
|
40
|
+
* the same derivation an edge's eid gets.
|
|
41
|
+
*
|
|
42
|
+
* ```ts
|
|
43
|
+
* leaseEid('@yaks/wake') == leaseEid('@yaks/wake') // true
|
|
44
|
+
* ```
|
|
45
|
+
*/ export let leaseEid = (name)=>derivedEid(`${LEASE}|${name}`);
|
|
46
|
+
let leaseOf = (g, eid)=>Promise.resolve(g.get([
|
|
47
|
+
eid
|
|
48
|
+
])).then(([row])=>row?.[LEASE]);
|
|
49
|
+
/** Whether this graph contends at all: a component its vocabulary does not
|
|
50
|
+
* declare cannot be stored on anything in it, so there is one process and the
|
|
51
|
+
* duty is its own. */ let contested = (g)=>!!g.vocab.comp(LEASE);
|
|
52
|
+
/**
|
|
53
|
+
* Take a lease, or find out somebody else holds it. Returns whether it is now
|
|
54
|
+
* ours — a holder taking its own again is a renewal, and pushes `until` out.
|
|
55
|
+
*
|
|
56
|
+
* ```ts
|
|
57
|
+
* import { take } from '@yaks/effects'
|
|
58
|
+
*
|
|
59
|
+
* // if (await take(graph, '@yaks/wake', { holder: me })) …
|
|
60
|
+
* ```
|
|
61
|
+
*/ export let take = async (g, name, o)=>{
|
|
62
|
+
if (!contested(g)) return true;
|
|
63
|
+
let [taken] = await taking(g, [
|
|
64
|
+
name
|
|
65
|
+
], o);
|
|
66
|
+
if (!taken) return false;
|
|
67
|
+
try {
|
|
68
|
+
await g.apply([
|
|
69
|
+
taken
|
|
70
|
+
]);
|
|
71
|
+
return true;
|
|
72
|
+
} catch (error) {
|
|
73
|
+
// Another process got there first, inside the transaction. That is the
|
|
74
|
+
// answer, not a failure.
|
|
75
|
+
if (error instanceof Stale) return false;
|
|
76
|
+
throw error;
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
// The write that takes each of `names`, or `undefined` for one somebody else
|
|
80
|
+
// holds, read in one look.
|
|
81
|
+
let taking = async (g, names, o)=>{
|
|
82
|
+
let eids = names.map(leaseEid);
|
|
83
|
+
let rows = new Map((await g.get(eids)).map((row)=>[
|
|
84
|
+
row.entity.eid,
|
|
85
|
+
row[LEASE]
|
|
86
|
+
]));
|
|
87
|
+
let now = (o.now ?? Date.now)();
|
|
88
|
+
return Promise.all(names.map(async (name, i)=>{
|
|
89
|
+
let eid = eids[i];
|
|
90
|
+
let held = rows.get(eid);
|
|
91
|
+
let until = held?.until ? Date.parse(String(held.until)) : 0;
|
|
92
|
+
// Somebody else's, and their take still stands: they are not known gone.
|
|
93
|
+
if (held?.holder && held.holder != o.holder && until > now && !await o.gone?.(held.holder)) return undefined;
|
|
94
|
+
return {
|
|
95
|
+
entity: {
|
|
96
|
+
eid
|
|
97
|
+
},
|
|
98
|
+
[LEASE]: {
|
|
99
|
+
name,
|
|
100
|
+
holder: o.holder,
|
|
101
|
+
until: new Date(now + (o.hold ?? HOLD)).toISOString()
|
|
102
|
+
},
|
|
103
|
+
// Both properties, because both move: a rival taking an expired lease
|
|
104
|
+
// moves `holder`, and the holder renewing it moves only `until`. Guarding
|
|
105
|
+
// one would let the other slip past.
|
|
106
|
+
$was: {
|
|
107
|
+
[LEASE]: {
|
|
108
|
+
holder: token(held?.holder ?? null),
|
|
109
|
+
until: token(held?.until ?? null)
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
}));
|
|
114
|
+
};
|
|
115
|
+
/**
|
|
116
|
+
* Release a lease, if we are the one holding it. The row stays — the duty
|
|
117
|
+
* outlives whoever was doing it — and the next process to ask gets it without
|
|
118
|
+
* waiting for the expiry.
|
|
119
|
+
*/ export let drop = async (g, name, o)=>{
|
|
120
|
+
if (!contested(g)) return;
|
|
121
|
+
let eid = leaseEid(name);
|
|
122
|
+
let held = await leaseOf(g, eid);
|
|
123
|
+
if (!held?.holder || held.holder != o.holder) return;
|
|
124
|
+
try {
|
|
125
|
+
await g.apply([
|
|
126
|
+
{
|
|
127
|
+
entity: {
|
|
128
|
+
eid
|
|
129
|
+
},
|
|
130
|
+
[LEASE]: {
|
|
131
|
+
holder: null,
|
|
132
|
+
until: null
|
|
133
|
+
},
|
|
134
|
+
$was: {
|
|
135
|
+
[LEASE]: {
|
|
136
|
+
holder: token(held.holder)
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
]);
|
|
141
|
+
} catch (error) {
|
|
142
|
+
// Somebody took it over while we were finishing. Releasing a lease we no
|
|
143
|
+
// longer hold is a no-op, not an error.
|
|
144
|
+
if (!(error instanceof Stale)) throw error;
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
let relinquish = (b, comp, props)=>({
|
|
148
|
+
entity: {
|
|
149
|
+
eid: b.entity.eid
|
|
150
|
+
},
|
|
151
|
+
[comp]: Object.fromEntries(props.map((p)=>[
|
|
152
|
+
p,
|
|
153
|
+
null
|
|
154
|
+
])),
|
|
155
|
+
$was: {
|
|
156
|
+
[comp]: Object.fromEntries(props.map((p)=>[
|
|
157
|
+
p,
|
|
158
|
+
token(b[comp]?.[p] ?? null)
|
|
159
|
+
]))
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
let started = (b, holder)=>{
|
|
163
|
+
let e = b.effect;
|
|
164
|
+
return e.kind == 'started' && e.target == holder && e.state == 'pending';
|
|
165
|
+
};
|
|
166
|
+
/**
|
|
167
|
+
* Every duty and effect lease a holder has, as bundles that release them,
|
|
168
|
+
* guarded against a concurrent handover — to be applied
|
|
169
|
+
* in the same batch that records the holder's ending, because they are one
|
|
170
|
+
* fact: a process that is over is not doing anything, and the next one to ask
|
|
171
|
+
* should not have to wait out an expiry nobody is using. Its pending startup
|
|
172
|
+
* runs end with it: another process owes its own startup, not this closure.
|
|
173
|
+
*/ export let released = (g, holder)=>after(contested(g) ? g.read(line`.${LEASE}.holder=${holder}`) : [], (leases)=>after(g.vocab.comp('effect') ? g.read(and(or(eq('effect.lease_owner', holder), and(eq('effect.kind', 'started'), eq('effect.target', holder), eq('effect.state', 'pending'))), every())) : [], (runs)=>[
|
|
174
|
+
...leases.map((b)=>relinquish(b, LEASE, [
|
|
175
|
+
'holder',
|
|
176
|
+
'until'
|
|
177
|
+
])),
|
|
178
|
+
...runs.flatMap((b)=>started(b, holder) ? finishedRun(b) : [
|
|
179
|
+
relinquish(b, 'effect', [
|
|
180
|
+
'lease_owner',
|
|
181
|
+
'lease_token',
|
|
182
|
+
'lease_expiry'
|
|
183
|
+
])
|
|
184
|
+
])
|
|
185
|
+
]));
|
|
186
|
+
/** Who holds a lease right now, if anybody — the read a check makes. */ export let held = (g, name)=>contested(g) ? leaseOf(g, leaseEid(name)) : Promise.resolve(undefined);
|
|
187
|
+
/** Wait, unless we are done waiting: a sleep the signal cuts short, so a pass
|
|
188
|
+
* between renewals releases the lease the moment it is asked to. */ export { sleep } from "@yaks/fp";
|
|
189
|
+
import { sleep } from "@yaks/fp";
|
|
190
|
+
// The leases one holder holds in one graph for one length of hold, renewed on
|
|
191
|
+
// one timer in one commit: a process holding fifteen duties writes once a beat,
|
|
192
|
+
// not fifteen times.
|
|
193
|
+
let beats = new WeakMap();
|
|
194
|
+
// Renew `r` beside the others its holder holds, until the answer is called.
|
|
195
|
+
// Renewed on a timer while the work runs: a holder still at it never expires,
|
|
196
|
+
// and one that stops existing does. One renewal at a time, so two of this
|
|
197
|
+
// process's own cannot refuse each other.
|
|
198
|
+
let beside = (g, r)=>{
|
|
199
|
+
let held = beats.get(g) ?? new Map();
|
|
200
|
+
beats.set(g, held);
|
|
201
|
+
let key = `${r.ask.holder}|${r.ask.hold}`;
|
|
202
|
+
let beat = held.get(key);
|
|
203
|
+
if (!beat) {
|
|
204
|
+
let b = beat = {
|
|
205
|
+
renewals: new Set(),
|
|
206
|
+
beating: false
|
|
207
|
+
};
|
|
208
|
+
held.set(key, b);
|
|
209
|
+
// A third of the hold, however short: a renewal later than the hold would
|
|
210
|
+
// let the lease lapse under work still running.
|
|
211
|
+
b.timer = setInterval(async ()=>{
|
|
212
|
+
if (b.beating) return;
|
|
213
|
+
b.beating = true;
|
|
214
|
+
try {
|
|
215
|
+
await renew(g, [
|
|
216
|
+
...b.renewals
|
|
217
|
+
], (r)=>b.renewals.has(r));
|
|
218
|
+
} finally{
|
|
219
|
+
b.beating = false;
|
|
220
|
+
}
|
|
221
|
+
}, Math.max(1, Math.floor(r.ask.hold / 3)));
|
|
222
|
+
}
|
|
223
|
+
let b = beat;
|
|
224
|
+
b.renewals.add(r);
|
|
225
|
+
return ()=>{
|
|
226
|
+
b.renewals.delete(r);
|
|
227
|
+
if (b.renewals.size) return;
|
|
228
|
+
clearInterval(b.timer);
|
|
229
|
+
held.delete(key);
|
|
230
|
+
};
|
|
231
|
+
};
|
|
232
|
+
// One commit renewing every lease a beat holds. One somebody else holds now is
|
|
233
|
+
// lost; a commit refused is asked again a lease at a time, and a refusal is
|
|
234
|
+
// read back before it counts, since only another holder means it is gone.
|
|
235
|
+
//
|
|
236
|
+
// A beat runs beside the work, so the work can end while one is under way.
|
|
237
|
+
// `kept` says whether a renewal is still wanted: a lease its holder has let go
|
|
238
|
+
// is not taken back, and nothing the store fails about it is anybody's to hear,
|
|
239
|
+
// since a holder on its way out may have closed the store behind it.
|
|
240
|
+
let renew = async (g, all, kept)=>{
|
|
241
|
+
if (!all.length) return;
|
|
242
|
+
let { ask } = all[0];
|
|
243
|
+
try {
|
|
244
|
+
let bundles = await taking(g, all.map((r)=>r.name), ask);
|
|
245
|
+
all.forEach((r, i)=>bundles[i] || r.lost.abort());
|
|
246
|
+
let taken = bundles.filter((b, i)=>!!b && kept(all[i]));
|
|
247
|
+
if (!taken.length) return;
|
|
248
|
+
try {
|
|
249
|
+
await g.apply(taken);
|
|
250
|
+
return;
|
|
251
|
+
} catch (error) {
|
|
252
|
+
if (!(error instanceof Stale)) throw error;
|
|
253
|
+
}
|
|
254
|
+
} catch (e) {
|
|
255
|
+
return all.find(kept)?.report(e);
|
|
256
|
+
}
|
|
257
|
+
for (let r of all){
|
|
258
|
+
if (r.lost.signal.aborted || !kept(r)) continue;
|
|
259
|
+
try {
|
|
260
|
+
if (await take(g, r.name, r.ask)) continue;
|
|
261
|
+
if ((await held(g, r.name))?.holder != r.ask.holder) r.lost.abort();
|
|
262
|
+
} catch (e) {
|
|
263
|
+
if (kept(r)) r.report(e);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
};
|
|
267
|
+
/**
|
|
268
|
+
* Run a duty for as long as this process is up: take the lease, renew it
|
|
269
|
+
* while the work runs, and release it at the end. Answers what the work last
|
|
270
|
+
* answered, or `undefined` where it never ran.
|
|
271
|
+
*
|
|
272
|
+
* The same call serves a process of either shape, which is the point — nothing
|
|
273
|
+
* here assumes a separate one. A server or a TUI passes a live signal and
|
|
274
|
+
* holds the lease until that aborts, waiting for the holder ahead of it to
|
|
275
|
+
* expire; a one-shot CLI command passes a signal that has already aborted,
|
|
276
|
+
* does the pass if nobody else is, and releases on the way out. Either way the
|
|
277
|
+
* lease is renewed for as long as the work runs.
|
|
278
|
+
*
|
|
279
|
+
* The work is handed a signal that also aborts when the lease is lost: a
|
|
280
|
+
* renewal that finds another process holding it means that process is doing
|
|
281
|
+
* the duty now, so this one stops, and goes back to waiting in case that one
|
|
282
|
+
* stops too. Renewals run on a timer beside the work, so the work has to
|
|
283
|
+
* yield to timers (a sleep, a wait on I/O) more often than a third of the
|
|
284
|
+
* hold; a step that blocks longer can lapse, and the next renewal to run
|
|
285
|
+
* finds out and stops it.
|
|
286
|
+
*
|
|
287
|
+
* ```ts
|
|
288
|
+
* import { holding } from '@yaks/effects'
|
|
289
|
+
*
|
|
290
|
+
* // await holding(graph, '@yaks/wake', { holder: me, signal }, (s) => loop(g, { signal: s }))
|
|
291
|
+
* ```
|
|
292
|
+
*/ export let holding = async (g, name, o, work)=>{
|
|
293
|
+
let signal = o.signal ?? AbortSignal.abort();
|
|
294
|
+
let wait = o.wait ?? !signal.aborted;
|
|
295
|
+
let hold = o.hold ?? HOLD;
|
|
296
|
+
let ask = {
|
|
297
|
+
...o,
|
|
298
|
+
hold
|
|
299
|
+
};
|
|
300
|
+
let report = o.report ?? ((e)=>console.error(`${name} —`, e));
|
|
301
|
+
// A take the store failed is not a no. Waiting, it is told and asked again
|
|
302
|
+
// next time; not waiting, there is no next time here, so the caller hears.
|
|
303
|
+
let ours = ()=>wait ? take(g, name, ask).catch((e)=>{
|
|
304
|
+
report(e);
|
|
305
|
+
return false;
|
|
306
|
+
}) : take(g, name, ask);
|
|
307
|
+
let out;
|
|
308
|
+
while(true){
|
|
309
|
+
while(!await ours()){
|
|
310
|
+
// Somebody is doing it. A process that is staying up waits them out — a
|
|
311
|
+
// holder that was killed expires and this is what takes over — and one
|
|
312
|
+
// that is only passing through leaves it to them.
|
|
313
|
+
if (!wait || signal.aborted) return out;
|
|
314
|
+
await sleep(o.poll ?? Math.max(250, Math.floor(hold / 10)), signal);
|
|
315
|
+
if (signal.aborted) return out;
|
|
316
|
+
}
|
|
317
|
+
let lost = new AbortController();
|
|
318
|
+
let leave = beside(g, {
|
|
319
|
+
name,
|
|
320
|
+
ask,
|
|
321
|
+
lost,
|
|
322
|
+
report
|
|
323
|
+
});
|
|
324
|
+
try {
|
|
325
|
+
out = await work(AbortSignal.any([
|
|
326
|
+
signal,
|
|
327
|
+
lost.signal
|
|
328
|
+
]));
|
|
329
|
+
} finally{
|
|
330
|
+
leave();
|
|
331
|
+
await drop(g, name, {
|
|
332
|
+
holder: o.holder
|
|
333
|
+
}).catch(report);
|
|
334
|
+
}
|
|
335
|
+
if (signal.aborted || !lost.signal.aborted) return out;
|
|
336
|
+
}
|
|
337
|
+
};
|
|
338
|
+
/** A promise that keeps a lease held and does nothing else, until the signal
|
|
339
|
+
* reports that we are done — what a pass that has already finished its work
|
|
340
|
+
* waits on, so the lease stays this process's while it is up. */ export let until = (signal)=>signal.aborted ? Promise.resolve() : new Promise((done)=>signal.addEventListener('abort', ()=>done(), {
|
|
341
|
+
once: true
|
|
342
|
+
}));
|
|
343
|
+
//# sourceMappingURL=lease.js.map
|
package/lease.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lease.js","sources":["./lease.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,EAAE;AACF,8EAA8E;AAC9E,6EAA6E;AAC7E,8EAA8E;AAC9E,8EAA8E;AAC9E,iEAAiE;AACjE,EAAE;AACF,+BAA+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