@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
|
@@ -158,7 +158,9 @@ export class RemoteFolio {
|
|
|
158
158
|
this.#headers.set('content-type', 'application/json');
|
|
159
159
|
this.#maximum = options.maximumResponseBytes ?? 2 * 1024 * 1024;
|
|
160
160
|
}
|
|
161
|
-
/**
|
|
161
|
+
/**
|
|
162
|
+
* Opens a session on a registered artifact. `workers` asks for a group width within host limits.
|
|
163
|
+
*/
|
|
162
164
|
static async open(url, artifact, options = {}) {
|
|
163
165
|
const headers = new Headers(options.headers);
|
|
164
166
|
headers.set('content-type', 'application/json');
|
|
@@ -218,7 +220,10 @@ export class RemoteFolio {
|
|
|
218
220
|
this.#busy = false;
|
|
219
221
|
}
|
|
220
222
|
}
|
|
221
|
-
/**
|
|
223
|
+
/**
|
|
224
|
+
* Resends the exact uncertain request. The host returns its cached result without repeating
|
|
225
|
+
* effects.
|
|
226
|
+
*/
|
|
222
227
|
async retryPending() {
|
|
223
228
|
if (this.#busy || !this.#pending)
|
|
224
229
|
throw new Error('no uncertain request is available');
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import { type CertificateRefusal, type StreamCertificate } from '../folds/certify.ts';
|
|
2
|
+
import { type OwnershipCertificate, type OwnershipOptions, type OwnershipRefusal } from '../ownership/index.ts';
|
|
3
|
+
/** @since 1.1.0 */
|
|
4
|
+
export declare const ROUTER_VERSION = "folio-router-2";
|
|
5
|
+
/** `summary` is the certified stream fold, `window` the certified private window on slices. */
|
|
6
|
+
export type Route = 'summary' | 'window' | 'explicit' | 'tracked' | 'serial';
|
|
7
|
+
/** One value per ablation arm. `serial` never leaves the owner thread. */
|
|
8
|
+
export type RouterMode = 'serial' | 'w1' | 'w2' | 'independent' | 'shared' | 'router';
|
|
9
|
+
/** Every decision names one of these. The first four are routes taken, the rest are refusals. */
|
|
10
|
+
export declare const ROUTER_REASONS: readonly ["certified-summary", "certified-window", "explicit-runner", "tracked-eligible", "mode-serial", "single-worker", "below-floor", "dispatch-lost", "not-a-stream", "stream-refused", "no-route-in-mode", "no-certificate", "allocator-state", "shared-state", "unclassified-dependency", "wild-store", "layout-overlap", "assumption-unasserted", "tracked-ineligible", "memory-not-imported"];
|
|
11
|
+
export type RouterReason = (typeof ROUTER_REASONS)[number];
|
|
12
|
+
/** A single call over `len` bytes of one stream: `entry(state, ptr, len)`. */
|
|
13
|
+
export interface StreamCall {
|
|
14
|
+
kind: 'stream';
|
|
15
|
+
entry: string;
|
|
16
|
+
ptr: number;
|
|
17
|
+
len: number;
|
|
18
|
+
}
|
|
19
|
+
/** A loop of independent calls: `entry(...args(0, count))` equals the serial program. */
|
|
20
|
+
export interface RecordsCall {
|
|
21
|
+
kind: 'records';
|
|
22
|
+
entry: string;
|
|
23
|
+
count: number;
|
|
24
|
+
args: (from: number, to: number) => (number | bigint)[];
|
|
25
|
+
/** Every region the records touch, for the window guard. */
|
|
26
|
+
regions: [number, number][];
|
|
27
|
+
/**
|
|
28
|
+
* The regions the records write outside any window. The list must name every range the records
|
|
29
|
+
* write: a range left out keeps the writes of the records after a trap, and the serial replay does
|
|
30
|
+
* not undo them.
|
|
31
|
+
*/
|
|
32
|
+
writes: [number, number][];
|
|
33
|
+
}
|
|
34
|
+
export type RouterCall = StreamCall | RecordsCall;
|
|
35
|
+
/** What the caller knows about the program that no static test can establish. */
|
|
36
|
+
export interface RouterAssumptions {
|
|
37
|
+
/** Every host import returns the same value for the same arguments. */
|
|
38
|
+
importsDeterministic?: boolean;
|
|
39
|
+
/** Nothing reads the stack zone or the arena past the program memory after the call. */
|
|
40
|
+
residueUnobserved?: boolean;
|
|
41
|
+
}
|
|
42
|
+
export interface RouterConstants {
|
|
43
|
+
/** Serial time of the remaining records below which the tracked and explicit routes stay serial. */
|
|
44
|
+
trackedFloorMs: number;
|
|
45
|
+
/** The same for the window route. */
|
|
46
|
+
windowFloorMs: number;
|
|
47
|
+
/** Stream length below which the summary route stays serial. */
|
|
48
|
+
summaryMinBytes: number;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* The tracked floor is the admission constants of the iteration route (fitted on the blake3 sweep,
|
|
52
|
+
* `results/corpus/iteration-admission`). The window floor is the smallest serial time at which all
|
|
53
|
+
* five paired runs of `aes-cbc-decrypt-shared` at 8 workers beat serial by 1.25 (4 records, 0.82
|
|
54
|
+
* ms; 3 records at 0.69 ms did not). The summary length is the smallest size at which every paired
|
|
55
|
+
* run of two hand stream modules did (1 MiB; 256 KiB did not). One driver and two hand modules,
|
|
56
|
+
* Mac, loaded.
|
|
57
|
+
*/
|
|
58
|
+
export declare const routerConstants: RouterConstants;
|
|
59
|
+
/** The per-record serial estimate after a tracked call: the lower of it and that call's plain first iteration. @internal */
|
|
60
|
+
export declare const lowerEstimate: (current: number, plainMs: number | undefined) => number;
|
|
61
|
+
export interface RouterOptions {
|
|
62
|
+
mode: RouterMode;
|
|
63
|
+
/** Initial pages of the memory the router allocates. */
|
|
64
|
+
pages: number;
|
|
65
|
+
/** Declared maximum of the shared memory a records call runs on; the module's own limit if lower. */
|
|
66
|
+
maxPages?: number;
|
|
67
|
+
workers?: number;
|
|
68
|
+
cache?: CertificateCache;
|
|
69
|
+
/** A module specifier or URL whose default export returns the imports besides the memory. */
|
|
70
|
+
imports?: string | URL;
|
|
71
|
+
assume?: RouterAssumptions;
|
|
72
|
+
/** Runs the records on a route the caller built; chosen after the window route in `router` mode. */
|
|
73
|
+
explicit?: (call: RecordsCall) => Promise<void>;
|
|
74
|
+
/** Overrides for `routerConstants`; a sweep sets them to 0 to force a dispatch. */
|
|
75
|
+
floors?: Partial<RouterConstants>;
|
|
76
|
+
/** Certifier options that change a certificate, and so the cache key. */
|
|
77
|
+
ownership?: OwnershipOptions;
|
|
78
|
+
}
|
|
79
|
+
export interface Consideration {
|
|
80
|
+
route: Route;
|
|
81
|
+
verdict: 'taken' | 'refused' | 'skipped';
|
|
82
|
+
reason: RouterReason;
|
|
83
|
+
detail: string;
|
|
84
|
+
}
|
|
85
|
+
export interface RouterDecision {
|
|
86
|
+
route: Route;
|
|
87
|
+
reason: RouterReason;
|
|
88
|
+
detail: string;
|
|
89
|
+
mode: RouterMode;
|
|
90
|
+
/** Wall time of the analyses this decision ran. Zero when every answer came from the cache. */
|
|
91
|
+
certifyMs: number;
|
|
92
|
+
cacheHit: boolean;
|
|
93
|
+
analyses: ('shape' | 'stream' | 'ownership')[];
|
|
94
|
+
considered: Consideration[];
|
|
95
|
+
}
|
|
96
|
+
export interface RouterRun {
|
|
97
|
+
/** The route that executed this call, which differs from the decision when the floor refuses. */
|
|
98
|
+
route: Route;
|
|
99
|
+
reason: RouterReason;
|
|
100
|
+
wallMs: number;
|
|
101
|
+
/** Time of the serial probe of record 0, on the call that measured it. */
|
|
102
|
+
probeMs?: number;
|
|
103
|
+
/** The stream's end state, for a stream call. */
|
|
104
|
+
state?: bigint;
|
|
105
|
+
/** The Folio report of a tracked call. */
|
|
106
|
+
tracked?: {
|
|
107
|
+
mode: string;
|
|
108
|
+
reason?: string;
|
|
109
|
+
iteration?: unknown;
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
type Slot = 'shape' | 'stream' | 'ownership';
|
|
113
|
+
interface Entry {
|
|
114
|
+
shape?: ModuleShape;
|
|
115
|
+
stream?: StreamCertificate | CertificateRefusal;
|
|
116
|
+
ownership?: OwnershipCertificate | OwnershipRefusal;
|
|
117
|
+
/** Wall time the analysis took on the call that filled the slot. */
|
|
118
|
+
ms: Partial<Record<Slot, number>>;
|
|
119
|
+
}
|
|
120
|
+
/** The runtime a certificate was made on: a different engine or checker build is a different key. */
|
|
121
|
+
export declare const defaultBackend: () => string;
|
|
122
|
+
/**
|
|
123
|
+
* Certificates and refusals keyed by the SHA-256 of the module and a configuration key (backend,
|
|
124
|
+
* checker and router versions, and the options that change a certificate). A refusal is stored
|
|
125
|
+
* like a certificate, so a refused module costs a map lookup after the first call.
|
|
126
|
+
* @since 1.1.0
|
|
127
|
+
*/
|
|
128
|
+
export declare class CertificateCache {
|
|
129
|
+
#private;
|
|
130
|
+
readonly backend: string;
|
|
131
|
+
hits: number;
|
|
132
|
+
misses: number;
|
|
133
|
+
constructor(options?: {
|
|
134
|
+
backend?: string;
|
|
135
|
+
});
|
|
136
|
+
get size(): number;
|
|
137
|
+
key(bytes: Uint8Array, config: unknown): string;
|
|
138
|
+
/** Returns the stored answer of `slot`, or makes, times and stores it. `ms` is 0 on a hit. */
|
|
139
|
+
get<S extends Slot>(bytes: Uint8Array, config: unknown, slot: S, make: () => NonNullable<Entry[S]>): {
|
|
140
|
+
value: NonNullable<Entry[S]>;
|
|
141
|
+
ms: number;
|
|
142
|
+
hit: boolean;
|
|
143
|
+
};
|
|
144
|
+
/** Wall time the analysis took when it filled the slot, for an offline certification report. */
|
|
145
|
+
filledMs(bytes: Uint8Array, config: unknown, slot: Slot): number | undefined;
|
|
146
|
+
serialize(): string;
|
|
147
|
+
/** Loads what `serialize` wrote. Entries made under another backend never match a key. */
|
|
148
|
+
load(text: string): void;
|
|
149
|
+
}
|
|
150
|
+
export interface ModuleShape {
|
|
151
|
+
valid: boolean;
|
|
152
|
+
entryFound: boolean;
|
|
153
|
+
entryParams: string[];
|
|
154
|
+
entryResults: number;
|
|
155
|
+
functionImports: number;
|
|
156
|
+
memoryImported: boolean;
|
|
157
|
+
}
|
|
158
|
+
/** One decode of the module: what both certificate builders need to know before they start. */
|
|
159
|
+
export declare function analyzeModule(bytes: Uint8Array, entry: string): ModuleShape;
|
|
160
|
+
/** The prefix domain is tried after a plain refusal unless the caller chose an option the checker does not combine with it. @internal */
|
|
161
|
+
export declare function effectiveOwnership(given: OwnershipOptions | undefined): {
|
|
162
|
+
options: OwnershipOptions | null;
|
|
163
|
+
prefixFallback: boolean;
|
|
164
|
+
};
|
|
165
|
+
/** Everything `decide` needs and makes: the choice, the certificate the route runs on, and the trace. */
|
|
166
|
+
interface Plan {
|
|
167
|
+
decision: RouterDecision;
|
|
168
|
+
stream?: StreamCertificate;
|
|
169
|
+
window?: OwnershipCertificate;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Chooses the route from the module bytes and the call, without running the call. The order is the
|
|
173
|
+
* certified summary, then the certified window, then the explicit route when the caller supplied
|
|
174
|
+
* one, then the tracked route when its assumptions hold, else serial. Both certifiers are asked
|
|
175
|
+
* only for the call shape they can serve, and a refusal is cached like a certificate.
|
|
176
|
+
* @since 1.1.0
|
|
177
|
+
*/
|
|
178
|
+
export declare function decide(bytes: Uint8Array, call: RouterCall, options: RouterOptions): Plan;
|
|
179
|
+
/**
|
|
180
|
+
* The open route behind one call description: it holds the memory, the pools and the sticky
|
|
181
|
+
* admission decision. Write the inputs into `memory` after `open`, then `run`.
|
|
182
|
+
* @since 1.1.0
|
|
183
|
+
*/
|
|
184
|
+
export declare class Router {
|
|
185
|
+
#private;
|
|
186
|
+
readonly decision: RouterDecision;
|
|
187
|
+
/** Wall time of `open` after the decision: memory, instances and pools. */
|
|
188
|
+
readonly setupMs: number;
|
|
189
|
+
private constructor();
|
|
190
|
+
get memory(): WebAssembly.Memory;
|
|
191
|
+
/** The route the next call takes: the decision's, or serial once a floor test refused it. */
|
|
192
|
+
get route(): Route;
|
|
193
|
+
static open(bytes: Uint8Array, call: RouterCall, options: RouterOptions): Promise<Router>;
|
|
194
|
+
/** Calls another export of the module on the owner thread, for setup that is not part of the loop. */
|
|
195
|
+
exec(name: string, args?: (number | bigint)[]): unknown;
|
|
196
|
+
/** Runs the call. A records call probes record 0 once and then follows the floor test. */
|
|
197
|
+
run(options?: {
|
|
198
|
+
initial?: bigint;
|
|
199
|
+
}): Promise<RouterRun>;
|
|
200
|
+
close(): Promise<void>;
|
|
201
|
+
}
|
|
202
|
+
export declare const openRouter: typeof Router.open;
|
|
203
|
+
export {};
|