@adhdev/daemon-core 0.9.77-rc.46 → 0.9.77-rc.48

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.
@@ -1,10 +1,12 @@
1
1
  /**
2
- * Mesh Sync — Sync local mesh config to/from cloud D1
2
+ * Mesh Sync — Sync local mesh metadata to/from cloud D1
3
3
  *
4
4
  * When cloud is available, this module pushes local mesh config
5
5
  * to the server and pulls remote meshes that were created from
6
6
  * other machines. The local ~/.adhdev/meshes.json remains the
7
- * canonical source; cloud is a persistence/relay layer.
7
+ * canonical source; cloud is a membership/metadata layer only.
8
+ * Task/chat/ledger evidence remains local-first and must not be
9
+ * synchronized through Cloud/D1.
8
10
  *
9
11
  * This is called lazily (not on daemon startup) — only when the
10
12
  * user explicitly opens the mesh page or runs `adhdev mesh sync`.
@@ -26,12 +28,6 @@ export interface MeshSyncTransport {
26
28
  }>;
27
29
  /** DELETE /api/v1/repo-meshes/:id */
28
30
  deleteRemoteMesh(meshId: string): Promise<void>;
29
- /** POST /api/v1/repo-meshes/:id/ledger/sync */
30
- syncMeshLedger?(meshId: string, data: {
31
- newEntries: any[];
32
- }): Promise<{
33
- missingEntries: any[];
34
- }>;
35
31
  }
36
32
  export interface RemoteMeshRecord {
37
33
  id: string;
@@ -55,7 +51,3 @@ export interface MeshSyncResult {
55
51
  * Pull remote meshes that don't exist locally.
56
52
  */
57
53
  export declare function syncMeshes(transport: MeshSyncTransport): Promise<MeshSyncResult>;
58
- /**
59
- * Sync the task ledger for a specific mesh.
60
- */
61
- export declare function syncMeshLedger(meshId: string, transport: MeshSyncTransport): Promise<void>;
@@ -1,4 +1,8 @@
1
1
  export type MeshTaskStatus = 'pending' | 'assigned' | 'completed' | 'failed' | 'cancelled';
2
+ export type MeshActiveTaskStatus = Extract<MeshTaskStatus, 'pending' | 'assigned'>;
3
+ export type MeshHistoricalTaskStatus = Extract<MeshTaskStatus, 'completed' | 'failed' | 'cancelled'>;
4
+ export declare const ACTIVE_MESH_QUEUE_STATUSES: MeshActiveTaskStatus[];
5
+ export declare const HISTORICAL_MESH_QUEUE_STATUSES: MeshHistoricalTaskStatus[];
2
6
  export interface MeshWorkQueueEntry {
3
7
  id: string;
4
8
  meshId: string;
@@ -84,6 +88,10 @@ export interface MeshWorkQueueStats {
84
88
  completed: number;
85
89
  failed: number;
86
90
  cancelled: number;
91
+ /** Source-of-truth active queue counters; only pending/assigned are live work. */
92
+ activeCounts: Record<MeshActiveTaskStatus, number>;
93
+ /** Terminal ledger records kept for audit/history; never count as active work. */
94
+ historicalCounts: Record<MeshHistoricalTaskStatus, number>;
87
95
  activeAssignments: Array<{
88
96
  id: string;
89
97
  nodeId?: string;
@@ -301,6 +301,15 @@ export interface SessionEntry {
301
301
  completed: number;
302
302
  failed: number;
303
303
  cancelled?: number;
304
+ activeCounts?: {
305
+ pending: number;
306
+ assigned: number;
307
+ };
308
+ historicalCounts?: {
309
+ completed: number;
310
+ failed: number;
311
+ cancelled: number;
312
+ };
304
313
  activeAssignments?: Array<{
305
314
  id: string;
306
315
  nodeId?: string;
@@ -355,6 +364,15 @@ export interface CompactSessionEntry {
355
364
  completed: number;
356
365
  failed: number;
357
366
  cancelled?: number;
367
+ activeCounts?: {
368
+ pending: number;
369
+ assigned: number;
370
+ };
371
+ historicalCounts?: {
372
+ completed: number;
373
+ failed: number;
374
+ cancelled: number;
375
+ };
358
376
  activeAssignments?: Array<{
359
377
  id: string;
360
378
  nodeId?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adhdev/daemon-core",
3
- "version": "0.9.77-rc.46",
3
+ "version": "0.9.77-rc.48",
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",
@@ -1825,12 +1825,23 @@ export class DaemonCommandRouter {
1825
1825
  const meshId = typeof args?.meshId === 'string' ? args.meshId.trim() : '';
1826
1826
  if (!meshId) return { success: false, error: 'meshId required' };
1827
1827
  try {
1828
- const { getQueue } = await import('../mesh/mesh-work-queue.js');
1828
+ const { getMeshQueueStats, getQueue } = await import('../mesh/mesh-work-queue.js');
1829
1829
  const status = Array.isArray(args?.status)
1830
1830
  ? args.status.map((s: any) => typeof s === 'string' ? s.trim() : '').filter(Boolean)
1831
1831
  : undefined;
1832
1832
  const queue = getQueue(meshId, { status: status as any });
1833
- return { success: true, queue };
1833
+ const summary = getMeshQueueStats(meshId);
1834
+ return {
1835
+ success: true,
1836
+ queue,
1837
+ summary,
1838
+ sourceOfTruth: {
1839
+ kind: 'mesh_work_queue_file',
1840
+ activeStatuses: ['pending', 'assigned'],
1841
+ historicalStatuses: ['completed', 'failed', 'cancelled'],
1842
+ notes: 'pending/assigned are active work; completed/failed/cancelled are historical records.',
1843
+ },
1844
+ };
1834
1845
  } catch (e: any) {
1835
1846
  return { success: false, error: e.message };
1836
1847
  }
@@ -1,10 +1,12 @@
1
1
  /**
2
- * Mesh Sync — Sync local mesh config to/from cloud D1
2
+ * Mesh Sync — Sync local mesh metadata to/from cloud D1
3
3
  *
4
4
  * When cloud is available, this module pushes local mesh config
5
5
  * to the server and pulls remote meshes that were created from
6
6
  * other machines. The local ~/.adhdev/meshes.json remains the
7
- * canonical source; cloud is a persistence/relay layer.
7
+ * canonical source; cloud is a membership/metadata layer only.
8
+ * Task/chat/ledger evidence remains local-first and must not be
9
+ * synchronized through Cloud/D1.
8
10
  *
9
11
  * This is called lazily (not on daemon startup) — only when the
10
12
  * user explicitly opens the mesh page or runs `adhdev mesh sync`.
@@ -26,8 +28,6 @@ export interface MeshSyncTransport {
26
28
  }): Promise<{ mesh: RemoteMeshRecord }>;
27
29
  /** DELETE /api/v1/repo-meshes/:id */
28
30
  deleteRemoteMesh(meshId: string): Promise<void>;
29
- /** POST /api/v1/repo-meshes/:id/ledger/sync */
30
- syncMeshLedger?(meshId: string, data: { newEntries: any[] }): Promise<{ missingEntries: any[] }>;
31
31
  }
32
32
 
33
33
  export interface RemoteMeshRecord {
@@ -107,35 +107,5 @@ export async function syncMeshes(transport: MeshSyncTransport): Promise<MeshSync
107
107
  }
108
108
  }
109
109
 
110
- // Sync ledgers for all local meshes if the transport supports it
111
- if (transport.syncMeshLedger) {
112
- for (const local of localMeshes) {
113
- try {
114
- await syncMeshLedger(local.id, transport);
115
- } catch (e: any) {
116
- result.errors.push(`Ledger sync failed for "${local.name}": ${e.message}`);
117
- }
118
- }
119
- }
120
-
121
110
  return result;
122
111
  }
123
-
124
- /**
125
- * Sync the task ledger for a specific mesh.
126
- */
127
- export async function syncMeshLedger(meshId: string, transport: MeshSyncTransport): Promise<void> {
128
- if (!transport.syncMeshLedger) return;
129
- const { readLedgerEntries, appendRemoteLedgerEntries } = await import('./mesh-ledger.js');
130
-
131
- // Read all local entries (no tail)
132
- const localEntries = readLedgerEntries(meshId);
133
-
134
- // Send to cloud and get missing entries back
135
- const res = await transport.syncMeshLedger(meshId, { newEntries: localEntries });
136
-
137
- // Append any missing entries from the cloud
138
- if (res.missingEntries && res.missingEntries.length > 0) {
139
- appendRemoteLedgerEntries(meshId, res.missingEntries);
140
- }
141
- }
@@ -4,6 +4,11 @@ import { randomUUID } from 'crypto';
4
4
  import { getLedgerDir } from './mesh-ledger.js';
5
5
 
6
6
  export type MeshTaskStatus = 'pending' | 'assigned' | 'completed' | 'failed' | 'cancelled';
7
+ export type MeshActiveTaskStatus = Extract<MeshTaskStatus, 'pending' | 'assigned'>;
8
+ export type MeshHistoricalTaskStatus = Extract<MeshTaskStatus, 'completed' | 'failed' | 'cancelled'>;
9
+
10
+ export const ACTIVE_MESH_QUEUE_STATUSES: MeshActiveTaskStatus[] = ['pending', 'assigned'];
11
+ export const HISTORICAL_MESH_QUEUE_STATUSES: MeshHistoricalTaskStatus[] = ['completed', 'failed', 'cancelled'];
7
12
 
8
13
  export interface MeshWorkQueueEntry {
9
14
  id: string;
@@ -260,6 +265,10 @@ export interface MeshWorkQueueStats {
260
265
  completed: number;
261
266
  failed: number;
262
267
  cancelled: number;
268
+ /** Source-of-truth active queue counters; only pending/assigned are live work. */
269
+ activeCounts: Record<MeshActiveTaskStatus, number>;
270
+ /** Terminal ledger records kept for audit/history; never count as active work. */
271
+ historicalCounts: Record<MeshHistoricalTaskStatus, number>;
263
272
  activeAssignments: Array<{
264
273
  id: string;
265
274
  nodeId?: string;
@@ -287,6 +296,15 @@ export function getMeshQueueStats(meshId: string): MeshWorkQueueStats {
287
296
  completed,
288
297
  failed,
289
298
  cancelled,
299
+ activeCounts: {
300
+ pending,
301
+ assigned,
302
+ },
303
+ historicalCounts: {
304
+ completed,
305
+ failed,
306
+ cancelled,
307
+ },
290
308
  activeAssignments: queue
291
309
  .filter(q => q.status === 'assigned')
292
310
  .map(q => ({
@@ -398,6 +398,15 @@ export interface SessionEntry {
398
398
  completed: number;
399
399
  failed: number;
400
400
  cancelled?: number;
401
+ activeCounts?: {
402
+ pending: number;
403
+ assigned: number;
404
+ };
405
+ historicalCounts?: {
406
+ completed: number;
407
+ failed: number;
408
+ cancelled: number;
409
+ };
401
410
  activeAssignments?: Array<{
402
411
  id: string;
403
412
  nodeId?: string;
@@ -453,6 +462,15 @@ export interface CompactSessionEntry {
453
462
  completed: number;
454
463
  failed: number;
455
464
  cancelled?: number;
465
+ activeCounts?: {
466
+ pending: number;
467
+ assigned: number;
468
+ };
469
+ historicalCounts?: {
470
+ completed: number;
471
+ failed: number;
472
+ cancelled: number;
473
+ };
456
474
  activeAssignments?: Array<{
457
475
  id: string;
458
476
  nodeId?: string;