@adhdev/daemon-standalone 0.9.82-rc.381 → 0.9.82-rc.383

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/dist/index.js CHANGED
@@ -30108,10 +30108,10 @@ var require_dist3 = __commonJS({
30108
30108
  }
30109
30109
  function getDaemonBuildInfo() {
30110
30110
  if (cached2) return cached2;
30111
- const commit = readInjected(true ? "18afac213951f79c502feb6b25b7399fe4d709b3" : void 0) ?? "unknown";
30112
- const commitShort = readInjected(true ? "18afac21" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
30113
- const version2 = readInjected(true ? "0.9.82-rc.381" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
30114
- const builtAt = readInjected(true ? "2026-06-25T11:45:12.459Z" : void 0);
30111
+ const commit = readInjected(true ? "6cca365bcea9757dd350c6bac460ca5a169a9280" : void 0) ?? "unknown";
30112
+ const commitShort = readInjected(true ? "6cca365b" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
30113
+ const version2 = readInjected(true ? "0.9.82-rc.383" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
30114
+ const builtAt = readInjected(true ? "2026-06-25T15:16:13.636Z" : void 0);
30115
30115
  cached2 = builtAt ? { commit, commitShort, version: version2, builtAt } : { commit, commitShort, version: version2 };
30116
30116
  return cached2;
30117
30117
  }
@@ -38363,6 +38363,107 @@ ${rendered}`, "utf-8");
38363
38363
  ]);
38364
38364
  }
38365
38365
  });
38366
+ var mesh_scheduling_runtime_exports = {};
38367
+ __export2(mesh_scheduling_runtime_exports, {
38368
+ buildMeshSchedulingRuntime: () => buildMeshSchedulingRuntime
38369
+ });
38370
+ function isReadonly(task) {
38371
+ return task.taskMode === "live_debug_readonly";
38372
+ }
38373
+ function isAssigned(task) {
38374
+ return task.status === "assigned";
38375
+ }
38376
+ function buildMeshSchedulingRuntime(mesh, queue) {
38377
+ const strategy = normalizeMeshSchedulingStrategy(mesh?.policy?.schedulingStrategy);
38378
+ const maxParallelTasks = resolveMaxParallelTasks(mesh?.policy?.maxParallelTasks);
38379
+ const maxReadonlyParallelTasks = Math.max(2, maxParallelTasks * 2);
38380
+ const assignedTasks = (Array.isArray(queue) ? queue : []).filter(isAssigned);
38381
+ const activeWriteAssigned = assignedTasks.filter((t) => !isReadonly(t)).length;
38382
+ const activeReadonlyAssigned = assignedTasks.filter(isReadonly).length;
38383
+ const globalWriteCapReached = activeWriteAssigned >= maxParallelTasks;
38384
+ const globalReadonlyCapReached = activeReadonlyAssigned >= maxReadonlyParallelTasks;
38385
+ const writeAssignedByNode = /* @__PURE__ */ new Map();
38386
+ const assignedByNode = /* @__PURE__ */ new Map();
38387
+ const providerCountByNode = /* @__PURE__ */ new Map();
38388
+ for (const task of assignedTasks) {
38389
+ const nodeId = typeof task.assignedNodeId === "string" ? task.assignedNodeId.trim() : "";
38390
+ if (!nodeId) continue;
38391
+ assignedByNode.set(nodeId, (assignedByNode.get(nodeId) ?? 0) + 1);
38392
+ if (!isReadonly(task)) {
38393
+ writeAssignedByNode.set(nodeId, (writeAssignedByNode.get(nodeId) ?? 0) + 1);
38394
+ }
38395
+ const provider = typeof task.assignedProviderType === "string" ? task.assignedProviderType : "";
38396
+ if (provider) {
38397
+ let byProvider = providerCountByNode.get(nodeId);
38398
+ if (!byProvider) {
38399
+ byProvider = /* @__PURE__ */ new Map();
38400
+ providerCountByNode.set(nodeId, byProvider);
38401
+ }
38402
+ byProvider.set(provider, (byProvider.get(provider) ?? 0) + 1);
38403
+ }
38404
+ }
38405
+ const nodes = [];
38406
+ for (const rawNode of Array.isArray(mesh?.nodes) ? mesh.nodes : []) {
38407
+ const nodeId = normalizeMeshNodeId(rawNode);
38408
+ if (!nodeId) continue;
38409
+ const policy = rawNode?.policy || void 0;
38410
+ const load4 = assignedByNode.get(nodeId) ?? 0;
38411
+ const schedulingPriority = resolveNodeSchedulingPriority(policy);
38412
+ const capReasons = [];
38413
+ if (globalWriteCapReached) capReasons.push("global_max_parallel_tasks_reached");
38414
+ if ((writeAssignedByNode.get(nodeId) ?? 0) > 0) capReasons.push("node_has_active_assignment");
38415
+ let providerRoles;
38416
+ const declaredRoles = Array.isArray(policy?.providerRoles) ? policy.providerRoles : [];
38417
+ if (declaredRoles.length) {
38418
+ const byProvider = providerCountByNode.get(nodeId);
38419
+ providerRoles = [];
38420
+ for (const role of declaredRoles) {
38421
+ if (!role || typeof role !== "object") continue;
38422
+ const providerType = typeof role.providerType === "string" ? role.providerType.trim() : "";
38423
+ if (!providerType) continue;
38424
+ const maxParallel = resolveProviderMaxParallel(policy, providerType);
38425
+ const activeAssigned = byProvider?.get(providerType) ?? 0;
38426
+ const capReached = maxParallel !== void 0 && activeAssigned >= maxParallel;
38427
+ providerRoles.push({
38428
+ providerType,
38429
+ ...maxParallel !== void 0 ? { maxParallel } : {},
38430
+ activeAssigned,
38431
+ capReached
38432
+ });
38433
+ if (capReached) capReasons.push(`max_provider_parallel_reached:${providerType}`);
38434
+ }
38435
+ if (!providerRoles.length) providerRoles = void 0;
38436
+ }
38437
+ const maxConcurrentSessions = Number(policy?.maxConcurrentSessions);
38438
+ const hasSessionCap = Number.isFinite(maxConcurrentSessions) && maxConcurrentSessions >= 0;
38439
+ nodes.push({
38440
+ nodeId,
38441
+ load: load4,
38442
+ schedulingPriority,
38443
+ ...hasSessionCap ? { maxConcurrentSessions: Math.floor(maxConcurrentSessions) } : {},
38444
+ ...providerRoles ? { providerRoles } : {},
38445
+ capReached: capReasons.length > 0,
38446
+ capReasons
38447
+ });
38448
+ }
38449
+ return {
38450
+ strategy,
38451
+ maxParallelTasks,
38452
+ maxReadonlyParallelTasks,
38453
+ activeWriteAssigned,
38454
+ activeReadonlyAssigned,
38455
+ globalWriteCapReached,
38456
+ globalReadonlyCapReached,
38457
+ nodes
38458
+ };
38459
+ }
38460
+ var init_mesh_scheduling_runtime = __esm2({
38461
+ "src/mesh/mesh-scheduling-runtime.ts"() {
38462
+ "use strict";
38463
+ init_repo_mesh_types();
38464
+ init_dist();
38465
+ }
38466
+ });
38366
38467
  function readNonEmptyString2(value) {
38367
38468
  return typeof value === "string" && value.trim() ? value.trim() : "";
38368
38469
  }
@@ -43619,6 +43720,20 @@ ${cleanBody}`;
43619
43720
  }
43620
43721
  return "";
43621
43722
  }
43723
+ function recoverMeshIdByCoordinatorAndNode(coordinatorDaemonId, nodeId) {
43724
+ if (!coordinatorDaemonId) return "";
43725
+ const hosted = listMeshes().filter((mesh) => {
43726
+ const host = resolveMeshHostStatus(mesh);
43727
+ return host.role === "host" && (!host.hostDaemonId || daemonIdsEquivalent(host.hostDaemonId, coordinatorDaemonId));
43728
+ });
43729
+ if (hosted.length === 0) return "";
43730
+ if (nodeId) {
43731
+ const byNode = hosted.find((mesh) => Array.isArray(mesh.nodes) && mesh.nodes.some((n) => meshNodeIdMatches(n, nodeId)));
43732
+ if (byNode) return readNonEmptyString2(byNode.id);
43733
+ return "";
43734
+ }
43735
+ return hosted.length === 1 ? readNonEmptyString2(hosted[0].id) : "";
43736
+ }
43622
43737
  function resolveForwardEventMeshId(components, payload) {
43623
43738
  const direct = readNonEmptyString2(payload.meshId);
43624
43739
  if (direct) return direct;
@@ -44365,7 +44480,10 @@ ${cleanBody}`;
44365
44480
  }
44366
44481
  const nodeId = readNonEmptyString2(payload.nodeId);
44367
44482
  const workspace = readNonEmptyString2(payload.workspace);
44368
- const meshId = readNonEmptyString2(payload.meshId) || (workspace ? readNonEmptyString2(getCachedMeshByWorkspace(workspace)?.id) : "") || recoverMeshIdByNodeId(nodeId);
44483
+ const meshId = readNonEmptyString2(payload.meshId) || (workspace ? readNonEmptyString2(getCachedMeshByWorkspace(workspace)?.id) : "") || recoverMeshIdByNodeId(nodeId) || recoverMeshIdByCoordinatorAndNode(
44484
+ readNonEmptyString2(payload.meshCoordinatorDaemonId) || readNonEmptyString2(payload.coordinatorDaemonId),
44485
+ nodeId
44486
+ );
44369
44487
  if (!meshId) {
44370
44488
  traceMeshEventDrop("meshId_required", {
44371
44489
  taskId: payload.taskId,
@@ -44420,7 +44538,12 @@ ${cleanBody}`;
44420
44538
  ...event,
44421
44539
  event: eventName,
44422
44540
  nodeId: readNonEmptyString2(routing.nodeId) || readNonEmptyString2(event.meshNodeId) || void 0,
44423
- workspace: readNonEmptyString2(routing.workspace) || readNonEmptyString2(event.workspace) || void 0
44541
+ workspace: readNonEmptyString2(routing.workspace) || readNonEmptyString2(event.workspace) || void 0,
44542
+ // Fix B: carry the resolved coordinator anchor so the coordinator's receive-side
44543
+ // recovery (recoverMeshIdByCoordinatorAndNode) can match this forward to one of the
44544
+ // meshes it hosts when workspace + nodeId both miss. routing.coordinatorDaemonId is
44545
+ // the same anchor this forward is addressed to (coordinatorDaemonId below).
44546
+ meshCoordinatorDaemonId: coordinatorDaemonId
44424
44547
  };
44425
44548
  const resolvedMeshId = resolveForwardEventMeshId(components, payload);
44426
44549
  if (resolvedMeshId) payload.meshId = resolvedMeshId;
@@ -44555,6 +44678,7 @@ ${cleanBody}`;
44555
44678
  init_mesh_runtime_store();
44556
44679
  init_mesh_events_pending();
44557
44680
  init_mesh_routing();
44681
+ init_mesh_host_ownership();
44558
44682
  init_mesh_unresolved_forward_outbox();
44559
44683
  init_mesh_event_trace();
44560
44684
  init_snapshot();
@@ -44842,8 +44966,7 @@ ${cleanBody}`;
44842
44966
  const idleCoordinators = meshCoordinators.filter((c) => c.idle);
44843
44967
  const generatingCoordinators = meshCoordinators.filter((c) => !c.idle && !c.modalParked);
44844
44968
  const modalParkedCoordinators = meshCoordinators.filter((c) => !c.idle && c.modalParked);
44845
- const targetCoordinators = idleCoordinators.length > 0 ? idleCoordinators : generatingCoordinators;
44846
- const forceOnly = idleCoordinators.length === 0;
44969
+ const targetCoordinators = idleCoordinators;
44847
44970
  if (targetCoordinators.length === 0) {
44848
44971
  if (modalParkedCoordinators.length > 0) {
44849
44972
  const liveSessionIds = new Set(
@@ -44910,6 +45033,23 @@ ${cleanBody}`;
44910
45033
  modalParkedCoordinators.length
44911
45034
  );
44912
45035
  }
45036
+ } else if (generatingCoordinators.length > 0) {
45037
+ let hasPending = true;
45038
+ if (store) {
45039
+ try {
45040
+ hasPending = store.pendingEventCount(meshId) > 0;
45041
+ } catch {
45042
+ }
45043
+ }
45044
+ if (hasPending) {
45045
+ LOG2.info("MeshReconcile", `Reconcile skip \u2192 generating: holding pending event(s) for mesh ${meshId} (${generatingCoordinators.length} coordinator(s) busy; events left queued for the next idle tick)`);
45046
+ recordHeldTerminalEventsToLedger(
45047
+ meshId,
45048
+ drainDaemonIds.length > 0 ? drainDaemonIds : localDaemonId ? [localDaemonId] : [],
45049
+ "generating_no_idle_coordinator",
45050
+ generatingCoordinators.length
45051
+ );
45052
+ }
44913
45053
  }
44914
45054
  continue;
44915
45055
  }
@@ -44923,16 +45063,14 @@ ${cleanBody}`;
44923
45063
  try {
44924
45064
  pendingEvents = drainPendingMeshCoordinatorEvents(
44925
45065
  meshId,
44926
- drainDaemonIds.length > 0 ? drainDaemonIds : localDaemonId,
44927
- forceOnly ? { onlyEvents: MESH_FORCE_INJECT_EVENTS } : void 0
45066
+ drainDaemonIds.length > 0 ? drainDaemonIds : localDaemonId
44928
45067
  );
44929
45068
  } catch (e) {
44930
45069
  LOG2.warn("MeshReconcile", `Drain failed for mesh ${meshId}: ${e?.message || e}`);
44931
45070
  continue;
44932
45071
  }
44933
45072
  if (pendingEvents.length === 0) continue;
44934
- const mode = forceOnly ? "force-drain \u2192 generating" : "inject \u2192 idle";
44935
- LOG2.info("MeshReconcile", `Reconcile ${mode}: ${pendingEvents.length} pending event(s) \u2192 ${targetCoordinators.length} coordinator(s) for mesh ${meshId}`);
45073
+ LOG2.info("MeshReconcile", `Reconcile inject \u2192 idle: ${pendingEvents.length} pending event(s) \u2192 ${targetCoordinators.length} coordinator(s) for mesh ${meshId}`);
44936
45074
  for (const pending of pendingEvents) {
44937
45075
  const wantSession = readNonEmptyString2(pending.targetCoordinatorSessionId);
44938
45076
  if (wantSession) {
@@ -53138,98 +53276,7 @@ ${lastSnapshot}`;
53138
53276
  init_mesh_work_queue();
53139
53277
  init_mesh_active_work();
53140
53278
  init_mesh_refine_status();
53141
- init_repo_mesh_types();
53142
- init_dist();
53143
- function isReadonly(task) {
53144
- return task.taskMode === "live_debug_readonly";
53145
- }
53146
- function isAssigned(task) {
53147
- return task.status === "assigned";
53148
- }
53149
- function buildMeshSchedulingRuntime(mesh, queue) {
53150
- const strategy = normalizeMeshSchedulingStrategy(mesh?.policy?.schedulingStrategy);
53151
- const maxParallelTasks = resolveMaxParallelTasks(mesh?.policy?.maxParallelTasks);
53152
- const maxReadonlyParallelTasks = Math.max(2, maxParallelTasks * 2);
53153
- const assignedTasks = (Array.isArray(queue) ? queue : []).filter(isAssigned);
53154
- const activeWriteAssigned = assignedTasks.filter((t) => !isReadonly(t)).length;
53155
- const activeReadonlyAssigned = assignedTasks.filter(isReadonly).length;
53156
- const globalWriteCapReached = activeWriteAssigned >= maxParallelTasks;
53157
- const globalReadonlyCapReached = activeReadonlyAssigned >= maxReadonlyParallelTasks;
53158
- const writeAssignedByNode = /* @__PURE__ */ new Map();
53159
- const assignedByNode = /* @__PURE__ */ new Map();
53160
- const providerCountByNode = /* @__PURE__ */ new Map();
53161
- for (const task of assignedTasks) {
53162
- const nodeId = typeof task.assignedNodeId === "string" ? task.assignedNodeId.trim() : "";
53163
- if (!nodeId) continue;
53164
- assignedByNode.set(nodeId, (assignedByNode.get(nodeId) ?? 0) + 1);
53165
- if (!isReadonly(task)) {
53166
- writeAssignedByNode.set(nodeId, (writeAssignedByNode.get(nodeId) ?? 0) + 1);
53167
- }
53168
- const provider = typeof task.assignedProviderType === "string" ? task.assignedProviderType : "";
53169
- if (provider) {
53170
- let byProvider = providerCountByNode.get(nodeId);
53171
- if (!byProvider) {
53172
- byProvider = /* @__PURE__ */ new Map();
53173
- providerCountByNode.set(nodeId, byProvider);
53174
- }
53175
- byProvider.set(provider, (byProvider.get(provider) ?? 0) + 1);
53176
- }
53177
- }
53178
- const nodes = [];
53179
- for (const rawNode of Array.isArray(mesh?.nodes) ? mesh.nodes : []) {
53180
- const nodeId = normalizeMeshNodeId(rawNode);
53181
- if (!nodeId) continue;
53182
- const policy = rawNode?.policy || void 0;
53183
- const load4 = assignedByNode.get(nodeId) ?? 0;
53184
- const schedulingPriority = resolveNodeSchedulingPriority(policy);
53185
- const capReasons = [];
53186
- if (globalWriteCapReached) capReasons.push("global_max_parallel_tasks_reached");
53187
- if ((writeAssignedByNode.get(nodeId) ?? 0) > 0) capReasons.push("node_has_active_assignment");
53188
- let providerRoles;
53189
- const declaredRoles = Array.isArray(policy?.providerRoles) ? policy.providerRoles : [];
53190
- if (declaredRoles.length) {
53191
- const byProvider = providerCountByNode.get(nodeId);
53192
- providerRoles = [];
53193
- for (const role of declaredRoles) {
53194
- if (!role || typeof role !== "object") continue;
53195
- const providerType = typeof role.providerType === "string" ? role.providerType.trim() : "";
53196
- if (!providerType) continue;
53197
- const maxParallel = resolveProviderMaxParallel(policy, providerType);
53198
- const activeAssigned = byProvider?.get(providerType) ?? 0;
53199
- const capReached = maxParallel !== void 0 && activeAssigned >= maxParallel;
53200
- providerRoles.push({
53201
- providerType,
53202
- ...maxParallel !== void 0 ? { maxParallel } : {},
53203
- activeAssigned,
53204
- capReached
53205
- });
53206
- if (capReached) capReasons.push(`max_provider_parallel_reached:${providerType}`);
53207
- }
53208
- if (!providerRoles.length) providerRoles = void 0;
53209
- }
53210
- const maxConcurrentSessions = Number(policy?.maxConcurrentSessions);
53211
- const hasSessionCap = Number.isFinite(maxConcurrentSessions) && maxConcurrentSessions >= 0;
53212
- nodes.push({
53213
- nodeId,
53214
- load: load4,
53215
- schedulingPriority,
53216
- ...hasSessionCap ? { maxConcurrentSessions: Math.floor(maxConcurrentSessions) } : {},
53217
- ...providerRoles ? { providerRoles } : {},
53218
- capReached: capReasons.length > 0,
53219
- capReasons
53220
- });
53221
- }
53222
- return {
53223
- strategy,
53224
- maxParallelTasks,
53225
- maxReadonlyParallelTasks,
53226
- activeWriteAssigned,
53227
- activeReadonlyAssigned,
53228
- globalWriteCapReached,
53229
- globalReadonlyCapReached,
53230
- nodes
53231
- };
53232
- }
53279
+ init_mesh_scheduling_runtime();
53233
53280
  init_mesh_host_ownership();
53234
53281
  init_mesh_events();
53235
53282
  init_mesh_events_utils();
@@ -68844,9 +68891,35 @@ ${body}
68844
68891
  * terminal state. Leaving meshNodeFor pinned would route this session's
68845
68892
  * subsequent unrelated turns (e.g. ad-hoc dashboard chats) to the
68846
68893
  * coordinator as if they were task completions.
68894
+ *
68895
+ * MESHID-DROP-ON-DETACH (Fix C): a coordinator-LAUNCHED worker session
68896
+ * (launchedByCoordinator) holds its mesh membership (meshNodeFor / meshNodeId /
68897
+ * meshCoordinatorDaemonId) at the SESSION level — set once at launch
68898
+ * (mesh_launch_session / queue auto-launch), independent of any single task.
68899
+ * The original detach wiped meshNodeFor + meshNodeId together with the
68900
+ * task-level meshActiveTaskId, so the FIRST task completion stripped the
68901
+ * membership and EVERY subsequent completion forwarded with meshId absent —
68902
+ * resolveWorkerDelegateRouting fell to mesh_unresolved and the coordinator
68903
+ * rejected the forward "meshId required". For a launched member we therefore
68904
+ * clear ONLY the task-level marker (meshActiveTaskId) and preserve the
68905
+ * session-level membership so its next task's completion still resolves.
68906
+ * A task-less ad-hoc turn on a preserved-membership session is NOT misrouted:
68907
+ * its completion carries no taskId and the session holds no active assignment,
68908
+ * so the forwarder's WARMUPGAP guard skips the dispatch-row flip (it only
68909
+ * injects a benign task-less notification). A NON-launched session (a plain CLI
68910
+ * session adopted by mesh_send_task --direct, launchedByCoordinator falsy)
68911
+ * keeps the original full clear so an ad-hoc session is never left pinned.
68847
68912
  */
68848
68913
  detachMeshAssignment() {
68849
68914
  if (!this.settings.meshNodeFor && !this.settings.meshActiveTaskId && !this.settings.meshNodeId) return;
68915
+ if (this.settings.launchedByCoordinator === true) {
68916
+ if (!this.settings.meshActiveTaskId) return;
68917
+ const { meshActiveTaskId: meshActiveTaskId2, ...rest2 } = this.settings;
68918
+ void meshActiveTaskId2;
68919
+ this.settings = rest2;
68920
+ this.adapter.updateRuntimeSettings?.(this.settings);
68921
+ return;
68922
+ }
68850
68923
  const { meshNodeFor, meshNodeId, meshActiveTaskId, ...rest } = this.settings;
68851
68924
  void meshNodeFor;
68852
68925
  void meshActiveTaskId;
@@ -78651,6 +78724,9 @@ ${ptyResult.output.slice(-2e3)}`);
78651
78724
  const { getMeshQueueStats: getMeshQueueStats2, getQueue: getQueue2 } = await Promise.resolve().then(() => (init_mesh_work_queue(), mesh_work_queue_exports));
78652
78725
  const queue = getQueue2(meshId);
78653
78726
  const queueSummary = getMeshQueueStats2(meshId);
78727
+ const { buildMeshSchedulingRuntime: buildMeshSchedulingRuntime2 } = await Promise.resolve().then(() => (init_mesh_scheduling_runtime(), mesh_scheduling_runtime_exports));
78728
+ const schedulingRuntime = buildMeshSchedulingRuntime2(mesh, queue);
78729
+ const schedulingByNode = new Map(schedulingRuntime.nodes.map((n) => [n.nodeId, n]));
78654
78730
  const { readLedgerEntries: readLedgerEntries2, getLedgerSummary: getLedgerSummary2 } = await Promise.resolve().then(() => (init_mesh_ledger(), mesh_ledger_exports));
78655
78731
  const ledgerEntries = readLedgerEntries2(meshId, { tail: 20 });
78656
78732
  const asyncRefineLedgerEntries = readLedgerEntries2(meshId, { tail: 100 });
@@ -78765,6 +78841,11 @@ ${ptyResult.output.slice(-2e3)}`);
78765
78841
  activeSessionDetails: [],
78766
78842
  launchReady: false
78767
78843
  };
78844
+ const nodeScheduling = schedulingByNode.get(nodeId);
78845
+ if (nodeScheduling) {
78846
+ const { nodeId: _omitNodeId, ...nodeSchedulingRest } = nodeScheduling;
78847
+ status.scheduling = nodeSchedulingRest;
78848
+ }
78768
78849
  if (isSelfNode) {
78769
78850
  status.connection = {
78770
78851
  perspective: "selected_coordinator",
@@ -78965,6 +79046,19 @@ ${ptyResult.output.slice(-2e3)}`);
78965
79046
  branchConvergenceSummary: summarizeInlineMeshBranchConvergence(nodeStatuses),
78966
79047
  ...previewFreshness ? { previewFreshness, deployFreshness: previewFreshness } : {},
78967
79048
  nodes: nodeStatuses,
79049
+ // Mesh-level scheduling rollup (strategy + global cap consumption). Mirrors
79050
+ // the MCP `mesh_status` tool's `scheduling` block field-for-field so both
79051
+ // surfaces read the same runtime; per-node detail lives on each
79052
+ // nodes[].scheduling above.
79053
+ scheduling: {
79054
+ strategy: schedulingRuntime.strategy,
79055
+ maxParallelTasks: schedulingRuntime.maxParallelTasks,
79056
+ maxReadonlyParallelTasks: schedulingRuntime.maxReadonlyParallelTasks,
79057
+ activeWriteAssigned: schedulingRuntime.activeWriteAssigned,
79058
+ activeReadonlyAssigned: schedulingRuntime.activeReadonlyAssigned,
79059
+ globalWriteCapReached: schedulingRuntime.globalWriteCapReached,
79060
+ globalReadonlyCapReached: schedulingRuntime.globalReadonlyCapReached
79061
+ },
78968
79062
  queue: { tasks: queue, summary: queueSummary },
78969
79063
  ledger: { entries: ledgerEntries, summary: ledgerSummary },
78970
79064
  ...missions.length > 0 ? { missions } : {},
@@ -81889,17 +81983,40 @@ ${mergeTreeErr?.stderr || ""}`;
81889
81983
  * the wider plural-shape scan so a controlbar/modal command targeting a non-primary remote
81890
81984
  * session still resolves its owner — the singular readCachedInlineMeshActiveSessions semantics
81891
81985
  * other consumers depend on stay untouched.
81986
+ *
81987
+ * CANCEL-STOP-RELAY: the session-id cache scan above only matches when the coordinator's
81988
+ * cached status snapshot already lists the worker's session id in a recognized active-sessions
81989
+ * shape. A worktree-clone worker session whose id form/timing differs from the cached snapshot
81990
+ * (or is simply not yet reflected) misses the scan, so a stop that carries the authoritative
81991
+ * owning nodeId (mesh_queue_cancel knows assignedNodeId) used to silently fail to forward.
81992
+ * `ownerNodeIdHint` adds a deterministic fallback: when the session-id scan misses, resolve the
81993
+ * owner daemonId by matching the node by id (meshNodeIdMatches — same form-tolerant compare the
81994
+ * rest of the router uses, no new raw compare). The same self-loopback guard applies to both
81995
+ * paths, so a coordinator-hosted node is still never force-forwarded to a remote form of itself.
81892
81996
  */
81893
- resolveRemoteMeshSessionOwnerDaemonId(sessionId) {
81997
+ resolveRemoteMeshSessionOwnerDaemonId(sessionId, ownerNodeIdHint) {
81894
81998
  const trimmed = typeof sessionId === "string" ? sessionId.trim() : "";
81895
- if (!trimmed) return void 0;
81999
+ const nodeHint = typeof ownerNodeIdHint === "string" ? ownerNodeIdHint.trim() : "";
82000
+ if (!trimmed && !nodeHint) return void 0;
81896
82001
  const selfDaemonId = this.deps.statusInstanceId;
81897
- for (const node of this.collectMeshSessionOwnerCandidateNodes()) {
81898
- if (!collectMeshNodeHostedSessionIds(node).has(trimmed)) continue;
81899
- const nodeDaemonId = readMeshNodeDaemonId(readObjectRecord(node));
81900
- if (!nodeDaemonId) continue;
81901
- if (selfDaemonId && daemonIdsEquivalent(nodeDaemonId, selfDaemonId)) return void 0;
81902
- return nodeDaemonId;
82002
+ const candidates = this.collectMeshSessionOwnerCandidateNodes();
82003
+ if (trimmed) {
82004
+ for (const node of candidates) {
82005
+ if (!collectMeshNodeHostedSessionIds(node).has(trimmed)) continue;
82006
+ const nodeDaemonId = readMeshNodeDaemonId(readObjectRecord(node));
82007
+ if (!nodeDaemonId) continue;
82008
+ if (selfDaemonId && daemonIdsEquivalent(nodeDaemonId, selfDaemonId)) return void 0;
82009
+ return nodeDaemonId;
82010
+ }
82011
+ }
82012
+ if (nodeHint) {
82013
+ for (const node of candidates) {
82014
+ if (!meshNodeIdMatches(node, nodeHint)) continue;
82015
+ const nodeDaemonId = readMeshNodeDaemonId(readObjectRecord(node));
82016
+ if (!nodeDaemonId) continue;
82017
+ if (selfDaemonId && daemonIdsEquivalent(nodeDaemonId, selfDaemonId)) return void 0;
82018
+ return nodeDaemonId;
82019
+ }
81903
82020
  }
81904
82021
  return void 0;
81905
82022
  }
@@ -84033,7 +84150,9 @@ ${hintLines.join("\n")}` : "",
84033
84150
  const localInstance = this.deps.instanceManager?.getInstance(targetSessionId);
84034
84151
  const localRegistry = this.deps.sessionRegistry?.get?.(targetSessionId);
84035
84152
  if (!localInstance && !localRegistry) {
84036
- const ownerDaemonId = this.resolveRemoteMeshSessionOwnerDaemonId(targetSessionId);
84153
+ const meshContext = readObjectRecord(args?.meshContext);
84154
+ const ownerNodeIdHint = readStringValue(meshContext.nodeId);
84155
+ const ownerDaemonId = this.resolveRemoteMeshSessionOwnerDaemonId(targetSessionId, ownerNodeIdHint);
84037
84156
  if (ownerDaemonId) {
84038
84157
  LOG2.info("Mesh", `[Mesh] Forwarding session-scoped '${cmd}' for remote worker session ${targetSessionId.split("_")[0]} \u2192 daemon ${ownerDaemonId.slice(0, 12)}`);
84039
84158
  const forwarded = await this.deps.dispatchMeshCommand(ownerDaemonId, cmd, {