@adhdev/daemon-core 0.9.82-rc.63 → 0.9.82-rc.64

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
@@ -25471,6 +25471,9 @@ function normalizeInlineMeshGitStatus(status, node, options) {
25471
25471
  headCommit: readStringValue(status.headCommit) ?? null,
25472
25472
  headMessage: readStringValue(status.headMessage) ?? null,
25473
25473
  upstream: readStringValue(status.upstream) ?? null,
25474
+ upstreamStatus: readStringValue(status.upstreamStatus, status.upstream_status) ?? (readStringValue(status.upstream) ? "unchecked" : "no_upstream"),
25475
+ upstreamFetchedAt: readNumberValue(status.upstreamFetchedAt, status.upstream_fetched_at),
25476
+ upstreamFetchError: readStringValue(status.upstreamFetchError, status.upstream_fetch_error),
25474
25477
  ahead: readNumberValue(status.ahead) ?? 0,
25475
25478
  behind: readNumberValue(status.behind) ?? 0,
25476
25479
  staged: readNumberValue(status.staged) ?? 0,
@@ -25669,8 +25672,11 @@ function reconcileInlineMeshCache(cached, incoming) {
25669
25672
  };
25670
25673
  }
25671
25674
  function hasGitWorktreeChanges(git) {
25672
- if (!git) return false;
25673
- return Number(git.staged || 0) + Number(git.modified || 0) + Number(git.untracked || 0) + Number(git.deleted || 0) + Number(git.renamed || 0) > 0;
25675
+ return countGitWorktreeChanges(git) > 0;
25676
+ }
25677
+ function countGitWorktreeChanges(git) {
25678
+ if (!git) return 0;
25679
+ return Number(git.staged || 0) + Number(git.modified || 0) + Number(git.untracked || 0) + Number(git.deleted || 0) + Number(git.renamed || 0);
25674
25680
  }
25675
25681
  function getGitSubmoduleDriftState(git) {
25676
25682
  const submodules = Array.isArray(git?.submodules) ? git.submodules : [];
@@ -25692,6 +25698,146 @@ function deriveMeshNodeHealthFromGit(git) {
25692
25698
  if (submoduleDrift.dirty || hasGitWorktreeChanges(git)) return "dirty";
25693
25699
  return "online";
25694
25700
  }
25701
+ function readMeshNodeLabel(status, node) {
25702
+ return readStringValue(status.nodeId, node?.id, node?.nodeId) ?? "unknown";
25703
+ }
25704
+ function buildInlineMeshBranchConvergence(args) {
25705
+ const git = readObjectRecord(args.status.git);
25706
+ const nodeLabel = readMeshNodeLabel(args.status, args.node);
25707
+ const defaultBranch = readStringValue(args.mesh?.defaultBranch) ?? "main";
25708
+ const branch = readStringValue(git.branch, args.node?.worktreeBranch) ?? null;
25709
+ const upstream = readStringValue(git.upstream) ?? null;
25710
+ const upstreamStatus = readStringValue(git.upstreamStatus, git.upstream_status) ?? (upstream ? "unchecked" : "no_upstream");
25711
+ const ahead = readNumberValue(git.ahead) ?? 0;
25712
+ const behind = readNumberValue(git.behind) ?? 0;
25713
+ const uncommittedChanges = countGitWorktreeChanges(git);
25714
+ const hasConflicts = readBooleanValue(git.hasConflicts) ?? (Array.isArray(git.conflictFiles) && git.conflictFiles.length > 0);
25715
+ const base = {
25716
+ defaultBranch,
25717
+ branch,
25718
+ upstream,
25719
+ upstreamStatus,
25720
+ ahead,
25721
+ behind,
25722
+ isWorktree: args.node?.isLocalWorktree === true || args.status.isLocalWorktree === true,
25723
+ isDefaultBranch: branch === defaultBranch
25724
+ };
25725
+ if (readBooleanValue(git.isGitRepo) !== true) {
25726
+ return {
25727
+ ...base,
25728
+ status: "blocked_review",
25729
+ needsConvergence: true,
25730
+ reason: "git_status_unavailable",
25731
+ nextStep: `Resolve git status for node '${nodeLabel}' before marking the task complete.`
25732
+ };
25733
+ }
25734
+ if (!branch) {
25735
+ return {
25736
+ ...base,
25737
+ status: "blocked_review",
25738
+ needsConvergence: true,
25739
+ reason: "branch_unknown",
25740
+ nextStep: `Inspect node '${nodeLabel}' git branch before deciding whether it is merged to ${defaultBranch}.`
25741
+ };
25742
+ }
25743
+ if (hasConflicts || uncommittedChanges > 0) {
25744
+ return {
25745
+ ...base,
25746
+ status: "not_mergeable",
25747
+ needsConvergence: true,
25748
+ reason: hasConflicts ? "conflicts_present" : "dirty_workspace",
25749
+ nextStep: `Commit, checkpoint, or resolve node '${nodeLabel}' before any main convergence step.`
25750
+ };
25751
+ }
25752
+ if (branch === defaultBranch) {
25753
+ if (upstream && upstreamStatus !== "fresh") {
25754
+ return {
25755
+ ...base,
25756
+ status: "blocked_review",
25757
+ needsConvergence: true,
25758
+ reason: "default_branch_upstream_unverified",
25759
+ nextStep: `Refresh ${defaultBranch}'s upstream refs or resolve the fetch failure before declaring convergence complete for node '${nodeLabel}'.`
25760
+ };
25761
+ }
25762
+ if (ahead > 0 || behind > 0) {
25763
+ return {
25764
+ ...base,
25765
+ status: "blocked_review",
25766
+ needsConvergence: true,
25767
+ reason: "default_branch_not_even_with_upstream",
25768
+ nextStep: `Bring ${defaultBranch} even with its upstream before declaring convergence complete.`
25769
+ };
25770
+ }
25771
+ return {
25772
+ ...base,
25773
+ status: "merged_to_main",
25774
+ needsConvergence: false,
25775
+ reason: "clean_default_branch",
25776
+ nextStep: null
25777
+ };
25778
+ }
25779
+ if (args.node?.isLocalWorktree === true || args.status.isLocalWorktree === true) {
25780
+ return {
25781
+ ...base,
25782
+ status: "cleanup_candidate",
25783
+ needsConvergence: true,
25784
+ reason: "clean_non_default_worktree_branch",
25785
+ nextStep: `Run mesh_refine_node(node_id: "${nodeLabel}") or explicitly classify this worktree as blocked_review/not_mergeable before ending the task.`
25786
+ };
25787
+ }
25788
+ if (upstream && upstreamStatus !== "fresh") {
25789
+ return {
25790
+ ...base,
25791
+ status: "blocked_review",
25792
+ needsConvergence: true,
25793
+ reason: "feature_branch_upstream_unverified",
25794
+ nextStep: `Refresh branch '${branch}' upstream refs or resolve the fetch failure before deciding whether it is ready to merge into ${defaultBranch}.`
25795
+ };
25796
+ }
25797
+ if (!upstream || ahead > 0 || behind > 0) {
25798
+ return {
25799
+ ...base,
25800
+ status: "blocked_review",
25801
+ needsConvergence: true,
25802
+ reason: !upstream ? "feature_branch_missing_upstream" : "feature_branch_not_even_with_upstream",
25803
+ nextStep: `Push or reconcile branch '${branch}', then merge it into ${defaultBranch} or mark it not_mergeable with a reason.`
25804
+ };
25805
+ }
25806
+ return {
25807
+ ...base,
25808
+ status: "pushed_feature_branch_needs_merge",
25809
+ needsConvergence: true,
25810
+ reason: "clean_non_default_branch",
25811
+ nextStep: `Review and merge branch '${branch}' into ${defaultBranch}; do not report the task as fully complete while it remains off main.`
25812
+ };
25813
+ }
25814
+ function applyInlineMeshBranchConvergence(mesh, node, status) {
25815
+ const git = readObjectRecord(status.git);
25816
+ if (Object.keys(git).length === 0 && !status.gitProbePending) return;
25817
+ const uncommittedChanges = countGitWorktreeChanges(git);
25818
+ status.isDirty = uncommittedChanges > 0;
25819
+ status.uncommittedChanges = uncommittedChanges;
25820
+ status.branchConvergence = buildInlineMeshBranchConvergence({ mesh, node, status });
25821
+ }
25822
+ function summarizeInlineMeshBranchConvergence(nodes) {
25823
+ const followUps = nodes.filter((node) => readObjectRecord(node.branchConvergence).needsConvergence === true).map((node) => {
25824
+ const convergence = readObjectRecord(node.branchConvergence);
25825
+ return {
25826
+ nodeId: node.nodeId,
25827
+ workspace: node.workspace,
25828
+ branch: convergence.branch,
25829
+ status: convergence.status,
25830
+ reason: convergence.reason,
25831
+ nextStep: convergence.nextStep
25832
+ };
25833
+ });
25834
+ return {
25835
+ needsFollowUp: followUps.length > 0,
25836
+ unresolvedCount: followUps.length,
25837
+ requiredFinalStates: ["merged_to_main", "pushed_feature_branch_needs_merge", "blocked_review", "cleanup_candidate", "not_mergeable"],
25838
+ followUps
25839
+ };
25840
+ }
25695
25841
  function readCachedInlineMeshActiveSessions(node) {
25696
25842
  const cachedStatus = readObjectRecord(node?.cachedStatus);
25697
25843
  const activeSession = readObjectRecord(cachedStatus.activeSession);
@@ -26365,6 +26511,7 @@ var DaemonCommandRouter = class {
26365
26511
  const nextStatus = { ...statusNode };
26366
26512
  nextStatus.git = liveGit;
26367
26513
  nextStatus.health = deriveMeshNodeHealthFromGit(liveGit);
26514
+ applyInlineMeshBranchConvergence(mesh, inlineNode, nextStatus);
26368
26515
  nextStatus.launchReady = readBooleanValue(nextStatus.launchReady) ?? true;
26369
26516
  const connection = readObjectRecord(nextStatus.connection);
26370
26517
  const connectionState = readStringValue(connection.state);
@@ -26403,6 +26550,7 @@ var DaemonCommandRouter = class {
26403
26550
  error: "Selected coordinator could not confirm direct mesh truth for every remote node yet."
26404
26551
  } : {},
26405
26552
  sourceOfTruth: nextSourceOfTruth,
26553
+ branchConvergenceSummary: summarizeInlineMeshBranchConvergence(nodes),
26406
26554
  nodes
26407
26555
  };
26408
26556
  }
@@ -29137,11 +29285,13 @@ ${block2}`);
29137
29285
  node,
29138
29286
  pendingPeerGitProbe ? { skipGit: true, skipError: true, skipHealth: true } : void 0
29139
29287
  )) {
29288
+ applyInlineMeshBranchConvergence(mesh, node, status);
29140
29289
  finalizeMeshNodeStatus({ status, node, daemonId, isSelfNode });
29141
29290
  nodeStatuses.push(status);
29142
29291
  continue;
29143
29292
  }
29144
29293
  if (meshRecord?.source === "inline_cache" && !isSelfNode) {
29294
+ applyInlineMeshBranchConvergence(mesh, node, status);
29145
29295
  finalizeMeshNodeStatus({ status, node, daemonId, isSelfNode });
29146
29296
  nodeStatuses.push(status);
29147
29297
  continue;
@@ -29167,6 +29317,7 @@ ${block2}`);
29167
29317
  } else {
29168
29318
  applyCachedInlineMeshNodeStatus(status, node);
29169
29319
  }
29320
+ applyInlineMeshBranchConvergence(mesh, node, status);
29170
29321
  finalizeMeshNodeStatus({ status, node, daemonId, isSelfNode });
29171
29322
  nodeStatuses.push(status);
29172
29323
  }
@@ -29202,6 +29353,7 @@ ${block2}`);
29202
29353
  } : {},
29203
29354
  historicalEvidenceOnly: ["recoveryHints", "ledger.summary", "queue.summary"]
29204
29355
  },
29356
+ branchConvergenceSummary: summarizeInlineMeshBranchConvergence(nodeStatuses),
29205
29357
  nodes: nodeStatuses,
29206
29358
  queue: { tasks: queue, summary: queueSummary },
29207
29359
  ledger: { entries: ledgerEntries, summary: ledgerSummary }