@adhdev/daemon-core 0.9.82-rc.304 → 0.9.82-rc.306
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 +198 -170
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +198 -170
- package/dist/index.mjs.map +1 -1
- package/dist/mesh/mesh-missions.d.ts +9 -0
- package/dist/repo-mesh-types.d.ts +7 -2
- package/package.json +2 -2
- package/src/commands/router.ts +165 -68
- package/src/mesh/mesh-missions.ts +18 -2
- package/src/repo-mesh-types.ts +7 -2
package/dist/index.js
CHANGED
|
@@ -295,10 +295,10 @@ function readInjected(value) {
|
|
|
295
295
|
}
|
|
296
296
|
function getDaemonBuildInfo() {
|
|
297
297
|
if (cached) return cached;
|
|
298
|
-
const commit = readInjected(true ? "
|
|
299
|
-
const commitShort = readInjected(true ? "
|
|
300
|
-
const version = readInjected(true ? "0.9.82-rc.
|
|
301
|
-
const builtAt = readInjected(true ? "2026-06-
|
|
298
|
+
const commit = readInjected(true ? "6ded896662908225a48ad662b6eec83267dbe9ba" : void 0) ?? "unknown";
|
|
299
|
+
const commitShort = readInjected(true ? "6ded8966" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
|
|
300
|
+
const version = readInjected(true ? "0.9.82-rc.306" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
|
|
301
|
+
const builtAt = readInjected(true ? "2026-06-17T07:21:37.675Z" : void 0);
|
|
302
302
|
cached = builtAt ? { commit, commitShort, version, builtAt } : { commit, commitShort, version };
|
|
303
303
|
return cached;
|
|
304
304
|
}
|
|
@@ -4535,6 +4535,110 @@ var init_mesh_runtime_store = __esm({
|
|
|
4535
4535
|
}
|
|
4536
4536
|
});
|
|
4537
4537
|
|
|
4538
|
+
// src/mesh/mesh-task-stats.ts
|
|
4539
|
+
function readPayloadTaskId(entry) {
|
|
4540
|
+
const value = entry.payload?.taskId;
|
|
4541
|
+
return typeof value === "string" && value.trim() ? value.trim() : "";
|
|
4542
|
+
}
|
|
4543
|
+
function parseTime(value) {
|
|
4544
|
+
if (!value) return null;
|
|
4545
|
+
const parsed = new Date(value).getTime();
|
|
4546
|
+
return Number.isFinite(parsed) ? parsed : null;
|
|
4547
|
+
}
|
|
4548
|
+
function computeMeshTaskStats(meshId, opts) {
|
|
4549
|
+
const queue = getQueue(meshId);
|
|
4550
|
+
const queueById = new Map(queue.map((task) => [task.id, task]));
|
|
4551
|
+
let targetIds;
|
|
4552
|
+
if (opts?.taskIds?.length) {
|
|
4553
|
+
targetIds = [...new Set(opts.taskIds)];
|
|
4554
|
+
} else if (opts?.missionId) {
|
|
4555
|
+
targetIds = queue.filter((task) => task.missionId === opts.missionId).map((task) => task.id);
|
|
4556
|
+
} else {
|
|
4557
|
+
targetIds = queue.map((task) => task.id);
|
|
4558
|
+
}
|
|
4559
|
+
if (targetIds.length === 0) return [];
|
|
4560
|
+
const targetSet = new Set(targetIds);
|
|
4561
|
+
const entries = readLedgerEntries(meshId, { tail: opts?.tail ?? 1e3 });
|
|
4562
|
+
const dispatches = /* @__PURE__ */ new Map();
|
|
4563
|
+
const terminals = /* @__PURE__ */ new Map();
|
|
4564
|
+
for (const entry of entries) {
|
|
4565
|
+
const taskId = readPayloadTaskId(entry);
|
|
4566
|
+
if (!taskId || !targetSet.has(taskId)) continue;
|
|
4567
|
+
if (entry.kind === "task_dispatched") {
|
|
4568
|
+
const existing = dispatches.get(taskId);
|
|
4569
|
+
if (existing) existing.count += 1;
|
|
4570
|
+
else dispatches.set(taskId, { first: entry.timestamp, count: 1 });
|
|
4571
|
+
} else if (entry.kind === "task_completed" || entry.kind === "task_failed") {
|
|
4572
|
+
terminals.set(taskId, { at: entry.timestamp, kind: entry.kind });
|
|
4573
|
+
}
|
|
4574
|
+
}
|
|
4575
|
+
return targetIds.map((taskId) => {
|
|
4576
|
+
const queueEntry = queueById.get(taskId);
|
|
4577
|
+
const status = queueEntry?.status ?? "unknown";
|
|
4578
|
+
const dispatch = dispatches.get(taskId);
|
|
4579
|
+
const terminal = terminals.get(taskId);
|
|
4580
|
+
const isTerminalStatus = status === "completed" || status === "failed" || status === "cancelled";
|
|
4581
|
+
const dispatchTime = parseTime(dispatch?.first ?? queueEntry?.dispatchTimestamp);
|
|
4582
|
+
const terminalTime = parseTime(terminal?.at);
|
|
4583
|
+
const stats = {
|
|
4584
|
+
taskId,
|
|
4585
|
+
status,
|
|
4586
|
+
dispatchedAt: dispatch?.first ?? queueEntry?.dispatchTimestamp ?? null,
|
|
4587
|
+
terminalAt: terminal?.at ?? null,
|
|
4588
|
+
terminalKind: terminal?.kind ?? null,
|
|
4589
|
+
durationMs: null,
|
|
4590
|
+
dispatchCount: dispatch?.count ?? 0,
|
|
4591
|
+
requeueCount: queueEntry?.requeueCount ?? 0
|
|
4592
|
+
};
|
|
4593
|
+
if (dispatchTime !== null && terminalTime !== null && terminalTime >= dispatchTime) {
|
|
4594
|
+
stats.durationMs = terminalTime - dispatchTime;
|
|
4595
|
+
} else if (isTerminalStatus) {
|
|
4596
|
+
stats.incompleteEvidence = true;
|
|
4597
|
+
}
|
|
4598
|
+
return stats;
|
|
4599
|
+
});
|
|
4600
|
+
}
|
|
4601
|
+
function computeMeshMissionStats(meshId, missionId) {
|
|
4602
|
+
const tasks = computeMeshTaskStats(meshId, { missionId });
|
|
4603
|
+
const stats = {
|
|
4604
|
+
missionId,
|
|
4605
|
+
taskCount: tasks.length,
|
|
4606
|
+
completed: 0,
|
|
4607
|
+
failed: 0,
|
|
4608
|
+
totalDurationMs: 0,
|
|
4609
|
+
wallClockMs: null,
|
|
4610
|
+
retries: 0,
|
|
4611
|
+
incompleteTaskIds: []
|
|
4612
|
+
};
|
|
4613
|
+
let firstDispatch = null;
|
|
4614
|
+
let lastTerminal = null;
|
|
4615
|
+
for (const task of tasks) {
|
|
4616
|
+
if (task.status === "completed") stats.completed += 1;
|
|
4617
|
+
else if (task.status === "failed") stats.failed += 1;
|
|
4618
|
+
stats.retries += task.requeueCount;
|
|
4619
|
+
if (task.incompleteEvidence) {
|
|
4620
|
+
stats.incompleteTaskIds.push(task.taskId);
|
|
4621
|
+
continue;
|
|
4622
|
+
}
|
|
4623
|
+
if (task.durationMs !== null) stats.totalDurationMs += task.durationMs;
|
|
4624
|
+
const dispatchTime = parseTime(task.dispatchedAt);
|
|
4625
|
+
const terminalTime = parseTime(task.terminalAt);
|
|
4626
|
+
if (dispatchTime !== null && (firstDispatch === null || dispatchTime < firstDispatch)) firstDispatch = dispatchTime;
|
|
4627
|
+
if (terminalTime !== null && (lastTerminal === null || terminalTime > lastTerminal)) lastTerminal = terminalTime;
|
|
4628
|
+
}
|
|
4629
|
+
if (firstDispatch !== null && lastTerminal !== null && lastTerminal >= firstDispatch) {
|
|
4630
|
+
stats.wallClockMs = lastTerminal - firstDispatch;
|
|
4631
|
+
}
|
|
4632
|
+
return stats;
|
|
4633
|
+
}
|
|
4634
|
+
var init_mesh_task_stats = __esm({
|
|
4635
|
+
"src/mesh/mesh-task-stats.ts"() {
|
|
4636
|
+
"use strict";
|
|
4637
|
+
init_mesh_ledger();
|
|
4638
|
+
init_mesh_work_queue();
|
|
4639
|
+
}
|
|
4640
|
+
});
|
|
4641
|
+
|
|
4538
4642
|
// src/mesh/mesh-missions.ts
|
|
4539
4643
|
var mesh_missions_exports = {};
|
|
4540
4644
|
__export(mesh_missions_exports, {
|
|
@@ -4626,7 +4730,10 @@ function getMeshStatusMissionSummaries(meshId, options) {
|
|
|
4626
4730
|
const all = getMeshMissions(meshId);
|
|
4627
4731
|
const live = all.filter((m) => m.status === "active" || m.status === "paused");
|
|
4628
4732
|
const history = all.filter((m) => m.status === "completed" || m.status === "abandoned").sort((a, b) => (b.updatedAt || "").localeCompare(a.updatedAt || "")).slice(0, historyLimit);
|
|
4629
|
-
|
|
4733
|
+
let full = [...live, ...history].map((mission) => summarizeMeshMission(meshId, mission));
|
|
4734
|
+
if (options?.withStats) {
|
|
4735
|
+
full = full.map((summary) => ({ ...summary, stats: computeMeshMissionStats(meshId, summary.id) }));
|
|
4736
|
+
}
|
|
4630
4737
|
return options?.verbose ? full : full.map(slimMissionSummary);
|
|
4631
4738
|
}
|
|
4632
4739
|
function listMeshMissionSummaries(meshId, options) {
|
|
@@ -4660,6 +4767,7 @@ var init_mesh_missions = __esm({
|
|
|
4660
4767
|
import_crypto6 = require("crypto");
|
|
4661
4768
|
init_mesh_runtime_store();
|
|
4662
4769
|
init_mesh_work_queue();
|
|
4770
|
+
init_mesh_task_stats();
|
|
4663
4771
|
MESH_MISSION_STATUSES = ["active", "paused", "completed", "abandoned"];
|
|
4664
4772
|
GOAL_PREVIEW_MAX = 120;
|
|
4665
4773
|
}
|
|
@@ -17347,107 +17455,7 @@ function getSavedProviderSessions(state, filters) {
|
|
|
17347
17455
|
init_mesh_config();
|
|
17348
17456
|
init_coordinator_prompt();
|
|
17349
17457
|
init_mesh_missions();
|
|
17350
|
-
|
|
17351
|
-
// src/mesh/mesh-task-stats.ts
|
|
17352
|
-
init_mesh_ledger();
|
|
17353
|
-
init_mesh_work_queue();
|
|
17354
|
-
function readPayloadTaskId(entry) {
|
|
17355
|
-
const value = entry.payload?.taskId;
|
|
17356
|
-
return typeof value === "string" && value.trim() ? value.trim() : "";
|
|
17357
|
-
}
|
|
17358
|
-
function parseTime(value) {
|
|
17359
|
-
if (!value) return null;
|
|
17360
|
-
const parsed = new Date(value).getTime();
|
|
17361
|
-
return Number.isFinite(parsed) ? parsed : null;
|
|
17362
|
-
}
|
|
17363
|
-
function computeMeshTaskStats(meshId, opts) {
|
|
17364
|
-
const queue = getQueue(meshId);
|
|
17365
|
-
const queueById = new Map(queue.map((task) => [task.id, task]));
|
|
17366
|
-
let targetIds;
|
|
17367
|
-
if (opts?.taskIds?.length) {
|
|
17368
|
-
targetIds = [...new Set(opts.taskIds)];
|
|
17369
|
-
} else if (opts?.missionId) {
|
|
17370
|
-
targetIds = queue.filter((task) => task.missionId === opts.missionId).map((task) => task.id);
|
|
17371
|
-
} else {
|
|
17372
|
-
targetIds = queue.map((task) => task.id);
|
|
17373
|
-
}
|
|
17374
|
-
if (targetIds.length === 0) return [];
|
|
17375
|
-
const targetSet = new Set(targetIds);
|
|
17376
|
-
const entries = readLedgerEntries(meshId, { tail: opts?.tail ?? 1e3 });
|
|
17377
|
-
const dispatches = /* @__PURE__ */ new Map();
|
|
17378
|
-
const terminals = /* @__PURE__ */ new Map();
|
|
17379
|
-
for (const entry of entries) {
|
|
17380
|
-
const taskId = readPayloadTaskId(entry);
|
|
17381
|
-
if (!taskId || !targetSet.has(taskId)) continue;
|
|
17382
|
-
if (entry.kind === "task_dispatched") {
|
|
17383
|
-
const existing = dispatches.get(taskId);
|
|
17384
|
-
if (existing) existing.count += 1;
|
|
17385
|
-
else dispatches.set(taskId, { first: entry.timestamp, count: 1 });
|
|
17386
|
-
} else if (entry.kind === "task_completed" || entry.kind === "task_failed") {
|
|
17387
|
-
terminals.set(taskId, { at: entry.timestamp, kind: entry.kind });
|
|
17388
|
-
}
|
|
17389
|
-
}
|
|
17390
|
-
return targetIds.map((taskId) => {
|
|
17391
|
-
const queueEntry = queueById.get(taskId);
|
|
17392
|
-
const status = queueEntry?.status ?? "unknown";
|
|
17393
|
-
const dispatch = dispatches.get(taskId);
|
|
17394
|
-
const terminal = terminals.get(taskId);
|
|
17395
|
-
const isTerminalStatus = status === "completed" || status === "failed" || status === "cancelled";
|
|
17396
|
-
const dispatchTime = parseTime(dispatch?.first ?? queueEntry?.dispatchTimestamp);
|
|
17397
|
-
const terminalTime = parseTime(terminal?.at);
|
|
17398
|
-
const stats = {
|
|
17399
|
-
taskId,
|
|
17400
|
-
status,
|
|
17401
|
-
dispatchedAt: dispatch?.first ?? queueEntry?.dispatchTimestamp ?? null,
|
|
17402
|
-
terminalAt: terminal?.at ?? null,
|
|
17403
|
-
terminalKind: terminal?.kind ?? null,
|
|
17404
|
-
durationMs: null,
|
|
17405
|
-
dispatchCount: dispatch?.count ?? 0,
|
|
17406
|
-
requeueCount: queueEntry?.requeueCount ?? 0
|
|
17407
|
-
};
|
|
17408
|
-
if (dispatchTime !== null && terminalTime !== null && terminalTime >= dispatchTime) {
|
|
17409
|
-
stats.durationMs = terminalTime - dispatchTime;
|
|
17410
|
-
} else if (isTerminalStatus) {
|
|
17411
|
-
stats.incompleteEvidence = true;
|
|
17412
|
-
}
|
|
17413
|
-
return stats;
|
|
17414
|
-
});
|
|
17415
|
-
}
|
|
17416
|
-
function computeMeshMissionStats(meshId, missionId) {
|
|
17417
|
-
const tasks = computeMeshTaskStats(meshId, { missionId });
|
|
17418
|
-
const stats = {
|
|
17419
|
-
missionId,
|
|
17420
|
-
taskCount: tasks.length,
|
|
17421
|
-
completed: 0,
|
|
17422
|
-
failed: 0,
|
|
17423
|
-
totalDurationMs: 0,
|
|
17424
|
-
wallClockMs: null,
|
|
17425
|
-
retries: 0,
|
|
17426
|
-
incompleteTaskIds: []
|
|
17427
|
-
};
|
|
17428
|
-
let firstDispatch = null;
|
|
17429
|
-
let lastTerminal = null;
|
|
17430
|
-
for (const task of tasks) {
|
|
17431
|
-
if (task.status === "completed") stats.completed += 1;
|
|
17432
|
-
else if (task.status === "failed") stats.failed += 1;
|
|
17433
|
-
stats.retries += task.requeueCount;
|
|
17434
|
-
if (task.incompleteEvidence) {
|
|
17435
|
-
stats.incompleteTaskIds.push(task.taskId);
|
|
17436
|
-
continue;
|
|
17437
|
-
}
|
|
17438
|
-
if (task.durationMs !== null) stats.totalDurationMs += task.durationMs;
|
|
17439
|
-
const dispatchTime = parseTime(task.dispatchedAt);
|
|
17440
|
-
const terminalTime = parseTime(task.terminalAt);
|
|
17441
|
-
if (dispatchTime !== null && (firstDispatch === null || dispatchTime < firstDispatch)) firstDispatch = dispatchTime;
|
|
17442
|
-
if (terminalTime !== null && (lastTerminal === null || terminalTime > lastTerminal)) lastTerminal = terminalTime;
|
|
17443
|
-
}
|
|
17444
|
-
if (firstDispatch !== null && lastTerminal !== null && lastTerminal >= firstDispatch) {
|
|
17445
|
-
stats.wallClockMs = lastTerminal - firstDispatch;
|
|
17446
|
-
}
|
|
17447
|
-
return stats;
|
|
17448
|
-
}
|
|
17449
|
-
|
|
17450
|
-
// src/index.ts
|
|
17458
|
+
init_mesh_task_stats();
|
|
17451
17459
|
init_mesh_review_inbox();
|
|
17452
17460
|
|
|
17453
17461
|
// src/mesh/coordinator-registry.ts
|
|
@@ -42343,6 +42351,31 @@ async function probeRemoteMeshGitStatus(args) {
|
|
|
42343
42351
|
const remoteGit = remoteResult?.status ?? remoteResult?.git ?? remoteResult;
|
|
42344
42352
|
return remoteGit && typeof remoteGit === "object" && typeof remoteGit.isGitRepo === "boolean" ? remoteGit : null;
|
|
42345
42353
|
}
|
|
42354
|
+
var MESH_DIRECT_PROBE_MAX_RETRIES = 2;
|
|
42355
|
+
function readMeshConnectionState(connection) {
|
|
42356
|
+
return readStringValue(connection?.state);
|
|
42357
|
+
}
|
|
42358
|
+
async function probeRemoteMeshGitStatusWithRetry(args) {
|
|
42359
|
+
for (let attempt = 0; attempt <= MESH_DIRECT_PROBE_MAX_RETRIES; attempt += 1) {
|
|
42360
|
+
if (attempt > 0) {
|
|
42361
|
+
const connection = args.getConnection?.(args.daemonId);
|
|
42362
|
+
if (args.getConnection && readMeshConnectionState(connection) !== "connected") break;
|
|
42363
|
+
if (connection) args.onConnection?.(connection);
|
|
42364
|
+
await new Promise((resolve24) => setTimeout(resolve24, 250 * 2 ** (attempt - 1)));
|
|
42365
|
+
}
|
|
42366
|
+
try {
|
|
42367
|
+
const remoteGit = await probeRemoteMeshGitStatus({
|
|
42368
|
+
dispatchMeshCommand: args.dispatchMeshCommand,
|
|
42369
|
+
daemonId: args.daemonId,
|
|
42370
|
+
workspace: args.workspace,
|
|
42371
|
+
timeoutMs: attempt === 0 ? args.timeoutMs : args.retryTimeoutMs ?? args.timeoutMs
|
|
42372
|
+
});
|
|
42373
|
+
if (remoteGit) return remoteGit;
|
|
42374
|
+
} catch {
|
|
42375
|
+
}
|
|
42376
|
+
}
|
|
42377
|
+
return null;
|
|
42378
|
+
}
|
|
42346
42379
|
async function hydrateInlineMeshDirectTruth(args) {
|
|
42347
42380
|
const nodes = Array.isArray(args.mesh?.nodes) ? args.mesh.nodes : [];
|
|
42348
42381
|
if (!nodes.length) {
|
|
@@ -42351,6 +42384,7 @@ async function hydrateInlineMeshDirectTruth(args) {
|
|
|
42351
42384
|
localConfirmedCount: 0,
|
|
42352
42385
|
peerAttemptedCount: 0,
|
|
42353
42386
|
peerConfirmedCount: 0,
|
|
42387
|
+
standingEvidenceCount: 0,
|
|
42354
42388
|
unavailableNodeIds: []
|
|
42355
42389
|
};
|
|
42356
42390
|
}
|
|
@@ -42362,6 +42396,7 @@ async function hydrateInlineMeshDirectTruth(args) {
|
|
|
42362
42396
|
let localConfirmedCount = 0;
|
|
42363
42397
|
let peerAttemptedCount = 0;
|
|
42364
42398
|
let peerConfirmedCount = 0;
|
|
42399
|
+
let standingEvidenceCount = 0;
|
|
42365
42400
|
const unavailableNodeIds = [];
|
|
42366
42401
|
for (const [nodeIndex, node] of nodes.entries()) {
|
|
42367
42402
|
const nodeId = normalizeMeshNodeId(node) || `node_${nodeIndex}`;
|
|
@@ -42387,32 +42422,40 @@ async function hydrateInlineMeshDirectTruth(args) {
|
|
|
42387
42422
|
} catch {
|
|
42388
42423
|
}
|
|
42389
42424
|
}
|
|
42425
|
+
const standingGit = buildInlineMeshTransitGitStatus(node);
|
|
42426
|
+
if (standingGit) {
|
|
42427
|
+
standingEvidenceCount += 1;
|
|
42428
|
+
continue;
|
|
42429
|
+
}
|
|
42430
|
+
if (!args.probeRemotePeers) {
|
|
42431
|
+
continue;
|
|
42432
|
+
}
|
|
42390
42433
|
if (!daemonId || !args.dispatchMeshCommand) {
|
|
42391
42434
|
if (!isSelfNode) unavailableNodeIds.push(nodeId);
|
|
42392
42435
|
continue;
|
|
42393
42436
|
}
|
|
42394
42437
|
peerAttemptedCount += 1;
|
|
42395
|
-
|
|
42396
|
-
|
|
42397
|
-
|
|
42398
|
-
|
|
42399
|
-
|
|
42400
|
-
|
|
42401
|
-
|
|
42402
|
-
|
|
42403
|
-
|
|
42404
|
-
|
|
42405
|
-
|
|
42406
|
-
|
|
42407
|
-
} catch {
|
|
42438
|
+
const remoteGit = await probeRemoteMeshGitStatusWithRetry({
|
|
42439
|
+
dispatchMeshCommand: args.dispatchMeshCommand,
|
|
42440
|
+
daemonId,
|
|
42441
|
+
workspace,
|
|
42442
|
+
timeoutMs: MESH_DIRECT_PROBE_TIMEOUT_MS,
|
|
42443
|
+
retryTimeoutMs: MESH_DIRECT_PROBE_RETRY_TIMEOUT_MS,
|
|
42444
|
+
getConnection: args.getMeshPeerConnectionStatus
|
|
42445
|
+
});
|
|
42446
|
+
if (remoteGit) {
|
|
42447
|
+
recordInlineMeshDirectGitTruth(node, remoteGit, "selected_coordinator_mesh_p2p_git");
|
|
42448
|
+
peerConfirmedCount += 1;
|
|
42449
|
+
continue;
|
|
42408
42450
|
}
|
|
42409
42451
|
unavailableNodeIds.push(nodeId);
|
|
42410
42452
|
}
|
|
42411
42453
|
return {
|
|
42412
|
-
directEvidenceCount: localConfirmedCount + peerConfirmedCount,
|
|
42454
|
+
directEvidenceCount: localConfirmedCount + peerConfirmedCount + standingEvidenceCount,
|
|
42413
42455
|
localConfirmedCount,
|
|
42414
42456
|
peerAttemptedCount,
|
|
42415
42457
|
peerConfirmedCount,
|
|
42458
|
+
standingEvidenceCount,
|
|
42416
42459
|
unavailableNodeIds
|
|
42417
42460
|
};
|
|
42418
42461
|
}
|
|
@@ -46616,12 +46659,15 @@ ${hintLines.join("\n")}` : "",
|
|
|
46616
46659
|
const meshRecord = await this.getMeshForCommand(meshId, args?.inlineMesh, { preferInline: true });
|
|
46617
46660
|
if (!meshRecord?.mesh) return { success: false, error: "Mesh not found" };
|
|
46618
46661
|
const requireDirectPeerTruth = args?.requireDirectPeerTruth === true;
|
|
46662
|
+
const probeRemotePeers = args?.refresh === true || args?.forceRefresh === true;
|
|
46619
46663
|
const directTruth = await hydrateInlineMeshDirectTruth({
|
|
46620
46664
|
mesh: meshRecord.mesh,
|
|
46621
46665
|
meshSource: meshRecord.source,
|
|
46622
46666
|
dispatchMeshCommand: this.deps.dispatchMeshCommand,
|
|
46667
|
+
getMeshPeerConnectionStatus: this.deps.getMeshPeerConnectionStatus,
|
|
46623
46668
|
statusInstanceId: this.deps.statusInstanceId,
|
|
46624
|
-
localMachineId: loadConfig().machineId || ""
|
|
46669
|
+
localMachineId: loadConfig().machineId || "",
|
|
46670
|
+
probeRemotePeers
|
|
46625
46671
|
});
|
|
46626
46672
|
const directTruthSatisfied = meshRecord.source !== "inline_bootstrap" || directTruth.directEvidenceCount > 0;
|
|
46627
46673
|
const sourceOfTruth = {
|
|
@@ -48201,21 +48247,27 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
48201
48247
|
mesh,
|
|
48202
48248
|
meshSource: meshRecord.source,
|
|
48203
48249
|
dispatchMeshCommand: this.deps.dispatchMeshCommand,
|
|
48250
|
+
getMeshPeerConnectionStatus: this.deps.getMeshPeerConnectionStatus,
|
|
48204
48251
|
statusInstanceId: this.deps.statusInstanceId,
|
|
48205
|
-
localMachineId
|
|
48252
|
+
localMachineId,
|
|
48253
|
+
// Standing-state model: only an explicit refresh fans
|
|
48254
|
+
// out a blocking peer git probe. Default loads return
|
|
48255
|
+
// held truth so one slow peer can't block the graph.
|
|
48256
|
+
probeRemotePeers: refreshRequested
|
|
48206
48257
|
}) : {
|
|
48207
48258
|
directEvidenceCount: 0,
|
|
48208
48259
|
localConfirmedCount: 0,
|
|
48209
48260
|
peerAttemptedCount: 0,
|
|
48210
48261
|
peerConfirmedCount: 0,
|
|
48262
|
+
standingEvidenceCount: 0,
|
|
48211
48263
|
unavailableNodeIds: []
|
|
48212
48264
|
};
|
|
48213
48265
|
const passivePeerTruthNotAttempted = requireDirectPeerTruth && !refreshRequested && directTruth.directEvidenceCount > 0 && directTruth.peerAttemptedCount === 0;
|
|
48214
48266
|
const effectiveDirectTruth = passivePeerTruthNotAttempted ? { ...directTruth, unavailableNodeIds: [] } : directTruth;
|
|
48215
48267
|
const unavailableDirectTruthNodeIds = new Set(effectiveDirectTruth.unavailableNodeIds);
|
|
48216
48268
|
const unavailableNodesAreOnlyRemovedWorktrees = unavailableDirectTruthNodeIds.size > 0 && Array.isArray(mesh.nodes) && mesh.nodes.filter((node) => unavailableDirectTruthNodeIds.has(normalizeMeshNodeId(node) ?? "")).every((node) => node?.isLocalWorktree === true);
|
|
48217
|
-
const directTruthSatisfied = !requireDirectPeerTruth || effectiveDirectTruth.directEvidenceCount > 0 && (effectiveDirectTruth.unavailableNodeIds.length === 0 || unavailableNodesAreOnlyRemovedWorktrees);
|
|
48218
|
-
if (requireDirectPeerTruth && !directTruthSatisfied) {
|
|
48269
|
+
const directTruthSatisfied = !requireDirectPeerTruth || !refreshRequested || effectiveDirectTruth.directEvidenceCount > 0 && (effectiveDirectTruth.unavailableNodeIds.length === 0 || unavailableNodesAreOnlyRemovedWorktrees);
|
|
48270
|
+
if (requireDirectPeerTruth && refreshRequested && !directTruthSatisfied) {
|
|
48219
48271
|
const failureResult = {
|
|
48220
48272
|
success: false,
|
|
48221
48273
|
code: "mesh_direct_peer_truth_unavailable",
|
|
@@ -48361,53 +48413,29 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
48361
48413
|
status.connection = buildLivePeerGitConnection(connection, refreshedAt);
|
|
48362
48414
|
}
|
|
48363
48415
|
remoteProbeApplied = true;
|
|
48364
|
-
} else if (!isSelfNode && daemonId && this.deps.dispatchMeshCommand && !directTruthUnavailableNodeIds.has(nodeId)) {
|
|
48365
|
-
|
|
48366
|
-
|
|
48367
|
-
|
|
48368
|
-
|
|
48369
|
-
|
|
48370
|
-
|
|
48371
|
-
|
|
48372
|
-
|
|
48373
|
-
status.
|
|
48374
|
-
status.health = remoteGit.isGitRepo ? deriveMeshNodeHealthFromGit(remoteGit) : "degraded";
|
|
48375
|
-
const connection = readObjectRecord(status.connection);
|
|
48376
|
-
const connectionState = readStringValue(connection.state);
|
|
48377
|
-
const connectionReported = readBooleanValue(connection.reported) ?? false;
|
|
48378
|
-
if (!connectionReported || connectionState === "unknown") {
|
|
48379
|
-
status.connection = buildLivePeerGitConnection(connection, refreshedAt);
|
|
48380
|
-
}
|
|
48381
|
-
recordInlineMeshDirectGitTruth(node, remoteGit, "selected_coordinator_mesh_p2p_git");
|
|
48382
|
-
remoteProbeApplied = true;
|
|
48416
|
+
} else if (refreshRequested && !isSelfNode && daemonId && this.deps.dispatchMeshCommand && !directTruthUnavailableNodeIds.has(nodeId)) {
|
|
48417
|
+
const remoteGit = await probeRemoteMeshGitStatusWithRetry({
|
|
48418
|
+
dispatchMeshCommand: this.deps.dispatchMeshCommand,
|
|
48419
|
+
daemonId,
|
|
48420
|
+
workspace,
|
|
48421
|
+
timeoutMs: MESH_DIRECT_PROBE_TIMEOUT_MS,
|
|
48422
|
+
retryTimeoutMs: MESH_DIRECT_PROBE_RETRY_TIMEOUT_MS,
|
|
48423
|
+
getConnection: this.deps.getMeshPeerConnectionStatus,
|
|
48424
|
+
onConnection: (connection) => {
|
|
48425
|
+
status.connection = connection;
|
|
48383
48426
|
}
|
|
48384
|
-
}
|
|
48385
|
-
|
|
48386
|
-
|
|
48387
|
-
|
|
48388
|
-
|
|
48389
|
-
|
|
48390
|
-
|
|
48391
|
-
|
|
48392
|
-
|
|
48393
|
-
workspace,
|
|
48394
|
-
timeoutMs: MESH_DIRECT_PROBE_RETRY_TIMEOUT_MS
|
|
48395
|
-
});
|
|
48396
|
-
if (remoteGit) {
|
|
48397
|
-
status.git = remoteGit;
|
|
48398
|
-
status.health = remoteGit.isGitRepo ? deriveMeshNodeHealthFromGit(remoteGit) : "degraded";
|
|
48399
|
-
const connection = readObjectRecord(status.connection);
|
|
48400
|
-
const connectionState = readStringValue(connection.state);
|
|
48401
|
-
const connectionReported = readBooleanValue(connection.reported) ?? false;
|
|
48402
|
-
if (!connectionReported || connectionState === "unknown") {
|
|
48403
|
-
status.connection = buildLivePeerGitConnection(connection, refreshedAt);
|
|
48404
|
-
}
|
|
48405
|
-
recordInlineMeshDirectGitTruth(node, remoteGit, "selected_coordinator_mesh_p2p_git");
|
|
48406
|
-
remoteProbeApplied = true;
|
|
48407
|
-
}
|
|
48408
|
-
} catch {
|
|
48409
|
-
}
|
|
48427
|
+
});
|
|
48428
|
+
if (remoteGit) {
|
|
48429
|
+
status.git = remoteGit;
|
|
48430
|
+
status.health = remoteGit.isGitRepo ? deriveMeshNodeHealthFromGit(remoteGit) : "degraded";
|
|
48431
|
+
const connection = readObjectRecord(status.connection);
|
|
48432
|
+
const connectionState = readStringValue(connection.state);
|
|
48433
|
+
const connectionReported = readBooleanValue(connection.reported) ?? false;
|
|
48434
|
+
if (!connectionReported || connectionState === "unknown") {
|
|
48435
|
+
status.connection = buildLivePeerGitConnection(connection, refreshedAt);
|
|
48410
48436
|
}
|
|
48437
|
+
recordInlineMeshDirectGitTruth(node, remoteGit, "selected_coordinator_mesh_p2p_git");
|
|
48438
|
+
remoteProbeApplied = true;
|
|
48411
48439
|
}
|
|
48412
48440
|
}
|
|
48413
48441
|
if (!remoteProbeApplied) {
|
|
@@ -48476,7 +48504,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
48476
48504
|
liveSessionRecords: liveMeshSessions
|
|
48477
48505
|
});
|
|
48478
48506
|
const { getMeshStatusMissionSummaries: getMeshStatusMissionSummaries2 } = await Promise.resolve().then(() => (init_mesh_missions(), mesh_missions_exports));
|
|
48479
|
-
const missions = getMeshStatusMissionSummaries2(meshId, { verbose: verboseMissions });
|
|
48507
|
+
const missions = getMeshStatusMissionSummaries2(meshId, { verbose: verboseMissions, withStats: true });
|
|
48480
48508
|
const statusResult = {
|
|
48481
48509
|
success: true,
|
|
48482
48510
|
meshId: mesh.id,
|