@mostra/runtime 0.4.0 → 0.6.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 +3 -2
- package/dist/bin.js +1 -1
- package/dist/index.js +1 -1
- package/dist/{instance-DxcGEQj_.js → instance-Da8UG_Qd.js} +35 -21
- package/dist/{instance-DxcGEQj_.js.map → instance-Da8UG_Qd.js.map} +1 -1
- package/package.json +7 -7
- package/src/home/platform.ts +7 -15
- package/src/live/index.ts +26 -7
- package/src/service/unit.ts +3 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mostra/runtime",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "The Mostra runtime: the supervisor that owns a home, its ledger, its child processes and the host protocol server (mostra-runtime host|daemon).",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "The Mostra Authors",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@hono/node-server": "2.1.3",
|
|
38
38
|
"@mdx-js/mdx": "3.1.1",
|
|
39
|
-
"@mostra/protocol": "0.
|
|
39
|
+
"@mostra/protocol": "0.6.0",
|
|
40
40
|
"@tailwindcss/vite": "4.3.3",
|
|
41
41
|
"@vitejs/plugin-react": "6.1.1",
|
|
42
42
|
"better-sqlite3": "13.0.3",
|
|
@@ -49,16 +49,16 @@
|
|
|
49
49
|
"semver": "7.8.5",
|
|
50
50
|
"tailwindcss": "4.3.3",
|
|
51
51
|
"typescript": "7.0.2",
|
|
52
|
-
"vite": "8.3.
|
|
52
|
+
"vite": "8.3.3",
|
|
53
53
|
"yaml": "2.9.1",
|
|
54
|
-
"zod": "4.6.
|
|
54
|
+
"zod": "4.6.6"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
|
-
"@mostra/shell": "0.
|
|
57
|
+
"@mostra/shell": "0.6.0",
|
|
58
58
|
"@mostra/tools": "0.0.0",
|
|
59
|
-
"@mostra/verify": "0.
|
|
59
|
+
"@mostra/verify": "0.6.0",
|
|
60
60
|
"@mostra/warm": "0.0.0",
|
|
61
|
-
"@mostra/worker": "0.
|
|
61
|
+
"@mostra/worker": "0.6.0",
|
|
62
62
|
"@types/better-sqlite3": "9.6.0",
|
|
63
63
|
"@types/node": "24.19.1",
|
|
64
64
|
"@types/semver": "7.8.0",
|
package/src/home/platform.ts
CHANGED
|
@@ -1,19 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The unsupported-platform gate (D35, D146, RT-07). Every entry point calls it before it touches
|
|
3
|
-
* the home: Mostra runs on macOS and
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* WP-W3 removes the switch.
|
|
3
|
+
* the home: Mostra runs on macOS, Linux and Windows, on x64 and arm64, and fails closed elsewhere.
|
|
4
|
+
* Windows was built behind a development switch by WP-W1 to WP-W3, and is supported since WP-W3
|
|
5
|
+
* like the others.
|
|
7
6
|
*/
|
|
8
7
|
import { createDiagnostic, type Diagnostic } from "@mostra/protocol";
|
|
9
8
|
import { OS } from "../platform/index.ts";
|
|
10
9
|
|
|
11
|
-
const OPERATING_SYSTEMS: readonly string[] = ["darwin", "linux"];
|
|
10
|
+
const OPERATING_SYSTEMS: readonly string[] = ["darwin", "linux", "win32"];
|
|
12
11
|
const ARCHITECTURES: readonly string[] = ["x64", "arm64"];
|
|
13
12
|
|
|
14
|
-
/** The development switch that admits Windows until WP-W3 (D146). */
|
|
15
|
-
export const WINDOWS_DEV_SWITCH = "MOSTRA_DEV_WINDOWS";
|
|
16
|
-
|
|
17
13
|
/** The platform as `<os>-<arch>`, as `InstanceInfo.platform` reports it. */
|
|
18
14
|
export function platformName(platform: string = OS, arch: string = process.arch): string {
|
|
19
15
|
return `${platform}-${arch}`;
|
|
@@ -21,22 +17,18 @@ export function platformName(platform: string = OS, arch: string = process.arch)
|
|
|
21
17
|
|
|
22
18
|
/**
|
|
23
19
|
* Returns `MOSTRA_PLATFORM_UNSUPPORTED` for a platform Mostra doesn't run on, or `undefined` for
|
|
24
|
-
* a supported one.
|
|
20
|
+
* a supported one.
|
|
25
21
|
*/
|
|
26
22
|
export function checkPlatform(
|
|
27
23
|
platform: string = OS,
|
|
28
24
|
arch: string = process.arch,
|
|
29
|
-
env: Readonly<Record<string, string | undefined>> = process.env,
|
|
30
25
|
): Diagnostic | undefined {
|
|
31
|
-
if (ARCHITECTURES.includes(arch))
|
|
32
|
-
if (OPERATING_SYSTEMS.includes(platform)) return undefined;
|
|
33
|
-
if (platform === "win32" && env[WINDOWS_DEV_SWITCH] === "1") return undefined;
|
|
34
|
-
}
|
|
26
|
+
if (ARCHITECTURES.includes(arch) && OPERATING_SYSTEMS.includes(platform)) return undefined;
|
|
35
27
|
const name =
|
|
36
28
|
platform === "win32"
|
|
37
29
|
? `Windows (${platformName(platform, arch)})`
|
|
38
30
|
: platformName(platform, arch);
|
|
39
31
|
return createDiagnostic("MOSTRA_PLATFORM_UNSUPPORTED", {
|
|
40
|
-
message: `Mostra doesn't run on ${name}; it supports macOS and
|
|
32
|
+
message: `Mostra doesn't run on ${name}; it supports macOS, Linux and Windows on x64 and arm64.`,
|
|
41
33
|
});
|
|
42
34
|
}
|
package/src/live/index.ts
CHANGED
|
@@ -147,6 +147,12 @@ export function createLive(options: LiveOptions): Live {
|
|
|
147
147
|
const retryAt = new Map<string, number>();
|
|
148
148
|
/** Versions whose producers stopped because their worker is parked, by version, to their artifact. */
|
|
149
149
|
const parkedVersions = new Map<string, string>();
|
|
150
|
+
/** Why each parked version parked: its sources' error names the last cause. */
|
|
151
|
+
const parkCauses = new Map<string, string>();
|
|
152
|
+
const parkError = (cause: string): WireError => ({
|
|
153
|
+
code: "MOSTRA_RUNTIME_WORKER_PARKED",
|
|
154
|
+
message: `The artifact's server code keeps crashing, so its live sources stopped (${cause}).`,
|
|
155
|
+
});
|
|
150
156
|
let timer: ReturnType<typeof setInterval> | undefined;
|
|
151
157
|
let scheduled = false;
|
|
152
158
|
let stopped = false;
|
|
@@ -279,6 +285,15 @@ export function createLive(options: LiveOptions): Live {
|
|
|
279
285
|
throw error;
|
|
280
286
|
}
|
|
281
287
|
} catch (error) {
|
|
288
|
+
// A start the park cut short says the park, never its own failure (#42). The park may not
|
|
289
|
+
// have named this source: a worker that never answered its start told nobody its sources
|
|
290
|
+
// (GPT review of MT-01).
|
|
291
|
+
if (parkedVersions.has(versionId)) {
|
|
292
|
+
if (failures.get(id)?.code !== "MOSTRA_RUNTIME_WORKER_PARKED") {
|
|
293
|
+
fail(artifactId, key, parkError(parkCauses.get(versionId) ?? "its last start failed"));
|
|
294
|
+
}
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
282
297
|
const diagnostic = error instanceof RpcError ? error.diagnostic : undefined;
|
|
283
298
|
fail(artifactId, key, {
|
|
284
299
|
message: diagnostic?.message ?? String(error),
|
|
@@ -484,18 +499,21 @@ export function createLive(options: LiveOptions): Live {
|
|
|
484
499
|
},
|
|
485
500
|
|
|
486
501
|
crashed(crash) {
|
|
502
|
+
const ended = new Set(crash.liveKeys);
|
|
487
503
|
for (const [id, producer] of running) {
|
|
488
|
-
if (producer.versionId
|
|
504
|
+
if (producer.versionId !== crash.versionId) continue;
|
|
505
|
+
running.delete(id);
|
|
506
|
+
ended.add(producer.key);
|
|
489
507
|
}
|
|
490
508
|
if (crash.parked) {
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
}
|
|
509
|
+
// Every source of the parked version says so, not only the producers the worker had
|
|
510
|
+
// started when it crashed: one being started then, or due after the backoff, never runs
|
|
511
|
+
// again either, and its page would otherwise wait on it without a word (#42).
|
|
512
|
+
for (const source of described.get(crash.versionId) ?? []) ended.add(source.key);
|
|
513
|
+
for (const key of ended) fail(crash.artifactId, key, parkError(crash.cause));
|
|
497
514
|
retryAt.set(crash.versionId, Number.POSITIVE_INFINITY);
|
|
498
515
|
parkedVersions.set(crash.versionId, crash.artifactId);
|
|
516
|
+
parkCauses.set(crash.versionId, crash.cause);
|
|
499
517
|
return;
|
|
500
518
|
}
|
|
501
519
|
retryAt.set(crash.versionId, Date.now() + crash.backoffMs);
|
|
@@ -521,6 +539,7 @@ export function createLive(options: LiveOptions): Live {
|
|
|
521
539
|
for (const [versionId, owner] of parkedVersions) {
|
|
522
540
|
if (owner !== artifactId) continue;
|
|
523
541
|
parkedVersions.delete(versionId);
|
|
542
|
+
parkCauses.delete(versionId);
|
|
524
543
|
retryAt.delete(versionId);
|
|
525
544
|
cleared = true;
|
|
526
545
|
}
|
package/src/service/unit.ts
CHANGED
|
@@ -121,11 +121,11 @@ export function serviceFor(spec: ServiceSpec): ServiceStatus {
|
|
|
121
121
|
|
|
122
122
|
/**
|
|
123
123
|
* What a Windows task passes on besides the user's logon environment, which Task Scheduler gives
|
|
124
|
-
* it: the
|
|
125
|
-
*
|
|
124
|
+
* it: the helper a checkout names, and the locale and time zone, as the POSIX units carry theirs.
|
|
125
|
+
* Nothing secret.
|
|
126
126
|
*/
|
|
127
127
|
function windowsServiceVariables(env: Environment): [string, string][] {
|
|
128
|
-
return ["
|
|
128
|
+
return ["MOSTRA_WIN_HELPER", "LANG", "TZ"].flatMap((name) => {
|
|
129
129
|
const value = env[name];
|
|
130
130
|
return value ? [[name, value] as [string, string]] : [];
|
|
131
131
|
});
|