adhdev 0.9.82-rc.44 → 0.9.82-rc.45

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 CHANGED
@@ -46770,8 +46770,12 @@ function buildInlineMeshTransitGitStatus(node) {
46770
46770
  const probeGitResult = readObjectRecord(probeGit.result);
46771
46771
  const probeDirectStatus = readObjectRecord(probeGit.status);
46772
46772
  const probeNestedStatus = readObjectRecord(probeGitResult.status);
46773
- const status = Object.keys(directStatus).length ? directStatus : Object.keys(nestedStatus).length ? nestedStatus : Object.keys(probeDirectStatus).length ? probeDirectStatus : Object.keys(probeNestedStatus).length ? probeNestedStatus : {};
46774
- return normalizeInlineMeshGitStatus(status, node, { lastCheckedAt: Date.now() });
46773
+ const candidates = [directStatus, nestedStatus, probeDirectStatus, probeNestedStatus];
46774
+ for (const status of candidates) {
46775
+ const normalized = normalizeInlineMeshGitStatus(status, node, { lastCheckedAt: Date.now() });
46776
+ if (normalized) return normalized;
46777
+ }
46778
+ return void 0;
46775
46779
  }
46776
46780
  function recordInlineMeshDirectGitTruth(node, git, source) {
46777
46781
  if (!node || typeof node !== "object" || Array.isArray(node)) return;
@@ -47677,10 +47681,69 @@ var init_router = __esm({
47677
47681
  if (typeof structuredClone === "function") return structuredClone(value);
47678
47682
  return JSON.parse(JSON.stringify(value));
47679
47683
  }
47680
- getCachedAggregateMeshStatus(meshId) {
47684
+ hydrateCachedAggregateMeshStatusFromInline(snapshot, mesh, options) {
47685
+ if (!mesh || typeof mesh !== "object" || !Array.isArray(mesh.nodes) || !Array.isArray(snapshot?.nodes)) return snapshot;
47686
+ const inlineNodesById = /* @__PURE__ */ new Map();
47687
+ for (const node of mesh.nodes) {
47688
+ const nodeId = readInlineMeshNodeId(node);
47689
+ if (nodeId) inlineNodesById.set(nodeId, node);
47690
+ }
47691
+ if (!inlineNodesById.size) return snapshot;
47692
+ let changed = false;
47693
+ const unavailableNodeIds = /* @__PURE__ */ new Set();
47694
+ const sourceOfTruth = readObjectRecord(snapshot.sourceOfTruth);
47695
+ const directPeerTruth = readObjectRecord(sourceOfTruth.directPeerTruth);
47696
+ for (const entry of Array.isArray(directPeerTruth.unavailableNodeIds) ? directPeerTruth.unavailableNodeIds : []) {
47697
+ const nodeId = readStringValue(entry);
47698
+ if (nodeId) unavailableNodeIds.add(nodeId);
47699
+ }
47700
+ const nodes = snapshot.nodes.map((statusNode) => {
47701
+ const nodeId = readStringValue(statusNode?.nodeId, statusNode?.id);
47702
+ const inlineNode = nodeId ? inlineNodesById.get(nodeId) : void 0;
47703
+ if (!inlineNode) return statusNode;
47704
+ const liveGit = buildInlineMeshTransitGitStatus(inlineNode);
47705
+ if (!liveGit) return statusNode;
47706
+ const nextStatus = { ...statusNode };
47707
+ nextStatus.git = liveGit;
47708
+ nextStatus.health = deriveMeshNodeHealthFromGit(liveGit);
47709
+ delete nextStatus.gitProbePending;
47710
+ if (readStringValue(nextStatus.error) === "waiting for live peer git snapshot") delete nextStatus.error;
47711
+ if (!readStringValue(nextStatus.machineStatus)) nextStatus.machineStatus = "online";
47712
+ if (nodeId) unavailableNodeIds.delete(nodeId);
47713
+ changed = true;
47714
+ return nextStatus;
47715
+ });
47716
+ if (!changed && !(options?.requireDirectPeerTruth && unavailableNodeIds.size > 0)) return snapshot;
47717
+ const nextSourceOfTruth = {
47718
+ ...sourceOfTruth,
47719
+ ...Object.keys(directPeerTruth).length ? {
47720
+ directPeerTruth: {
47721
+ ...directPeerTruth,
47722
+ satisfied: options?.requireDirectPeerTruth === true ? unavailableNodeIds.size === 0 : directPeerTruth.satisfied,
47723
+ unavailableNodeIds: [...unavailableNodeIds]
47724
+ },
47725
+ ...options?.requireDirectPeerTruth === true ? {
47726
+ coordinatorOwnsLiveTruth: unavailableNodeIds.size === 0,
47727
+ currentStatus: unavailableNodeIds.size === 0 ? "live_git_and_session_probes" : "direct_peer_truth_unavailable"
47728
+ } : {}
47729
+ } : {}
47730
+ };
47731
+ return {
47732
+ ...snapshot,
47733
+ ...options?.requireDirectPeerTruth === true && unavailableNodeIds.size > 0 ? {
47734
+ success: false,
47735
+ code: "mesh_direct_peer_truth_unavailable",
47736
+ error: "Selected coordinator could not confirm direct mesh truth for every remote node yet."
47737
+ } : {},
47738
+ sourceOfTruth: nextSourceOfTruth,
47739
+ nodes
47740
+ };
47741
+ }
47742
+ getCachedAggregateMeshStatus(meshId, mesh, options) {
47681
47743
  const cached2 = this.aggregateMeshStatusCache.get(meshId);
47682
47744
  if (!cached2?.snapshot || cached2.snapshot.success !== true || !Array.isArray(cached2.snapshot.nodes)) return null;
47683
- const snapshot = this.cloneJsonValue(cached2.snapshot);
47745
+ let snapshot = this.cloneJsonValue(cached2.snapshot);
47746
+ snapshot = this.hydrateCachedAggregateMeshStatusFromInline(snapshot, mesh, options);
47684
47747
  const ageMs = Math.max(0, Date.now() - cached2.builtAt);
47685
47748
  const sourceOfTruth = snapshot.sourceOfTruth && typeof snapshot.sourceOfTruth === "object" ? snapshot.sourceOfTruth : {};
47686
47749
  snapshot.sourceOfTruth = {
@@ -47740,7 +47803,14 @@ var init_router = __esm({
47740
47803
  const preferInline = options?.preferInline === true;
47741
47804
  if (preferInline) {
47742
47805
  const cached3 = this.getCachedInlineMesh(meshId);
47743
- if (cached3) return { mesh: cached3, inline: true, source: "inline_cache" };
47806
+ if (cached3) {
47807
+ if (inlineMeshCarriesTransientNodeTruth(inlineMesh)) {
47808
+ const merged = reconcileInlineMeshCache(cached3, inlineMesh);
47809
+ this.inlineMeshCache.set(meshId, sanitizeInlineMesh(merged));
47810
+ return { mesh: merged, inline: true, source: "inline_cache" };
47811
+ }
47812
+ return { mesh: cached3, inline: true, source: "inline_cache" };
47813
+ }
47744
47814
  if (inlineMeshCarriesTransientNodeTruth(inlineMesh)) {
47745
47815
  this.warmInlineMeshCache(meshId, inlineMesh);
47746
47816
  return { mesh: inlineMesh, inline: true, source: "inline_bootstrap" };
@@ -49720,7 +49790,7 @@ ${block}`);
49720
49790
  if (!mesh) return { success: false, error: "Mesh not found" };
49721
49791
  const refreshRequested = args?.refresh === true || args?.forceRefresh === true;
49722
49792
  if (!refreshRequested) {
49723
- const cachedStatus = this.getCachedAggregateMeshStatus(meshId);
49793
+ const cachedStatus = this.getCachedAggregateMeshStatus(meshId, mesh, { requireDirectPeerTruth: args?.requireDirectPeerTruth === true });
49724
49794
  if (cachedStatus) {
49725
49795
  logRepoMeshStatusDebug("return_cached", {
49726
49796
  meshId,
@@ -49755,7 +49825,7 @@ ${block}`);
49755
49825
  peerConfirmedCount: 0,
49756
49826
  unavailableNodeIds: []
49757
49827
  };
49758
- const directTruthSatisfied = meshRecord.source !== "inline_bootstrap" || directTruth.directEvidenceCount > 0;
49828
+ const directTruthSatisfied = !requireDirectPeerTruth || directTruth.directEvidenceCount > 0 && directTruth.unavailableNodeIds.length === 0;
49759
49829
  if (requireDirectPeerTruth && !directTruthSatisfied) {
49760
49830
  const failureResult = {
49761
49831
  success: false,
@@ -99236,7 +99306,7 @@ var init_adhdev_daemon = __esm({
99236
99306
  init_version();
99237
99307
  init_src();
99238
99308
  init_runtime_defaults();
99239
- pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.82-rc.44" });
99309
+ pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.82-rc.45" });
99240
99310
  AdhdevDaemon = class _AdhdevDaemon {
99241
99311
  localHttpServer = null;
99242
99312
  localWss = null;