@adhdev/daemon-standalone 0.9.82-rc.63 → 0.9.82-rc.65

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
@@ -47374,6 +47374,7 @@ ${(0, import_node_path.resolve)(workspace || os17.tmpdir())}`;
47374
47374
  meshId: readStringValue(status?.meshId, status?.mesh_id) ?? null,
47375
47375
  refreshedAt: readStringValue(status?.refreshedAt, status?.refreshed_at) ?? null,
47376
47376
  sourceOfTruth: status?.sourceOfTruth ?? null,
47377
+ branchConvergenceSummary: status?.branchConvergenceSummary ?? status?.branch_convergence_summary ?? null,
47377
47378
  nodeCount: nodes.length,
47378
47379
  nodes: nodes.map((node) => ({
47379
47380
  nodeId: readStringValue(node?.nodeId, node?.id) ?? null,
@@ -47389,7 +47390,8 @@ ${(0, import_node_path.resolve)(workspace || os17.tmpdir())}`;
47389
47390
  } : null,
47390
47391
  gitProbePending: node?.gitProbePending === true,
47391
47392
  launchReady: node?.launchReady === true,
47392
- git: summarizeRepoMeshDebugGit(node?.git)
47393
+ git: summarizeRepoMeshDebugGit(node?.git),
47394
+ branchConvergence: node?.branchConvergence ?? node?.branch_convergence ?? null
47393
47395
  }))
47394
47396
  };
47395
47397
  }
@@ -47444,6 +47446,9 @@ ${(0, import_node_path.resolve)(workspace || os17.tmpdir())}`;
47444
47446
  headCommit: readStringValue(status.headCommit) ?? null,
47445
47447
  headMessage: readStringValue(status.headMessage) ?? null,
47446
47448
  upstream: readStringValue(status.upstream) ?? null,
47449
+ upstreamStatus: readStringValue(status.upstreamStatus, status.upstream_status) ?? (readStringValue(status.upstream) ? "unchecked" : "no_upstream"),
47450
+ upstreamFetchedAt: readNumberValue(status.upstreamFetchedAt, status.upstream_fetched_at),
47451
+ upstreamFetchError: readStringValue(status.upstreamFetchError, status.upstream_fetch_error),
47447
47452
  ahead: readNumberValue(status.ahead) ?? 0,
47448
47453
  behind: readNumberValue(status.behind) ?? 0,
47449
47454
  staged: readNumberValue(status.staged) ?? 0,
@@ -47642,8 +47647,11 @@ ${(0, import_node_path.resolve)(workspace || os17.tmpdir())}`;
47642
47647
  };
47643
47648
  }
47644
47649
  function hasGitWorktreeChanges(git) {
47645
- if (!git) return false;
47646
- return Number(git.staged || 0) + Number(git.modified || 0) + Number(git.untracked || 0) + Number(git.deleted || 0) + Number(git.renamed || 0) > 0;
47650
+ return countGitWorktreeChanges(git) > 0;
47651
+ }
47652
+ function countGitWorktreeChanges(git) {
47653
+ if (!git) return 0;
47654
+ return Number(git.staged || 0) + Number(git.modified || 0) + Number(git.untracked || 0) + Number(git.deleted || 0) + Number(git.renamed || 0);
47647
47655
  }
47648
47656
  function getGitSubmoduleDriftState(git) {
47649
47657
  const submodules = Array.isArray(git?.submodules) ? git.submodules : [];
@@ -47665,6 +47673,146 @@ ${(0, import_node_path.resolve)(workspace || os17.tmpdir())}`;
47665
47673
  if (submoduleDrift.dirty || hasGitWorktreeChanges(git)) return "dirty";
47666
47674
  return "online";
47667
47675
  }
47676
+ function readMeshNodeLabel(status, node) {
47677
+ return readStringValue(status.nodeId, node?.id, node?.nodeId) ?? "unknown";
47678
+ }
47679
+ function buildInlineMeshBranchConvergence(args) {
47680
+ const git = readObjectRecord(args.status.git);
47681
+ const nodeLabel = readMeshNodeLabel(args.status, args.node);
47682
+ const defaultBranch = readStringValue(args.mesh?.defaultBranch) ?? "main";
47683
+ const branch = readStringValue(git.branch, args.node?.worktreeBranch) ?? null;
47684
+ const upstream = readStringValue(git.upstream) ?? null;
47685
+ const upstreamStatus = readStringValue(git.upstreamStatus, git.upstream_status) ?? (upstream ? "unchecked" : "no_upstream");
47686
+ const ahead = readNumberValue(git.ahead) ?? 0;
47687
+ const behind = readNumberValue(git.behind) ?? 0;
47688
+ const uncommittedChanges = countGitWorktreeChanges(git);
47689
+ const hasConflicts = readBooleanValue(git.hasConflicts) ?? (Array.isArray(git.conflictFiles) && git.conflictFiles.length > 0);
47690
+ const base = {
47691
+ defaultBranch,
47692
+ branch,
47693
+ upstream,
47694
+ upstreamStatus,
47695
+ ahead,
47696
+ behind,
47697
+ isWorktree: args.node?.isLocalWorktree === true || args.status.isLocalWorktree === true,
47698
+ isDefaultBranch: branch === defaultBranch
47699
+ };
47700
+ if (readBooleanValue(git.isGitRepo) !== true) {
47701
+ return {
47702
+ ...base,
47703
+ status: "blocked_review",
47704
+ needsConvergence: true,
47705
+ reason: "git_status_unavailable",
47706
+ nextStep: `Resolve git status for node '${nodeLabel}' before marking the task complete.`
47707
+ };
47708
+ }
47709
+ if (!branch) {
47710
+ return {
47711
+ ...base,
47712
+ status: "blocked_review",
47713
+ needsConvergence: true,
47714
+ reason: "branch_unknown",
47715
+ nextStep: `Inspect node '${nodeLabel}' git branch before deciding whether it is merged to ${defaultBranch}.`
47716
+ };
47717
+ }
47718
+ if (hasConflicts || uncommittedChanges > 0) {
47719
+ return {
47720
+ ...base,
47721
+ status: "not_mergeable",
47722
+ needsConvergence: true,
47723
+ reason: hasConflicts ? "conflicts_present" : "dirty_workspace",
47724
+ nextStep: `Commit, checkpoint, or resolve node '${nodeLabel}' before any main convergence step.`
47725
+ };
47726
+ }
47727
+ if (branch === defaultBranch) {
47728
+ if (upstream && upstreamStatus !== "fresh") {
47729
+ return {
47730
+ ...base,
47731
+ status: "blocked_review",
47732
+ needsConvergence: true,
47733
+ reason: "default_branch_upstream_unverified",
47734
+ nextStep: `Refresh ${defaultBranch}'s upstream refs or resolve the fetch failure before declaring convergence complete for node '${nodeLabel}'.`
47735
+ };
47736
+ }
47737
+ if (ahead > 0 || behind > 0) {
47738
+ return {
47739
+ ...base,
47740
+ status: "blocked_review",
47741
+ needsConvergence: true,
47742
+ reason: "default_branch_not_even_with_upstream",
47743
+ nextStep: `Bring ${defaultBranch} even with its upstream before declaring convergence complete.`
47744
+ };
47745
+ }
47746
+ return {
47747
+ ...base,
47748
+ status: "merged_to_main",
47749
+ needsConvergence: false,
47750
+ reason: "clean_default_branch",
47751
+ nextStep: null
47752
+ };
47753
+ }
47754
+ if (args.node?.isLocalWorktree === true || args.status.isLocalWorktree === true) {
47755
+ return {
47756
+ ...base,
47757
+ status: "cleanup_candidate",
47758
+ needsConvergence: true,
47759
+ reason: "clean_non_default_worktree_branch",
47760
+ nextStep: `Run mesh_refine_node(node_id: "${nodeLabel}") or explicitly classify this worktree as blocked_review/not_mergeable before ending the task.`
47761
+ };
47762
+ }
47763
+ if (upstream && upstreamStatus !== "fresh") {
47764
+ return {
47765
+ ...base,
47766
+ status: "blocked_review",
47767
+ needsConvergence: true,
47768
+ reason: "feature_branch_upstream_unverified",
47769
+ nextStep: `Refresh branch '${branch}' upstream refs or resolve the fetch failure before deciding whether it is ready to merge into ${defaultBranch}.`
47770
+ };
47771
+ }
47772
+ if (!upstream || ahead > 0 || behind > 0) {
47773
+ return {
47774
+ ...base,
47775
+ status: "blocked_review",
47776
+ needsConvergence: true,
47777
+ reason: !upstream ? "feature_branch_missing_upstream" : "feature_branch_not_even_with_upstream",
47778
+ nextStep: `Push or reconcile branch '${branch}', then merge it into ${defaultBranch} or mark it not_mergeable with a reason.`
47779
+ };
47780
+ }
47781
+ return {
47782
+ ...base,
47783
+ status: "pushed_feature_branch_needs_merge",
47784
+ needsConvergence: true,
47785
+ reason: "clean_non_default_branch",
47786
+ nextStep: `Review and merge branch '${branch}' into ${defaultBranch}; do not report the task as fully complete while it remains off main.`
47787
+ };
47788
+ }
47789
+ function applyInlineMeshBranchConvergence(mesh, node, status) {
47790
+ const git = readObjectRecord(status.git);
47791
+ if (Object.keys(git).length === 0 && !status.gitProbePending) return;
47792
+ const uncommittedChanges = countGitWorktreeChanges(git);
47793
+ status.isDirty = uncommittedChanges > 0;
47794
+ status.uncommittedChanges = uncommittedChanges;
47795
+ status.branchConvergence = buildInlineMeshBranchConvergence({ mesh, node, status });
47796
+ }
47797
+ function summarizeInlineMeshBranchConvergence(nodes) {
47798
+ const followUps = nodes.filter((node) => readObjectRecord(node.branchConvergence).needsConvergence === true).map((node) => {
47799
+ const convergence = readObjectRecord(node.branchConvergence);
47800
+ return {
47801
+ nodeId: node.nodeId,
47802
+ workspace: node.workspace,
47803
+ branch: convergence.branch,
47804
+ status: convergence.status,
47805
+ reason: convergence.reason,
47806
+ nextStep: convergence.nextStep
47807
+ };
47808
+ });
47809
+ return {
47810
+ needsFollowUp: followUps.length > 0,
47811
+ unresolvedCount: followUps.length,
47812
+ requiredFinalStates: ["merged_to_main", "pushed_feature_branch_needs_merge", "blocked_review", "cleanup_candidate", "not_mergeable"],
47813
+ followUps
47814
+ };
47815
+ }
47668
47816
  function readCachedInlineMeshActiveSessions(node) {
47669
47817
  const cachedStatus = readObjectRecord(node?.cachedStatus);
47670
47818
  const activeSession = readObjectRecord(cachedStatus.activeSession);
@@ -47745,7 +47893,7 @@ ${(0, import_node_path.resolve)(workspace || os17.tmpdir())}`;
47745
47893
  async function probeRemoteMeshGitStatus(args) {
47746
47894
  if (!args.dispatchMeshCommand) return null;
47747
47895
  const remoteResult = await Promise.race([
47748
- args.dispatchMeshCommand(args.daemonId, "git_status", { workspace: args.workspace }),
47896
+ args.dispatchMeshCommand(args.daemonId, "git_status", { workspace: args.workspace, refreshUpstream: true }),
47749
47897
  new Promise((_, reject) => setTimeout(() => reject(new Error("timeout")), args.timeoutMs))
47750
47898
  ]);
47751
47899
  const remoteGit = remoteResult?.status ?? remoteResult?.git ?? remoteResult;
@@ -48338,6 +48486,7 @@ ${(0, import_node_path.resolve)(workspace || os17.tmpdir())}`;
48338
48486
  const nextStatus = { ...statusNode };
48339
48487
  nextStatus.git = liveGit;
48340
48488
  nextStatus.health = deriveMeshNodeHealthFromGit(liveGit);
48489
+ applyInlineMeshBranchConvergence(mesh, inlineNode, nextStatus);
48341
48490
  nextStatus.launchReady = readBooleanValue(nextStatus.launchReady) ?? true;
48342
48491
  const connection = readObjectRecord(nextStatus.connection);
48343
48492
  const connectionState = readStringValue(connection.state);
@@ -48376,6 +48525,7 @@ ${(0, import_node_path.resolve)(workspace || os17.tmpdir())}`;
48376
48525
  error: "Selected coordinator could not confirm direct mesh truth for every remote node yet."
48377
48526
  } : {},
48378
48527
  sourceOfTruth: nextSourceOfTruth,
48528
+ branchConvergenceSummary: summarizeInlineMeshBranchConvergence(nodes),
48379
48529
  nodes
48380
48530
  };
48381
48531
  }
@@ -51110,11 +51260,13 @@ ${block2}`);
51110
51260
  node,
51111
51261
  pendingPeerGitProbe ? { skipGit: true, skipError: true, skipHealth: true } : void 0
51112
51262
  )) {
51263
+ applyInlineMeshBranchConvergence(mesh, node, status);
51113
51264
  finalizeMeshNodeStatus({ status, node, daemonId, isSelfNode });
51114
51265
  nodeStatuses.push(status);
51115
51266
  continue;
51116
51267
  }
51117
51268
  if (meshRecord?.source === "inline_cache" && !isSelfNode) {
51269
+ applyInlineMeshBranchConvergence(mesh, node, status);
51118
51270
  finalizeMeshNodeStatus({ status, node, daemonId, isSelfNode });
51119
51271
  nodeStatuses.push(status);
51120
51272
  continue;
@@ -51140,6 +51292,7 @@ ${block2}`);
51140
51292
  } else {
51141
51293
  applyCachedInlineMeshNodeStatus(status, node);
51142
51294
  }
51295
+ applyInlineMeshBranchConvergence(mesh, node, status);
51143
51296
  finalizeMeshNodeStatus({ status, node, daemonId, isSelfNode });
51144
51297
  nodeStatuses.push(status);
51145
51298
  }
@@ -51175,6 +51328,7 @@ ${block2}`);
51175
51328
  } : {},
51176
51329
  historicalEvidenceOnly: ["recoveryHints", "ledger.summary", "queue.summary"]
51177
51330
  },
51331
+ branchConvergenceSummary: summarizeInlineMeshBranchConvergence(nodeStatuses),
51178
51332
  nodes: nodeStatuses,
51179
51333
  queue: { tasks: queue, summary: queueSummary },
51180
51334
  ledger: { entries: ledgerEntries, summary: ledgerSummary }