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/cli/index.js
CHANGED
|
@@ -46760,6 +46760,21 @@ function normalizeInlineMeshGitStatus(status, node, options) {
|
|
|
46760
46760
|
...submodules ? { submodules } : {}
|
|
46761
46761
|
};
|
|
46762
46762
|
}
|
|
46763
|
+
function scoreInlineMeshGitStatus(git) {
|
|
46764
|
+
if (!git) return Number.NEGATIVE_INFINITY;
|
|
46765
|
+
let score = 0;
|
|
46766
|
+
if (readBooleanValue(git.isGitRepo) === true) score += 50;
|
|
46767
|
+
if (readBooleanValue(git.isGitRepo) === false) score -= 10;
|
|
46768
|
+
if (readStringValue(git.branch)) score += 20;
|
|
46769
|
+
if (readStringValue(git.headCommit)) score += 20;
|
|
46770
|
+
if (readStringValue(git.upstream)) score += 10;
|
|
46771
|
+
if (readStringValue(git.upstreamStatus)) score += 5;
|
|
46772
|
+
if (readNumberValue(git.ahead) !== void 0) score += 2;
|
|
46773
|
+
if (readNumberValue(git.behind) !== void 0) score += 2;
|
|
46774
|
+
if (Array.isArray(git.submodules) && git.submodules.length > 0) score += 4 + git.submodules.length;
|
|
46775
|
+
if (readStringValue(git.error)) score -= 20;
|
|
46776
|
+
return score;
|
|
46777
|
+
}
|
|
46763
46778
|
function buildInlineMeshTransitGitStatus(node) {
|
|
46764
46779
|
const rawGit = readObjectRecord(node?.lastGit ?? node?.last_git);
|
|
46765
46780
|
const gitResult = readObjectRecord(rawGit.result);
|
|
@@ -46771,11 +46786,36 @@ function buildInlineMeshTransitGitStatus(node) {
|
|
|
46771
46786
|
const probeDirectStatus = readObjectRecord(probeGit.status);
|
|
46772
46787
|
const probeNestedStatus = readObjectRecord(probeGitResult.status);
|
|
46773
46788
|
const candidates = [directStatus, nestedStatus, probeDirectStatus, probeNestedStatus];
|
|
46789
|
+
let best = null;
|
|
46774
46790
|
for (const status of candidates) {
|
|
46775
46791
|
const normalized = normalizeInlineMeshGitStatus(status, node, { lastCheckedAt: Date.now() });
|
|
46776
|
-
if (normalized)
|
|
46777
|
-
|
|
46778
|
-
|
|
46792
|
+
if (!normalized) continue;
|
|
46793
|
+
const score = scoreInlineMeshGitStatus(normalized);
|
|
46794
|
+
if (!best || score > best.score) best = { git: normalized, score };
|
|
46795
|
+
}
|
|
46796
|
+
return best?.git;
|
|
46797
|
+
}
|
|
46798
|
+
function shouldRefreshStalePendingAggregate(snapshot, options) {
|
|
46799
|
+
if (options?.requireDirectPeerTruth !== true || !Array.isArray(snapshot?.nodes)) return false;
|
|
46800
|
+
return snapshot.nodes.some((node) => {
|
|
46801
|
+
if (node?.gitProbePending !== true) return false;
|
|
46802
|
+
const git = readObjectRecord(node?.git);
|
|
46803
|
+
return !readBooleanValue(git.isGitRepo) && !readStringValue(git.branch, git.headCommit, git.upstream);
|
|
46804
|
+
});
|
|
46805
|
+
}
|
|
46806
|
+
function buildLivePeerGitConnection(connection, timestamp2 = (/* @__PURE__ */ new Date()).toISOString()) {
|
|
46807
|
+
const source = readStringValue(connection.source);
|
|
46808
|
+
const transport = readStringValue(connection.transport);
|
|
46809
|
+
return {
|
|
46810
|
+
...connection,
|
|
46811
|
+
perspective: readStringValue(connection.perspective) ?? "selected_coordinator",
|
|
46812
|
+
source: source && source !== "not_reported" ? source : "mesh_peer_status",
|
|
46813
|
+
state: "connected",
|
|
46814
|
+
transport: transport && transport !== "unknown" ? transport : "direct",
|
|
46815
|
+
reported: true,
|
|
46816
|
+
reason: "Live peer git snapshot reported by the selected coordinator.",
|
|
46817
|
+
lastStateChangeAt: readStringValue(connection.lastStateChangeAt) ?? timestamp2
|
|
46818
|
+
};
|
|
46779
46819
|
}
|
|
46780
46820
|
function recordInlineMeshDirectGitTruth(node, git, source) {
|
|
46781
46821
|
if (!node || typeof node !== "object" || Array.isArray(node)) return;
|
|
@@ -47706,8 +47746,16 @@ var init_router = __esm({
|
|
|
47706
47746
|
const nextStatus = { ...statusNode };
|
|
47707
47747
|
nextStatus.git = liveGit;
|
|
47708
47748
|
nextStatus.health = deriveMeshNodeHealthFromGit(liveGit);
|
|
47749
|
+
nextStatus.launchReady = readBooleanValue(nextStatus.launchReady) ?? true;
|
|
47750
|
+
const connection = readObjectRecord(nextStatus.connection);
|
|
47751
|
+
const connectionState = readStringValue(connection.state);
|
|
47752
|
+
const connectionReported = readBooleanValue(connection.reported) ?? false;
|
|
47753
|
+
if (!connectionReported || connectionState === "unknown") {
|
|
47754
|
+
nextStatus.connection = buildLivePeerGitConnection(connection);
|
|
47755
|
+
}
|
|
47709
47756
|
delete nextStatus.gitProbePending;
|
|
47710
|
-
|
|
47757
|
+
const error48 = readStringValue(nextStatus.error);
|
|
47758
|
+
if (error48 && /pending_git|git probe|live peer git snapshot|no peer git snapshot/i.test(error48)) delete nextStatus.error;
|
|
47711
47759
|
if (!readStringValue(nextStatus.machineStatus)) nextStatus.machineStatus = "online";
|
|
47712
47760
|
if (nodeId) unavailableNodeIds.delete(nodeId);
|
|
47713
47761
|
changed = true;
|
|
@@ -47744,6 +47792,7 @@ var init_router = __esm({
|
|
|
47744
47792
|
if (!cached2?.snapshot || cached2.snapshot.success !== true || !Array.isArray(cached2.snapshot.nodes)) return null;
|
|
47745
47793
|
let snapshot = this.cloneJsonValue(cached2.snapshot);
|
|
47746
47794
|
snapshot = this.hydrateCachedAggregateMeshStatusFromInline(snapshot, mesh, options);
|
|
47795
|
+
if (shouldRefreshStalePendingAggregate(snapshot, options)) return null;
|
|
47747
47796
|
const ageMs = Math.max(0, Date.now() - cached2.builtAt);
|
|
47748
47797
|
const sourceOfTruth = snapshot.sourceOfTruth && typeof snapshot.sourceOfTruth === "object" ? snapshot.sourceOfTruth : {};
|
|
47749
47798
|
snapshot.sourceOfTruth = {
|
|
@@ -49789,6 +49838,7 @@ ${block}`);
|
|
|
49789
49838
|
const mesh = meshRecord?.mesh;
|
|
49790
49839
|
if (!mesh) return { success: false, error: "Mesh not found" };
|
|
49791
49840
|
const refreshRequested = args?.refresh === true || args?.forceRefresh === true;
|
|
49841
|
+
const hadAggregateCache = this.aggregateMeshStatusCache.has(meshId);
|
|
49792
49842
|
if (!refreshRequested) {
|
|
49793
49843
|
const cachedStatus = this.getCachedAggregateMeshStatus(meshId, mesh, { requireDirectPeerTruth: args?.requireDirectPeerTruth === true });
|
|
49794
49844
|
if (cachedStatus) {
|
|
@@ -49801,7 +49851,7 @@ ${block}`);
|
|
|
49801
49851
|
return cachedStatus;
|
|
49802
49852
|
}
|
|
49803
49853
|
}
|
|
49804
|
-
const refreshReason = refreshRequested ? "explicit_refresh" : "cold_cache_miss";
|
|
49854
|
+
const refreshReason = refreshRequested ? "explicit_refresh" : hadAggregateCache ? "stale_pending_cache_refresh" : "cold_cache_miss";
|
|
49805
49855
|
const { getMeshQueueStats: getMeshQueueStats2, getQueue: getQueue2 } = await Promise.resolve().then(() => (init_mesh_work_queue(), mesh_work_queue_exports));
|
|
49806
49856
|
const queue = getQueue2(meshId);
|
|
49807
49857
|
const queueSummary = getMeshQueueStats2(meshId);
|
|
@@ -49825,7 +49875,9 @@ ${block}`);
|
|
|
49825
49875
|
peerConfirmedCount: 0,
|
|
49826
49876
|
unavailableNodeIds: []
|
|
49827
49877
|
};
|
|
49828
|
-
const
|
|
49878
|
+
const passivePeerTruthNotAttempted = requireDirectPeerTruth && !refreshRequested && directTruth.directEvidenceCount > 0 && directTruth.peerAttemptedCount === 0;
|
|
49879
|
+
const effectiveDirectTruth = passivePeerTruthNotAttempted ? { ...directTruth, unavailableNodeIds: [] } : directTruth;
|
|
49880
|
+
const directTruthSatisfied = !requireDirectPeerTruth || effectiveDirectTruth.directEvidenceCount > 0 && effectiveDirectTruth.unavailableNodeIds.length === 0;
|
|
49829
49881
|
if (requireDirectPeerTruth && !directTruthSatisfied) {
|
|
49830
49882
|
const failureResult = {
|
|
49831
49883
|
success: false,
|
|
@@ -49855,7 +49907,7 @@ ${block}`);
|
|
|
49855
49907
|
});
|
|
49856
49908
|
return failureResult;
|
|
49857
49909
|
}
|
|
49858
|
-
const directTruthUnavailableNodeIds = new Set(
|
|
49910
|
+
const directTruthUnavailableNodeIds = new Set(effectiveDirectTruth.unavailableNodeIds);
|
|
49859
49911
|
const selectedCoordinatorNodeId = readStringValue(
|
|
49860
49912
|
mesh.coordinator?.preferredNodeId,
|
|
49861
49913
|
mesh.nodes?.[0]?.id,
|
|
@@ -49950,6 +50002,12 @@ ${block}`);
|
|
|
49950
50002
|
if (inlineTransitGit) {
|
|
49951
50003
|
status.git = inlineTransitGit;
|
|
49952
50004
|
status.health = inlineTransitGit.isGitRepo ? deriveMeshNodeHealthFromGit(inlineTransitGit) : "degraded";
|
|
50005
|
+
const connection = readObjectRecord(status.connection);
|
|
50006
|
+
const connectionState = readStringValue(connection.state);
|
|
50007
|
+
const connectionReported = readBooleanValue(connection.reported) ?? false;
|
|
50008
|
+
if (!connectionReported || connectionState === "unknown") {
|
|
50009
|
+
status.connection = buildLivePeerGitConnection(connection, refreshedAt);
|
|
50010
|
+
}
|
|
49953
50011
|
remoteProbeApplied = true;
|
|
49954
50012
|
} else if (!isSelfNode && daemonId && this.deps.dispatchMeshCommand && !directTruthUnavailableNodeIds.has(nodeId)) {
|
|
49955
50013
|
try {
|
|
@@ -49962,6 +50020,12 @@ ${block}`);
|
|
|
49962
50020
|
if (remoteGit) {
|
|
49963
50021
|
status.git = remoteGit;
|
|
49964
50022
|
status.health = remoteGit.isGitRepo ? deriveMeshNodeHealthFromGit(remoteGit) : "degraded";
|
|
50023
|
+
const connection = readObjectRecord(status.connection);
|
|
50024
|
+
const connectionState = readStringValue(connection.state);
|
|
50025
|
+
const connectionReported = readBooleanValue(connection.reported) ?? false;
|
|
50026
|
+
if (!connectionReported || connectionState === "unknown") {
|
|
50027
|
+
status.connection = buildLivePeerGitConnection(connection, refreshedAt);
|
|
50028
|
+
}
|
|
49965
50029
|
recordInlineMeshDirectGitTruth(node, remoteGit, "selected_coordinator_mesh_p2p_git");
|
|
49966
50030
|
remoteProbeApplied = true;
|
|
49967
50031
|
}
|
|
@@ -49980,6 +50044,12 @@ ${block}`);
|
|
|
49980
50044
|
if (remoteGit) {
|
|
49981
50045
|
status.git = remoteGit;
|
|
49982
50046
|
status.health = remoteGit.isGitRepo ? deriveMeshNodeHealthFromGit(remoteGit) : "degraded";
|
|
50047
|
+
const connection = readObjectRecord(status.connection);
|
|
50048
|
+
const connectionState = readStringValue(connection.state);
|
|
50049
|
+
const connectionReported = readBooleanValue(connection.reported) ?? false;
|
|
50050
|
+
if (!connectionReported || connectionState === "unknown") {
|
|
50051
|
+
status.connection = buildLivePeerGitConnection(connection, refreshedAt);
|
|
50052
|
+
}
|
|
49983
50053
|
recordInlineMeshDirectGitTruth(node, remoteGit, "selected_coordinator_mesh_p2p_git");
|
|
49984
50054
|
remoteProbeApplied = true;
|
|
49985
50055
|
}
|
|
@@ -50048,11 +50118,11 @@ ${block}`);
|
|
|
50048
50118
|
directPeerTruth: {
|
|
50049
50119
|
required: true,
|
|
50050
50120
|
satisfied: directTruthSatisfied,
|
|
50051
|
-
directEvidenceCount:
|
|
50052
|
-
localConfirmedCount:
|
|
50053
|
-
peerAttemptedCount:
|
|
50054
|
-
peerConfirmedCount:
|
|
50055
|
-
unavailableNodeIds:
|
|
50121
|
+
directEvidenceCount: effectiveDirectTruth.directEvidenceCount,
|
|
50122
|
+
localConfirmedCount: effectiveDirectTruth.localConfirmedCount,
|
|
50123
|
+
peerAttemptedCount: effectiveDirectTruth.peerAttemptedCount,
|
|
50124
|
+
peerConfirmedCount: effectiveDirectTruth.peerConfirmedCount,
|
|
50125
|
+
unavailableNodeIds: effectiveDirectTruth.unavailableNodeIds
|
|
50056
50126
|
}
|
|
50057
50127
|
} : {},
|
|
50058
50128
|
historicalEvidenceOnly: ["recoveryHints", "ledger.summary", "queue.summary"]
|
|
@@ -99306,7 +99376,7 @@ var init_adhdev_daemon = __esm({
|
|
|
99306
99376
|
init_version();
|
|
99307
99377
|
init_src();
|
|
99308
99378
|
init_runtime_defaults();
|
|
99309
|
-
pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.82-rc.
|
|
99379
|
+
pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.82-rc.47" });
|
|
99310
99380
|
AdhdevDaemon = class _AdhdevDaemon {
|
|
99311
99381
|
localHttpServer = null;
|
|
99312
99382
|
localWss = null;
|