@adhdev/daemon-standalone 0.9.82-rc.78 → 0.9.82-rc.79

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
@@ -25218,27 +25218,46 @@ Do NOT retry on this node. Consider reassigning to a different node or asking th
25218
25218
  const jobId = readRefineJobId({ metadataEvent: args.metadataEvent });
25219
25219
  const result = readRecord(args.metadataEvent.result);
25220
25220
  const validationSummary = readRecord(result?.validationSummary);
25221
+ const patchEquivalence = readRecord(result?.patchEquivalence);
25222
+ const finalConvergence = readRecord(result?.finalBranchConvergenceState);
25221
25223
  const validationStatus = readNonEmptyString2(validationSummary?.status);
25224
+ const patchStatus = readNonEmptyString2(patchEquivalence?.status) || (patchEquivalence?.equivalent === true ? "passed" : "");
25222
25225
  const into = readNonEmptyString2(result?.into);
25223
25226
  const branch = readNonEmptyString2(result?.branch);
25227
+ const mergeStatus = result?.merged === true ? "merged" : readNonEmptyString2(finalConvergence?.status);
25228
+ const convergenceStatus = readNonEmptyString2(finalConvergence?.status);
25229
+ const nextStep = readNonEmptyString2(result?.nextStep) || readNonEmptyString2(finalConvergence?.nextStep) || "Continue from the updated mesh state.";
25224
25230
  const details = [
25225
25231
  jobId ? `job_id=${jobId}` : "",
25226
25232
  branch && into ? `${branch}\u2192${into}` : "",
25227
- validationStatus ? `validation=${validationStatus}` : ""
25233
+ validationStatus ? `validation=${validationStatus}` : "",
25234
+ patchStatus ? `patch_equivalence=${patchStatus}` : "",
25235
+ mergeStatus ? `merge=${mergeStatus}` : "",
25236
+ convergenceStatus ? `final_convergence=${convergenceStatus}` : ""
25228
25237
  ].filter(Boolean).join("; ");
25229
- return `[System] Refinery async job for ${args.nodeLabel} completed successfully${details ? ` (${details})` : ""}. The worktree was merged and cleanup completed; continue from the updated mesh state.`;
25238
+ return `[System] Refinery async job for ${args.nodeLabel} completed successfully${details ? ` (${details})` : ""}.
25239
+ Next step: ${nextStep}`;
25230
25240
  }
25231
25241
  if (args.event === "refine:failed") {
25232
25242
  const jobId = readRefineJobId({ metadataEvent: args.metadataEvent });
25233
25243
  const result = readRecord(args.metadataEvent.result);
25244
+ const validationSummary = readRecord(result?.validationSummary);
25245
+ const patchEquivalence = readRecord(result?.patchEquivalence);
25246
+ const finalConvergence = readRecord(result?.finalBranchConvergenceState);
25234
25247
  const code = readNonEmptyString2(result?.code);
25235
25248
  const error48 = readNonEmptyString2(result?.error);
25236
- const convergenceStatus = readNonEmptyString2(result?.convergenceStatus);
25249
+ const validationStatus = readNonEmptyString2(validationSummary?.status);
25250
+ const patchStatus = readNonEmptyString2(patchEquivalence?.status) || (patchEquivalence?.equivalent === true ? "passed" : "");
25251
+ const mergeStatus = result?.merged === true ? "merged" : finalConvergence?.merged === false ? "not_merged" : "";
25252
+ const convergenceStatus = readNonEmptyString2(result?.convergenceStatus) || readNonEmptyString2(finalConvergence?.status);
25237
25253
  const blockedReason = readNonEmptyString2(result?.blockedReason);
25238
- const nextStep = readNonEmptyString2(result?.nextStep) || readNonEmptyString2(readRecord(result?.finalBranchConvergenceState)?.nextStep);
25254
+ const nextStep = readNonEmptyString2(result?.nextStep) || readNonEmptyString2(finalConvergence?.nextStep);
25239
25255
  const details = [
25240
25256
  jobId ? `job_id=${jobId}` : "",
25241
25257
  code ? `code=${code}` : "",
25258
+ validationStatus ? `validation=${validationStatus}` : "",
25259
+ patchStatus ? `patch_equivalence=${patchStatus}` : "",
25260
+ mergeStatus ? `merge=${mergeStatus}` : "",
25242
25261
  convergenceStatus ? `convergence=${convergenceStatus}` : "",
25243
25262
  blockedReason ? `reason=${blockedReason}` : ""
25244
25263
  ].filter(Boolean).join("; ");
@@ -25464,6 +25483,13 @@ Do NOT retry on this node. Consider reassigning to a different node or asking th
25464
25483
  LOG2.warn("MeshRecovery", `Failed to build recovery context: ${e?.message || e}`);
25465
25484
  }
25466
25485
  }
25486
+ const messageText = buildMeshSystemMessage({
25487
+ event: args.event,
25488
+ nodeLabel: args.nodeLabel,
25489
+ metadataEvent: args.metadataEvent,
25490
+ recoveryContext
25491
+ });
25492
+ if (!messageText) return { success: false, error: "unsupported mesh event" };
25467
25493
  const coordinatorInstances = components.instanceManager.getByCategory("cli").filter((inst) => {
25468
25494
  const instState = inst.getState();
25469
25495
  if (instState.settings?.meshCoordinatorFor !== args.meshId) return false;
@@ -25481,19 +25507,13 @@ Do NOT retry on this node. Consider reassigning to a different node or asking th
25481
25507
  ...args.metadataEvent,
25482
25508
  ...recoveryContext ? { recoveryContext } : {}
25483
25509
  },
25510
+ coordinatorMessage: messageText,
25484
25511
  queuedAt: Date.now()
25485
25512
  })) {
25486
25513
  LOG2.info("MeshEvents", `Queued ${args.event} for MCP coordinator (mesh ${args.meshId})`);
25487
25514
  }
25488
25515
  return { success: true, forwarded: 0 };
25489
25516
  }
25490
- const messageText = buildMeshSystemMessage({
25491
- event: args.event,
25492
- nodeLabel: args.nodeLabel,
25493
- metadataEvent: args.metadataEvent,
25494
- recoveryContext
25495
- });
25496
- if (!messageText) return { success: false, error: "unsupported mesh event" };
25497
25517
  for (const coord of coordinatorInstances) {
25498
25518
  const coordState = coord.getState();
25499
25519
  LOG2.info("MeshEvents", `Forwarding mesh event to coordinator ${coordState.instanceId}`);
@@ -48691,16 +48711,9 @@ ${(0, import_node_path.resolve)(workspace || os17.tmpdir())}`;
48691
48711
  });
48692
48712
  return String(stdout || "");
48693
48713
  };
48694
- const verifyRemoteMainContainsCommit = async (remoteUrl, commit, branch = "main") => {
48695
- const probeDir = fs11.mkdtempSync((0, import_path8.join)((0, import_os3.tmpdir)(), "adhdev-submodule-reachability-"));
48696
- try {
48697
- await runGit2(probeDir, ["init", "-q"]);
48698
- await runGit2(probeDir, ["-c", "protocol.file.allow=always", "fetch", "--depth=1", remoteUrl, `refs/heads/${branch}:refs/remotes/origin/${branch}`]);
48699
- await runGit2(probeDir, ["cat-file", "-e", `${commit}^{commit}`]);
48700
- await runGit2(probeDir, ["merge-base", "--is-ancestor", commit, `refs/remotes/origin/${branch}`]);
48701
- } finally {
48702
- fs11.rmSync(probeDir, { recursive: true, force: true });
48703
- }
48714
+ const verifyRemoteMainContainsCommit = async (submodulePath, commit, branch = "main") => {
48715
+ await runGit2(submodulePath, ["-c", "protocol.file.allow=always", "fetch", "origin", `refs/heads/${branch}:refs/remotes/origin/${branch}`]);
48716
+ await runGit2(submodulePath, ["merge-base", "--is-ancestor", commit, `refs/remotes/origin/${branch}`]);
48704
48717
  };
48705
48718
  const treeOutput = await runGit2(repoRoot, ["ls-tree", "-r", "-z", mergedTree]);
48706
48719
  const gitlinks = treeOutput.split("\0").filter(Boolean).map((record2) => {
@@ -48742,7 +48755,7 @@ ${(0, import_node_path.resolve)(workspace || os17.tmpdir())}`;
48742
48755
  continue;
48743
48756
  }
48744
48757
  entry.remoteMainBranch = "main";
48745
- await verifyRemoteMainContainsCommit(remoteUrl, gitlink.commit, "main");
48758
+ await verifyRemoteMainContainsCommit(submodulePath, gitlink.commit, "main");
48746
48759
  entry.fetchedFromOrigin = true;
48747
48760
  entry.remoteReachable = true;
48748
48761
  entry.remoteMainReachable = true;
@@ -49727,28 +49740,51 @@ ${(0, import_node_path.resolve)(workspace || os17.tmpdir())}`;
49727
49740
  };
49728
49741
  }
49729
49742
  queueRefineJobEvent(event, handle, result) {
49730
- queuePendingMeshCoordinatorEvent({
49743
+ const metadataEvent = {
49744
+ source: "refine_mesh_node_async_job",
49745
+ jobId: handle.jobId,
49746
+ interactionId: handle.interactionId,
49747
+ meshId: handle.meshId,
49748
+ nodeId: handle.targetNodeId,
49749
+ targetDaemonId: handle.targetDaemonId,
49750
+ workspace: handle.workspace,
49751
+ status: handle.status,
49752
+ startedAt: handle.startedAt,
49753
+ completedAt: handle.completedAt,
49754
+ retryOfJobId: handle.retryOfJobId,
49755
+ ...result ? { result } : {}
49756
+ };
49757
+ const eventPayload = {
49731
49758
  event,
49732
49759
  meshId: handle.meshId,
49733
49760
  nodeLabel: handle.targetNodeId,
49734
49761
  nodeId: handle.targetNodeId,
49735
49762
  workspace: handle.workspace,
49736
- metadataEvent: {
49737
- source: "refine_mesh_node_async_job",
49738
- jobId: handle.jobId,
49739
- interactionId: handle.interactionId,
49740
- meshId: handle.meshId,
49741
- nodeId: handle.targetNodeId,
49742
- targetDaemonId: handle.targetDaemonId,
49743
- workspace: handle.workspace,
49744
- status: handle.status,
49745
- startedAt: handle.startedAt,
49746
- completedAt: handle.completedAt,
49747
- retryOfJobId: handle.retryOfJobId,
49748
- ...result ? { result } : {}
49749
- },
49763
+ metadataEvent,
49750
49764
  queuedAt: Date.now()
49751
- });
49765
+ };
49766
+ if (typeof this.deps.instanceManager?.getByCategory === "function") {
49767
+ const forwarded = handleMeshForwardEvent(
49768
+ { instanceManager: this.deps.instanceManager },
49769
+ {
49770
+ event,
49771
+ meshId: handle.meshId,
49772
+ nodeId: handle.targetNodeId,
49773
+ workspace: handle.workspace,
49774
+ jobId: handle.jobId,
49775
+ interactionId: handle.interactionId,
49776
+ status: handle.status,
49777
+ targetDaemonId: handle.targetDaemonId,
49778
+ startedAt: handle.startedAt,
49779
+ completedAt: handle.completedAt,
49780
+ retryOfJobId: handle.retryOfJobId,
49781
+ ...result ? { result } : {}
49782
+ }
49783
+ );
49784
+ if (forwarded?.success === true) return;
49785
+ LOG2.warn("Mesh", `[Refinery] Failed to forward async refine event ${event}: ${forwarded?.error || "unknown error"}`);
49786
+ }
49787
+ queuePendingMeshCoordinatorEvent(eventPayload);
49752
49788
  }
49753
49789
  async appendRefineJobLedger(kind, handle, result) {
49754
49790
  try {