@gmitch215/folio 1.0.1 → 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 +98 -460
- package/dist/boot.d.ts +1 -0
- package/dist/boot.js +1 -0
- package/dist/browser/index.d.ts +73 -0
- package/dist/browser/index.js +277 -0
- package/dist/browser.d.ts +1 -68
- package/dist/browser.js +1 -274
- package/dist/continuation.d.ts +1 -0
- package/dist/continuation.js +1 -0
- package/dist/{compiler.d.ts → execution/compiler.d.ts} +1 -1
- package/dist/{compiler.js → execution/compiler.js} +5 -12
- package/dist/{coordinator.d.ts → execution/coordinator.d.ts} +1 -1
- package/dist/{coordinator.js → execution/coordinator.js} +55 -8
- package/dist/{extract.d.ts → execution/extract.d.ts} +22 -13
- package/dist/{extract.js → execution/extract.js} +137 -10
- package/dist/execution/fold.d.ts +44 -0
- package/dist/execution/fold.js +105 -0
- package/dist/{guards.d.ts → execution/guards.d.ts} +2 -1
- package/dist/execution/runs.d.ts +44 -0
- package/dist/execution/runs.js +182 -0
- package/dist/{transaction.d.ts → execution/transaction.d.ts} +10 -0
- package/dist/execution/types.d.ts +221 -0
- package/dist/folds/affine-state.d.ts +142 -0
- package/dist/folds/affine-state.js +737 -0
- package/dist/folds/affine.d.ts +148 -0
- package/dist/folds/affine.js +562 -0
- package/dist/folds/boundaries.d.ts +48 -0
- package/dist/folds/boundaries.js +119 -0
- package/dist/folds/certified.d.ts +55 -0
- package/dist/folds/certified.js +178 -0
- package/dist/folds/certify.d.ts +87 -0
- package/dist/folds/certify.js +2611 -0
- package/dist/footprints/memo.d.ts +74 -0
- package/dist/footprints/memo.js +256 -0
- package/dist/footprints/ranges.d.ts +78 -0
- package/dist/footprints/ranges.js +263 -0
- package/dist/footprints/read-scan.d.ts +18 -0
- package/dist/footprints/read-scan.js +94 -0
- package/dist/footprints/read-windows.d.ts +77 -0
- package/dist/footprints/read-windows.js +245 -0
- package/dist/index.d.ts +16 -4
- package/dist/index.js +14 -2
- package/dist/iteration/admission.d.ts +149 -0
- package/dist/iteration/admission.js +201 -0
- package/dist/iteration/index.d.ts +239 -0
- package/dist/iteration/index.js +1210 -0
- package/dist/iteration/inline.d.ts +182 -0
- package/dist/{inline.js → iteration/inline.js} +277 -21
- package/dist/{iteration-owner.d.ts → iteration/owner.d.ts} +16 -3
- package/dist/{iteration-owner.js → iteration/owner.js} +6 -5
- package/dist/iteration/worker.js +216 -0
- package/dist/{managed.d.ts → managed/index.d.ts} +75 -3
- package/dist/managed/index.js +817 -0
- package/dist/managed/outbox.d.ts +128 -0
- package/dist/managed/outbox.js +156 -0
- package/dist/managed/pool.d.ts +221 -0
- package/dist/managed/pool.js +310 -0
- package/dist/managed/tasks.d.ts +154 -0
- package/dist/managed/tasks.js +183 -0
- package/dist/{bake.d.ts → memory/bake.d.ts} +12 -6
- package/dist/{bake.js → memory/bake.js} +9 -7
- package/dist/memory/continuation.d.ts +141 -0
- package/dist/memory/continuation.js +495 -0
- package/dist/memory/elastic-peer.d.ts +20 -0
- package/dist/memory/elastic-peer.js +39 -0
- package/dist/memory/elastic-sql.d.ts +11 -0
- package/dist/memory/elastic-sql.js +35 -0
- package/dist/memory/elastic.d.ts +130 -0
- package/dist/memory/elastic.js +475 -0
- package/dist/memory/growth-governor.d.ts +16 -0
- package/dist/memory/growth-governor.js +42 -0
- package/dist/memory/imports.d.ts +10 -0
- package/dist/memory/imports.js +89 -0
- package/dist/{iteration-layout.d.ts → memory/iteration-layout.d.ts} +61 -1
- package/dist/{iteration-layout.js → memory/iteration-layout.js} +54 -3
- package/dist/memory/lease.d.ts +45 -0
- package/dist/memory/lease.js +274 -0
- package/dist/{pages.d.ts → memory/pages.d.ts} +3 -3
- package/dist/memory.d.ts +5 -10
- package/dist/memory.js +5 -89
- package/dist/{context.d.ts → node/context.d.ts} +17 -3
- package/dist/{context.js → node/context.js} +60 -14
- package/dist/{host.d.ts → node/host.d.ts} +1 -1
- package/dist/{host.js → node/host.js} +2 -2
- package/dist/{node.d.ts → node/index.d.ts} +46 -49
- package/dist/{node.js → node/index.js} +101 -26
- package/dist/{tasks.d.ts → node/tasks.d.ts} +16 -17
- package/dist/{tasks.js → node/tasks.js} +12 -11
- package/dist/node/worker.d.ts +1 -0
- package/dist/{worker.js → node/worker.js} +2 -2
- package/dist/ownership/index.d.ts +161 -0
- package/dist/ownership/index.js +6565 -0
- package/dist/ownership/redirect.d.ts +30 -0
- package/dist/ownership/redirect.js +179 -0
- package/dist/ownership/slices.d.ts +44 -0
- package/dist/ownership/slices.js +72 -0
- package/dist/{frames.d.ts → remote/frames.d.ts} +6 -2
- package/dist/remote/frames.js +306 -0
- package/dist/{remote.d.ts → remote/index.d.ts} +7 -2
- package/dist/{remote.js → remote/index.js} +7 -2
- package/dist/routing/index.d.ts +203 -0
- package/dist/routing/index.js +671 -0
- package/dist/routing/worker.d.ts +1 -0
- package/dist/routing/worker.js +4 -0
- package/dist/slices/index.d.ts +126 -0
- package/dist/slices/index.js +441 -0
- package/dist/slices/worker.d.ts +1 -0
- package/dist/slices/worker.js +38 -0
- package/dist/workers.d.ts +5 -0
- package/dist/workers.js +5 -0
- package/package.json +32 -46
- package/dist/frames.js +0 -159
- package/dist/inline.d.ts +0 -68
- package/dist/iteration-admission.d.ts +0 -76
- package/dist/iteration-admission.js +0 -72
- package/dist/iteration-worker.js +0 -150
- package/dist/iteration.d.ts +0 -163
- package/dist/iteration.js +0 -435
- package/dist/managed.js +0 -421
- /package/dist/{browser-worker.d.ts → browser/worker.d.ts} +0 -0
- /package/dist/{browser-worker.js → browser/worker.js} +0 -0
- /package/dist/{guards.js → execution/guards.js} +0 -0
- /package/dist/{import-order.d.ts → execution/import-order.d.ts} +0 -0
- /package/dist/{import-order.js → execution/import-order.js} +0 -0
- /package/dist/{transaction.js → execution/transaction.js} +0 -0
- /package/dist/{iteration-worker.d.ts → execution/types.js} +0 -0
- /package/dist/{worker.d.ts → iteration/worker.d.ts} +0 -0
- /package/dist/{pages.js → memory/pages.js} +0 -0
- /package/dist/{values.d.ts → remote/values.d.ts} +0 -0
- /package/dist/{values.js → remote/values.js} +0 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type IterationRoute, type OwnershipPlan } from '../execution/extract.ts';
|
|
2
|
+
import { type OwnershipCertificate } from './index.ts';
|
|
3
|
+
export type RedirectErrorCode = 'unbound' | 'stale' | 'invalid' | 'unsupported';
|
|
4
|
+
export declare class OwnershipRedirectError extends Error {
|
|
5
|
+
readonly code: RedirectErrorCode;
|
|
6
|
+
constructor(code: RedirectErrorCode, detail: string);
|
|
7
|
+
}
|
|
8
|
+
export interface RedirectStats {
|
|
9
|
+
redirected: number;
|
|
10
|
+
skipped: number;
|
|
11
|
+
bulk: number;
|
|
12
|
+
straddle: number;
|
|
13
|
+
functions: number;
|
|
14
|
+
}
|
|
15
|
+
export interface OwnershipRedirect {
|
|
16
|
+
module: Uint8Array;
|
|
17
|
+
plan: OwnershipPlan;
|
|
18
|
+
stats: RedirectStats;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Rewrites the closure of a certified module so each window access adds a per-worker delta. The
|
|
22
|
+
* delta globals start at 0, so the module still runs in place. Throws `OwnershipRedirectError`
|
|
23
|
+
* when the certificate does not bind to the bytes or the module cannot be rewritten.
|
|
24
|
+
*/
|
|
25
|
+
export declare function redirectOwnership(bytes: Uint8Array, certificate: OwnershipCertificate): OwnershipRedirect;
|
|
26
|
+
/** The iteration route of the redirected module, with the plan the executor needs. */
|
|
27
|
+
export declare function ownershipRoute(bytes: Uint8Array, certificate: OwnershipCertificate): {
|
|
28
|
+
route: IterationRoute;
|
|
29
|
+
redirect: OwnershipRedirect;
|
|
30
|
+
};
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import binaryen from 'binaryen';
|
|
2
|
+
import { createHash } from 'node:crypto';
|
|
3
|
+
import { iterationRoute, redirectDelta, stackRoute } from "../execution/extract.js";
|
|
4
|
+
import { memoryAccesses, verifyOwnership } from "./index.js";
|
|
5
|
+
export class OwnershipRedirectError extends Error {
|
|
6
|
+
code;
|
|
7
|
+
constructor(code, detail) {
|
|
8
|
+
super(detail);
|
|
9
|
+
this.name = 'OwnershipRedirectError';
|
|
10
|
+
this.code = code;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
const i32 = binaryen.i32;
|
|
14
|
+
const api = binaryen;
|
|
15
|
+
const sha = (bytes) => createHash('sha256').update(bytes).digest('hex');
|
|
16
|
+
/**
|
|
17
|
+
* Rewrites the closure of a certified module so each window access adds a per-worker delta. The
|
|
18
|
+
* delta globals start at 0, so the module still runs in place. Throws `OwnershipRedirectError`
|
|
19
|
+
* when the certificate does not bind to the bytes or the module cannot be rewritten.
|
|
20
|
+
*/
|
|
21
|
+
export function redirectOwnership(bytes, certificate) {
|
|
22
|
+
if (certificate.kind !== 'certificate' || certificate.moduleSha256 !== sha(bytes))
|
|
23
|
+
throw new OwnershipRedirectError('unbound', 'the certificate is for another module');
|
|
24
|
+
if (!verifyOwnership(bytes, certificate))
|
|
25
|
+
throw new OwnershipRedirectError('stale', 'the certificate does not re-derive');
|
|
26
|
+
const m = binaryen.readBinary(Uint8Array.from(bytes));
|
|
27
|
+
const debug = api.getDebugInfo?.() ?? false;
|
|
28
|
+
try {
|
|
29
|
+
const compact = binaryen.Features.CompactImports;
|
|
30
|
+
m.setFeatures(binaryen.Features.All & ~compact);
|
|
31
|
+
const windows = certificate.windows.map((w, i) => ({
|
|
32
|
+
low: w.low,
|
|
33
|
+
end: w.end,
|
|
34
|
+
delta: `${redirectDelta}${i}`
|
|
35
|
+
}));
|
|
36
|
+
for (const w of windows)
|
|
37
|
+
if (m.getGlobal(w.delta) || m.getExport(w.delta))
|
|
38
|
+
throw new OwnershipRedirectError('unsupported', `${w.delta} is already defined`);
|
|
39
|
+
for (const w of windows) {
|
|
40
|
+
m.addGlobal(w.delta, i32, true, m.i32.const(0));
|
|
41
|
+
m.addGlobalExport(w.delta, w.delta);
|
|
42
|
+
}
|
|
43
|
+
const c = (v) => m.i32.const(v | 0);
|
|
44
|
+
const get = (index) => m.local.get(index, i32);
|
|
45
|
+
const stats = {
|
|
46
|
+
redirected: 0,
|
|
47
|
+
skipped: 0,
|
|
48
|
+
bulk: 0,
|
|
49
|
+
straddle: 0,
|
|
50
|
+
functions: 0
|
|
51
|
+
};
|
|
52
|
+
const lowest = Math.min(...windows.map((w) => w.low));
|
|
53
|
+
// the byte at `a + k` lies wholly in window w when the offset from low is below `limit`
|
|
54
|
+
const inside = (a, k, w, width) => m.i32.lt_u(m.i32.sub(k ? m.i32.add(get(a), c(k)) : get(a), c(w.low)), c(w.end - w.low - width + 1));
|
|
55
|
+
const overlaps = (a, k, w, width) => m.i32.lt_u(m.i32.sub(k ? m.i32.add(get(a), c(k)) : get(a), c(w.low - width + 1)), c(w.end - w.low + width - 1));
|
|
56
|
+
const partial = (a, k, w, width) => m.i32.and(overlaps(a, k, w, width), m.i32.eqz(inside(a, k, w, width)));
|
|
57
|
+
const chain = (test) => windows.reduceRight((rest, w) => m.select(test(w), m.global.get(w.delta, i32), rest), c(0));
|
|
58
|
+
const any = (test) => windows.map(test).reduce((left, right) => m.i32.or(left, right));
|
|
59
|
+
for (const name of certificate.functions) {
|
|
60
|
+
const ref = m.getFunction(name);
|
|
61
|
+
if (!ref)
|
|
62
|
+
throw new OwnershipRedirectError('stale', `no function ${name}`);
|
|
63
|
+
const body = binaryen.getFunctionInfo(ref).body;
|
|
64
|
+
const sites = memoryAccesses(body);
|
|
65
|
+
const modes = certificate.accesses[name] ?? '';
|
|
66
|
+
if (modes.length !== sites.length)
|
|
67
|
+
throw new OwnershipRedirectError('stale', `the accesses of ${name} changed`);
|
|
68
|
+
const infos = sites.map((e) => ({ e, v: binaryen.getExpressionInfo(e) }));
|
|
69
|
+
let t = -1;
|
|
70
|
+
let bulk = [];
|
|
71
|
+
stats.functions++;
|
|
72
|
+
infos.forEach(({ e, v }, at) => {
|
|
73
|
+
const mode = modes[at];
|
|
74
|
+
if (mode === 'o') {
|
|
75
|
+
stats.skipped++;
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
const id = binaryen.getExpressionId(e);
|
|
79
|
+
if (id === binaryen.LoadId || id === binaryen.StoreId) {
|
|
80
|
+
const k = Number(BigInt.asUintN(32, BigInt(v.offset)));
|
|
81
|
+
// a constant base plus the offset cannot wrap, so only a dynamic base needs the bound
|
|
82
|
+
const fixed = binaryen.getExpressionId(v.ptr) === binaryen.ConstId &&
|
|
83
|
+
(binaryen.getExpressionInfo(v.ptr).value >>> 0) + k <= 0xffffffff;
|
|
84
|
+
if (k > lowest && !fixed)
|
|
85
|
+
throw new OwnershipRedirectError('unsupported', 'an access offset passes a window');
|
|
86
|
+
if (t < 0)
|
|
87
|
+
t = api._BinaryenFunctionAddVar(ref, i32);
|
|
88
|
+
const width = v.bytes;
|
|
89
|
+
let delta = chain((w) => inside(t, k, w, width));
|
|
90
|
+
if (width > 1 && mode !== 'x' && mode !== 'b') {
|
|
91
|
+
delta = m.if(any((w) => partial(t, k, w, width)), m.unreachable(), delta);
|
|
92
|
+
stats.straddle++;
|
|
93
|
+
}
|
|
94
|
+
const ptr = m.i32.add(m.local.tee(t, v.ptr, i32), delta);
|
|
95
|
+
if (id === binaryen.LoadId)
|
|
96
|
+
api._BinaryenLoadSetPtr(e, ptr);
|
|
97
|
+
else
|
|
98
|
+
api._BinaryenStoreSetPtr(e, ptr);
|
|
99
|
+
stats.redirected++;
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
if (bulk.length === 0) {
|
|
103
|
+
bulk = [0, 1, 2, 3].map(() => api._BinaryenFunctionAddVar(ref, i32));
|
|
104
|
+
}
|
|
105
|
+
const [td, ts, tn, tv] = bulk;
|
|
106
|
+
void tv;
|
|
107
|
+
const isCopy = id === binaryen.MemoryCopyId;
|
|
108
|
+
const dest = v.dest;
|
|
109
|
+
const second = isCopy
|
|
110
|
+
? v.source
|
|
111
|
+
: id === binaryen.MemoryFillId
|
|
112
|
+
? v.value
|
|
113
|
+
: v.offset;
|
|
114
|
+
const size = v.size;
|
|
115
|
+
const room = (a) => {
|
|
116
|
+
const n = (w) => w.end - w.low;
|
|
117
|
+
const inn = (w) => m.i32.and(m.i32.le_u(get(tn), c(n(w))), m.i32.le_u(m.i32.sub(get(a), c(w.low)), m.i32.sub(c(n(w)), get(tn))));
|
|
118
|
+
const part = (w) => m.i32.and(m.i32.and(m.i32.lt_u(get(a), c(w.end)), m.i32.gt_u(m.i32.add(get(a), get(tn)), c(w.low))), m.i32.eqz(inn(w)));
|
|
119
|
+
const pick = windows.reduceRight((rest, w) => m.select(inn(w), m.global.get(w.delta, i32), rest), c(0));
|
|
120
|
+
return m.if(any(part), m.unreachable(), pick);
|
|
121
|
+
};
|
|
122
|
+
const first = m.block(null, [
|
|
123
|
+
m.local.set(td, dest),
|
|
124
|
+
m.local.set(ts, second),
|
|
125
|
+
m.local.set(tn, size),
|
|
126
|
+
m.i32.add(get(td), room(td))
|
|
127
|
+
], i32);
|
|
128
|
+
const next = isCopy ? m.i32.add(get(ts), room(ts)) : get(ts);
|
|
129
|
+
if (isCopy) {
|
|
130
|
+
api._BinaryenMemoryCopySetDest(e, first);
|
|
131
|
+
api._BinaryenMemoryCopySetSource(e, next);
|
|
132
|
+
api._BinaryenMemoryCopySetSize(e, get(tn));
|
|
133
|
+
}
|
|
134
|
+
else if (id === binaryen.MemoryFillId) {
|
|
135
|
+
api._BinaryenMemoryFillSetDest(e, first);
|
|
136
|
+
api._BinaryenMemoryFillSetValue(e, next);
|
|
137
|
+
api._BinaryenMemoryFillSetSize(e, get(tn));
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
api._BinaryenMemoryInitSetDest(e, first);
|
|
141
|
+
api._BinaryenMemoryInitSetOffset(e, next);
|
|
142
|
+
api._BinaryenMemoryInitSetSize(e, get(tn));
|
|
143
|
+
}
|
|
144
|
+
stats.bulk++;
|
|
145
|
+
stats.straddle++;
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
if (!m.validate())
|
|
149
|
+
throw new OwnershipRedirectError('invalid', 'the redirected module is invalid');
|
|
150
|
+
api.setDebugInfo?.(true);
|
|
151
|
+
const out = Uint8Array.from(m.emitBinary());
|
|
152
|
+
try {
|
|
153
|
+
new WebAssembly.Module(out);
|
|
154
|
+
}
|
|
155
|
+
catch (error) {
|
|
156
|
+
throw new OwnershipRedirectError('invalid', `the redirected module does not compile: ${error}`);
|
|
157
|
+
}
|
|
158
|
+
return {
|
|
159
|
+
module: out,
|
|
160
|
+
plan: {
|
|
161
|
+
windows: windows.map((w) => ({ low: w.low, end: w.end, delta: w.delta })),
|
|
162
|
+
copyOut: certificate.copyOut.map(([a, b]) => [a, b])
|
|
163
|
+
},
|
|
164
|
+
stats
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
finally {
|
|
168
|
+
api.setDebugInfo?.(debug);
|
|
169
|
+
m.dispose();
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
/** The iteration route of the redirected module, with the plan the executor needs. */
|
|
173
|
+
export function ownershipRoute(bytes, certificate) {
|
|
174
|
+
const redirect = redirectOwnership(bytes, certificate);
|
|
175
|
+
const route = iterationRoute(redirect.module, stackRoute(redirect.module));
|
|
176
|
+
if (route.eligible)
|
|
177
|
+
route.ownership = redirect.plan;
|
|
178
|
+
return { route, redirect };
|
|
179
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { type SlicePoolOptions, type SliceReport, type SliceRunOptions } from '../slices/index.ts';
|
|
2
|
+
import { type OwnershipCertificate } from './index.ts';
|
|
3
|
+
import { type OwnershipRedirect } from './redirect.ts';
|
|
4
|
+
/**
|
|
5
|
+
* `layout`: a record region overlaps a certified window, so the certificate does not apply.
|
|
6
|
+
* `wild-store`: the module stores to an address outside every window that no record owns, and
|
|
7
|
+
* nothing here tracks it.
|
|
8
|
+
* `config`: the memory or a table word differs from the config the certificate was made for.
|
|
9
|
+
*/
|
|
10
|
+
export declare class OwnershipSlicesError extends Error {
|
|
11
|
+
readonly code: 'layout' | 'wild-store' | 'config';
|
|
12
|
+
constructor(code: 'layout' | 'wild-store' | 'config', detail: string);
|
|
13
|
+
}
|
|
14
|
+
export interface OwnershipSliceRunOptions extends Omit<SliceRunOptions, 'writes'> {
|
|
15
|
+
/** Every region the records touch: the table, inputs, aux data, outputs and arena slices. */
|
|
16
|
+
regions: [number, number][];
|
|
17
|
+
/**
|
|
18
|
+
* The regions the records write outside the windows. They are restored when a slice traps. The
|
|
19
|
+
* list must name every range the records write: a range left out keeps the writes of the records
|
|
20
|
+
* after the trap, and the serial replay does not undo them.
|
|
21
|
+
*/
|
|
22
|
+
writes: [number, number][];
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* The slice pool over a certified module whose windows are redirected to private copies. A trap in
|
|
26
|
+
* any slice puts `writes` back and runs the calls serially in place, so the serial run decides the
|
|
27
|
+
* memory and the trap.
|
|
28
|
+
* @since 1.1.0
|
|
29
|
+
*/
|
|
30
|
+
export declare class OwnershipSlices {
|
|
31
|
+
#private;
|
|
32
|
+
readonly redirect: OwnershipRedirect;
|
|
33
|
+
private constructor();
|
|
34
|
+
/** Redirects the module and opens the pool. Throws `OwnershipRedirectError` on a stale certificate. */
|
|
35
|
+
static open(bytes: Uint8Array, certificate: OwnershipCertificate, options: Omit<SlicePoolOptions, 'ownership'>): Promise<OwnershipSlices>;
|
|
36
|
+
get memory(): WebAssembly.Memory;
|
|
37
|
+
get size(): number;
|
|
38
|
+
/** First byte of the private regions; the memory below it is the program's. */
|
|
39
|
+
get privateBase(): number | undefined;
|
|
40
|
+
/** Calls the certified entry for `[0, count)`. Refuses with `OwnershipSlicesError` on a layout overlap. */
|
|
41
|
+
run(count: number, args: (from: number, to: number) => (number | bigint)[], options: OwnershipSliceRunOptions): Promise<SliceReport>;
|
|
42
|
+
close(): Promise<void>;
|
|
43
|
+
}
|
|
44
|
+
export declare const ownershipSlices: typeof OwnershipSlices.open;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { SlicePool } from "../slices/index.js";
|
|
2
|
+
import { checkConfig, guardRecords } from "./index.js";
|
|
3
|
+
import { redirectOwnership } from "./redirect.js";
|
|
4
|
+
/**
|
|
5
|
+
* `layout`: a record region overlaps a certified window, so the certificate does not apply.
|
|
6
|
+
* `wild-store`: the module stores to an address outside every window that no record owns, and
|
|
7
|
+
* nothing here tracks it.
|
|
8
|
+
* `config`: the memory or a table word differs from the config the certificate was made for.
|
|
9
|
+
*/
|
|
10
|
+
export class OwnershipSlicesError extends Error {
|
|
11
|
+
code;
|
|
12
|
+
constructor(code, detail) {
|
|
13
|
+
super(detail);
|
|
14
|
+
this.name = 'OwnershipSlicesError';
|
|
15
|
+
this.code = code;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The slice pool over a certified module whose windows are redirected to private copies. A trap in
|
|
20
|
+
* any slice puts `writes` back and runs the calls serially in place, so the serial run decides the
|
|
21
|
+
* memory and the trap.
|
|
22
|
+
* @since 1.1.0
|
|
23
|
+
*/
|
|
24
|
+
export class OwnershipSlices {
|
|
25
|
+
#pool;
|
|
26
|
+
#certificate;
|
|
27
|
+
redirect;
|
|
28
|
+
constructor(pool, certificate, redirect) {
|
|
29
|
+
this.#pool = pool;
|
|
30
|
+
this.#certificate = certificate;
|
|
31
|
+
this.redirect = redirect;
|
|
32
|
+
}
|
|
33
|
+
/** Redirects the module and opens the pool. Throws `OwnershipRedirectError` on a stale certificate. */
|
|
34
|
+
static async open(bytes, certificate, options) {
|
|
35
|
+
if (certificate.wildStores)
|
|
36
|
+
throw new OwnershipSlicesError('wild-store', `${certificate.wildStores} store sites write an address no record owns`);
|
|
37
|
+
const redirect = redirectOwnership(bytes, certificate);
|
|
38
|
+
const pool = await SlicePool.open(redirect.module, {
|
|
39
|
+
...options,
|
|
40
|
+
ownership: redirect.plan
|
|
41
|
+
});
|
|
42
|
+
return new OwnershipSlices(pool, certificate, redirect);
|
|
43
|
+
}
|
|
44
|
+
get memory() {
|
|
45
|
+
return this.#pool.memory;
|
|
46
|
+
}
|
|
47
|
+
get size() {
|
|
48
|
+
return this.#pool.size;
|
|
49
|
+
}
|
|
50
|
+
/** First byte of the private regions; the memory below it is the program's. */
|
|
51
|
+
get privateBase() {
|
|
52
|
+
return this.#pool.privateBase;
|
|
53
|
+
}
|
|
54
|
+
/** Calls the certified entry for `[0, count)`. Refuses with `OwnershipSlicesError` on a layout overlap. */
|
|
55
|
+
async run(count, args, options) {
|
|
56
|
+
const { regions, ...rest } = options;
|
|
57
|
+
if (!guardRecords(this.#certificate, [...regions, ...options.writes]))
|
|
58
|
+
throw new OwnershipSlicesError('layout', 'a record region overlaps a certified window');
|
|
59
|
+
const table = args(0, count)[0];
|
|
60
|
+
if (this.#certificate.config &&
|
|
61
|
+
!checkConfig(this.#certificate, new Uint8Array(this.memory.buffer), {
|
|
62
|
+
at: Number(table),
|
|
63
|
+
count
|
|
64
|
+
}))
|
|
65
|
+
throw new OwnershipSlicesError('config', 'the config words differ from the certificate');
|
|
66
|
+
return this.#pool.run(this.#certificate.entry, count, args, rest);
|
|
67
|
+
}
|
|
68
|
+
close() {
|
|
69
|
+
return this.#pool.close();
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
export const ownershipSlices = OwnershipSlices.open;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { TransactionResult } from '
|
|
1
|
+
import type { TransactionResult } from '../execution/transaction.ts';
|
|
2
2
|
/** Lossless page encoding; omitted pages contain only zero bytes. */
|
|
3
3
|
export interface SnapshotPages {
|
|
4
4
|
memoryBytes: number;
|
|
@@ -24,10 +24,14 @@ export interface FrameIdentity {
|
|
|
24
24
|
sequence: number;
|
|
25
25
|
}
|
|
26
26
|
export declare function validateIdentity(value: FrameIdentity): void;
|
|
27
|
-
|
|
27
|
+
/** Version of the run encoding of a results frame, named in the request and the response. */
|
|
28
|
+
export declare const runsVersion = 1;
|
|
29
|
+
export declare function encodeResults(identity: FrameIdentity, results: TransactionResult[], maximum?: number, runs?: boolean): Uint8Array;
|
|
28
30
|
export declare function decodeResults(bytes: Uint8Array, identity: FrameIdentity, options: {
|
|
29
31
|
maximumFrameBytes: number;
|
|
30
32
|
memoryBytes: number;
|
|
31
33
|
maxBytes: number;
|
|
32
34
|
calls: number;
|
|
35
|
+
/** The request asked for run encoding. A reply in addresses still decodes; see `runsVersion`. */
|
|
36
|
+
runs?: boolean;
|
|
33
37
|
}): TransactionResult[];
|
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
import { checkRuns, runBytes, runsOfSorted, writeRunsOf } from "../execution/runs.js";
|
|
2
|
+
import { decodeValue, encodeValue } from "./index.js";
|
|
3
|
+
const magic = 0x314f4c46;
|
|
4
|
+
const encoder = new TextEncoder();
|
|
5
|
+
const decoder = new TextDecoder('utf-8', { fatal: true });
|
|
6
|
+
/** Encodes sparse arenas. A dense payload borrows the input until encodeFrame copies it. */
|
|
7
|
+
export function encodeSnapshot(bytes) {
|
|
8
|
+
if (bytes.length % 65536)
|
|
9
|
+
throw new RangeError('invalid snapshot page size');
|
|
10
|
+
const pages = [];
|
|
11
|
+
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
12
|
+
for (let offset = 0; offset < bytes.length; offset += 65536) {
|
|
13
|
+
for (let word = offset; word < offset + 65536; word += 4)
|
|
14
|
+
if (view.getUint32(word, true) !== 0) {
|
|
15
|
+
pages.push(offset / 65536);
|
|
16
|
+
break;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
if (pages.length > 4096 || pages.length * 65536 + pages.length * 8 + 64 >= bytes.length)
|
|
20
|
+
return { payload: bytes };
|
|
21
|
+
const payload = new Uint8Array(pages.length * 65536);
|
|
22
|
+
pages.forEach((page, index) => payload.set(bytes.subarray(page * 65536, (page + 1) * 65536), index * 65536));
|
|
23
|
+
return { snapshot: { memoryBytes: bytes.length, pages }, payload };
|
|
24
|
+
}
|
|
25
|
+
/** Checks sparse metadata before allocation or writes; returns the complete logical byte length. */
|
|
26
|
+
export function snapshotLength(snapshot, payload) {
|
|
27
|
+
if (snapshot === undefined)
|
|
28
|
+
return payload.length;
|
|
29
|
+
if (!Number.isSafeInteger(snapshot?.memoryBytes) ||
|
|
30
|
+
snapshot.memoryBytes < 0 ||
|
|
31
|
+
snapshot.memoryBytes % 65536 ||
|
|
32
|
+
!Array.isArray(snapshot.pages) ||
|
|
33
|
+
snapshot.pages.length * 65536 !== payload.length)
|
|
34
|
+
throw new TypeError('invalid sparse snapshot');
|
|
35
|
+
let previous = -1;
|
|
36
|
+
for (const page of snapshot.pages) {
|
|
37
|
+
if (!Number.isSafeInteger(page) || page <= previous || page * 65536 >= snapshot.memoryBytes)
|
|
38
|
+
throw new TypeError('invalid sparse snapshot page');
|
|
39
|
+
previous = page;
|
|
40
|
+
}
|
|
41
|
+
return snapshot.memoryBytes;
|
|
42
|
+
}
|
|
43
|
+
/** Restores a complete snapshot, clearing pages omitted by the sparse representation. */
|
|
44
|
+
export function restoreSnapshot(target, payload, snapshot) {
|
|
45
|
+
if (snapshotLength(snapshot, payload) !== target.length)
|
|
46
|
+
throw new RangeError('snapshot size differs');
|
|
47
|
+
if (!snapshot) {
|
|
48
|
+
target.set(payload);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
target.fill(0);
|
|
52
|
+
snapshot.pages.forEach((page, index) => target.set(payload.subarray(index * 65536, (index + 1) * 65536), page * 65536));
|
|
53
|
+
}
|
|
54
|
+
export function encodeFrame(header, payload = new Uint8Array(), maximum = 0x100100000) {
|
|
55
|
+
const metadata = encoder.encode(JSON.stringify(encodeValue(header)));
|
|
56
|
+
if (metadata.length > 65536)
|
|
57
|
+
throw new RangeError('frame header exceeds limit');
|
|
58
|
+
const length = 12 + metadata.length + payload.length;
|
|
59
|
+
if (payload.length > 0xffffffff || length > maximum)
|
|
60
|
+
throw new RangeError(`frame of ${length} bytes exceeds the limit of ${maximum} bytes`);
|
|
61
|
+
const bytes = new Uint8Array(length);
|
|
62
|
+
const view = new DataView(bytes.buffer);
|
|
63
|
+
view.setUint32(0, magic, true);
|
|
64
|
+
view.setUint32(4, metadata.length, true);
|
|
65
|
+
view.setUint32(8, payload.length, true);
|
|
66
|
+
bytes.set(metadata, 12);
|
|
67
|
+
bytes.set(payload, 12 + metadata.length);
|
|
68
|
+
return bytes;
|
|
69
|
+
}
|
|
70
|
+
export function decodeFrame(bytes, maximum) {
|
|
71
|
+
if (bytes.length < 12 || bytes.length > maximum)
|
|
72
|
+
throw new RangeError('invalid frame size');
|
|
73
|
+
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
74
|
+
const header = view.getUint32(4, true), payload = view.getUint32(8, true);
|
|
75
|
+
if (view.getUint32(0, true) !== magic ||
|
|
76
|
+
header > 65536 ||
|
|
77
|
+
12 + header + payload !== bytes.length)
|
|
78
|
+
throw new TypeError('invalid frame layout');
|
|
79
|
+
return {
|
|
80
|
+
header: decodeValue(JSON.parse(decoder.decode(bytes.subarray(12, 12 + header)))),
|
|
81
|
+
payload: bytes.subarray(12 + header)
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
export function validateIdentity(value) {
|
|
85
|
+
if (typeof value?.session !== 'string' ||
|
|
86
|
+
value.session.length < 1 ||
|
|
87
|
+
value.session.length > 128 ||
|
|
88
|
+
!Number.isSafeInteger(value.epoch) ||
|
|
89
|
+
value.epoch < 0 ||
|
|
90
|
+
!Number.isSafeInteger(value.sequence) ||
|
|
91
|
+
value.sequence < 0)
|
|
92
|
+
throw new TypeError('invalid frame identity');
|
|
93
|
+
}
|
|
94
|
+
/** Version of the run encoding of a results frame, named in the request and the response. */
|
|
95
|
+
export const runsVersion = 1;
|
|
96
|
+
/**
|
|
97
|
+
* Run encoding of a results frame, `runs` of the request: per result the read runs and the write
|
|
98
|
+
* runs as start, length pairs, then the written bytes back to back, then the escapes. Results
|
|
99
|
+
* that carry addresses are converted, so a lane may mix paths.
|
|
100
|
+
*/
|
|
101
|
+
function encodeRunResults(identity, results, maximum) {
|
|
102
|
+
const parts = results.map((result) => {
|
|
103
|
+
const readRuns = result.readRuns ?? runsOfSorted(Uint32Array.from(result.reads).sort());
|
|
104
|
+
const packed = result.writeRuns
|
|
105
|
+
? { runs: result.writeRuns, data: result.writeData ?? new Uint8Array() }
|
|
106
|
+
: writeRunsOf(result.writes);
|
|
107
|
+
if (packed.data.length !== runBytes(packed.runs))
|
|
108
|
+
throw new RangeError('write runs and write data differ');
|
|
109
|
+
return { result, readRuns, packed };
|
|
110
|
+
});
|
|
111
|
+
const length = parts.reduce((sum, { result, readRuns, packed }) => sum +
|
|
112
|
+
readRuns.length * 4 +
|
|
113
|
+
packed.runs.length * 4 +
|
|
114
|
+
packed.data.length +
|
|
115
|
+
(result.escapes?.length ?? 0) * 8, 0);
|
|
116
|
+
if (length > 0xffffffff || length + 12 > maximum)
|
|
117
|
+
throw new RangeError('result payload exceeds limit');
|
|
118
|
+
const payload = new Uint8Array(length), view = new DataView(payload.buffer);
|
|
119
|
+
let offset = 0;
|
|
120
|
+
const put = (runs) => {
|
|
121
|
+
for (let i = 0; i < runs.length; i++, offset += 4)
|
|
122
|
+
view.setUint32(offset, runs[i], true);
|
|
123
|
+
};
|
|
124
|
+
const descriptors = parts.map(({ result, readRuns, packed }) => {
|
|
125
|
+
const { reads, writes, readRuns: _r, writeRuns: _w, writeData: _d, escapes, ...rest } = result;
|
|
126
|
+
put(readRuns);
|
|
127
|
+
put(packed.runs);
|
|
128
|
+
payload.set(packed.data, offset);
|
|
129
|
+
offset += packed.data.length;
|
|
130
|
+
for (const [start, size] of escapes ?? []) {
|
|
131
|
+
view.setUint32(offset, start, true);
|
|
132
|
+
view.setUint32(offset + 4, size, true);
|
|
133
|
+
offset += 8;
|
|
134
|
+
}
|
|
135
|
+
return {
|
|
136
|
+
...rest,
|
|
137
|
+
reads: readRuns.length / 2,
|
|
138
|
+
writes: packed.runs.length / 2,
|
|
139
|
+
readBytes: runBytes(readRuns),
|
|
140
|
+
writeBytes: packed.data.length,
|
|
141
|
+
...(escapes?.length ? { escapes: escapes.length } : {})
|
|
142
|
+
};
|
|
143
|
+
});
|
|
144
|
+
return encodeFrame({
|
|
145
|
+
session: identity.session,
|
|
146
|
+
epoch: identity.epoch,
|
|
147
|
+
sequence: identity.sequence,
|
|
148
|
+
runs: runsVersion,
|
|
149
|
+
results: descriptors
|
|
150
|
+
}, payload, maximum);
|
|
151
|
+
}
|
|
152
|
+
export function encodeResults(identity, results, maximum = 0x100100000, runs = false) {
|
|
153
|
+
if (runs)
|
|
154
|
+
return encodeRunResults(identity, results, maximum);
|
|
155
|
+
const length = results.reduce((sum, result) => sum +
|
|
156
|
+
result.reads.length * 4 +
|
|
157
|
+
result.writes.length * 8 +
|
|
158
|
+
(result.escapes?.length ?? 0) * 8, 0);
|
|
159
|
+
if (length > 0xffffffff || length + 12 > maximum)
|
|
160
|
+
throw new RangeError('result payload exceeds limit');
|
|
161
|
+
const payload = new Uint8Array(length), view = new DataView(payload.buffer);
|
|
162
|
+
let offset = 0;
|
|
163
|
+
const descriptors = results.map(({ reads, writes, escapes, ...result }) => {
|
|
164
|
+
for (const address of reads) {
|
|
165
|
+
view.setUint32(offset, address, true);
|
|
166
|
+
offset += 4;
|
|
167
|
+
}
|
|
168
|
+
for (const [address, value] of writes) {
|
|
169
|
+
view.setUint32(offset, address, true);
|
|
170
|
+
view.setUint32(offset + 4, value, true);
|
|
171
|
+
offset += 8;
|
|
172
|
+
}
|
|
173
|
+
for (const [start, size] of escapes ?? []) {
|
|
174
|
+
view.setUint32(offset, start, true);
|
|
175
|
+
view.setUint32(offset + 4, size, true);
|
|
176
|
+
offset += 8;
|
|
177
|
+
}
|
|
178
|
+
return {
|
|
179
|
+
...result,
|
|
180
|
+
reads: reads.length,
|
|
181
|
+
writes: writes.length,
|
|
182
|
+
...(escapes?.length ? { escapes: escapes.length } : {})
|
|
183
|
+
};
|
|
184
|
+
});
|
|
185
|
+
return encodeFrame({
|
|
186
|
+
session: identity.session,
|
|
187
|
+
epoch: identity.epoch,
|
|
188
|
+
sequence: identity.sequence,
|
|
189
|
+
results: descriptors
|
|
190
|
+
}, payload, maximum);
|
|
191
|
+
}
|
|
192
|
+
export function decodeResults(bytes, identity, options) {
|
|
193
|
+
const { header, payload } = decodeFrame(bytes, options.maximumFrameBytes);
|
|
194
|
+
validateIdentity(header);
|
|
195
|
+
if (header.session !== identity.session ||
|
|
196
|
+
header.epoch !== identity.epoch ||
|
|
197
|
+
header.sequence !== identity.sequence)
|
|
198
|
+
throw new TypeError('stale lane response');
|
|
199
|
+
if (!Array.isArray(header.results) || header.results.length !== options.calls)
|
|
200
|
+
throw new TypeError('invalid lane result count');
|
|
201
|
+
if (header.runs !== undefined) {
|
|
202
|
+
if (header.runs !== runsVersion)
|
|
203
|
+
throw new TypeError('unsupported results encoding');
|
|
204
|
+
if (!options.runs)
|
|
205
|
+
throw new TypeError('unrequested run encoding');
|
|
206
|
+
return decodeRunResults(header.results, payload, options);
|
|
207
|
+
}
|
|
208
|
+
let offset = 0, retained = 0;
|
|
209
|
+
const view = new DataView(payload.buffer, payload.byteOffset, payload.byteLength);
|
|
210
|
+
const results = header.results.map(({ reads, writes, escapes = 0, ...result }) => {
|
|
211
|
+
if (![reads, writes, escapes].every((n) => Number.isSafeInteger(n) && n >= 0) ||
|
|
212
|
+
escapes > reads)
|
|
213
|
+
throw new TypeError('invalid lane tracking counts');
|
|
214
|
+
retained += reads + writes;
|
|
215
|
+
if (retained > options.maxBytes + 8 ||
|
|
216
|
+
offset + reads * 4 + writes * 8 + escapes * 8 > payload.length)
|
|
217
|
+
throw new RangeError('lane tracking exceeds limit');
|
|
218
|
+
if ((result.trap !== undefined && typeof result.trap !== 'string') ||
|
|
219
|
+
(result.errorKind !== undefined && typeof result.errorKind !== 'string') ||
|
|
220
|
+
(result.exhausted !== undefined && typeof result.exhausted !== 'boolean') ||
|
|
221
|
+
(result.inconclusive !== undefined && typeof result.inconclusive !== 'boolean'))
|
|
222
|
+
throw new TypeError('invalid lane trap');
|
|
223
|
+
const readSet = [], writeSet = [];
|
|
224
|
+
for (let i = 0; i < reads; i++) {
|
|
225
|
+
const address = view.getUint32(offset, true);
|
|
226
|
+
offset += 4;
|
|
227
|
+
if (address >= options.memoryBytes)
|
|
228
|
+
throw new RangeError('lane read outside arena');
|
|
229
|
+
readSet.push(address);
|
|
230
|
+
}
|
|
231
|
+
for (let i = 0; i < writes; i++) {
|
|
232
|
+
const address = view.getUint32(offset, true), value = view.getUint32(offset + 4, true);
|
|
233
|
+
offset += 8;
|
|
234
|
+
if (address >= options.memoryBytes || value > 255)
|
|
235
|
+
throw new RangeError('lane write outside arena');
|
|
236
|
+
writeSet.push([address, value]);
|
|
237
|
+
}
|
|
238
|
+
const escapeSet = [];
|
|
239
|
+
for (let i = 0; i < escapes; i++) {
|
|
240
|
+
const start = view.getUint32(offset, true), size = view.getUint32(offset + 4, true);
|
|
241
|
+
offset += 8;
|
|
242
|
+
if (size < 1 || start + size > options.memoryBytes)
|
|
243
|
+
throw new RangeError('lane escape outside arena');
|
|
244
|
+
escapeSet.push([start, size]);
|
|
245
|
+
}
|
|
246
|
+
return {
|
|
247
|
+
...result,
|
|
248
|
+
reads: readSet,
|
|
249
|
+
writes: writeSet,
|
|
250
|
+
...(escapes ? { escapes: escapeSet } : {})
|
|
251
|
+
};
|
|
252
|
+
});
|
|
253
|
+
if (offset !== payload.length)
|
|
254
|
+
throw new TypeError('unconsumed lane payload');
|
|
255
|
+
return results;
|
|
256
|
+
}
|
|
257
|
+
function decodeRunResults(descriptors, payload, options) {
|
|
258
|
+
let offset = 0, retained = 0;
|
|
259
|
+
const view = new DataView(payload.buffer, payload.byteOffset, payload.byteLength);
|
|
260
|
+
const take = (count) => {
|
|
261
|
+
const out = new Uint32Array(count * 2);
|
|
262
|
+
for (let i = 0; i < out.length; i++, offset += 4)
|
|
263
|
+
out[i] = view.getUint32(offset, true);
|
|
264
|
+
return out;
|
|
265
|
+
};
|
|
266
|
+
const results = descriptors.map(({ reads, writes, readBytes, writeBytes, escapes = 0, ...result }) => {
|
|
267
|
+
if (![reads, writes, readBytes, writeBytes, escapes].every((n) => Number.isSafeInteger(n) && n >= 0))
|
|
268
|
+
throw new TypeError('invalid lane tracking counts');
|
|
269
|
+
retained += readBytes + writeBytes;
|
|
270
|
+
if (retained > options.maxBytes + 8 ||
|
|
271
|
+
offset + reads * 8 + writes * 8 + writeBytes + escapes * 8 > payload.length)
|
|
272
|
+
throw new RangeError('lane tracking exceeds limit');
|
|
273
|
+
if ((result.trap !== undefined && typeof result.trap !== 'string') ||
|
|
274
|
+
(result.errorKind !== undefined && typeof result.errorKind !== 'string') ||
|
|
275
|
+
(result.exhausted !== undefined && typeof result.exhausted !== 'boolean') ||
|
|
276
|
+
(result.inconclusive !== undefined && typeof result.inconclusive !== 'boolean'))
|
|
277
|
+
throw new TypeError('invalid lane trap');
|
|
278
|
+
const readRuns = take(reads), writeRuns = take(writes);
|
|
279
|
+
checkRuns(readRuns, options.memoryBytes, 'read');
|
|
280
|
+
checkRuns(writeRuns, options.memoryBytes, 'write');
|
|
281
|
+
if (runBytes(readRuns) !== readBytes || runBytes(writeRuns) !== writeBytes)
|
|
282
|
+
throw new TypeError('invalid lane tracking counts');
|
|
283
|
+
const writeData = payload.slice(offset, offset + writeBytes);
|
|
284
|
+
offset += writeBytes;
|
|
285
|
+
const escapeSet = [];
|
|
286
|
+
for (let i = 0; i < escapes; i++) {
|
|
287
|
+
const start = view.getUint32(offset, true), size = view.getUint32(offset + 4, true);
|
|
288
|
+
offset += 8;
|
|
289
|
+
if (size < 1 || start + size > options.memoryBytes)
|
|
290
|
+
throw new RangeError('lane escape outside arena');
|
|
291
|
+
escapeSet.push([start, size]);
|
|
292
|
+
}
|
|
293
|
+
return {
|
|
294
|
+
...result,
|
|
295
|
+
reads: [],
|
|
296
|
+
writes: [],
|
|
297
|
+
readRuns,
|
|
298
|
+
writeRuns,
|
|
299
|
+
writeData,
|
|
300
|
+
...(escapes ? { escapes: escapeSet } : {})
|
|
301
|
+
};
|
|
302
|
+
});
|
|
303
|
+
if (offset !== payload.length)
|
|
304
|
+
throw new TypeError('unconsumed lane payload');
|
|
305
|
+
return results;
|
|
306
|
+
}
|
|
@@ -64,11 +64,16 @@ export declare class RemoteFolio {
|
|
|
64
64
|
capabilities: unknown;
|
|
65
65
|
};
|
|
66
66
|
private constructor();
|
|
67
|
-
/**
|
|
67
|
+
/**
|
|
68
|
+
* Opens a session on a registered artifact. `workers` asks for a group width within host limits.
|
|
69
|
+
*/
|
|
68
70
|
static open(url: string | URL, artifact: string, options?: RemoteOptions & {
|
|
69
71
|
workers?: number;
|
|
70
72
|
}): Promise<RemoteFolio>;
|
|
71
|
-
/**
|
|
73
|
+
/**
|
|
74
|
+
* Resends the exact uncertain request. The host returns its cached result without repeating
|
|
75
|
+
* effects.
|
|
76
|
+
*/
|
|
72
77
|
retryPending(): Promise<any>;
|
|
73
78
|
/** Runs one allowlisted export in order on the host. */
|
|
74
79
|
run(entry: string, args?: readonly unknown[], options?: {
|