@mostra/runtime 0.4.0 → 0.5.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mostra/runtime",
3
- "version": "0.4.0",
3
+ "version": "0.5.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.4.0",
39
+ "@mostra/protocol": "0.5.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.2",
52
+ "vite": "8.3.3",
53
53
  "yaml": "2.9.1",
54
- "zod": "4.6.5"
54
+ "zod": "4.6.6"
55
55
  },
56
56
  "devDependencies": {
57
- "@mostra/shell": "0.4.0",
57
+ "@mostra/shell": "0.5.0",
58
58
  "@mostra/tools": "0.0.0",
59
- "@mostra/verify": "0.4.0",
59
+ "@mostra/verify": "0.5.0",
60
60
  "@mostra/warm": "0.0.0",
61
- "@mostra/worker": "0.4.0",
61
+ "@mostra/worker": "0.5.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/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 === crash.versionId) running.delete(id);
504
+ if (producer.versionId !== crash.versionId) continue;
505
+ running.delete(id);
506
+ ended.add(producer.key);
489
507
  }
490
508
  if (crash.parked) {
491
- for (const key of crash.liveKeys) {
492
- fail(crash.artifactId, key, {
493
- code: "MOSTRA_RUNTIME_WORKER_PARKED",
494
- message: `The artifact's server code keeps crashing, so its live sources stopped (${crash.cause}).`,
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
  }