adhdev 0.9.82-rc.44 → 0.9.82-rc.46

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 CHANGED
@@ -45782,8 +45782,12 @@ function buildInlineMeshTransitGitStatus(node) {
45782
45782
  const probeGitResult = readObjectRecord(probeGit.result);
45783
45783
  const probeDirectStatus = readObjectRecord(probeGit.status);
45784
45784
  const probeNestedStatus = readObjectRecord(probeGitResult.status);
45785
- const status = Object.keys(directStatus).length ? directStatus : Object.keys(nestedStatus).length ? nestedStatus : Object.keys(probeDirectStatus).length ? probeDirectStatus : Object.keys(probeNestedStatus).length ? probeNestedStatus : {};
45786
- return normalizeInlineMeshGitStatus(status, node, { lastCheckedAt: Date.now() });
45785
+ const candidates = [directStatus, nestedStatus, probeDirectStatus, probeNestedStatus];
45786
+ for (const status of candidates) {
45787
+ const normalized = normalizeInlineMeshGitStatus(status, node, { lastCheckedAt: Date.now() });
45788
+ if (normalized) return normalized;
45789
+ }
45790
+ return void 0;
45787
45791
  }
45788
45792
  function recordInlineMeshDirectGitTruth(node, git, source) {
45789
45793
  if (!node || typeof node !== "object" || Array.isArray(node)) return;
@@ -46689,10 +46693,69 @@ var init_router = __esm({
46689
46693
  if (typeof structuredClone === "function") return structuredClone(value);
46690
46694
  return JSON.parse(JSON.stringify(value));
46691
46695
  }
46692
- getCachedAggregateMeshStatus(meshId) {
46696
+ hydrateCachedAggregateMeshStatusFromInline(snapshot, mesh, options) {
46697
+ if (!mesh || typeof mesh !== "object" || !Array.isArray(mesh.nodes) || !Array.isArray(snapshot?.nodes)) return snapshot;
46698
+ const inlineNodesById = /* @__PURE__ */ new Map();
46699
+ for (const node of mesh.nodes) {
46700
+ const nodeId = readInlineMeshNodeId(node);
46701
+ if (nodeId) inlineNodesById.set(nodeId, node);
46702
+ }
46703
+ if (!inlineNodesById.size) return snapshot;
46704
+ let changed = false;
46705
+ const unavailableNodeIds = /* @__PURE__ */ new Set();
46706
+ const sourceOfTruth = readObjectRecord(snapshot.sourceOfTruth);
46707
+ const directPeerTruth = readObjectRecord(sourceOfTruth.directPeerTruth);
46708
+ for (const entry of Array.isArray(directPeerTruth.unavailableNodeIds) ? directPeerTruth.unavailableNodeIds : []) {
46709
+ const nodeId = readStringValue(entry);
46710
+ if (nodeId) unavailableNodeIds.add(nodeId);
46711
+ }
46712
+ const nodes = snapshot.nodes.map((statusNode) => {
46713
+ const nodeId = readStringValue(statusNode?.nodeId, statusNode?.id);
46714
+ const inlineNode = nodeId ? inlineNodesById.get(nodeId) : void 0;
46715
+ if (!inlineNode) return statusNode;
46716
+ const liveGit = buildInlineMeshTransitGitStatus(inlineNode);
46717
+ if (!liveGit) return statusNode;
46718
+ const nextStatus = { ...statusNode };
46719
+ nextStatus.git = liveGit;
46720
+ nextStatus.health = deriveMeshNodeHealthFromGit(liveGit);
46721
+ delete nextStatus.gitProbePending;
46722
+ if (readStringValue(nextStatus.error) === "waiting for live peer git snapshot") delete nextStatus.error;
46723
+ if (!readStringValue(nextStatus.machineStatus)) nextStatus.machineStatus = "online";
46724
+ if (nodeId) unavailableNodeIds.delete(nodeId);
46725
+ changed = true;
46726
+ return nextStatus;
46727
+ });
46728
+ if (!changed && !(options?.requireDirectPeerTruth && unavailableNodeIds.size > 0)) return snapshot;
46729
+ const nextSourceOfTruth = {
46730
+ ...sourceOfTruth,
46731
+ ...Object.keys(directPeerTruth).length ? {
46732
+ directPeerTruth: {
46733
+ ...directPeerTruth,
46734
+ satisfied: options?.requireDirectPeerTruth === true ? unavailableNodeIds.size === 0 : directPeerTruth.satisfied,
46735
+ unavailableNodeIds: [...unavailableNodeIds]
46736
+ },
46737
+ ...options?.requireDirectPeerTruth === true ? {
46738
+ coordinatorOwnsLiveTruth: unavailableNodeIds.size === 0,
46739
+ currentStatus: unavailableNodeIds.size === 0 ? "live_git_and_session_probes" : "direct_peer_truth_unavailable"
46740
+ } : {}
46741
+ } : {}
46742
+ };
46743
+ return {
46744
+ ...snapshot,
46745
+ ...options?.requireDirectPeerTruth === true && unavailableNodeIds.size > 0 ? {
46746
+ success: false,
46747
+ code: "mesh_direct_peer_truth_unavailable",
46748
+ error: "Selected coordinator could not confirm direct mesh truth for every remote node yet."
46749
+ } : {},
46750
+ sourceOfTruth: nextSourceOfTruth,
46751
+ nodes
46752
+ };
46753
+ }
46754
+ getCachedAggregateMeshStatus(meshId, mesh, options) {
46693
46755
  const cached2 = this.aggregateMeshStatusCache.get(meshId);
46694
46756
  if (!cached2?.snapshot || cached2.snapshot.success !== true || !Array.isArray(cached2.snapshot.nodes)) return null;
46695
- const snapshot = this.cloneJsonValue(cached2.snapshot);
46757
+ let snapshot = this.cloneJsonValue(cached2.snapshot);
46758
+ snapshot = this.hydrateCachedAggregateMeshStatusFromInline(snapshot, mesh, options);
46696
46759
  const ageMs = Math.max(0, Date.now() - cached2.builtAt);
46697
46760
  const sourceOfTruth = snapshot.sourceOfTruth && typeof snapshot.sourceOfTruth === "object" ? snapshot.sourceOfTruth : {};
46698
46761
  snapshot.sourceOfTruth = {
@@ -46752,7 +46815,14 @@ var init_router = __esm({
46752
46815
  const preferInline = options?.preferInline === true;
46753
46816
  if (preferInline) {
46754
46817
  const cached3 = this.getCachedInlineMesh(meshId);
46755
- if (cached3) return { mesh: cached3, inline: true, source: "inline_cache" };
46818
+ if (cached3) {
46819
+ if (inlineMeshCarriesTransientNodeTruth(inlineMesh)) {
46820
+ const merged = reconcileInlineMeshCache(cached3, inlineMesh);
46821
+ this.inlineMeshCache.set(meshId, sanitizeInlineMesh(merged));
46822
+ return { mesh: merged, inline: true, source: "inline_cache" };
46823
+ }
46824
+ return { mesh: cached3, inline: true, source: "inline_cache" };
46825
+ }
46756
46826
  if (inlineMeshCarriesTransientNodeTruth(inlineMesh)) {
46757
46827
  this.warmInlineMeshCache(meshId, inlineMesh);
46758
46828
  return { mesh: inlineMesh, inline: true, source: "inline_bootstrap" };
@@ -48732,7 +48802,7 @@ ${block}`);
48732
48802
  if (!mesh) return { success: false, error: "Mesh not found" };
48733
48803
  const refreshRequested = args?.refresh === true || args?.forceRefresh === true;
48734
48804
  if (!refreshRequested) {
48735
- const cachedStatus = this.getCachedAggregateMeshStatus(meshId);
48805
+ const cachedStatus = this.getCachedAggregateMeshStatus(meshId, mesh, { requireDirectPeerTruth: args?.requireDirectPeerTruth === true });
48736
48806
  if (cachedStatus) {
48737
48807
  logRepoMeshStatusDebug("return_cached", {
48738
48808
  meshId,
@@ -48767,7 +48837,9 @@ ${block}`);
48767
48837
  peerConfirmedCount: 0,
48768
48838
  unavailableNodeIds: []
48769
48839
  };
48770
- const directTruthSatisfied = meshRecord.source !== "inline_bootstrap" || directTruth.directEvidenceCount > 0;
48840
+ const passivePeerTruthNotAttempted = requireDirectPeerTruth && !refreshRequested && directTruth.directEvidenceCount > 0 && directTruth.peerAttemptedCount === 0;
48841
+ const effectiveDirectTruth = passivePeerTruthNotAttempted ? { ...directTruth, unavailableNodeIds: [] } : directTruth;
48842
+ const directTruthSatisfied = !requireDirectPeerTruth || effectiveDirectTruth.directEvidenceCount > 0 && effectiveDirectTruth.unavailableNodeIds.length === 0;
48771
48843
  if (requireDirectPeerTruth && !directTruthSatisfied) {
48772
48844
  const failureResult = {
48773
48845
  success: false,
@@ -48797,7 +48869,7 @@ ${block}`);
48797
48869
  });
48798
48870
  return failureResult;
48799
48871
  }
48800
- const directTruthUnavailableNodeIds = new Set(directTruth.unavailableNodeIds);
48872
+ const directTruthUnavailableNodeIds = new Set(effectiveDirectTruth.unavailableNodeIds);
48801
48873
  const selectedCoordinatorNodeId = readStringValue(
48802
48874
  mesh.coordinator?.preferredNodeId,
48803
48875
  mesh.nodes?.[0]?.id,
@@ -48990,11 +49062,11 @@ ${block}`);
48990
49062
  directPeerTruth: {
48991
49063
  required: true,
48992
49064
  satisfied: directTruthSatisfied,
48993
- directEvidenceCount: directTruth.directEvidenceCount,
48994
- localConfirmedCount: directTruth.localConfirmedCount,
48995
- peerAttemptedCount: directTruth.peerAttemptedCount,
48996
- peerConfirmedCount: directTruth.peerConfirmedCount,
48997
- unavailableNodeIds: directTruth.unavailableNodeIds
49065
+ directEvidenceCount: effectiveDirectTruth.directEvidenceCount,
49066
+ localConfirmedCount: effectiveDirectTruth.localConfirmedCount,
49067
+ peerAttemptedCount: effectiveDirectTruth.peerAttemptedCount,
49068
+ peerConfirmedCount: effectiveDirectTruth.peerConfirmedCount,
49069
+ unavailableNodeIds: effectiveDirectTruth.unavailableNodeIds
48998
49070
  }
48999
49071
  } : {},
49000
49072
  historicalEvidenceOnly: ["recoveryHints", "ledger.summary", "queue.summary"]
@@ -68066,7 +68138,7 @@ var init_adhdev_daemon = __esm({
68066
68138
  init_version();
68067
68139
  init_src();
68068
68140
  init_runtime_defaults();
68069
- pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.82-rc.44" });
68141
+ pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.82-rc.46" });
68070
68142
  AdhdevDaemon = class _AdhdevDaemon {
68071
68143
  localHttpServer = null;
68072
68144
  localWss = null;