@adhdev/daemon-standalone 0.9.82-rc.326 → 0.9.82-rc.328

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-standalone",
3
- "version": "0.9.82-rc.326",
3
+ "version": "0.9.82-rc.328",
4
4
  "description": "ADHDev standalone daemon — embedded HTTP/WS server for local dashboard",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -3203,39 +3203,17 @@ async function meshPruneStaleDirect(ctx, args = {}) {
3203
3203
  const liveNodes = await collectMeshViewQueueNodesWithLiveSessions(ctx);
3204
3204
  const ledgerEntries = (0, import_daemon_core.readLedgerEntries)(ctx.mesh.id, { tail: 500 });
3205
3205
  const directDispatches = (0, import_daemon_core.getActiveDirectDispatches)(ctx.mesh.id);
3206
- const activeWorkEvidence = (0, import_daemon_core.buildMeshActiveWork)({
3206
+ const result = (0, import_daemon_core.pruneStaleDirectDispatches)({
3207
3207
  meshId: ctx.mesh.id,
3208
3208
  queue: (0, import_daemon_core.getQueue)(ctx.mesh.id),
3209
3209
  ledgerEntries,
3210
3210
  directDispatches,
3211
3211
  nodes: liveNodes,
3212
- includeTerminalDirect: includeTerminal
3212
+ execute,
3213
+ includeTerminal,
3214
+ source: "mesh_prune_stale_direct"
3213
3215
  });
3214
- const candidates = [
3215
- ...activeWorkEvidence.staleDirectWork,
3216
- ...includeTerminal ? activeWorkEvidence.terminalDirectWork : []
3217
- ];
3218
- const storeTaskIds = new Set(directDispatches.map((d) => d.taskId));
3219
- const prunable = [];
3220
- const preservedUnacknowledged = [];
3221
- const preservedLedgerOnly = [];
3222
- const preservedNotOrphan = [];
3223
- for (const record of candidates) {
3224
- const classification = (0, import_daemon_core.classifyStaleDirectForPrune)(record, { includeTerminal });
3225
- if (classification === "preserve_unacknowledged") {
3226
- preservedUnacknowledged.push(record);
3227
- continue;
3228
- }
3229
- if (classification === "preserve_active") {
3230
- preservedNotOrphan.push(record);
3231
- continue;
3232
- }
3233
- if (!storeTaskIds.has(record.taskId)) {
3234
- preservedLedgerOnly.push(record);
3235
- continue;
3236
- }
3237
- prunable.push(record);
3238
- }
3216
+ const { prunable, prunedCount, preservedUnacknowledged, preservedLedgerOnly, preservedNotOrphan } = result;
3239
3217
  const summarize = (records) => records.map((r) => ({
3240
3218
  taskId: r.taskId,
3241
3219
  nodeId: r.nodeId,
@@ -3246,25 +3224,12 @@ async function meshPruneStaleDirect(ctx, args = {}) {
3246
3224
  taskTitle: r.taskTitle,
3247
3225
  createdAt: r.createdAt
3248
3226
  }));
3249
- let prunedCount = 0;
3250
- if (execute && prunable.length) {
3251
- prunedCount = (0, import_daemon_core.deleteDirectDispatchesByTaskId)(ctx.mesh.id, prunable.map((r) => r.taskId));
3252
- (0, import_daemon_core.appendLedgerEntry)(ctx.mesh.id, {
3253
- kind: "direct_dispatch_pruned",
3254
- payload: {
3255
- source: "mesh_prune_stale_direct",
3256
- prunedCount,
3257
- taskIds: prunable.map((r) => r.taskId),
3258
- reasons: Array.from(new Set(prunable.map((r) => r.staleReason || (r.terminal ? "terminal" : "unknown"))))
3259
- }
3260
- });
3261
- }
3262
3227
  return JSON.stringify({
3263
3228
  success: true,
3264
- mode: execute ? "execute" : "dry_run",
3229
+ mode: result.mode,
3265
3230
  meshId: ctx.mesh.id,
3266
3231
  includeTerminal,
3267
- candidateCount: candidates.length,
3232
+ candidateCount: result.candidateCount,
3268
3233
  prunableCount: prunable.length,
3269
3234
  prunedCount,
3270
3235
  prunable: summarize(prunable),