@adhdev/daemon-core 0.9.82-rc.43 → 0.9.82-rc.44

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adhdev/daemon-core",
3
- "version": "0.9.82-rc.43",
3
+ "version": "0.9.82-rc.44",
4
4
  "description": "ADHDev daemon core — CDP, IDE detection, providers, command execution",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -114,6 +114,75 @@ function readBooleanValue(...values: unknown[]): boolean | undefined {
114
114
  return undefined;
115
115
  }
116
116
 
117
+ function summarizeRepoMeshDebugGit(git: unknown): Record<string, unknown> | null {
118
+ const record = readObjectRecord(git);
119
+ if (!Object.keys(record).length) return null;
120
+ const submodules = Array.isArray(record.submodules)
121
+ ? record.submodules.map((entry: any) => ({
122
+ path: readStringValue(entry?.path) ?? null,
123
+ commit: readStringValue(entry?.commit)?.slice(0, 12) ?? null,
124
+ dirty: readBooleanValue(entry?.dirty) ?? false,
125
+ outOfSync: readBooleanValue(entry?.outOfSync, entry?.out_of_sync) ?? false,
126
+ }))
127
+ : [];
128
+ return {
129
+ isGitRepo: readBooleanValue(record.isGitRepo),
130
+ workspace: readStringValue(record.workspace) ?? null,
131
+ repoRoot: readStringValue(record.repoRoot, record.repo_root) ?? null,
132
+ branch: readStringValue(record.branch) ?? null,
133
+ upstream: readStringValue(record.upstream) ?? null,
134
+ upstreamStatus: readStringValue(record.upstreamStatus, record.upstream_status) ?? null,
135
+ headCommit: readStringValue(record.headCommit, record.head_commit)?.slice(0, 12) ?? null,
136
+ ahead: readNumberValue(record.ahead) ?? null,
137
+ behind: readNumberValue(record.behind) ?? null,
138
+ dirtyCounts: {
139
+ staged: readNumberValue(record.staged) ?? 0,
140
+ modified: readNumberValue(record.modified) ?? 0,
141
+ untracked: readNumberValue(record.untracked) ?? 0,
142
+ deleted: readNumberValue(record.deleted) ?? 0,
143
+ renamed: readNumberValue(record.renamed) ?? 0,
144
+ },
145
+ lastCheckedAt: readNumberValue(record.lastCheckedAt, record.last_checked_at) ?? null,
146
+ submoduleCount: submodules.length,
147
+ submodules,
148
+ };
149
+ }
150
+
151
+ function summarizeRepoMeshStatusDebug(status: any): Record<string, unknown> {
152
+ const nodes = Array.isArray(status?.nodes) ? status.nodes : [];
153
+ return {
154
+ success: status?.success,
155
+ meshId: readStringValue(status?.meshId, status?.mesh_id) ?? null,
156
+ refreshedAt: readStringValue(status?.refreshedAt, status?.refreshed_at) ?? null,
157
+ sourceOfTruth: status?.sourceOfTruth ?? null,
158
+ nodeCount: nodes.length,
159
+ nodes: nodes.map((node: any) => ({
160
+ nodeId: readStringValue(node?.nodeId, node?.id) ?? null,
161
+ daemonId: readStringValue(node?.daemonId, node?.daemon_id) ?? null,
162
+ workspace: readStringValue(node?.workspace, node?.git?.workspace) ?? null,
163
+ health: readStringValue(node?.health) ?? null,
164
+ machineStatus: readStringValue(node?.machineStatus, node?.machine_status) ?? null,
165
+ connection: node?.connection && typeof node.connection === 'object' ? {
166
+ state: readStringValue(node.connection.state) ?? null,
167
+ transport: readStringValue(node.connection.transport) ?? null,
168
+ source: readStringValue(node.connection.source) ?? null,
169
+ reported: readBooleanValue(node.connection.reported) ?? null,
170
+ } : null,
171
+ gitProbePending: node?.gitProbePending === true,
172
+ launchReady: node?.launchReady === true,
173
+ git: summarizeRepoMeshDebugGit(node?.git),
174
+ })),
175
+ };
176
+ }
177
+
178
+ function logRepoMeshStatusDebug(event: string, fields: Record<string, unknown>): void {
179
+ try {
180
+ LOG.info('MeshStatusDebug', `[RepoMeshStatusDebug] ${JSON.stringify({ event, ...fields })}`);
181
+ } catch {
182
+ LOG.info('MeshStatusDebug', `[RepoMeshStatusDebug] ${event}`);
183
+ }
184
+ }
185
+
117
186
  function joinRepoPath(root: string | undefined, relativePath: string | undefined): string | undefined {
118
187
  const normalizedRoot = typeof root === 'string' ? root.trim().replace(/[\\/]+$/, '') : '';
119
188
  const normalizedPath = typeof relativePath === 'string' ? relativePath.trim() : '';
@@ -3726,7 +3795,15 @@ export class DaemonCommandRouter {
3726
3795
  const refreshRequested = args?.refresh === true || args?.forceRefresh === true;
3727
3796
  if (!refreshRequested) {
3728
3797
  const cachedStatus = this.getCachedAggregateMeshStatus(meshId);
3729
- if (cachedStatus) return cachedStatus;
3798
+ if (cachedStatus) {
3799
+ logRepoMeshStatusDebug('return_cached', {
3800
+ meshId,
3801
+ command: 'mesh_status',
3802
+ refreshRequested,
3803
+ summary: summarizeRepoMeshStatusDebug(cachedStatus),
3804
+ });
3805
+ return cachedStatus;
3806
+ }
3730
3807
  }
3731
3808
  const refreshReason = refreshRequested ? 'explicit_refresh' : 'cold_cache_miss';
3732
3809
 
@@ -3761,7 +3838,7 @@ export class DaemonCommandRouter {
3761
3838
  };
3762
3839
  const directTruthSatisfied = meshRecord.source !== 'inline_bootstrap' || directTruth.directEvidenceCount > 0;
3763
3840
  if (requireDirectPeerTruth && !directTruthSatisfied) {
3764
- return {
3841
+ const failureResult = {
3765
3842
  success: false,
3766
3843
  code: 'mesh_direct_peer_truth_unavailable',
3767
3844
  error: 'Selected coordinator could not confirm direct mesh truth yet. Bootstrap inventory stays unavailable until direct mesh_status probes succeed.',
@@ -3784,6 +3861,14 @@ export class DaemonCommandRouter {
3784
3861
  },
3785
3862
  },
3786
3863
  };
3864
+ logRepoMeshStatusDebug('direct_truth_unavailable', {
3865
+ meshId,
3866
+ command: 'mesh_status',
3867
+ refreshRequested,
3868
+ meshSource: meshRecord.source,
3869
+ directTruth,
3870
+ });
3871
+ return failureResult;
3787
3872
  }
3788
3873
  const directTruthUnavailableNodeIds = new Set(directTruth.unavailableNodeIds);
3789
3874
  const selectedCoordinatorNodeId = readStringValue(
@@ -4019,7 +4104,17 @@ export class DaemonCommandRouter {
4019
4104
  queue: { tasks: queue, summary: queueSummary },
4020
4105
  ledger: { entries: ledgerEntries, summary: ledgerSummary },
4021
4106
  };
4022
- return this.rememberAggregateMeshStatus(meshId, statusResult, refreshReason);
4107
+ const rememberedStatus = this.rememberAggregateMeshStatus(meshId, statusResult, refreshReason);
4108
+ logRepoMeshStatusDebug('return_live', {
4109
+ meshId,
4110
+ command: 'mesh_status',
4111
+ refreshRequested,
4112
+ refreshReason,
4113
+ meshSource: meshRecord.source,
4114
+ directTruth,
4115
+ summary: summarizeRepoMeshStatusDebug(rememberedStatus),
4116
+ });
4117
+ return rememberedStatus;
4023
4118
  } catch (e: any) {
4024
4119
  return { success: false, error: e.message };
4025
4120
  }