adhdev 0.9.82-rc.45 → 0.9.82-rc.47
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/cli/index.js +83 -13
- package/dist/cli/index.js.map +1 -1
- package/dist/index.js +83 -13
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -45772,6 +45772,21 @@ function normalizeInlineMeshGitStatus(status, node, options) {
|
|
|
45772
45772
|
...submodules ? { submodules } : {}
|
|
45773
45773
|
};
|
|
45774
45774
|
}
|
|
45775
|
+
function scoreInlineMeshGitStatus(git) {
|
|
45776
|
+
if (!git) return Number.NEGATIVE_INFINITY;
|
|
45777
|
+
let score = 0;
|
|
45778
|
+
if (readBooleanValue(git.isGitRepo) === true) score += 50;
|
|
45779
|
+
if (readBooleanValue(git.isGitRepo) === false) score -= 10;
|
|
45780
|
+
if (readStringValue(git.branch)) score += 20;
|
|
45781
|
+
if (readStringValue(git.headCommit)) score += 20;
|
|
45782
|
+
if (readStringValue(git.upstream)) score += 10;
|
|
45783
|
+
if (readStringValue(git.upstreamStatus)) score += 5;
|
|
45784
|
+
if (readNumberValue(git.ahead) !== void 0) score += 2;
|
|
45785
|
+
if (readNumberValue(git.behind) !== void 0) score += 2;
|
|
45786
|
+
if (Array.isArray(git.submodules) && git.submodules.length > 0) score += 4 + git.submodules.length;
|
|
45787
|
+
if (readStringValue(git.error)) score -= 20;
|
|
45788
|
+
return score;
|
|
45789
|
+
}
|
|
45775
45790
|
function buildInlineMeshTransitGitStatus(node) {
|
|
45776
45791
|
const rawGit = readObjectRecord(node?.lastGit ?? node?.last_git);
|
|
45777
45792
|
const gitResult = readObjectRecord(rawGit.result);
|
|
@@ -45783,11 +45798,36 @@ function buildInlineMeshTransitGitStatus(node) {
|
|
|
45783
45798
|
const probeDirectStatus = readObjectRecord(probeGit.status);
|
|
45784
45799
|
const probeNestedStatus = readObjectRecord(probeGitResult.status);
|
|
45785
45800
|
const candidates = [directStatus, nestedStatus, probeDirectStatus, probeNestedStatus];
|
|
45801
|
+
let best = null;
|
|
45786
45802
|
for (const status of candidates) {
|
|
45787
45803
|
const normalized = normalizeInlineMeshGitStatus(status, node, { lastCheckedAt: Date.now() });
|
|
45788
|
-
if (normalized)
|
|
45789
|
-
|
|
45790
|
-
|
|
45804
|
+
if (!normalized) continue;
|
|
45805
|
+
const score = scoreInlineMeshGitStatus(normalized);
|
|
45806
|
+
if (!best || score > best.score) best = { git: normalized, score };
|
|
45807
|
+
}
|
|
45808
|
+
return best?.git;
|
|
45809
|
+
}
|
|
45810
|
+
function shouldRefreshStalePendingAggregate(snapshot, options) {
|
|
45811
|
+
if (options?.requireDirectPeerTruth !== true || !Array.isArray(snapshot?.nodes)) return false;
|
|
45812
|
+
return snapshot.nodes.some((node) => {
|
|
45813
|
+
if (node?.gitProbePending !== true) return false;
|
|
45814
|
+
const git = readObjectRecord(node?.git);
|
|
45815
|
+
return !readBooleanValue(git.isGitRepo) && !readStringValue(git.branch, git.headCommit, git.upstream);
|
|
45816
|
+
});
|
|
45817
|
+
}
|
|
45818
|
+
function buildLivePeerGitConnection(connection, timestamp2 = (/* @__PURE__ */ new Date()).toISOString()) {
|
|
45819
|
+
const source = readStringValue(connection.source);
|
|
45820
|
+
const transport = readStringValue(connection.transport);
|
|
45821
|
+
return {
|
|
45822
|
+
...connection,
|
|
45823
|
+
perspective: readStringValue(connection.perspective) ?? "selected_coordinator",
|
|
45824
|
+
source: source && source !== "not_reported" ? source : "mesh_peer_status",
|
|
45825
|
+
state: "connected",
|
|
45826
|
+
transport: transport && transport !== "unknown" ? transport : "direct",
|
|
45827
|
+
reported: true,
|
|
45828
|
+
reason: "Live peer git snapshot reported by the selected coordinator.",
|
|
45829
|
+
lastStateChangeAt: readStringValue(connection.lastStateChangeAt) ?? timestamp2
|
|
45830
|
+
};
|
|
45791
45831
|
}
|
|
45792
45832
|
function recordInlineMeshDirectGitTruth(node, git, source) {
|
|
45793
45833
|
if (!node || typeof node !== "object" || Array.isArray(node)) return;
|
|
@@ -46718,8 +46758,16 @@ var init_router = __esm({
|
|
|
46718
46758
|
const nextStatus = { ...statusNode };
|
|
46719
46759
|
nextStatus.git = liveGit;
|
|
46720
46760
|
nextStatus.health = deriveMeshNodeHealthFromGit(liveGit);
|
|
46761
|
+
nextStatus.launchReady = readBooleanValue(nextStatus.launchReady) ?? true;
|
|
46762
|
+
const connection = readObjectRecord(nextStatus.connection);
|
|
46763
|
+
const connectionState = readStringValue(connection.state);
|
|
46764
|
+
const connectionReported = readBooleanValue(connection.reported) ?? false;
|
|
46765
|
+
if (!connectionReported || connectionState === "unknown") {
|
|
46766
|
+
nextStatus.connection = buildLivePeerGitConnection(connection);
|
|
46767
|
+
}
|
|
46721
46768
|
delete nextStatus.gitProbePending;
|
|
46722
|
-
|
|
46769
|
+
const error48 = readStringValue(nextStatus.error);
|
|
46770
|
+
if (error48 && /pending_git|git probe|live peer git snapshot|no peer git snapshot/i.test(error48)) delete nextStatus.error;
|
|
46723
46771
|
if (!readStringValue(nextStatus.machineStatus)) nextStatus.machineStatus = "online";
|
|
46724
46772
|
if (nodeId) unavailableNodeIds.delete(nodeId);
|
|
46725
46773
|
changed = true;
|
|
@@ -46756,6 +46804,7 @@ var init_router = __esm({
|
|
|
46756
46804
|
if (!cached2?.snapshot || cached2.snapshot.success !== true || !Array.isArray(cached2.snapshot.nodes)) return null;
|
|
46757
46805
|
let snapshot = this.cloneJsonValue(cached2.snapshot);
|
|
46758
46806
|
snapshot = this.hydrateCachedAggregateMeshStatusFromInline(snapshot, mesh, options);
|
|
46807
|
+
if (shouldRefreshStalePendingAggregate(snapshot, options)) return null;
|
|
46759
46808
|
const ageMs = Math.max(0, Date.now() - cached2.builtAt);
|
|
46760
46809
|
const sourceOfTruth = snapshot.sourceOfTruth && typeof snapshot.sourceOfTruth === "object" ? snapshot.sourceOfTruth : {};
|
|
46761
46810
|
snapshot.sourceOfTruth = {
|
|
@@ -48801,6 +48850,7 @@ ${block}`);
|
|
|
48801
48850
|
const mesh = meshRecord?.mesh;
|
|
48802
48851
|
if (!mesh) return { success: false, error: "Mesh not found" };
|
|
48803
48852
|
const refreshRequested = args?.refresh === true || args?.forceRefresh === true;
|
|
48853
|
+
const hadAggregateCache = this.aggregateMeshStatusCache.has(meshId);
|
|
48804
48854
|
if (!refreshRequested) {
|
|
48805
48855
|
const cachedStatus = this.getCachedAggregateMeshStatus(meshId, mesh, { requireDirectPeerTruth: args?.requireDirectPeerTruth === true });
|
|
48806
48856
|
if (cachedStatus) {
|
|
@@ -48813,7 +48863,7 @@ ${block}`);
|
|
|
48813
48863
|
return cachedStatus;
|
|
48814
48864
|
}
|
|
48815
48865
|
}
|
|
48816
|
-
const refreshReason = refreshRequested ? "explicit_refresh" : "cold_cache_miss";
|
|
48866
|
+
const refreshReason = refreshRequested ? "explicit_refresh" : hadAggregateCache ? "stale_pending_cache_refresh" : "cold_cache_miss";
|
|
48817
48867
|
const { getMeshQueueStats: getMeshQueueStats2, getQueue: getQueue2 } = await Promise.resolve().then(() => (init_mesh_work_queue(), mesh_work_queue_exports));
|
|
48818
48868
|
const queue = getQueue2(meshId);
|
|
48819
48869
|
const queueSummary = getMeshQueueStats2(meshId);
|
|
@@ -48837,7 +48887,9 @@ ${block}`);
|
|
|
48837
48887
|
peerConfirmedCount: 0,
|
|
48838
48888
|
unavailableNodeIds: []
|
|
48839
48889
|
};
|
|
48840
|
-
const
|
|
48890
|
+
const passivePeerTruthNotAttempted = requireDirectPeerTruth && !refreshRequested && directTruth.directEvidenceCount > 0 && directTruth.peerAttemptedCount === 0;
|
|
48891
|
+
const effectiveDirectTruth = passivePeerTruthNotAttempted ? { ...directTruth, unavailableNodeIds: [] } : directTruth;
|
|
48892
|
+
const directTruthSatisfied = !requireDirectPeerTruth || effectiveDirectTruth.directEvidenceCount > 0 && effectiveDirectTruth.unavailableNodeIds.length === 0;
|
|
48841
48893
|
if (requireDirectPeerTruth && !directTruthSatisfied) {
|
|
48842
48894
|
const failureResult = {
|
|
48843
48895
|
success: false,
|
|
@@ -48867,7 +48919,7 @@ ${block}`);
|
|
|
48867
48919
|
});
|
|
48868
48920
|
return failureResult;
|
|
48869
48921
|
}
|
|
48870
|
-
const directTruthUnavailableNodeIds = new Set(
|
|
48922
|
+
const directTruthUnavailableNodeIds = new Set(effectiveDirectTruth.unavailableNodeIds);
|
|
48871
48923
|
const selectedCoordinatorNodeId = readStringValue(
|
|
48872
48924
|
mesh.coordinator?.preferredNodeId,
|
|
48873
48925
|
mesh.nodes?.[0]?.id,
|
|
@@ -48962,6 +49014,12 @@ ${block}`);
|
|
|
48962
49014
|
if (inlineTransitGit) {
|
|
48963
49015
|
status.git = inlineTransitGit;
|
|
48964
49016
|
status.health = inlineTransitGit.isGitRepo ? deriveMeshNodeHealthFromGit(inlineTransitGit) : "degraded";
|
|
49017
|
+
const connection = readObjectRecord(status.connection);
|
|
49018
|
+
const connectionState = readStringValue(connection.state);
|
|
49019
|
+
const connectionReported = readBooleanValue(connection.reported) ?? false;
|
|
49020
|
+
if (!connectionReported || connectionState === "unknown") {
|
|
49021
|
+
status.connection = buildLivePeerGitConnection(connection, refreshedAt);
|
|
49022
|
+
}
|
|
48965
49023
|
remoteProbeApplied = true;
|
|
48966
49024
|
} else if (!isSelfNode && daemonId && this.deps.dispatchMeshCommand && !directTruthUnavailableNodeIds.has(nodeId)) {
|
|
48967
49025
|
try {
|
|
@@ -48974,6 +49032,12 @@ ${block}`);
|
|
|
48974
49032
|
if (remoteGit) {
|
|
48975
49033
|
status.git = remoteGit;
|
|
48976
49034
|
status.health = remoteGit.isGitRepo ? deriveMeshNodeHealthFromGit(remoteGit) : "degraded";
|
|
49035
|
+
const connection = readObjectRecord(status.connection);
|
|
49036
|
+
const connectionState = readStringValue(connection.state);
|
|
49037
|
+
const connectionReported = readBooleanValue(connection.reported) ?? false;
|
|
49038
|
+
if (!connectionReported || connectionState === "unknown") {
|
|
49039
|
+
status.connection = buildLivePeerGitConnection(connection, refreshedAt);
|
|
49040
|
+
}
|
|
48977
49041
|
recordInlineMeshDirectGitTruth(node, remoteGit, "selected_coordinator_mesh_p2p_git");
|
|
48978
49042
|
remoteProbeApplied = true;
|
|
48979
49043
|
}
|
|
@@ -48992,6 +49056,12 @@ ${block}`);
|
|
|
48992
49056
|
if (remoteGit) {
|
|
48993
49057
|
status.git = remoteGit;
|
|
48994
49058
|
status.health = remoteGit.isGitRepo ? deriveMeshNodeHealthFromGit(remoteGit) : "degraded";
|
|
49059
|
+
const connection = readObjectRecord(status.connection);
|
|
49060
|
+
const connectionState = readStringValue(connection.state);
|
|
49061
|
+
const connectionReported = readBooleanValue(connection.reported) ?? false;
|
|
49062
|
+
if (!connectionReported || connectionState === "unknown") {
|
|
49063
|
+
status.connection = buildLivePeerGitConnection(connection, refreshedAt);
|
|
49064
|
+
}
|
|
48995
49065
|
recordInlineMeshDirectGitTruth(node, remoteGit, "selected_coordinator_mesh_p2p_git");
|
|
48996
49066
|
remoteProbeApplied = true;
|
|
48997
49067
|
}
|
|
@@ -49060,11 +49130,11 @@ ${block}`);
|
|
|
49060
49130
|
directPeerTruth: {
|
|
49061
49131
|
required: true,
|
|
49062
49132
|
satisfied: directTruthSatisfied,
|
|
49063
|
-
directEvidenceCount:
|
|
49064
|
-
localConfirmedCount:
|
|
49065
|
-
peerAttemptedCount:
|
|
49066
|
-
peerConfirmedCount:
|
|
49067
|
-
unavailableNodeIds:
|
|
49133
|
+
directEvidenceCount: effectiveDirectTruth.directEvidenceCount,
|
|
49134
|
+
localConfirmedCount: effectiveDirectTruth.localConfirmedCount,
|
|
49135
|
+
peerAttemptedCount: effectiveDirectTruth.peerAttemptedCount,
|
|
49136
|
+
peerConfirmedCount: effectiveDirectTruth.peerConfirmedCount,
|
|
49137
|
+
unavailableNodeIds: effectiveDirectTruth.unavailableNodeIds
|
|
49068
49138
|
}
|
|
49069
49139
|
} : {},
|
|
49070
49140
|
historicalEvidenceOnly: ["recoveryHints", "ledger.summary", "queue.summary"]
|
|
@@ -68136,7 +68206,7 @@ var init_adhdev_daemon = __esm({
|
|
|
68136
68206
|
init_version();
|
|
68137
68207
|
init_src();
|
|
68138
68208
|
init_runtime_defaults();
|
|
68139
|
-
pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.82-rc.
|
|
68209
|
+
pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.82-rc.47" });
|
|
68140
68210
|
AdhdevDaemon = class _AdhdevDaemon {
|
|
68141
68211
|
localHttpServer = null;
|
|
68142
68212
|
localWss = null;
|