@serfab/cadre-core 1.19.0 → 1.20.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.
Files changed (131) hide show
  1. package/dist/cadre-node.d.ts +118 -16
  2. package/dist/cadre-node.js +210 -31
  3. package/dist/cadre-node.js.map +1 -1
  4. package/dist/control-database.d.ts +2 -1
  5. package/dist/control-database.js +128 -126
  6. package/dist/control-database.js.map +1 -1
  7. package/dist/control-protocol-guard.js +3 -2
  8. package/dist/control-protocol-guard.js.map +1 -1
  9. package/dist/control-read-retry.d.ts +19 -16
  10. package/dist/control-read-retry.js +22 -54
  11. package/dist/control-read-retry.js.map +1 -1
  12. package/dist/control-retry.d.ts +50 -6
  13. package/dist/control-retry.js +53 -6
  14. package/dist/control-retry.js.map +1 -1
  15. package/dist/control-stream.js +2 -1
  16. package/dist/control-stream.js.map +1 -1
  17. package/dist/control-write-retry.d.ts +24 -16
  18. package/dist/control-write-retry.js +58 -30
  19. package/dist/control-write-retry.js.map +1 -1
  20. package/dist/describe-thrown.d.ts +12 -0
  21. package/dist/describe-thrown.js +59 -0
  22. package/dist/describe-thrown.js.map +1 -0
  23. package/dist/edge-node/config.d.ts +8 -2
  24. package/dist/edge-node/config.js +5 -1
  25. package/dist/edge-node/config.js.map +1 -1
  26. package/dist/edge-node/dissolve.d.ts +1 -1
  27. package/dist/edge-node/dissolve.js +1 -1
  28. package/dist/edge-node/dissolve.js.map +1 -1
  29. package/dist/edge-node/edge-join.js +4 -1
  30. package/dist/edge-node/edge-join.js.map +1 -1
  31. package/dist/edge-node/edge-node.d.ts +10 -0
  32. package/dist/edge-node/edge-node.js +54 -9
  33. package/dist/edge-node/edge-node.js.map +1 -1
  34. package/dist/edge-node/options.d.ts +11 -2
  35. package/dist/edge-node/options.js +11 -4
  36. package/dist/edge-node/options.js.map +1 -1
  37. package/dist/edge-node/platform.d.ts +15 -3
  38. package/dist/edge-node/strand-move.d.ts +0 -2
  39. package/dist/edge-node/strand-move.js +1 -4
  40. package/dist/edge-node/strand-move.js.map +1 -1
  41. package/dist/edge-node/strands.js +5 -3
  42. package/dist/edge-node/strands.js.map +1 -1
  43. package/dist/enrollment.js +2 -1
  44. package/dist/enrollment.js.map +1 -1
  45. package/dist/index.d.ts +6 -2
  46. package/dist/index.js +9 -1
  47. package/dist/index.js.map +1 -1
  48. package/dist/member-redemption.js +3 -9
  49. package/dist/member-redemption.js.map +1 -1
  50. package/dist/node-local-snapshot.js +2 -1
  51. package/dist/node-local-snapshot.js.map +1 -1
  52. package/dist/peer-dial.js +3 -2
  53. package/dist/peer-dial.js.map +1 -1
  54. package/dist/pending-join-runner.d.ts +29 -2
  55. package/dist/pending-join-runner.js +60 -20
  56. package/dist/pending-join-runner.js.map +1 -1
  57. package/dist/push-notifier-apns.js +8 -7
  58. package/dist/push-notifier-apns.js.map +1 -1
  59. package/dist/push-notifier-fcm.js +6 -5
  60. package/dist/push-notifier-fcm.js.map +1 -1
  61. package/dist/push-notifier-shared.d.ts +0 -2
  62. package/dist/push-notifier-shared.js +4 -4
  63. package/dist/push-notifier-shared.js.map +1 -1
  64. package/dist/relay-reservation.js +4 -3
  65. package/dist/relay-reservation.js.map +1 -1
  66. package/dist/strand-addr-protocol.js +2 -1
  67. package/dist/strand-addr-protocol.js.map +1 -1
  68. package/dist/strand-app-schema-report.d.ts +53 -0
  69. package/dist/strand-app-schema-report.js +77 -0
  70. package/dist/strand-app-schema-report.js.map +1 -0
  71. package/dist/strand-database.d.ts +60 -0
  72. package/dist/strand-database.js +93 -0
  73. package/dist/strand-database.js.map +1 -1
  74. package/dist/strand-first-sync-gate.js +4 -3
  75. package/dist/strand-first-sync-gate.js.map +1 -1
  76. package/dist/strand-formation-protocol.js +4 -3
  77. package/dist/strand-formation-protocol.js.map +1 -1
  78. package/dist/strand-instance-manager.d.ts +73 -2
  79. package/dist/strand-instance-manager.js +112 -9
  80. package/dist/strand-instance-manager.js.map +1 -1
  81. package/dist/strand-membership-reconciler.d.ts +13 -1
  82. package/dist/strand-membership-reconciler.js +25 -16
  83. package/dist/strand-membership-reconciler.js.map +1 -1
  84. package/dist/strand-membership-writer.d.ts +16 -2
  85. package/dist/strand-membership-writer.js +54 -8
  86. package/dist/strand-membership-writer.js.map +1 -1
  87. package/dist/strand-move.js +4 -6
  88. package/dist/strand-move.js.map +1 -1
  89. package/dist/strand-offline.d.ts +102 -0
  90. package/dist/strand-offline.js +97 -0
  91. package/dist/strand-offline.js.map +1 -0
  92. package/dist/types.d.ts +37 -0
  93. package/dist/types.js.map +1 -1
  94. package/package.json +8 -8
  95. package/src/cadre-node.ts +230 -31
  96. package/src/control-database.ts +5594 -5592
  97. package/src/control-protocol-guard.ts +3 -2
  98. package/src/control-read-retry.ts +22 -58
  99. package/src/control-retry.ts +54 -6
  100. package/src/control-stream.ts +2 -1
  101. package/src/control-write-retry.ts +58 -30
  102. package/src/describe-thrown.ts +60 -0
  103. package/src/edge-node/config.ts +11 -2
  104. package/src/edge-node/dissolve.ts +2 -1
  105. package/src/edge-node/edge-join.ts +2 -1
  106. package/src/edge-node/edge-node.ts +57 -7
  107. package/src/edge-node/options.ts +20 -4
  108. package/src/edge-node/platform.ts +15 -3
  109. package/src/edge-node/strand-move.ts +1 -5
  110. package/src/edge-node/strands.ts +74 -72
  111. package/src/enrollment.ts +2 -1
  112. package/src/index.ts +27 -1
  113. package/src/member-redemption.ts +3 -9
  114. package/src/node-local-snapshot.ts +2 -1
  115. package/src/peer-dial.ts +605 -604
  116. package/src/pending-join-runner.ts +68 -22
  117. package/src/push-notifier-apns.ts +8 -7
  118. package/src/push-notifier-fcm.ts +6 -5
  119. package/src/push-notifier-shared.ts +5 -5
  120. package/src/relay-reservation.ts +1212 -1211
  121. package/src/strand-addr-protocol.ts +2 -1
  122. package/src/strand-app-schema-report.ts +115 -0
  123. package/src/strand-database.ts +123 -1
  124. package/src/strand-first-sync-gate.ts +600 -599
  125. package/src/strand-formation-protocol.ts +4 -3
  126. package/src/strand-instance-manager.ts +137 -10
  127. package/src/strand-membership-reconciler.ts +942 -928
  128. package/src/strand-membership-writer.ts +61 -14
  129. package/src/strand-move.ts +594 -597
  130. package/src/strand-offline.ts +178 -0
  131. package/src/types.ts +36 -0
@@ -42,6 +42,7 @@ import {
42
42
  type FormationRejectionCode
43
43
  } from './strand-formation-rejection.js';
44
44
  import type { FormationTokenCheck, FormationTokenRead } from './formation-token.js';
45
+ import { describeThrown, toError } from './describe-thrown.js';
45
46
 
46
47
  const log = debug('sereus:cadre:formation-proto');
47
48
 
@@ -918,7 +919,7 @@ async function releaseFormationConnection(connection: Connection): Promise<void>
918
919
  await connection.close();
919
920
  } catch (error) {
920
921
  log('closing the formation connection to %s failed; aborting it: %o', connection.remotePeer.toString(), error);
921
- connection.abort(error instanceof Error ? error : new Error(String(error)));
922
+ connection.abort(toError(error));
922
923
  }
923
924
  }
924
925
 
@@ -1011,7 +1012,7 @@ function noMachineReached(failures: Array<{ peerId: string; error: FormationUnre
1011
1012
  */
1012
1013
  function describeAllAddressesFailed(error: unknown): unknown {
1013
1014
  if (!(error instanceof AggregateError)) return error;
1014
- const reasons = error.errors.map((reason: unknown) => reason instanceof Error ? reason.message : String(reason));
1015
+ const reasons = error.errors.map(describeThrown);
1015
1016
  return new FormationUnreachableError(
1016
1017
  `Formation could not reach the inviter at any of the ${reasons.length} addresses tried: ${reasons.join('; ')}`,
1017
1018
  { cause: error }
@@ -1021,7 +1022,7 @@ function describeAllAddressesFailed(error: unknown): unknown {
1021
1022
  /** Report a failure that came before any answer as {@link FormationUnreachableError}, keeping its message. */
1022
1023
  function asUnreachable(error: unknown): FormationUnreachableError {
1023
1024
  if (error instanceof FormationUnreachableError) return error;
1024
- return new FormationUnreachableError(error instanceof Error ? error.message : String(error), { cause: error });
1025
+ return new FormationUnreachableError(describeThrown(error), { cause: error });
1025
1026
  }
1026
1027
 
1027
1028
  /**
@@ -2,8 +2,10 @@ import debug from 'debug';
2
2
  import type { Libp2p, PrivateKey } from '@libp2p/interface';
3
3
  import { createLibp2pNode, type IRawStorage } from '@optimystic/db-p2p';
4
4
  import { wrapStorageWithCache, disposeStorageCache } from '@serfab/quereus-plugin-sereus';
5
- import { StrandDatabase } from './strand-database.js';
5
+ import { StrandDatabase, type StrandDatabaseOffline } from './strand-database.js';
6
6
  import type { StrandCommitDurability, StrandCommitHeld } from './strand-commit-durability.js';
7
+ import type { StrandOfflineConfig, StrandOfflineListeners, StrandOfflineMode } from './strand-offline.js';
8
+ import type { StrandAppSchemaListeners } from './strand-app-schema-report.js';
7
9
  import { PeerJoinBackfill, type PeerJoinBackfillConfig } from './peer-join-backfill.js';
8
10
  import { strandNetworkStatePersistence, type StrandNetworkStateStore } from './strand-network-state.js';
9
11
  import {
@@ -49,6 +51,7 @@ import { strandRedialTimings, superviseStrandPeerRedial, type StrandPeerRedial }
49
51
  import { groupAddrsByPeerId } from './peer-addr-book.js';
50
52
  import { isCohortUnreachableRead } from './control-read-retry.js';
51
53
  import { declaredCohortReadDeadlineMs, optimysticDialLimits, peerJoinPushBudget, relayReservationBudgetMs, resolveLinkRoundTripMs } from './link-budget.js';
54
+ import { describeThrown } from './describe-thrown.js';
52
55
 
53
56
  const log = debug('sereus:cadre:strand-manager');
54
57
 
@@ -304,6 +307,20 @@ export interface StartStrandConfig {
304
307
  */
305
308
  onCommitHeld?: (event: StrandCommitHeld) => void;
306
309
 
310
+ /**
311
+ * Offline mode for this strand (docs/strands.md → "Offline mode"), forwarded from
312
+ * `CadreNodeConfig.strandOffline`, with where each database built for the launch reports its
313
+ * queue (`CadreNode` emits them as events). Absent: no database gets an offline queue. The mode
314
+ * itself is the manager's, per strand ({@link StrandInstanceManager.setOfflineMode}).
315
+ */
316
+ offline?: StrandOfflineConfig & StrandOfflineListeners;
317
+
318
+ /**
319
+ * Where each database built for the launch reports an `App` schema apply it held back
320
+ * (`CadreNode` emits them as events). Retained and isolated like {@link onCommitDurability}.
321
+ */
322
+ appSchema?: StrandAppSchemaListeners;
323
+
307
324
  /**
308
325
  * Re-announce this strand's delegate peer id (`delegatePeerId` — the strand
309
326
  * node's own transport peer id) to ONE relay (`relayAddr`, a direct dial addr
@@ -561,6 +578,20 @@ export class StrandInstanceManager {
561
578
  * {@link releaseRuntime}, so a stop or a quiesce cancels it.
562
579
  */
563
580
  private unreachableJoinRetries: Map<string, unknown> = new Map();
581
+ /**
582
+ * The offline mode set per strand id ({@link setOfflineMode}); a strand absent here runs in its
583
+ * launch's `initialMode`. Never cleared: the mode belongs to the strand, not to one database, so
584
+ * it outlives hibernation, every rebuild and a stop, for as long as the process runs.
585
+ */
586
+ private offlineModes: Map<string, StrandOfflineMode> = new Map();
587
+ /**
588
+ * The transaction ids each strand's offline queue listed when its database last closed
589
+ * ({@link releaseRuntime}), for a leave from a hibernating strand, whose queue is then only in
590
+ * its journal ({@link queuedTransactionIds}). Exact while the strand hibernates: nothing drains
591
+ * a journal without a database. Deleted with the instance: on {@link stopStrand}, and when a
592
+ * {@link startStrand} fails.
593
+ */
594
+ private closedQueues: Map<string, readonly string[]> = new Map();
564
595
  private stopping = false;
565
596
 
566
597
  constructor() {
@@ -675,13 +706,15 @@ export class StrandInstanceManager {
675
706
  } catch (error) {
676
707
  // Status/error first — the (now discarded) record is still what `log` reports on.
677
708
  instance.status = 'error';
678
- instance.error = error instanceof Error ? error.message : String(error);
709
+ instance.error = describeThrown(error);
679
710
  log('Failed to start strand %s: %s', strandId, instance.error);
680
711
  // Drop the dead record so this strand id can be launched again. Keep the
681
712
  // `launchConfigs` has an entry iff `instances` does invariant — resumeStrand
682
713
  // reads both, and a config without an instance would strand the config.
683
714
  this.instances.delete(strandId);
684
715
  this.launchConfigs.delete(strandId);
716
+ // The cleanup above remembered the half-built database's queue; an untracked strand keeps none.
717
+ this.closedQueues.delete(strandId);
685
718
  // The store this launch resolved goes with it: nothing owns it any more, and a
686
719
  // retained cache wrapper would be handed back (already retired) on a retry.
687
720
  await this.disposeStrandStorage(strandId);
@@ -1127,7 +1160,9 @@ export class StrandInstanceManager {
1127
1160
  // reconciler that would otherwise write it is disarmed (see buildStrandRuntime).
1128
1161
  bindFounderPeer: config.membershipReconciliation?.enabled !== false,
1129
1162
  onCommitDurability: config.onCommitDurability,
1130
- onCommitHeld: config.onCommitHeld
1163
+ onCommitHeld: config.onCommitHeld,
1164
+ offline: this.offlineDatabaseConfig(strandId, config.offline),
1165
+ appSchema: config.appSchema
1131
1166
  });
1132
1167
  const storageRepo = node.storageRepo;
1133
1168
  const gate = new StrandFirstSyncGate({
@@ -1155,7 +1190,7 @@ export class StrandInstanceManager {
1155
1190
  await this.discardDatabaseAttempt(strandId, gate);
1156
1191
  log('Strand %s: no seed peer has answered yet, so this joiner cannot build its database (%s); ' +
1157
1192
  'its runtime stays up and the build is retried every %dms',
1158
- strandId, error instanceof Error ? error.message : String(error), UNREACHABLE_JOIN_RETRY_MS);
1193
+ strandId, describeThrown(error), UNREACHABLE_JOIN_RETRY_MS);
1159
1194
  return 'awaiting-seed';
1160
1195
  }
1161
1196
  timing('[buildStrandRuntime:%s] strandDatabase.initialize: %dms', strandId, Math.round(performance.now() - t0));
@@ -1201,6 +1236,23 @@ export class StrandInstanceManager {
1201
1236
  return 'built';
1202
1237
  }
1203
1238
 
1239
+ /**
1240
+ * One build's {@link StrandDatabaseOffline}: the strand's journal, which the database resolves as
1241
+ * it initializes (a throw or rejection fails the build), and the strand's mode, which it reads each
1242
+ * time it applies it.
1243
+ */
1244
+ private offlineDatabaseConfig(strandId: string, offline: StartStrandConfig['offline']): StrandDatabaseOffline | undefined {
1245
+ if (!offline) {
1246
+ return undefined;
1247
+ }
1248
+ const { journal, initialMode: _initialMode, ...listeners } = offline;
1249
+ return {
1250
+ ...listeners,
1251
+ journal: () => journal(strandId),
1252
+ mode: () => this.currentOfflineMode(strandId, offline)
1253
+ };
1254
+ }
1255
+
1204
1256
  /**
1205
1257
  * Whether this strand's raw store holds no block. False for a store that cannot list its
1206
1258
  * blocks, or whose listing fails, so such a launch probes at once.
@@ -1288,7 +1340,7 @@ export class StrandInstanceManager {
1288
1340
  log('Strand %s: releasing the runtime after a failed database retry also failed: %o', strandId, cleanupErr);
1289
1341
  });
1290
1342
  instance.status = 'error';
1291
- instance.error = error instanceof Error ? error.message : String(error);
1343
+ instance.error = describeThrown(error);
1292
1344
  log('Strand %s: building the database of a joiner that was waiting for a seed peer failed: %s', strandId, instance.error);
1293
1345
  return;
1294
1346
  }
@@ -1361,9 +1413,11 @@ export class StrandInstanceManager {
1361
1413
  if (gate) {
1362
1414
  gate.stop();
1363
1415
  this.firstSyncGates.delete(instance.strandId);
1416
+ this.rememberQueue(instance.strandId, gate.database);
1364
1417
  await gate.database.close();
1365
1418
  }
1366
1419
  if (instance.database) {
1420
+ this.rememberQueue(instance.strandId, instance.database);
1367
1421
  await instance.database.close();
1368
1422
  instance.database = undefined;
1369
1423
  }
@@ -1504,8 +1558,9 @@ export class StrandInstanceManager {
1504
1558
  * this removal again — the in-memory retained key is the last chance.
1505
1559
  *
1506
1560
  * Never throws. Quiet no-op for a strand that is untracked, open, or launched
1507
- * without a party key; a quiesced (hibernating) strand, or a strand whose write
1508
- * quorum is already unreachable, leaves the stale binding behind with a log —
1561
+ * without a party key; a quiesced (hibernating) strand, a strand whose offline queue
1562
+ * still holds transactions (the writer refuses with `StrandOfflineQueueBusyError`), or a
1563
+ * strand whose write quorum is already unreachable, leaves the stale binding behind with a log —
1509
1564
  * it grants nothing today (admission is not allowlist-gated) and only
1510
1565
  * mis-credits diversity. The strand's own membership reconciler is stopped —
1511
1566
  * and its in-flight pass awaited — FIRST, so a pass that was already past its
@@ -1537,7 +1592,8 @@ export class StrandInstanceManager {
1537
1592
  return;
1538
1593
  }
1539
1594
  try {
1540
- // Background write on the app's database: never join a transaction the app has open.
1595
+ // Background write on the app's database: never join a transaction the app has open, and
1596
+ // never wait behind its offline queue (the writer refuses both; the catch below logs it).
1541
1597
  await removeMemberPeer(db, {
1542
1598
  memberKeyPair: strandMemberKeyPair(config.partyMemberPrivateKey),
1543
1599
  peerId
@@ -1711,7 +1767,7 @@ export class StrandInstanceManager {
1711
1767
  return instance;
1712
1768
  } catch (error) {
1713
1769
  instance.status = 'error';
1714
- instance.error = error instanceof Error ? error.message : String(error);
1770
+ instance.error = describeThrown(error);
1715
1771
  log('Failed to resume strand %s: %s', strandId, instance.error);
1716
1772
  throw error;
1717
1773
  }
@@ -1966,6 +2022,7 @@ export class StrandInstanceManager {
1966
2022
  if (wasGated) {
1967
2023
  this.launchConfigs.get(strandId)?.onWritable?.(strandId);
1968
2024
  }
2025
+ database.reportPublished();
1969
2026
  // Neither throws nor awaits: publishing must stay synchronous. `start()` is a no-op on an
1970
2027
  // enforcer already started or stopped, and the reconciler pass chains on the loop's own
1971
2028
  // tail, so it cannot overlap a pass already in flight.
@@ -1973,6 +2030,75 @@ export class StrandInstanceManager {
1973
2030
  void this.membershipReconcilers.get(strandId)?.reconcile();
1974
2031
  }
1975
2032
 
2033
+ /**
2034
+ * A tracked strand's offline mode: the one last set ({@link setOfflineMode}), else its launch's
2035
+ * `initialMode`, else `'online'`.
2036
+ *
2037
+ * @throws when the strand is not tracked.
2038
+ */
2039
+ offlineMode(strandId: string): StrandOfflineMode {
2040
+ const config = this.launchConfigs.get(strandId);
2041
+ if (!config) {
2042
+ throw new Error(`Cannot read the offline mode of strand ${strandId}: not tracked`);
2043
+ }
2044
+ return this.currentOfflineMode(strandId, config.offline);
2045
+ }
2046
+
2047
+ private currentOfflineMode(strandId: string, offline: StrandOfflineConfig | undefined): StrandOfflineMode {
2048
+ return this.offlineModes.get(strandId) ?? offline?.initialMode ?? 'online';
2049
+ }
2050
+
2051
+ /**
2052
+ * Set a tracked strand's offline mode, for the rest of the process (see {@link offlineModes}).
2053
+ * A live database takes it now, published or still behind the first-sync gate, for transactions
2054
+ * begun from then on; a build in progress reads it when it applies the mode, and a hibernating
2055
+ * strand gets it at its next build.
2056
+ *
2057
+ * @throws when the strand is not tracked.
2058
+ */
2059
+ setOfflineMode(strandId: string, mode: StrandOfflineMode): void {
2060
+ const instance = this.instances.get(strandId);
2061
+ if (!instance) {
2062
+ throw new Error(`Cannot set the offline mode of strand ${strandId}: not tracked`);
2063
+ }
2064
+ this.offlineModes.set(strandId, mode);
2065
+ this.liveDatabase(strandId)?.applyOfflineMode();
2066
+ }
2067
+
2068
+ /**
2069
+ * The transaction ids a strand's offline queue holds: its live database's, else what its
2070
+ * database listed when it last closed (a hibernating strand, see {@link closedQueues}), else none.
2071
+ *
2072
+ * NOTE: a strand this process has built no database for reads as empty, though its journal may
2073
+ * hold transactions from an earlier run, which come back if the strand is ever attached again.
2074
+ * If apps are found leaving strands with transactions journaled that way, read the journal here.
2075
+ */
2076
+ queuedTransactionIds(strandId: string): readonly string[] {
2077
+ return this.liveDatabase(strandId)?.queuedTransactionIds() ?? this.closedQueues.get(strandId) ?? [];
2078
+ }
2079
+
2080
+ /**
2081
+ * Withdraw what the live database's offline queue never sent (`StrandDatabase.discardQueuedTransactions`),
2082
+ * returning the ids it kept; `undefined` when no live database has a queue (a hibernating
2083
+ * strand, whose queue is back once a build restores it from the journal).
2084
+ */
2085
+ discardQueuedTransactions(strandId: string): readonly string[] | undefined {
2086
+ return this.liveDatabase(strandId)?.discardQueuedTransactions();
2087
+ }
2088
+
2089
+ /** A strand's database: the published one, else the one still behind the first-sync gate. */
2090
+ private liveDatabase(strandId: string): StrandDatabase | undefined {
2091
+ return this.instances.get(strandId)?.database ?? this.firstSyncGates.get(strandId)?.database;
2092
+ }
2093
+
2094
+ /** Keep what a closing database's queue lists, for {@link queuedTransactionIds}; one with no queue changes nothing. */
2095
+ private rememberQueue(strandId: string, database: StrandDatabase): void {
2096
+ const queued = database.queuedTransactionIds();
2097
+ if (queued !== undefined) {
2098
+ this.closedQueues.set(strandId, queued);
2099
+ }
2100
+ }
2101
+
1976
2102
  /** Reject every {@link whenWritable} waiter for a strand that is going away. */
1977
2103
  private rejectWritableWaiters(strandId: string, reason: string): void {
1978
2104
  const waiters = this.writableWaiters.get(strandId);
@@ -2060,12 +2186,13 @@ export class StrandInstanceManager {
2060
2186
  instance.status = 'stopped';
2061
2187
  this.instances.delete(strandId);
2062
2188
  this.launchConfigs.delete(strandId);
2189
+ this.closedQueues.delete(strandId);
2063
2190
  // Storage is released only here — NOT in releaseRuntime, which a quiesce shares.
2064
2191
  await this.disposeStrandStorage(strandId);
2065
2192
  log('Strand %s stopped successfully', strandId);
2066
2193
  } catch (error) {
2067
2194
  instance.status = 'error';
2068
- instance.error = error instanceof Error ? error.message : String(error);
2195
+ instance.error = describeThrown(error);
2069
2196
  log('Error stopping strand %s: %s', strandId, instance.error);
2070
2197
  throw error;
2071
2198
  }