@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.mjs
CHANGED
|
@@ -290,10 +290,10 @@ function readInjected(value) {
|
|
|
290
290
|
}
|
|
291
291
|
function getDaemonBuildInfo() {
|
|
292
292
|
if (cached) return cached;
|
|
293
|
-
const commit = readInjected(true ? "
|
|
294
|
-
const commitShort = readInjected(true ? "
|
|
295
|
-
const version = readInjected(true ? "0.9.82-rc.
|
|
296
|
-
const builtAt = readInjected(true ? "2026-06-
|
|
293
|
+
const commit = readInjected(true ? "6ded896662908225a48ad662b6eec83267dbe9ba" : void 0) ?? "unknown";
|
|
294
|
+
const commitShort = readInjected(true ? "6ded8966" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
|
|
295
|
+
const version = readInjected(true ? "0.9.82-rc.306" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
|
|
296
|
+
const builtAt = readInjected(true ? "2026-06-17T07:21:37.675Z" : void 0);
|
|
297
297
|
cached = builtAt ? { commit, commitShort, version, builtAt } : { commit, commitShort, version };
|
|
298
298
|
return cached;
|
|
299
299
|
}
|
|
@@ -4529,6 +4529,110 @@ var init_mesh_runtime_store = __esm({
|
|
|
4529
4529
|
}
|
|
4530
4530
|
});
|
|
4531
4531
|
|
|
4532
|
+
// src/mesh/mesh-task-stats.ts
|
|
4533
|
+
function readPayloadTaskId(entry) {
|
|
4534
|
+
const value = entry.payload?.taskId;
|
|
4535
|
+
return typeof value === "string" && value.trim() ? value.trim() : "";
|
|
4536
|
+
}
|
|
4537
|
+
function parseTime(value) {
|
|
4538
|
+
if (!value) return null;
|
|
4539
|
+
const parsed = new Date(value).getTime();
|
|
4540
|
+
return Number.isFinite(parsed) ? parsed : null;
|
|
4541
|
+
}
|
|
4542
|
+
function computeMeshTaskStats(meshId, opts) {
|
|
4543
|
+
const queue = getQueue(meshId);
|
|
4544
|
+
const queueById = new Map(queue.map((task) => [task.id, task]));
|
|
4545
|
+
let targetIds;
|
|
4546
|
+
if (opts?.taskIds?.length) {
|
|
4547
|
+
targetIds = [...new Set(opts.taskIds)];
|
|
4548
|
+
} else if (opts?.missionId) {
|
|
4549
|
+
targetIds = queue.filter((task) => task.missionId === opts.missionId).map((task) => task.id);
|
|
4550
|
+
} else {
|
|
4551
|
+
targetIds = queue.map((task) => task.id);
|
|
4552
|
+
}
|
|
4553
|
+
if (targetIds.length === 0) return [];
|
|
4554
|
+
const targetSet = new Set(targetIds);
|
|
4555
|
+
const entries = readLedgerEntries(meshId, { tail: opts?.tail ?? 1e3 });
|
|
4556
|
+
const dispatches = /* @__PURE__ */ new Map();
|
|
4557
|
+
const terminals = /* @__PURE__ */ new Map();
|
|
4558
|
+
for (const entry of entries) {
|
|
4559
|
+
const taskId = readPayloadTaskId(entry);
|
|
4560
|
+
if (!taskId || !targetSet.has(taskId)) continue;
|
|
4561
|
+
if (entry.kind === "task_dispatched") {
|
|
4562
|
+
const existing = dispatches.get(taskId);
|
|
4563
|
+
if (existing) existing.count += 1;
|
|
4564
|
+
else dispatches.set(taskId, { first: entry.timestamp, count: 1 });
|
|
4565
|
+
} else if (entry.kind === "task_completed" || entry.kind === "task_failed") {
|
|
4566
|
+
terminals.set(taskId, { at: entry.timestamp, kind: entry.kind });
|
|
4567
|
+
}
|
|
4568
|
+
}
|
|
4569
|
+
return targetIds.map((taskId) => {
|
|
4570
|
+
const queueEntry = queueById.get(taskId);
|
|
4571
|
+
const status = queueEntry?.status ?? "unknown";
|
|
4572
|
+
const dispatch = dispatches.get(taskId);
|
|
4573
|
+
const terminal = terminals.get(taskId);
|
|
4574
|
+
const isTerminalStatus = status === "completed" || status === "failed" || status === "cancelled";
|
|
4575
|
+
const dispatchTime = parseTime(dispatch?.first ?? queueEntry?.dispatchTimestamp);
|
|
4576
|
+
const terminalTime = parseTime(terminal?.at);
|
|
4577
|
+
const stats = {
|
|
4578
|
+
taskId,
|
|
4579
|
+
status,
|
|
4580
|
+
dispatchedAt: dispatch?.first ?? queueEntry?.dispatchTimestamp ?? null,
|
|
4581
|
+
terminalAt: terminal?.at ?? null,
|
|
4582
|
+
terminalKind: terminal?.kind ?? null,
|
|
4583
|
+
durationMs: null,
|
|
4584
|
+
dispatchCount: dispatch?.count ?? 0,
|
|
4585
|
+
requeueCount: queueEntry?.requeueCount ?? 0
|
|
4586
|
+
};
|
|
4587
|
+
if (dispatchTime !== null && terminalTime !== null && terminalTime >= dispatchTime) {
|
|
4588
|
+
stats.durationMs = terminalTime - dispatchTime;
|
|
4589
|
+
} else if (isTerminalStatus) {
|
|
4590
|
+
stats.incompleteEvidence = true;
|
|
4591
|
+
}
|
|
4592
|
+
return stats;
|
|
4593
|
+
});
|
|
4594
|
+
}
|
|
4595
|
+
function computeMeshMissionStats(meshId, missionId) {
|
|
4596
|
+
const tasks = computeMeshTaskStats(meshId, { missionId });
|
|
4597
|
+
const stats = {
|
|
4598
|
+
missionId,
|
|
4599
|
+
taskCount: tasks.length,
|
|
4600
|
+
completed: 0,
|
|
4601
|
+
failed: 0,
|
|
4602
|
+
totalDurationMs: 0,
|
|
4603
|
+
wallClockMs: null,
|
|
4604
|
+
retries: 0,
|
|
4605
|
+
incompleteTaskIds: []
|
|
4606
|
+
};
|
|
4607
|
+
let firstDispatch = null;
|
|
4608
|
+
let lastTerminal = null;
|
|
4609
|
+
for (const task of tasks) {
|
|
4610
|
+
if (task.status === "completed") stats.completed += 1;
|
|
4611
|
+
else if (task.status === "failed") stats.failed += 1;
|
|
4612
|
+
stats.retries += task.requeueCount;
|
|
4613
|
+
if (task.incompleteEvidence) {
|
|
4614
|
+
stats.incompleteTaskIds.push(task.taskId);
|
|
4615
|
+
continue;
|
|
4616
|
+
}
|
|
4617
|
+
if (task.durationMs !== null) stats.totalDurationMs += task.durationMs;
|
|
4618
|
+
const dispatchTime = parseTime(task.dispatchedAt);
|
|
4619
|
+
const terminalTime = parseTime(task.terminalAt);
|
|
4620
|
+
if (dispatchTime !== null && (firstDispatch === null || dispatchTime < firstDispatch)) firstDispatch = dispatchTime;
|
|
4621
|
+
if (terminalTime !== null && (lastTerminal === null || terminalTime > lastTerminal)) lastTerminal = terminalTime;
|
|
4622
|
+
}
|
|
4623
|
+
if (firstDispatch !== null && lastTerminal !== null && lastTerminal >= firstDispatch) {
|
|
4624
|
+
stats.wallClockMs = lastTerminal - firstDispatch;
|
|
4625
|
+
}
|
|
4626
|
+
return stats;
|
|
4627
|
+
}
|
|
4628
|
+
var init_mesh_task_stats = __esm({
|
|
4629
|
+
"src/mesh/mesh-task-stats.ts"() {
|
|
4630
|
+
"use strict";
|
|
4631
|
+
init_mesh_ledger();
|
|
4632
|
+
init_mesh_work_queue();
|
|
4633
|
+
}
|
|
4634
|
+
});
|
|
4635
|
+
|
|
4532
4636
|
// src/mesh/mesh-missions.ts
|
|
4533
4637
|
var mesh_missions_exports = {};
|
|
4534
4638
|
__export(mesh_missions_exports, {
|
|
@@ -4621,7 +4725,10 @@ function getMeshStatusMissionSummaries(meshId, options) {
|
|
|
4621
4725
|
const all = getMeshMissions(meshId);
|
|
4622
4726
|
const live = all.filter((m) => m.status === "active" || m.status === "paused");
|
|
4623
4727
|
const history = all.filter((m) => m.status === "completed" || m.status === "abandoned").sort((a, b) => (b.updatedAt || "").localeCompare(a.updatedAt || "")).slice(0, historyLimit);
|
|
4624
|
-
|
|
4728
|
+
let full = [...live, ...history].map((mission) => summarizeMeshMission(meshId, mission));
|
|
4729
|
+
if (options?.withStats) {
|
|
4730
|
+
full = full.map((summary) => ({ ...summary, stats: computeMeshMissionStats(meshId, summary.id) }));
|
|
4731
|
+
}
|
|
4625
4732
|
return options?.verbose ? full : full.map(slimMissionSummary);
|
|
4626
4733
|
}
|
|
4627
4734
|
function listMeshMissionSummaries(meshId, options) {
|
|
@@ -4654,6 +4761,7 @@ var init_mesh_missions = __esm({
|
|
|
4654
4761
|
"use strict";
|
|
4655
4762
|
init_mesh_runtime_store();
|
|
4656
4763
|
init_mesh_work_queue();
|
|
4764
|
+
init_mesh_task_stats();
|
|
4657
4765
|
MESH_MISSION_STATUSES = ["active", "paused", "completed", "abandoned"];
|
|
4658
4766
|
GOAL_PREVIEW_MAX = 120;
|
|
4659
4767
|
}
|
|
@@ -17003,107 +17111,7 @@ function getSavedProviderSessions(state, filters) {
|
|
|
17003
17111
|
init_mesh_config();
|
|
17004
17112
|
init_coordinator_prompt();
|
|
17005
17113
|
init_mesh_missions();
|
|
17006
|
-
|
|
17007
|
-
// src/mesh/mesh-task-stats.ts
|
|
17008
|
-
init_mesh_ledger();
|
|
17009
|
-
init_mesh_work_queue();
|
|
17010
|
-
function readPayloadTaskId(entry) {
|
|
17011
|
-
const value = entry.payload?.taskId;
|
|
17012
|
-
return typeof value === "string" && value.trim() ? value.trim() : "";
|
|
17013
|
-
}
|
|
17014
|
-
function parseTime(value) {
|
|
17015
|
-
if (!value) return null;
|
|
17016
|
-
const parsed = new Date(value).getTime();
|
|
17017
|
-
return Number.isFinite(parsed) ? parsed : null;
|
|
17018
|
-
}
|
|
17019
|
-
function computeMeshTaskStats(meshId, opts) {
|
|
17020
|
-
const queue = getQueue(meshId);
|
|
17021
|
-
const queueById = new Map(queue.map((task) => [task.id, task]));
|
|
17022
|
-
let targetIds;
|
|
17023
|
-
if (opts?.taskIds?.length) {
|
|
17024
|
-
targetIds = [...new Set(opts.taskIds)];
|
|
17025
|
-
} else if (opts?.missionId) {
|
|
17026
|
-
targetIds = queue.filter((task) => task.missionId === opts.missionId).map((task) => task.id);
|
|
17027
|
-
} else {
|
|
17028
|
-
targetIds = queue.map((task) => task.id);
|
|
17029
|
-
}
|
|
17030
|
-
if (targetIds.length === 0) return [];
|
|
17031
|
-
const targetSet = new Set(targetIds);
|
|
17032
|
-
const entries = readLedgerEntries(meshId, { tail: opts?.tail ?? 1e3 });
|
|
17033
|
-
const dispatches = /* @__PURE__ */ new Map();
|
|
17034
|
-
const terminals = /* @__PURE__ */ new Map();
|
|
17035
|
-
for (const entry of entries) {
|
|
17036
|
-
const taskId = readPayloadTaskId(entry);
|
|
17037
|
-
if (!taskId || !targetSet.has(taskId)) continue;
|
|
17038
|
-
if (entry.kind === "task_dispatched") {
|
|
17039
|
-
const existing = dispatches.get(taskId);
|
|
17040
|
-
if (existing) existing.count += 1;
|
|
17041
|
-
else dispatches.set(taskId, { first: entry.timestamp, count: 1 });
|
|
17042
|
-
} else if (entry.kind === "task_completed" || entry.kind === "task_failed") {
|
|
17043
|
-
terminals.set(taskId, { at: entry.timestamp, kind: entry.kind });
|
|
17044
|
-
}
|
|
17045
|
-
}
|
|
17046
|
-
return targetIds.map((taskId) => {
|
|
17047
|
-
const queueEntry = queueById.get(taskId);
|
|
17048
|
-
const status = queueEntry?.status ?? "unknown";
|
|
17049
|
-
const dispatch = dispatches.get(taskId);
|
|
17050
|
-
const terminal = terminals.get(taskId);
|
|
17051
|
-
const isTerminalStatus = status === "completed" || status === "failed" || status === "cancelled";
|
|
17052
|
-
const dispatchTime = parseTime(dispatch?.first ?? queueEntry?.dispatchTimestamp);
|
|
17053
|
-
const terminalTime = parseTime(terminal?.at);
|
|
17054
|
-
const stats = {
|
|
17055
|
-
taskId,
|
|
17056
|
-
status,
|
|
17057
|
-
dispatchedAt: dispatch?.first ?? queueEntry?.dispatchTimestamp ?? null,
|
|
17058
|
-
terminalAt: terminal?.at ?? null,
|
|
17059
|
-
terminalKind: terminal?.kind ?? null,
|
|
17060
|
-
durationMs: null,
|
|
17061
|
-
dispatchCount: dispatch?.count ?? 0,
|
|
17062
|
-
requeueCount: queueEntry?.requeueCount ?? 0
|
|
17063
|
-
};
|
|
17064
|
-
if (dispatchTime !== null && terminalTime !== null && terminalTime >= dispatchTime) {
|
|
17065
|
-
stats.durationMs = terminalTime - dispatchTime;
|
|
17066
|
-
} else if (isTerminalStatus) {
|
|
17067
|
-
stats.incompleteEvidence = true;
|
|
17068
|
-
}
|
|
17069
|
-
return stats;
|
|
17070
|
-
});
|
|
17071
|
-
}
|
|
17072
|
-
function computeMeshMissionStats(meshId, missionId) {
|
|
17073
|
-
const tasks = computeMeshTaskStats(meshId, { missionId });
|
|
17074
|
-
const stats = {
|
|
17075
|
-
missionId,
|
|
17076
|
-
taskCount: tasks.length,
|
|
17077
|
-
completed: 0,
|
|
17078
|
-
failed: 0,
|
|
17079
|
-
totalDurationMs: 0,
|
|
17080
|
-
wallClockMs: null,
|
|
17081
|
-
retries: 0,
|
|
17082
|
-
incompleteTaskIds: []
|
|
17083
|
-
};
|
|
17084
|
-
let firstDispatch = null;
|
|
17085
|
-
let lastTerminal = null;
|
|
17086
|
-
for (const task of tasks) {
|
|
17087
|
-
if (task.status === "completed") stats.completed += 1;
|
|
17088
|
-
else if (task.status === "failed") stats.failed += 1;
|
|
17089
|
-
stats.retries += task.requeueCount;
|
|
17090
|
-
if (task.incompleteEvidence) {
|
|
17091
|
-
stats.incompleteTaskIds.push(task.taskId);
|
|
17092
|
-
continue;
|
|
17093
|
-
}
|
|
17094
|
-
if (task.durationMs !== null) stats.totalDurationMs += task.durationMs;
|
|
17095
|
-
const dispatchTime = parseTime(task.dispatchedAt);
|
|
17096
|
-
const terminalTime = parseTime(task.terminalAt);
|
|
17097
|
-
if (dispatchTime !== null && (firstDispatch === null || dispatchTime < firstDispatch)) firstDispatch = dispatchTime;
|
|
17098
|
-
if (terminalTime !== null && (lastTerminal === null || terminalTime > lastTerminal)) lastTerminal = terminalTime;
|
|
17099
|
-
}
|
|
17100
|
-
if (firstDispatch !== null && lastTerminal !== null && lastTerminal >= firstDispatch) {
|
|
17101
|
-
stats.wallClockMs = lastTerminal - firstDispatch;
|
|
17102
|
-
}
|
|
17103
|
-
return stats;
|
|
17104
|
-
}
|
|
17105
|
-
|
|
17106
|
-
// src/index.ts
|
|
17114
|
+
init_mesh_task_stats();
|
|
17107
17115
|
init_mesh_review_inbox();
|
|
17108
17116
|
|
|
17109
17117
|
// src/mesh/coordinator-registry.ts
|
|
@@ -42004,6 +42012,31 @@ async function probeRemoteMeshGitStatus(args) {
|
|
|
42004
42012
|
const remoteGit = remoteResult?.status ?? remoteResult?.git ?? remoteResult;
|
|
42005
42013
|
return remoteGit && typeof remoteGit === "object" && typeof remoteGit.isGitRepo === "boolean" ? remoteGit : null;
|
|
42006
42014
|
}
|
|
42015
|
+
var MESH_DIRECT_PROBE_MAX_RETRIES = 2;
|
|
42016
|
+
function readMeshConnectionState(connection) {
|
|
42017
|
+
return readStringValue(connection?.state);
|
|
42018
|
+
}
|
|
42019
|
+
async function probeRemoteMeshGitStatusWithRetry(args) {
|
|
42020
|
+
for (let attempt = 0; attempt <= MESH_DIRECT_PROBE_MAX_RETRIES; attempt += 1) {
|
|
42021
|
+
if (attempt > 0) {
|
|
42022
|
+
const connection = args.getConnection?.(args.daemonId);
|
|
42023
|
+
if (args.getConnection && readMeshConnectionState(connection) !== "connected") break;
|
|
42024
|
+
if (connection) args.onConnection?.(connection);
|
|
42025
|
+
await new Promise((resolve24) => setTimeout(resolve24, 250 * 2 ** (attempt - 1)));
|
|
42026
|
+
}
|
|
42027
|
+
try {
|
|
42028
|
+
const remoteGit = await probeRemoteMeshGitStatus({
|
|
42029
|
+
dispatchMeshCommand: args.dispatchMeshCommand,
|
|
42030
|
+
daemonId: args.daemonId,
|
|
42031
|
+
workspace: args.workspace,
|
|
42032
|
+
timeoutMs: attempt === 0 ? args.timeoutMs : args.retryTimeoutMs ?? args.timeoutMs
|
|
42033
|
+
});
|
|
42034
|
+
if (remoteGit) return remoteGit;
|
|
42035
|
+
} catch {
|
|
42036
|
+
}
|
|
42037
|
+
}
|
|
42038
|
+
return null;
|
|
42039
|
+
}
|
|
42007
42040
|
async function hydrateInlineMeshDirectTruth(args) {
|
|
42008
42041
|
const nodes = Array.isArray(args.mesh?.nodes) ? args.mesh.nodes : [];
|
|
42009
42042
|
if (!nodes.length) {
|
|
@@ -42012,6 +42045,7 @@ async function hydrateInlineMeshDirectTruth(args) {
|
|
|
42012
42045
|
localConfirmedCount: 0,
|
|
42013
42046
|
peerAttemptedCount: 0,
|
|
42014
42047
|
peerConfirmedCount: 0,
|
|
42048
|
+
standingEvidenceCount: 0,
|
|
42015
42049
|
unavailableNodeIds: []
|
|
42016
42050
|
};
|
|
42017
42051
|
}
|
|
@@ -42023,6 +42057,7 @@ async function hydrateInlineMeshDirectTruth(args) {
|
|
|
42023
42057
|
let localConfirmedCount = 0;
|
|
42024
42058
|
let peerAttemptedCount = 0;
|
|
42025
42059
|
let peerConfirmedCount = 0;
|
|
42060
|
+
let standingEvidenceCount = 0;
|
|
42026
42061
|
const unavailableNodeIds = [];
|
|
42027
42062
|
for (const [nodeIndex, node] of nodes.entries()) {
|
|
42028
42063
|
const nodeId = normalizeMeshNodeId(node) || `node_${nodeIndex}`;
|
|
@@ -42048,32 +42083,40 @@ async function hydrateInlineMeshDirectTruth(args) {
|
|
|
42048
42083
|
} catch {
|
|
42049
42084
|
}
|
|
42050
42085
|
}
|
|
42086
|
+
const standingGit = buildInlineMeshTransitGitStatus(node);
|
|
42087
|
+
if (standingGit) {
|
|
42088
|
+
standingEvidenceCount += 1;
|
|
42089
|
+
continue;
|
|
42090
|
+
}
|
|
42091
|
+
if (!args.probeRemotePeers) {
|
|
42092
|
+
continue;
|
|
42093
|
+
}
|
|
42051
42094
|
if (!daemonId || !args.dispatchMeshCommand) {
|
|
42052
42095
|
if (!isSelfNode) unavailableNodeIds.push(nodeId);
|
|
42053
42096
|
continue;
|
|
42054
42097
|
}
|
|
42055
42098
|
peerAttemptedCount += 1;
|
|
42056
|
-
|
|
42057
|
-
|
|
42058
|
-
|
|
42059
|
-
|
|
42060
|
-
|
|
42061
|
-
|
|
42062
|
-
|
|
42063
|
-
|
|
42064
|
-
|
|
42065
|
-
|
|
42066
|
-
|
|
42067
|
-
|
|
42068
|
-
} catch {
|
|
42099
|
+
const remoteGit = await probeRemoteMeshGitStatusWithRetry({
|
|
42100
|
+
dispatchMeshCommand: args.dispatchMeshCommand,
|
|
42101
|
+
daemonId,
|
|
42102
|
+
workspace,
|
|
42103
|
+
timeoutMs: MESH_DIRECT_PROBE_TIMEOUT_MS,
|
|
42104
|
+
retryTimeoutMs: MESH_DIRECT_PROBE_RETRY_TIMEOUT_MS,
|
|
42105
|
+
getConnection: args.getMeshPeerConnectionStatus
|
|
42106
|
+
});
|
|
42107
|
+
if (remoteGit) {
|
|
42108
|
+
recordInlineMeshDirectGitTruth(node, remoteGit, "selected_coordinator_mesh_p2p_git");
|
|
42109
|
+
peerConfirmedCount += 1;
|
|
42110
|
+
continue;
|
|
42069
42111
|
}
|
|
42070
42112
|
unavailableNodeIds.push(nodeId);
|
|
42071
42113
|
}
|
|
42072
42114
|
return {
|
|
42073
|
-
directEvidenceCount: localConfirmedCount + peerConfirmedCount,
|
|
42115
|
+
directEvidenceCount: localConfirmedCount + peerConfirmedCount + standingEvidenceCount,
|
|
42074
42116
|
localConfirmedCount,
|
|
42075
42117
|
peerAttemptedCount,
|
|
42076
42118
|
peerConfirmedCount,
|
|
42119
|
+
standingEvidenceCount,
|
|
42077
42120
|
unavailableNodeIds
|
|
42078
42121
|
};
|
|
42079
42122
|
}
|
|
@@ -46277,12 +46320,15 @@ ${hintLines.join("\n")}` : "",
|
|
|
46277
46320
|
const meshRecord = await this.getMeshForCommand(meshId, args?.inlineMesh, { preferInline: true });
|
|
46278
46321
|
if (!meshRecord?.mesh) return { success: false, error: "Mesh not found" };
|
|
46279
46322
|
const requireDirectPeerTruth = args?.requireDirectPeerTruth === true;
|
|
46323
|
+
const probeRemotePeers = args?.refresh === true || args?.forceRefresh === true;
|
|
46280
46324
|
const directTruth = await hydrateInlineMeshDirectTruth({
|
|
46281
46325
|
mesh: meshRecord.mesh,
|
|
46282
46326
|
meshSource: meshRecord.source,
|
|
46283
46327
|
dispatchMeshCommand: this.deps.dispatchMeshCommand,
|
|
46328
|
+
getMeshPeerConnectionStatus: this.deps.getMeshPeerConnectionStatus,
|
|
46284
46329
|
statusInstanceId: this.deps.statusInstanceId,
|
|
46285
|
-
localMachineId: loadConfig().machineId || ""
|
|
46330
|
+
localMachineId: loadConfig().machineId || "",
|
|
46331
|
+
probeRemotePeers
|
|
46286
46332
|
});
|
|
46287
46333
|
const directTruthSatisfied = meshRecord.source !== "inline_bootstrap" || directTruth.directEvidenceCount > 0;
|
|
46288
46334
|
const sourceOfTruth = {
|
|
@@ -47862,21 +47908,27 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
47862
47908
|
mesh,
|
|
47863
47909
|
meshSource: meshRecord.source,
|
|
47864
47910
|
dispatchMeshCommand: this.deps.dispatchMeshCommand,
|
|
47911
|
+
getMeshPeerConnectionStatus: this.deps.getMeshPeerConnectionStatus,
|
|
47865
47912
|
statusInstanceId: this.deps.statusInstanceId,
|
|
47866
|
-
localMachineId
|
|
47913
|
+
localMachineId,
|
|
47914
|
+
// Standing-state model: only an explicit refresh fans
|
|
47915
|
+
// out a blocking peer git probe. Default loads return
|
|
47916
|
+
// held truth so one slow peer can't block the graph.
|
|
47917
|
+
probeRemotePeers: refreshRequested
|
|
47867
47918
|
}) : {
|
|
47868
47919
|
directEvidenceCount: 0,
|
|
47869
47920
|
localConfirmedCount: 0,
|
|
47870
47921
|
peerAttemptedCount: 0,
|
|
47871
47922
|
peerConfirmedCount: 0,
|
|
47923
|
+
standingEvidenceCount: 0,
|
|
47872
47924
|
unavailableNodeIds: []
|
|
47873
47925
|
};
|
|
47874
47926
|
const passivePeerTruthNotAttempted = requireDirectPeerTruth && !refreshRequested && directTruth.directEvidenceCount > 0 && directTruth.peerAttemptedCount === 0;
|
|
47875
47927
|
const effectiveDirectTruth = passivePeerTruthNotAttempted ? { ...directTruth, unavailableNodeIds: [] } : directTruth;
|
|
47876
47928
|
const unavailableDirectTruthNodeIds = new Set(effectiveDirectTruth.unavailableNodeIds);
|
|
47877
47929
|
const unavailableNodesAreOnlyRemovedWorktrees = unavailableDirectTruthNodeIds.size > 0 && Array.isArray(mesh.nodes) && mesh.nodes.filter((node) => unavailableDirectTruthNodeIds.has(normalizeMeshNodeId(node) ?? "")).every((node) => node?.isLocalWorktree === true);
|
|
47878
|
-
const directTruthSatisfied = !requireDirectPeerTruth || effectiveDirectTruth.directEvidenceCount > 0 && (effectiveDirectTruth.unavailableNodeIds.length === 0 || unavailableNodesAreOnlyRemovedWorktrees);
|
|
47879
|
-
if (requireDirectPeerTruth && !directTruthSatisfied) {
|
|
47930
|
+
const directTruthSatisfied = !requireDirectPeerTruth || !refreshRequested || effectiveDirectTruth.directEvidenceCount > 0 && (effectiveDirectTruth.unavailableNodeIds.length === 0 || unavailableNodesAreOnlyRemovedWorktrees);
|
|
47931
|
+
if (requireDirectPeerTruth && refreshRequested && !directTruthSatisfied) {
|
|
47880
47932
|
const failureResult = {
|
|
47881
47933
|
success: false,
|
|
47882
47934
|
code: "mesh_direct_peer_truth_unavailable",
|
|
@@ -48022,53 +48074,29 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
48022
48074
|
status.connection = buildLivePeerGitConnection(connection, refreshedAt);
|
|
48023
48075
|
}
|
|
48024
48076
|
remoteProbeApplied = true;
|
|
48025
|
-
} else if (!isSelfNode && daemonId && this.deps.dispatchMeshCommand && !directTruthUnavailableNodeIds.has(nodeId)) {
|
|
48026
|
-
|
|
48027
|
-
|
|
48028
|
-
|
|
48029
|
-
|
|
48030
|
-
|
|
48031
|
-
|
|
48032
|
-
|
|
48033
|
-
|
|
48034
|
-
status.
|
|
48035
|
-
status.health = remoteGit.isGitRepo ? deriveMeshNodeHealthFromGit(remoteGit) : "degraded";
|
|
48036
|
-
const connection = readObjectRecord(status.connection);
|
|
48037
|
-
const connectionState = readStringValue(connection.state);
|
|
48038
|
-
const connectionReported = readBooleanValue(connection.reported) ?? false;
|
|
48039
|
-
if (!connectionReported || connectionState === "unknown") {
|
|
48040
|
-
status.connection = buildLivePeerGitConnection(connection, refreshedAt);
|
|
48041
|
-
}
|
|
48042
|
-
recordInlineMeshDirectGitTruth(node, remoteGit, "selected_coordinator_mesh_p2p_git");
|
|
48043
|
-
remoteProbeApplied = true;
|
|
48077
|
+
} else if (refreshRequested && !isSelfNode && daemonId && this.deps.dispatchMeshCommand && !directTruthUnavailableNodeIds.has(nodeId)) {
|
|
48078
|
+
const remoteGit = await probeRemoteMeshGitStatusWithRetry({
|
|
48079
|
+
dispatchMeshCommand: this.deps.dispatchMeshCommand,
|
|
48080
|
+
daemonId,
|
|
48081
|
+
workspace,
|
|
48082
|
+
timeoutMs: MESH_DIRECT_PROBE_TIMEOUT_MS,
|
|
48083
|
+
retryTimeoutMs: MESH_DIRECT_PROBE_RETRY_TIMEOUT_MS,
|
|
48084
|
+
getConnection: this.deps.getMeshPeerConnectionStatus,
|
|
48085
|
+
onConnection: (connection) => {
|
|
48086
|
+
status.connection = connection;
|
|
48044
48087
|
}
|
|
48045
|
-
}
|
|
48046
|
-
|
|
48047
|
-
|
|
48048
|
-
|
|
48049
|
-
|
|
48050
|
-
|
|
48051
|
-
|
|
48052
|
-
|
|
48053
|
-
|
|
48054
|
-
workspace,
|
|
48055
|
-
timeoutMs: MESH_DIRECT_PROBE_RETRY_TIMEOUT_MS
|
|
48056
|
-
});
|
|
48057
|
-
if (remoteGit) {
|
|
48058
|
-
status.git = remoteGit;
|
|
48059
|
-
status.health = remoteGit.isGitRepo ? deriveMeshNodeHealthFromGit(remoteGit) : "degraded";
|
|
48060
|
-
const connection = readObjectRecord(status.connection);
|
|
48061
|
-
const connectionState = readStringValue(connection.state);
|
|
48062
|
-
const connectionReported = readBooleanValue(connection.reported) ?? false;
|
|
48063
|
-
if (!connectionReported || connectionState === "unknown") {
|
|
48064
|
-
status.connection = buildLivePeerGitConnection(connection, refreshedAt);
|
|
48065
|
-
}
|
|
48066
|
-
recordInlineMeshDirectGitTruth(node, remoteGit, "selected_coordinator_mesh_p2p_git");
|
|
48067
|
-
remoteProbeApplied = true;
|
|
48068
|
-
}
|
|
48069
|
-
} catch {
|
|
48070
|
-
}
|
|
48088
|
+
});
|
|
48089
|
+
if (remoteGit) {
|
|
48090
|
+
status.git = remoteGit;
|
|
48091
|
+
status.health = remoteGit.isGitRepo ? deriveMeshNodeHealthFromGit(remoteGit) : "degraded";
|
|
48092
|
+
const connection = readObjectRecord(status.connection);
|
|
48093
|
+
const connectionState = readStringValue(connection.state);
|
|
48094
|
+
const connectionReported = readBooleanValue(connection.reported) ?? false;
|
|
48095
|
+
if (!connectionReported || connectionState === "unknown") {
|
|
48096
|
+
status.connection = buildLivePeerGitConnection(connection, refreshedAt);
|
|
48071
48097
|
}
|
|
48098
|
+
recordInlineMeshDirectGitTruth(node, remoteGit, "selected_coordinator_mesh_p2p_git");
|
|
48099
|
+
remoteProbeApplied = true;
|
|
48072
48100
|
}
|
|
48073
48101
|
}
|
|
48074
48102
|
if (!remoteProbeApplied) {
|
|
@@ -48137,7 +48165,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
48137
48165
|
liveSessionRecords: liveMeshSessions
|
|
48138
48166
|
});
|
|
48139
48167
|
const { getMeshStatusMissionSummaries: getMeshStatusMissionSummaries2 } = await Promise.resolve().then(() => (init_mesh_missions(), mesh_missions_exports));
|
|
48140
|
-
const missions = getMeshStatusMissionSummaries2(meshId, { verbose: verboseMissions });
|
|
48168
|
+
const missions = getMeshStatusMissionSummaries2(meshId, { verbose: verboseMissions, withStats: true });
|
|
48141
48169
|
const statusResult = {
|
|
48142
48170
|
success: true,
|
|
48143
48171
|
meshId: mesh.id,
|