@adhdev/daemon-core 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.mjs CHANGED
@@ -3063,27 +3063,46 @@ Do NOT retry on this node. Consider reassigning to a different node or asking th
3063
3063
  const jobId = readRefineJobId({ metadataEvent: args.metadataEvent });
3064
3064
  const result = readRecord(args.metadataEvent.result);
3065
3065
  const validationSummary = readRecord(result?.validationSummary);
3066
+ const patchEquivalence = readRecord(result?.patchEquivalence);
3067
+ const finalConvergence = readRecord(result?.finalBranchConvergenceState);
3066
3068
  const validationStatus = readNonEmptyString2(validationSummary?.status);
3069
+ const patchStatus = readNonEmptyString2(patchEquivalence?.status) || (patchEquivalence?.equivalent === true ? "passed" : "");
3067
3070
  const into = readNonEmptyString2(result?.into);
3068
3071
  const branch = readNonEmptyString2(result?.branch);
3072
+ const mergeStatus = result?.merged === true ? "merged" : readNonEmptyString2(finalConvergence?.status);
3073
+ const convergenceStatus = readNonEmptyString2(finalConvergence?.status);
3074
+ const nextStep = readNonEmptyString2(result?.nextStep) || readNonEmptyString2(finalConvergence?.nextStep) || "Continue from the updated mesh state.";
3069
3075
  const details = [
3070
3076
  jobId ? `job_id=${jobId}` : "",
3071
3077
  branch && into ? `${branch}\u2192${into}` : "",
3072
- validationStatus ? `validation=${validationStatus}` : ""
3078
+ validationStatus ? `validation=${validationStatus}` : "",
3079
+ patchStatus ? `patch_equivalence=${patchStatus}` : "",
3080
+ mergeStatus ? `merge=${mergeStatus}` : "",
3081
+ convergenceStatus ? `final_convergence=${convergenceStatus}` : ""
3073
3082
  ].filter(Boolean).join("; ");
3074
- 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.`;
3083
+ return `[System] Refinery async job for ${args.nodeLabel} completed successfully${details ? ` (${details})` : ""}.
3084
+ Next step: ${nextStep}`;
3075
3085
  }
3076
3086
  if (args.event === "refine:failed") {
3077
3087
  const jobId = readRefineJobId({ metadataEvent: args.metadataEvent });
3078
3088
  const result = readRecord(args.metadataEvent.result);
3089
+ const validationSummary = readRecord(result?.validationSummary);
3090
+ const patchEquivalence = readRecord(result?.patchEquivalence);
3091
+ const finalConvergence = readRecord(result?.finalBranchConvergenceState);
3079
3092
  const code = readNonEmptyString2(result?.code);
3080
3093
  const error = readNonEmptyString2(result?.error);
3081
- const convergenceStatus = readNonEmptyString2(result?.convergenceStatus);
3094
+ const validationStatus = readNonEmptyString2(validationSummary?.status);
3095
+ const patchStatus = readNonEmptyString2(patchEquivalence?.status) || (patchEquivalence?.equivalent === true ? "passed" : "");
3096
+ const mergeStatus = result?.merged === true ? "merged" : finalConvergence?.merged === false ? "not_merged" : "";
3097
+ const convergenceStatus = readNonEmptyString2(result?.convergenceStatus) || readNonEmptyString2(finalConvergence?.status);
3082
3098
  const blockedReason = readNonEmptyString2(result?.blockedReason);
3083
- const nextStep = readNonEmptyString2(result?.nextStep) || readNonEmptyString2(readRecord(result?.finalBranchConvergenceState)?.nextStep);
3099
+ const nextStep = readNonEmptyString2(result?.nextStep) || readNonEmptyString2(finalConvergence?.nextStep);
3084
3100
  const details = [
3085
3101
  jobId ? `job_id=${jobId}` : "",
3086
3102
  code ? `code=${code}` : "",
3103
+ validationStatus ? `validation=${validationStatus}` : "",
3104
+ patchStatus ? `patch_equivalence=${patchStatus}` : "",
3105
+ mergeStatus ? `merge=${mergeStatus}` : "",
3087
3106
  convergenceStatus ? `convergence=${convergenceStatus}` : "",
3088
3107
  blockedReason ? `reason=${blockedReason}` : ""
3089
3108
  ].filter(Boolean).join("; ");
@@ -3309,6 +3328,13 @@ function injectMeshSystemMessage(components, args) {
3309
3328
  LOG.warn("MeshRecovery", `Failed to build recovery context: ${e?.message || e}`);
3310
3329
  }
3311
3330
  }
3331
+ const messageText = buildMeshSystemMessage({
3332
+ event: args.event,
3333
+ nodeLabel: args.nodeLabel,
3334
+ metadataEvent: args.metadataEvent,
3335
+ recoveryContext
3336
+ });
3337
+ if (!messageText) return { success: false, error: "unsupported mesh event" };
3312
3338
  const coordinatorInstances = components.instanceManager.getByCategory("cli").filter((inst) => {
3313
3339
  const instState = inst.getState();
3314
3340
  if (instState.settings?.meshCoordinatorFor !== args.meshId) return false;
@@ -3326,19 +3352,13 @@ function injectMeshSystemMessage(components, args) {
3326
3352
  ...args.metadataEvent,
3327
3353
  ...recoveryContext ? { recoveryContext } : {}
3328
3354
  },
3355
+ coordinatorMessage: messageText,
3329
3356
  queuedAt: Date.now()
3330
3357
  })) {
3331
3358
  LOG.info("MeshEvents", `Queued ${args.event} for MCP coordinator (mesh ${args.meshId})`);
3332
3359
  }
3333
3360
  return { success: true, forwarded: 0 };
3334
3361
  }
3335
- const messageText = buildMeshSystemMessage({
3336
- event: args.event,
3337
- nodeLabel: args.nodeLabel,
3338
- metadataEvent: args.metadataEvent,
3339
- recoveryContext
3340
- });
3341
- if (!messageText) return { success: false, error: "unsupported mesh event" };
3342
3362
  for (const coord of coordinatorInstances) {
3343
3363
  const coordState = coord.getState();
3344
3364
  LOG.info("MeshEvents", `Forwarding mesh event to coordinator ${coordState.instanceId}`);
@@ -25553,7 +25573,7 @@ async function maybeRunDaemonUpgradeHelperFromEnv() {
25553
25573
 
25554
25574
  // src/commands/router.ts
25555
25575
  init_mesh_work_queue();
25556
- import { homedir as homedir19, tmpdir as tmpdir5 } from "os";
25576
+ import { homedir as homedir19 } from "os";
25557
25577
  import { basename as pathBasename, join as pathJoin, resolve as pathResolve } from "path";
25558
25578
  import * as fs11 from "fs";
25559
25579
  var CHANNEL_NPM_TAG = { stable: "latest", preview: "next" };
@@ -26465,16 +26485,9 @@ async function runMeshRefineSubmoduleReachabilityGate(repoRoot, mergedTree) {
26465
26485
  });
26466
26486
  return String(stdout || "");
26467
26487
  };
26468
- const verifyRemoteMainContainsCommit = async (remoteUrl, commit, branch = "main") => {
26469
- const probeDir = fs11.mkdtempSync(pathJoin(tmpdir5(), "adhdev-submodule-reachability-"));
26470
- try {
26471
- await runGit2(probeDir, ["init", "-q"]);
26472
- await runGit2(probeDir, ["-c", "protocol.file.allow=always", "fetch", "--depth=1", remoteUrl, `refs/heads/${branch}:refs/remotes/origin/${branch}`]);
26473
- await runGit2(probeDir, ["cat-file", "-e", `${commit}^{commit}`]);
26474
- await runGit2(probeDir, ["merge-base", "--is-ancestor", commit, `refs/remotes/origin/${branch}`]);
26475
- } finally {
26476
- fs11.rmSync(probeDir, { recursive: true, force: true });
26477
- }
26488
+ const verifyRemoteMainContainsCommit = async (submodulePath, commit, branch = "main") => {
26489
+ await runGit2(submodulePath, ["-c", "protocol.file.allow=always", "fetch", "origin", `refs/heads/${branch}:refs/remotes/origin/${branch}`]);
26490
+ await runGit2(submodulePath, ["merge-base", "--is-ancestor", commit, `refs/remotes/origin/${branch}`]);
26478
26491
  };
26479
26492
  const treeOutput = await runGit2(repoRoot, ["ls-tree", "-r", "-z", mergedTree]);
26480
26493
  const gitlinks = treeOutput.split("\0").filter(Boolean).map((record) => {
@@ -26516,7 +26529,7 @@ async function runMeshRefineSubmoduleReachabilityGate(repoRoot, mergedTree) {
26516
26529
  continue;
26517
26530
  }
26518
26531
  entry.remoteMainBranch = "main";
26519
- await verifyRemoteMainContainsCommit(remoteUrl, gitlink.commit, "main");
26532
+ await verifyRemoteMainContainsCommit(submodulePath, gitlink.commit, "main");
26520
26533
  entry.fetchedFromOrigin = true;
26521
26534
  entry.remoteReachable = true;
26522
26535
  entry.remoteMainReachable = true;
@@ -27501,28 +27514,51 @@ var DaemonCommandRouter = class {
27501
27514
  };
27502
27515
  }
27503
27516
  queueRefineJobEvent(event, handle, result) {
27504
- queuePendingMeshCoordinatorEvent({
27517
+ const metadataEvent = {
27518
+ source: "refine_mesh_node_async_job",
27519
+ jobId: handle.jobId,
27520
+ interactionId: handle.interactionId,
27521
+ meshId: handle.meshId,
27522
+ nodeId: handle.targetNodeId,
27523
+ targetDaemonId: handle.targetDaemonId,
27524
+ workspace: handle.workspace,
27525
+ status: handle.status,
27526
+ startedAt: handle.startedAt,
27527
+ completedAt: handle.completedAt,
27528
+ retryOfJobId: handle.retryOfJobId,
27529
+ ...result ? { result } : {}
27530
+ };
27531
+ const eventPayload = {
27505
27532
  event,
27506
27533
  meshId: handle.meshId,
27507
27534
  nodeLabel: handle.targetNodeId,
27508
27535
  nodeId: handle.targetNodeId,
27509
27536
  workspace: handle.workspace,
27510
- metadataEvent: {
27511
- source: "refine_mesh_node_async_job",
27512
- jobId: handle.jobId,
27513
- interactionId: handle.interactionId,
27514
- meshId: handle.meshId,
27515
- nodeId: handle.targetNodeId,
27516
- targetDaemonId: handle.targetDaemonId,
27517
- workspace: handle.workspace,
27518
- status: handle.status,
27519
- startedAt: handle.startedAt,
27520
- completedAt: handle.completedAt,
27521
- retryOfJobId: handle.retryOfJobId,
27522
- ...result ? { result } : {}
27523
- },
27537
+ metadataEvent,
27524
27538
  queuedAt: Date.now()
27525
- });
27539
+ };
27540
+ if (typeof this.deps.instanceManager?.getByCategory === "function") {
27541
+ const forwarded = handleMeshForwardEvent(
27542
+ { instanceManager: this.deps.instanceManager },
27543
+ {
27544
+ event,
27545
+ meshId: handle.meshId,
27546
+ nodeId: handle.targetNodeId,
27547
+ workspace: handle.workspace,
27548
+ jobId: handle.jobId,
27549
+ interactionId: handle.interactionId,
27550
+ status: handle.status,
27551
+ targetDaemonId: handle.targetDaemonId,
27552
+ startedAt: handle.startedAt,
27553
+ completedAt: handle.completedAt,
27554
+ retryOfJobId: handle.retryOfJobId,
27555
+ ...result ? { result } : {}
27556
+ }
27557
+ );
27558
+ if (forwarded?.success === true) return;
27559
+ LOG.warn("Mesh", `[Refinery] Failed to forward async refine event ${event}: ${forwarded?.error || "unknown error"}`);
27560
+ }
27561
+ queuePendingMeshCoordinatorEvent(eventPayload);
27526
27562
  }
27527
27563
  async appendRefineJobLedger(kind, handle, result) {
27528
27564
  try {