@waffle-os/runtime 0.0.145 → 0.0.146
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 +32 -0
- package/browser/command-input.ts +86 -0
- package/browser/command-owner.ts +5 -0
- package/browser/display/guest.ts +2 -18
- package/browser/display/surface-info.ts +19 -0
- package/browser/operations/cells.ts +90 -0
- package/browser/operations/guest.ts +94 -0
- package/browser/operations/owner.ts +201 -0
- package/browser/operations/protocol.ts +16 -0
- package/browser/operations/types.ts +41 -0
- package/browser/operations/writer.ts +106 -0
- package/browser/preview1-worker.ts +8 -1
- package/browser/process-broker.ts +372 -22
- package/browser/process-start.ts +5 -2
- package/browser/run-command.ts +388 -0
- package/browser/shared-fs.ts +20 -3
- package/browser/worker-memory.ts +6 -0
- package/browser/worker.ts +121 -27
- package/dist/browser/command-input.js +82 -0
- package/dist/browser/command-owner.js +2 -0
- package/dist/browser/display/guest.js +2 -18
- package/dist/browser/display/surface-info.js +18 -0
- package/dist/browser/operations/cells.js +80 -0
- package/dist/browser/operations/guest.js +67 -0
- package/dist/browser/operations/owner.js +175 -0
- package/dist/browser/operations/protocol.js +0 -0
- package/dist/browser/operations/types.js +0 -0
- package/dist/browser/operations/writer.js +98 -0
- package/dist/browser/preview1-worker.js +4 -0
- package/dist/browser/process-broker.js +317 -18
- package/dist/browser/process-start.js +3 -0
- package/dist/browser/run-command.js +377 -0
- package/dist/browser/shared-fs.js +8 -3
- package/dist/browser/worker-memory.js +10 -1
- package/dist/browser/worker.js +83 -28
- package/dist/fs/client.js +81 -18
- package/dist/fs/resolve-observation.js +11 -0
- package/dist/fs/service.js +51 -4
- package/dist/proc/command-transfer.js +72 -0
- package/dist/proc/directory.js +9 -1
- package/dist/proc/intrinsics/host.js +4 -1
- package/dist/proc/intrinsics.js +1 -0
- package/dist/proc/pipes.js +37 -4
- package/dist/proc/registry.js +25 -14
- package/dist/proc/start-command.js +101 -0
- package/dist/proc/supervisor.js +34 -10
- package/dist/proc/worker-broker.js +86 -31
- package/dist/proc/worker-client.js +67 -31
- package/dist/programs/collection.js +2 -0
- package/dist/runtime.js +14 -1
- package/dist/tooling/program/program-transformer.json +1 -1
- package/fs/client.ts +113 -17
- package/fs/resolve-observation.ts +25 -0
- package/fs/service.ts +63 -4
- package/index.ts +5 -0
- package/package.json +9 -1
- package/proc/command-transfer.ts +96 -0
- package/proc/directory.ts +10 -1
- package/proc/intrinsics/host.ts +5 -1
- package/proc/intrinsics.ts +1 -0
- package/proc/pipes.ts +39 -6
- package/proc/registry.ts +52 -17
- package/proc/start-command.ts +157 -0
- package/proc/supervisor.ts +34 -9
- package/proc/worker-broker.ts +100 -38
- package/proc/worker-client.ts +84 -31
- package/programs/collection.ts +4 -0
- package/runtime.ts +44 -3
- package/scripts/test-browser.ts +49 -29
- package/tests/browser-controls-discovery.test.ts +2 -10
- package/tests/browser-matrix.test.ts +105 -59
- package/tests/browser-navigation.test.ts +1 -1
- package/tests/browser-runner-lifecycle.ts +23 -13
- package/tests/command-input.test.ts +40 -0
- package/tests/command-scope.test.ts +422 -0
- package/tests/filesystem-client-intrinsics.test.ts +2 -0
- package/tests/filesystem-refcount.test.ts +2 -0
- package/tests/filesystem-resolve-observation.test.ts +185 -0
- package/tests/fixtures/command-bounded-admission.ts +31 -0
- package/tests/fixtures/command-disposal.ts +47 -0
- package/tests/fixtures/command-guests.ts +123 -0
- package/tests/fixtures/operation-fs-worker.ts +114 -0
- package/tests/fixtures/operation-observer-worker.ts +41 -0
- package/tests/fixtures/operation-page.ts +522 -0
- package/tests/fixtures/process-start-worker.ts +32 -0
- package/tests/link-browser-runner.ts +95 -22
- package/tests/node-exports.test.ts +29 -0
- package/tests/operation-diagnostics-browser.ts +192 -0
- package/tests/operation-diagnostics.test.ts +291 -0
- package/tests/page-runner/browser-controls-process-fixture.ts +24 -0
- package/tests/page-runner/browser-controls-runner.test.ts +20 -0
- package/tests/page-runner/browser-controls-runner.ts +1 -0
- package/tests/page-runner/browser-controls-suite.ts +20 -3
- package/tests/page-runner/control-run.ts +9 -1
- package/tests/page-runner/driver.ts +2 -0
- package/tests/page-runner/playwright-driver.ts +1 -1
- package/tests/page-runner/suite-host.ts +26 -1
- package/tests/page-runner/suite-startup.test.ts +39 -0
- package/tests/page-runner/threads-runtime-browser.test.ts +4 -6
- package/tests/page-runner/threads-runtime-suite.test.ts +14 -5
- package/tests/page-runner/worker-capability-controls.ts +174 -15
- package/tests/pipe-reader-reuse-races.test.ts +44 -0
- package/tests/process-start-browser-runner.ts +12 -4
- package/tests/process-start-browser.ts +66 -5
- package/tests/program-build-tools.test.ts +1 -1
- package/tests/runtime-facade.test.ts +5 -0
- package/tests/start-command.test.ts +109 -0
- package/tests/threads-guest-fixture.ts +1 -1
- package/tests/threads-guest-module.ts +6 -3
- package/tests/threads-guest.test.ts +25 -0
- package/tests/threads-runtime-browser-runner.ts +36 -13
- package/tests/threads-runtime-browser.ts +231 -92
- package/tests/threads-runtime-cases.ts +18 -1
- package/tests/threads-runtime-cleanup.ts +5 -1
- package/tests/threads-runtime-fd-browser.ts +247 -0
- package/tests/threads-runtime-fd-control.ts +3 -385
- package/tests/threads-runtime-fd-descriptors.test.ts +15 -13
- package/tests/threads-runtime-fd-module.ts +13 -2
- package/tests/threads-runtime-fd-service.ts +23 -2
- package/tests/threads-runtime-growth-worker.ts +61 -0
- package/tests/threads-runtime-host.ts +17 -4
- package/tests/threads-runtime-modules.ts +23 -5
- package/tests/threads-runtime-regression-controls.ts +386 -0
- package/tests/threads-runtime-regression-modules.ts +242 -0
- package/tests/threads-runtime-service-barrier.ts +8 -1
- package/tests/webkit-diagnostics.ts +125 -0
- package/tests/webkit-error-output.test.ts +118 -0
- package/tests/worker-memory-bootstrap.test.ts +19 -1
- package/tests/worker-memory-broker.test.ts +16 -8
- package/tooling/ci-paths.test.ts +329 -61
- package/tooling/private-authority.ts +14 -0
- package/tooling/program/program-transformer.json +1 -1
- package/tooling/tarball-smoke.ts +3 -1
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ACKNOWLEDGED,
|
|
3
|
+
elapsedFrom,
|
|
4
|
+
Field,
|
|
5
|
+
MAX_VALUE,
|
|
6
|
+
OPERATION_BYTES,
|
|
7
|
+
OPERATION_SLOTS,
|
|
8
|
+
OperationCells,
|
|
9
|
+
operationClock,
|
|
10
|
+
PIPE_OFFSET,
|
|
11
|
+
RESOLVE_OFFSET,
|
|
12
|
+
Result
|
|
13
|
+
} from "./cells.js";
|
|
14
|
+
function result(code) {
|
|
15
|
+
switch (code) {
|
|
16
|
+
case Result.completed:
|
|
17
|
+
return { phase: "completed" };
|
|
18
|
+
case Result.signalPending:
|
|
19
|
+
return { phase: "cancelled", reason: "signal-pending" };
|
|
20
|
+
case Result.processStop:
|
|
21
|
+
return { phase: "cancelled", reason: "process-stop" };
|
|
22
|
+
case Result.filesystemCancelled:
|
|
23
|
+
return { phase: "cancelled", reason: "filesystem-cancelled" };
|
|
24
|
+
case Result.pollError:
|
|
25
|
+
return { phase: "failed", reason: "poll-error" };
|
|
26
|
+
case Result.resolveError:
|
|
27
|
+
return { phase: "failed", reason: "resolve-error" };
|
|
28
|
+
case Result.transportError:
|
|
29
|
+
return { phase: "failed", reason: "transport-error" };
|
|
30
|
+
case Result.submissionError:
|
|
31
|
+
return { phase: "failed", reason: "submission-error" };
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function readSummary(capture, offset, now) {
|
|
35
|
+
const { cells, origin } = capture;
|
|
36
|
+
for (let attempt = 0;attempt < 2; attempt++) {
|
|
37
|
+
const first = cells.read(offset + Field.sequence);
|
|
38
|
+
if (first === undefined || first % 2 !== 0)
|
|
39
|
+
continue;
|
|
40
|
+
const active = cells.read(offset + Field.active);
|
|
41
|
+
const started = cells.read(offset + Field.started);
|
|
42
|
+
const code = cells.read(offset + Field.result);
|
|
43
|
+
const duration = cells.read(offset + Field.duration);
|
|
44
|
+
const timed = cells.read(offset + Field.timed);
|
|
45
|
+
const completed = cells.read(offset + Field.completed);
|
|
46
|
+
const cancelled = cells.read(offset + Field.cancelled);
|
|
47
|
+
const failed = cells.read(offset + Field.failed);
|
|
48
|
+
const accepted = offset === RESOLVE_OFFSET && cells.read(ACKNOWLEDGED) === active;
|
|
49
|
+
if (cells.read(offset + Field.sequence) !== first)
|
|
50
|
+
continue;
|
|
51
|
+
if (active === undefined || started === undefined || code === undefined || duration === undefined || completed === undefined || cancelled === undefined || failed === undefined)
|
|
52
|
+
continue;
|
|
53
|
+
const phase = offset === PIPE_OFFSET ? "waiting" : accepted ? "accepted" : "submitted";
|
|
54
|
+
const latest = result(code);
|
|
55
|
+
return {
|
|
56
|
+
...active ? {
|
|
57
|
+
active: {
|
|
58
|
+
phase,
|
|
59
|
+
elapsedMs: started === MAX_VALUE ? null : elapsedFrom(origin + started, now)
|
|
60
|
+
}
|
|
61
|
+
} : {},
|
|
62
|
+
...latest ? { latest: { ...latest, elapsedMs: timed ? duration : null } } : {},
|
|
63
|
+
completed,
|
|
64
|
+
cancelled,
|
|
65
|
+
failed
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
function retire(summary) {
|
|
70
|
+
if (!summary?.active)
|
|
71
|
+
return summary;
|
|
72
|
+
const { active, ...confirmed } = summary;
|
|
73
|
+
return {
|
|
74
|
+
...confirmed,
|
|
75
|
+
retirement: { phase: "retired-unconfirmed", elapsedMs: active.elapsedMs }
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
function copy(summary) {
|
|
79
|
+
if (!summary)
|
|
80
|
+
return;
|
|
81
|
+
return {
|
|
82
|
+
completed: summary.completed,
|
|
83
|
+
cancelled: summary.cancelled,
|
|
84
|
+
failed: summary.failed,
|
|
85
|
+
...summary.active ? { active: { ...summary.active } } : {},
|
|
86
|
+
...summary.latest ? { latest: { ...summary.latest } } : {},
|
|
87
|
+
...summary.retirement ? { retirement: { ...summary.retirement } } : {}
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export class OperationOwner {
|
|
92
|
+
allocate;
|
|
93
|
+
owned;
|
|
94
|
+
buffer;
|
|
95
|
+
unavailable = false;
|
|
96
|
+
slots = Array.from({ length: OPERATION_SLOTS });
|
|
97
|
+
history = [];
|
|
98
|
+
nextHistory = 0;
|
|
99
|
+
captureId = 0;
|
|
100
|
+
skippedImages = 0;
|
|
101
|
+
constructor(allocate, owned) {
|
|
102
|
+
this.allocate = allocate;
|
|
103
|
+
this.owned = owned;
|
|
104
|
+
}
|
|
105
|
+
enroll(pid, generation) {
|
|
106
|
+
if (this.unavailable || this.captureId === MAX_VALUE)
|
|
107
|
+
return;
|
|
108
|
+
if (!this.buffer) {
|
|
109
|
+
try {
|
|
110
|
+
this.buffer = this.allocate(OPERATION_BYTES);
|
|
111
|
+
} catch {
|
|
112
|
+
this.unavailable = true;
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
this.reconcile();
|
|
117
|
+
const slot = this.slots.indexOf(undefined);
|
|
118
|
+
if (slot < 0) {
|
|
119
|
+
this.skippedImages = Math.min(MAX_VALUE, this.skippedImages + 1);
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
const captureId = ++this.captureId;
|
|
123
|
+
const origin = operationClock();
|
|
124
|
+
const binding = { buffer: this.buffer, slot, captureId, origin };
|
|
125
|
+
const cells = new OperationCells(binding);
|
|
126
|
+
cells.assign();
|
|
127
|
+
this.slots[slot] = { image: { pid, generation, captureId }, cells, origin };
|
|
128
|
+
return binding;
|
|
129
|
+
}
|
|
130
|
+
snapshot() {
|
|
131
|
+
if (this.unavailable)
|
|
132
|
+
return { status: "unavailable" };
|
|
133
|
+
if (!this.buffer)
|
|
134
|
+
return { status: "empty" };
|
|
135
|
+
const owned = this.reconcile();
|
|
136
|
+
const history = this.history.slice(this.nextHistory).concat(this.history.slice(0, this.nextHistory));
|
|
137
|
+
const departed = history.map(({ pipeReadWait, fsResolve, ...image }) => ({
|
|
138
|
+
...image,
|
|
139
|
+
pipeReadWait: copy(pipeReadWait),
|
|
140
|
+
fsResolve: copy(fsResolve)
|
|
141
|
+
}));
|
|
142
|
+
return { status: "recording", owned, departed, skippedImages: this.skippedImages };
|
|
143
|
+
}
|
|
144
|
+
reconcile() {
|
|
145
|
+
const now = operationClock();
|
|
146
|
+
const rows = [];
|
|
147
|
+
for (let slot = 0;slot < OPERATION_SLOTS; slot++) {
|
|
148
|
+
const capture = this.slots[slot];
|
|
149
|
+
if (!capture)
|
|
150
|
+
continue;
|
|
151
|
+
const pipeReadWait = readSummary(capture, PIPE_OFFSET, now);
|
|
152
|
+
const fsResolve = readSummary(capture, RESOLVE_OFFSET, now);
|
|
153
|
+
if (pipeReadWait)
|
|
154
|
+
capture.pipeReadWait = pipeReadWait;
|
|
155
|
+
if (fsResolve)
|
|
156
|
+
capture.fsResolve = fsResolve;
|
|
157
|
+
if (!this.owned(capture.image)) {
|
|
158
|
+
this.archive(slot, capture);
|
|
159
|
+
continue;
|
|
160
|
+
}
|
|
161
|
+
rows.push({ ...capture.image, pipeReadWait: copy(pipeReadWait), fsResolve: copy(fsResolve) });
|
|
162
|
+
}
|
|
163
|
+
return rows;
|
|
164
|
+
}
|
|
165
|
+
archive(slot, capture) {
|
|
166
|
+
new OperationCells({ buffer: this.buffer, slot, captureId: 0 }).assign();
|
|
167
|
+
this.slots[slot] = undefined;
|
|
168
|
+
this.history[this.nextHistory] = {
|
|
169
|
+
...capture.image,
|
|
170
|
+
pipeReadWait: retire(capture.pipeReadWait),
|
|
171
|
+
fsResolve: retire(capture.fsResolve)
|
|
172
|
+
};
|
|
173
|
+
this.nextHistory = (this.nextHistory + 1) % OPERATION_SLOTS;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ACKNOWLEDGED,
|
|
3
|
+
elapsedFrom,
|
|
4
|
+
Field,
|
|
5
|
+
MAX_VALUE,
|
|
6
|
+
OperationCells,
|
|
7
|
+
operationClock,
|
|
8
|
+
PIPE_OFFSET,
|
|
9
|
+
RESOLVE_OFFSET,
|
|
10
|
+
Result
|
|
11
|
+
} from "./cells.js";
|
|
12
|
+
const staleCapture = new Error("Operation capture was retired");
|
|
13
|
+
|
|
14
|
+
class Writer {
|
|
15
|
+
cells;
|
|
16
|
+
offset;
|
|
17
|
+
origin;
|
|
18
|
+
#sequence;
|
|
19
|
+
#started;
|
|
20
|
+
constructor(cells, offset, origin) {
|
|
21
|
+
this.cells = cells;
|
|
22
|
+
this.offset = offset;
|
|
23
|
+
this.origin = origin;
|
|
24
|
+
const previous = cells.read(offset + Field.sequence);
|
|
25
|
+
this.#sequence = previous !== undefined && previous % 2 === 0 ? previous : MAX_VALUE;
|
|
26
|
+
}
|
|
27
|
+
begin(id) {
|
|
28
|
+
if (this.#started !== undefined || this.#sequence > MAX_VALUE - 5)
|
|
29
|
+
return;
|
|
30
|
+
try {
|
|
31
|
+
const started = operationClock();
|
|
32
|
+
if (!this.open())
|
|
33
|
+
return;
|
|
34
|
+
this.put(Field.started, elapsedFrom(this.origin, started));
|
|
35
|
+
this.put(Field.active, id);
|
|
36
|
+
this.close();
|
|
37
|
+
this.#started = started;
|
|
38
|
+
} catch {
|
|
39
|
+
this.#sequence = MAX_VALUE;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
settle(result) {
|
|
43
|
+
const started = this.#started;
|
|
44
|
+
if (started === undefined)
|
|
45
|
+
return;
|
|
46
|
+
this.#started = undefined;
|
|
47
|
+
this.finish(Result[result], started);
|
|
48
|
+
}
|
|
49
|
+
submissionFailed(result) {
|
|
50
|
+
this.finish(Result[result], undefined);
|
|
51
|
+
}
|
|
52
|
+
finish(result, started) {
|
|
53
|
+
try {
|
|
54
|
+
if (!this.open())
|
|
55
|
+
return;
|
|
56
|
+
const count = result === Result.completed ? Field.completed : result <= Result.filesystemCancelled ? Field.cancelled : Field.failed;
|
|
57
|
+
const previous = this.cells.read(this.offset + count);
|
|
58
|
+
if (previous === undefined)
|
|
59
|
+
throw staleCapture;
|
|
60
|
+
this.put(count, previous === MAX_VALUE ? previous : previous + 1);
|
|
61
|
+
this.put(Field.result, result);
|
|
62
|
+
this.put(Field.duration, started === undefined ? 0 : elapsedFrom(started));
|
|
63
|
+
this.put(Field.timed, started === undefined ? 0 : 1);
|
|
64
|
+
this.put(Field.active, 0);
|
|
65
|
+
this.close();
|
|
66
|
+
} catch {
|
|
67
|
+
this.#sequence = MAX_VALUE;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
open() {
|
|
71
|
+
if (this.#sequence >= MAX_VALUE - 1)
|
|
72
|
+
return false;
|
|
73
|
+
this.put(Field.sequence, ++this.#sequence);
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
close() {
|
|
77
|
+
this.put(Field.sequence, ++this.#sequence);
|
|
78
|
+
}
|
|
79
|
+
put(field, value) {
|
|
80
|
+
if (!this.cells.write(this.offset + field, value))
|
|
81
|
+
throw staleCapture;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
export function createOperationWriters(binding) {
|
|
85
|
+
const cells = new OperationCells(binding);
|
|
86
|
+
return {
|
|
87
|
+
pipe: new Writer(cells, PIPE_OFFSET, binding.origin),
|
|
88
|
+
resolve: new Writer(cells, RESOLVE_OFFSET, binding.origin)
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
export function captureAcceptance(binding) {
|
|
92
|
+
const cells = new OperationCells(binding);
|
|
93
|
+
return (id) => {
|
|
94
|
+
const previous = cells.read(ACKNOWLEDGED);
|
|
95
|
+
if (previous !== undefined && id > previous)
|
|
96
|
+
cells.write(ACKNOWLEDGED, id);
|
|
97
|
+
};
|
|
98
|
+
}
|