@adhdev/daemon-standalone 1.0.49-rc.2 → 1.0.49-rc.3

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
@@ -37056,10 +37056,10 @@ var require_dist3 = __commonJS({
37056
37056
  }
37057
37057
  function getDaemonBuildInfo() {
37058
37058
  if (cached2) return cached2;
37059
- const commit = readInjected(true ? "48ce5d9b7420dbc3520cd6c7ddee34af47c23627" : void 0) ?? "unknown";
37060
- const commitShort = readInjected(true ? "48ce5d9b" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
37061
- const version2 = readInjected(true ? "1.0.49-rc.2" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
37062
- const builtAt = readInjected(true ? "2026-08-14T06:05:14.635Z" : void 0);
37059
+ const commit = readInjected(true ? "a102f64d5a470598fb2ef67d1942a1dc2e42384d" : void 0) ?? "unknown";
37060
+ const commitShort = readInjected(true ? "a102f64d" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
37061
+ const version2 = readInjected(true ? "1.0.49-rc.3" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
37062
+ const builtAt = readInjected(true ? "2026-08-14T08:12:25.976Z" : void 0);
37063
37063
  cached2 = builtAt ? { commit, commitShort, version: version2, builtAt } : { commit, commitShort, version: version2 };
37064
37064
  return cached2;
37065
37065
  }
@@ -113669,6 +113669,7 @@ ${ptyResult.output.slice(-2e3)}`);
113669
113669
  init_dist();
113670
113670
  init_mesh_events();
113671
113671
  init_mesh_reconcile_identity();
113672
+ init_mesh_reconcile_acked_hold();
113672
113673
  init_mesh_fast_forward();
113673
113674
  var import_node_child_process7 = require("child_process");
113674
113675
  var import_node_util5 = require("util");
@@ -115671,11 +115672,20 @@ ${mergeTreeErr?.stderr || ""}`;
115671
115672
  LOG2.warn("Mesh", `[Refinery] Failed to append async refine ledger entry: ${e?.message || e}`);
115672
115673
  }
115673
115674
  }
115675
+ function resolveRefineResumeDispatchGraceMs() {
115676
+ return resolveTunedReconcileMs("MESH_REFINE_RESUME_DISPATCH_GRACE_MS", 6e4, 0, 10 * 6e4);
115677
+ }
115678
+ function resolveRefineResumeZombieCutoffMs() {
115679
+ return resolveTunedReconcileMs("MESH_REFINE_RESUME_ZOMBIE_CUTOFF_MS", 24 * 60 * 6e4, 5 * 6e4, 30 * 24 * 60 * 6e4);
115680
+ }
115674
115681
  async function resumePendingRefineJobsOnStartup(self) {
115675
115682
  try {
115676
115683
  const { listMeshes: listMeshes2 } = await Promise.resolve().then(() => (init_mesh_config(), mesh_config_exports));
115677
115684
  const { readLedgerEntries: readLedgerEntries2 } = await Promise.resolve().then(() => (init_mesh_ledger(), mesh_ledger_exports));
115678
115685
  const meshIds = listMeshes2().map((m) => m.id).filter(Boolean);
115686
+ const nowMs = Date.now();
115687
+ const dispatchGraceMs = resolveRefineResumeDispatchGraceMs();
115688
+ const zombieCutoffMs = resolveRefineResumeZombieCutoffMs();
115679
115689
  for (const meshId of meshIds) {
115680
115690
  const entries = readLedgerEntries2(meshId, { kind: ["task_dispatched", "task_completed", "task_failed"] });
115681
115691
  const terminal = /* @__PURE__ */ new Set();
@@ -115693,10 +115703,44 @@ ${mergeTreeErr?.stderr || ""}`;
115693
115703
  if (!jobId || terminal.has(`${e.nodeId}:${jobId}`)) continue;
115694
115704
  const key2 = buildRefineJobKey(self, meshId, e.nodeId);
115695
115705
  if (self.runningRefineJobs.has(key2)) continue;
115706
+ const dispatchedAtMs = new Date(e.timestamp).getTime();
115707
+ const ageMs2 = Number.isFinite(dispatchedAtMs) ? nowMs - dispatchedAtMs : void 0;
115708
+ if (ageMs2 !== void 0 && ageMs2 >= 0 && ageMs2 < dispatchGraceMs) {
115709
+ LOG2.info("Mesh", `[Refinery] Deferring resume of refine job for node ${e.nodeId} (jobId=${jobId}) \u2014 dispatched ${ageMs2}ms ago, within the ${dispatchGraceMs}ms grace window; may still be running.`);
115710
+ continue;
115711
+ }
115712
+ if (ageMs2 !== void 0 && ageMs2 >= zombieCutoffMs) {
115713
+ const node = e.payload?.refineJob;
115714
+ const coordinatorDaemonId2 = node?.targetCoordinatorDaemonId;
115715
+ const coordinatorSessionId2 = node?.targetCoordinatorSessionId;
115716
+ const zombieHandle = buildRefineJobHandle(self, {
115717
+ meshId,
115718
+ nodeId: e.nodeId,
115719
+ jobId,
115720
+ interactionId: typeof node?.interactionId === "string" ? node.interactionId : void 0,
115721
+ status: "failed",
115722
+ startedAt: typeof node?.startedAt === "string" ? node.startedAt : e.timestamp,
115723
+ completedAt: (/* @__PURE__ */ new Date()).toISOString(),
115724
+ coordinatorDaemonId: coordinatorDaemonId2,
115725
+ coordinatorSessionId: coordinatorSessionId2
115726
+ });
115727
+ LOG2.warn("Mesh", `[Refinery] Closing out stale refine job for node ${e.nodeId} (jobId=${jobId}) as failed \u2014 dispatched ${ageMs2}ms ago, past the ${zombieCutoffMs}ms zombie cutoff with no terminal entry; not resuming.`);
115728
+ const zombieResult = {
115729
+ success: false,
115730
+ code: "resume_abandoned_stale_dispatch",
115731
+ error: `Refine job dispatched at ${e.timestamp} never reached a terminal state and exceeded the ${zombieCutoffMs}ms zombie cutoff on daemon restart; closed out without resuming.`
115732
+ };
115733
+ await appendRefineJobLedger(self, "task_failed", zombieHandle, zombieResult);
115734
+ queueRefineJobEvent(self, "refine:failed", zombieHandle, zombieResult);
115735
+ continue;
115736
+ }
115696
115737
  const coordinatorDaemonId = e.payload?.refineJob?.targetCoordinatorDaemonId;
115738
+ const coordinatorSessionId = e.payload?.refineJob?.targetCoordinatorSessionId;
115697
115739
  LOG2.info("Mesh", `[Refinery] Auto-resuming interrupted refine job for node ${e.nodeId} (jobId=${jobId})`);
115698
115740
  void startMeshRefineJob(self, meshId, e.nodeId, {
115699
- coordinatorDaemonId
115741
+ jobId,
115742
+ coordinatorDaemonId,
115743
+ coordinatorSessionId
115700
115744
  });
115701
115745
  }
115702
115746
  }
@@ -117420,7 +117464,7 @@ ${e?.stderr || ""}`;
117420
117464
  const terminal = self.terminalRefineJobs.get(key2);
117421
117465
  const alreadyRunning = self.runningRefineJobs.get(key2);
117422
117466
  if (alreadyRunning) return { ...alreadyRunning, duplicate: true };
117423
- const jobId = `refine_${createInteractionId()}`;
117467
+ const jobId = typeof args?.jobId === "string" && args.jobId.trim() ? args.jobId.trim() : `refine_${createInteractionId()}`;
117424
117468
  const interactionId = createInteractionId();
117425
117469
  const placeholder = buildRefineJobHandle(self, { meshId, nodeId, jobId, interactionId, retryOfJobId: terminal?.jobId });
117426
117470
  self.runningRefineJobs.set(key2, placeholder);