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