@adhdev/daemon-standalone 0.9.82-rc.89 → 0.9.82-rc.90

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
@@ -30835,6 +30835,23 @@ ${lastSnapshot}`;
30835
30835
  env: { type: "object", additionalProperties: { type: "string" } }
30836
30836
  }
30837
30837
  }
30838
+ },
30839
+ bootstrapCommands: {
30840
+ type: "array",
30841
+ maxItems: 4,
30842
+ items: {
30843
+ type: "object",
30844
+ additionalProperties: false,
30845
+ required: ["command"],
30846
+ properties: {
30847
+ command: { type: "string", minLength: 1 },
30848
+ args: { type: "array", items: { type: "string" } },
30849
+ category: { enum: [...MESH_REFINE_VALIDATION_CATEGORIES, "custom"] },
30850
+ cwd: { type: "string" },
30851
+ timeoutMs: { type: "number", minimum: 1e3, maximum: 6e5 },
30852
+ env: { type: "object", additionalProperties: { type: "string" } }
30853
+ }
30854
+ }
30838
30855
  }
30839
30856
  }
30840
30857
  }
@@ -30901,9 +30918,10 @@ ${lastSnapshot}`;
30901
30918
  }
30902
30919
  function validateMeshRefineConfig(config2, source = "inline") {
30903
30920
  const errors = [];
30921
+ const bootstrapCommands = [];
30904
30922
  const commands = [];
30905
30923
  const rejectedCommands = [];
30906
- if (!isRecord(config2)) return { valid: false, errors: ["config must be an object"], commands, rejectedCommands };
30924
+ if (!isRecord(config2)) return { valid: false, errors: ["config must be an object"], bootstrapCommands, commands, rejectedCommands };
30907
30925
  if (config2.version !== 1) errors.push("version must be 1");
30908
30926
  if (config2.allowAutoPublishSubmoduleMainCommits !== void 0 && typeof config2.allowAutoPublishSubmoduleMainCommits !== "boolean") {
30909
30927
  errors.push("allowAutoPublishSubmoduleMainCommits must be a boolean when provided");
@@ -30911,7 +30929,16 @@ ${lastSnapshot}`;
30911
30929
  const validation = config2.validation;
30912
30930
  if (validation !== void 0 && !isRecord(validation)) errors.push("validation must be an object");
30913
30931
  const rawCommands = isRecord(validation) ? validation.commands : void 0;
30932
+ const rawBootstrapCommands = isRecord(validation) ? validation.bootstrapCommands : void 0;
30914
30933
  if (rawCommands !== void 0 && !Array.isArray(rawCommands)) errors.push("validation.commands must be an array");
30934
+ if (rawBootstrapCommands !== void 0 && !Array.isArray(rawBootstrapCommands)) errors.push("validation.bootstrapCommands must be an array");
30935
+ if (Array.isArray(rawBootstrapCommands)) {
30936
+ rawBootstrapCommands.forEach((entry, index) => {
30937
+ const normalized = normalizeCommandConfig(entry, `${source}:validation.bootstrapCommands[${index}]`);
30938
+ if (normalized.command) bootstrapCommands.push(normalized.command);
30939
+ if (normalized.rejected) rejectedCommands.push(normalized.rejected);
30940
+ });
30941
+ }
30915
30942
  if (Array.isArray(rawCommands)) {
30916
30943
  rawCommands.forEach((entry, index) => {
30917
30944
  const normalized = normalizeCommandConfig(entry, `${source}:validation.commands[${index}]`);
@@ -30920,7 +30947,7 @@ ${lastSnapshot}`;
30920
30947
  });
30921
30948
  }
30922
30949
  if (rejectedCommands.length) errors.push("one or more validation commands are invalid");
30923
- return { valid: errors.length === 0, errors, commands, rejectedCommands };
30950
+ return { valid: errors.length === 0, errors, bootstrapCommands, commands, rejectedCommands };
30924
30951
  }
30925
30952
  function parseConfigText(path28, text) {
30926
30953
  if (/\.json$/i.test(path28)) return JSON.parse(text);
@@ -31005,6 +31032,7 @@ ${lastSnapshot}`;
31005
31032
  return {
31006
31033
  source: loaded.source,
31007
31034
  sourceType: loaded.sourceType,
31035
+ bootstrapCommands: [],
31008
31036
  commands: [],
31009
31037
  rejectedCommands: loaded.error ? [{ source: loaded.source, reason: loaded.error }] : [],
31010
31038
  suggestions: suggestion.suggestions,
@@ -31016,6 +31044,7 @@ ${lastSnapshot}`;
31016
31044
  return {
31017
31045
  source: loaded.path || loaded.source,
31018
31046
  sourceType: loaded.sourceType,
31047
+ bootstrapCommands: validation.bootstrapCommands,
31019
31048
  commands: validation.commands,
31020
31049
  rejectedCommands: validation.rejectedCommands,
31021
31050
  suggestions: suggestion.suggestions,
@@ -49013,6 +49042,17 @@ ${(0, import_node_path.resolve)(workspace || os17.tmpdir())}`;
49013
49042
  });
49014
49043
  return { stdout: String(stdout || ""), stderr: String(stderr || ""), refspec };
49015
49044
  };
49045
+ const importCommitFromWorktreeSubmodule = async (submodulePath, worktreeSubmodulePath, commit) => {
49046
+ if (!fs11.existsSync(worktreeSubmodulePath)) return false;
49047
+ try {
49048
+ await runGit2(worktreeSubmodulePath, ["cat-file", "-e", `${commit}^{commit}`]);
49049
+ } catch {
49050
+ return false;
49051
+ }
49052
+ await runGit2(submodulePath, ["-c", "protocol.file.allow=always", "fetch", worktreeSubmodulePath, commit]);
49053
+ await runGit2(submodulePath, ["cat-file", "-e", `${commit}^{commit}`]);
49054
+ return true;
49055
+ };
49016
49056
  const treeOutput = await runGit2(repoRoot, ["ls-tree", "-r", "-z", mergedTree]);
49017
49057
  const gitlinks = treeOutput.split("\0").filter(Boolean).map((record2) => {
49018
49058
  const match = /^160000\s+commit\s+([0-9a-f]{40})\t(.+)$/.exec(record2);
@@ -49029,6 +49069,11 @@ ${(0, import_node_path.resolve)(workspace || os17.tmpdir())}`;
49029
49069
  if (!fs11.existsSync(submodulePath)) {
49030
49070
  entry.error = `Submodule checkout missing at ${gitlink.path}`;
49031
49071
  entry.publishRequired = true;
49072
+ if (options.allowAutoPublishSubmoduleMainCommits === true) {
49073
+ entry.autoPublishAllowed = true;
49074
+ entry.autoPublishAttempted = false;
49075
+ entry.autoPublishSkippedReason = `submodule checkout missing at ${gitlink.path}; cannot perform non-force push to origin/main`;
49076
+ }
49032
49077
  entries.push(entry);
49033
49078
  continue;
49034
49079
  }
@@ -49038,6 +49083,21 @@ ${(0, import_node_path.resolve)(workspace || os17.tmpdir())}`;
49038
49083
  entry.localReachable = true;
49039
49084
  } catch {
49040
49085
  entry.localReachable = false;
49086
+ if (options.allowAutoPublishSubmoduleMainCommits === true && options.worktreeRoot) {
49087
+ try {
49088
+ const imported = await importCommitFromWorktreeSubmodule(
49089
+ submodulePath,
49090
+ (0, import_path8.resolve)(options.worktreeRoot, gitlink.path),
49091
+ gitlink.commit
49092
+ );
49093
+ if (imported) {
49094
+ entry.localReachable = true;
49095
+ entry.importedFromWorktree = true;
49096
+ }
49097
+ } catch (importError) {
49098
+ entry.autoPublishSkippedReason = `candidate commit was not present in the source checkout and could not be imported from worktree submodule: ${truncateValidationOutput(importError?.stderr || importError?.message || String(importError))}`;
49099
+ }
49100
+ }
49041
49101
  }
49042
49102
  try {
49043
49103
  entry.remote = "origin";
@@ -49049,6 +49109,11 @@ ${(0, import_node_path.resolve)(workspace || os17.tmpdir())}`;
49049
49109
  } catch {
49050
49110
  entry.error = "Submodule remote reachability check failed: no configured origin remote";
49051
49111
  entry.publishRequired = true;
49112
+ if (options.allowAutoPublishSubmoduleMainCommits === true) {
49113
+ entry.autoPublishAllowed = true;
49114
+ entry.autoPublishAttempted = false;
49115
+ entry.autoPublishSkippedReason = "submodule origin remote is not configured; cannot perform non-force push to origin/main";
49116
+ }
49052
49117
  entries.push(entry);
49053
49118
  continue;
49054
49119
  }
@@ -49088,6 +49153,10 @@ ${(0, import_node_path.resolve)(workspace || os17.tmpdir())}`;
49088
49153
  const publishDetails = truncateValidationOutput(publishError?.stderr || publishError?.message || String(publishError));
49089
49154
  entry.error = `Submodule auto-publish to origin/main failed or could not be verified: ${publishDetails}`;
49090
49155
  }
49156
+ } else if (options.allowAutoPublishSubmoduleMainCommits === true) {
49157
+ entry.autoPublishAllowed = true;
49158
+ entry.autoPublishAttempted = false;
49159
+ entry.autoPublishSkippedReason = entry.autoPublishSkippedReason || "candidate commit is not reachable in the source checkout or worktree submodule, so Refinery cannot push it to origin/main";
49091
49160
  }
49092
49161
  }
49093
49162
  } catch (e) {
@@ -49129,16 +49198,18 @@ ${(0, import_node_path.resolve)(workspace || os17.tmpdir())}`;
49129
49198
  }
49130
49199
  function buildMeshRefineValidationPlan(mesh, workspace) {
49131
49200
  const plan = resolveMeshRefineValidationPlan(mesh, workspace);
49201
+ const mapCommand = (command) => ({
49202
+ displayCommand: command.displayCommand,
49203
+ category: command.category,
49204
+ source: command.source,
49205
+ cwd: command.cwd,
49206
+ timeoutMs: command.timeoutMs
49207
+ });
49132
49208
  return {
49133
49209
  source: plan.source,
49134
49210
  sourceType: plan.sourceType,
49135
- commands: plan.commands.map((command) => ({
49136
- displayCommand: command.displayCommand,
49137
- category: command.category,
49138
- source: command.source,
49139
- cwd: command.cwd,
49140
- timeoutMs: command.timeoutMs
49141
- })),
49211
+ bootstrapCommands: plan.bootstrapCommands.map(mapCommand),
49212
+ commands: plan.commands.map(mapCommand),
49142
49213
  unavailableReason: plan.unavailableReason,
49143
49214
  rejectedCommands: plan.rejectedCommands,
49144
49215
  suggestions: plan.suggestions,
@@ -49155,6 +49226,7 @@ ${(0, import_node_path.resolve)(workspace || os17.tmpdir())}`;
49155
49226
  status: "skipped",
49156
49227
  required: true,
49157
49228
  commandsRun: [],
49229
+ bootstrapCommandsRun: [],
49158
49230
  rejectedCommands: selection.rejectedCommands,
49159
49231
  skippedReason: void 0,
49160
49232
  timeoutMs: REFINE_VALIDATION_TIMEOUT_MS,
@@ -49168,7 +49240,29 @@ ${(0, import_node_path.resolve)(workspace || os17.tmpdir())}`;
49168
49240
  summary.skippedReason = selection.unavailableReason || "validation_unavailable: repo mesh/refine config did not provide executable validation.commands";
49169
49241
  return summary;
49170
49242
  }
49171
- for (const candidate of selection.commands) {
49243
+ const commandRecord = (candidate, cwd, startedAt, result, passed, extras = {}) => ({
49244
+ command: candidate.command,
49245
+ args: candidate.args,
49246
+ displayCommand: candidate.displayCommand,
49247
+ category: candidate.category,
49248
+ source: candidate.source,
49249
+ cwd,
49250
+ passed,
49251
+ durationMs: Date.now() - startedAt,
49252
+ stdout: truncateValidationOutput(result?.stdout),
49253
+ stderr: truncateValidationOutput(result?.stderr || result?.message),
49254
+ ...extras
49255
+ });
49256
+ const isPackageManagerValidation = (candidate) => {
49257
+ const command = (0, import_path8.basename)(candidate.command).replace(/\.(?:cmd|exe)$/i, "");
49258
+ return ["npm", "pnpm", "yarn", "bun"].includes(command) && candidate.args.some((arg) => arg === "run" || arg === "test" || arg === "exec");
49259
+ };
49260
+ const dependenciesLikelyMissing = (cwd) => {
49261
+ if (!fs11.existsSync((0, import_path8.join)(cwd, "package.json"))) return false;
49262
+ if (fs11.existsSync((0, import_path8.join)(cwd, "node_modules"))) return false;
49263
+ return ["package-lock.json", "npm-shrinkwrap.json", "pnpm-lock.yaml", "yarn.lock", "bun.lockb", "bun.lock"].some((lock) => fs11.existsSync((0, import_path8.join)(cwd, lock)));
49264
+ };
49265
+ for (const candidate of selection.bootstrapCommands) {
49172
49266
  const startedAt = Date.now();
49173
49267
  const cwd = candidate.cwd ? (0, import_path8.resolve)(workspace, candidate.cwd) : workspace;
49174
49268
  const timeout = candidate.timeoutMs || REFINE_VALIDATION_TIMEOUT_MS;
@@ -49180,36 +49274,60 @@ ${(0, import_node_path.resolve)(workspace || os17.tmpdir())}`;
49180
49274
  maxBuffer: REFINE_VALIDATION_OUTPUT_LIMIT_BYTES,
49181
49275
  env: { ...process.env, CI: process.env.CI || "1", ...candidate.env || {} }
49182
49276
  });
49183
- summary.commandsRun.push({
49184
- command: candidate.command,
49185
- args: candidate.args,
49186
- displayCommand: candidate.displayCommand,
49187
- category: candidate.category,
49188
- source: candidate.source,
49277
+ summary.bootstrapCommandsRun.push(commandRecord(candidate, cwd, startedAt, result, true, { exitCode: 0 }));
49278
+ } catch (error48) {
49279
+ summary.bootstrapCommandsRun.push(commandRecord(candidate, cwd, startedAt, error48, false, {
49280
+ exitCode: typeof error48?.code === "number" ? error48.code : null,
49281
+ signal: typeof error48?.signal === "string" ? error48.signal : null,
49282
+ timedOut: error48?.killed === true || /timed out/i.test(String(error48?.message || "")),
49283
+ failureKind: "dependency_bootstrap_failed"
49284
+ }));
49285
+ summary.status = "failed";
49286
+ summary.failureKind = "dependency_bootstrap_failed";
49287
+ summary.failureCode = "dependency_bootstrap_failed";
49288
+ return summary;
49289
+ }
49290
+ }
49291
+ for (const candidate of selection.commands) {
49292
+ const startedAt = Date.now();
49293
+ const cwd = candidate.cwd ? (0, import_path8.resolve)(workspace, candidate.cwd) : workspace;
49294
+ const timeout = candidate.timeoutMs || REFINE_VALIDATION_TIMEOUT_MS;
49295
+ if (selection.bootstrapCommands.length === 0 && isPackageManagerValidation(candidate) && dependenciesLikelyMissing(cwd)) {
49296
+ summary.commandsRun.push(commandRecord(candidate, cwd, startedAt, {
49297
+ stderr: "Dependencies appear to be missing: package.json and a lockfile are present, but node_modules is absent. Configure validation.bootstrapCommands in repo mesh/refine config if Refinery should install/bootstrap before validation."
49298
+ }, false, {
49299
+ exitCode: null,
49300
+ skipped: true,
49301
+ failureKind: "missing_dependencies"
49302
+ }));
49303
+ summary.status = "failed";
49304
+ summary.failureKind = "missing_dependencies";
49305
+ summary.failureCode = "missing_dependencies";
49306
+ return summary;
49307
+ }
49308
+ try {
49309
+ const result = await execFileAsync3(candidate.command, candidate.args, {
49189
49310
  cwd,
49190
- passed: true,
49191
- exitCode: 0,
49192
- durationMs: Date.now() - startedAt,
49193
- stdout: truncateValidationOutput(result.stdout),
49194
- stderr: truncateValidationOutput(result.stderr)
49311
+ encoding: "utf8",
49312
+ timeout,
49313
+ maxBuffer: REFINE_VALIDATION_OUTPUT_LIMIT_BYTES,
49314
+ env: { ...process.env, CI: process.env.CI || "1", ...candidate.env || {} }
49195
49315
  });
49316
+ summary.commandsRun.push(commandRecord(candidate, cwd, startedAt, result, true, { exitCode: 0 }));
49196
49317
  } catch (error48) {
49197
- summary.commandsRun.push({
49198
- command: candidate.command,
49199
- args: candidate.args,
49200
- displayCommand: candidate.displayCommand,
49201
- category: candidate.category,
49202
- source: candidate.source,
49203
- cwd,
49204
- passed: false,
49318
+ const stderr = truncateValidationOutput(error48?.stderr || error48?.message);
49319
+ const missingDependencyFailure = /Cannot find module|MODULE_NOT_FOUND|node_modules|command not found|not found/i.test(stderr);
49320
+ summary.commandsRun.push(commandRecord(candidate, cwd, startedAt, error48, false, {
49205
49321
  exitCode: typeof error48?.code === "number" ? error48.code : null,
49206
49322
  signal: typeof error48?.signal === "string" ? error48.signal : null,
49207
49323
  timedOut: error48?.killed === true || /timed out/i.test(String(error48?.message || "")),
49208
- durationMs: Date.now() - startedAt,
49209
- stdout: truncateValidationOutput(error48?.stdout),
49210
- stderr: truncateValidationOutput(error48?.stderr || error48?.message)
49211
- });
49324
+ ...missingDependencyFailure ? { failureKind: "missing_dependencies" } : {}
49325
+ }));
49212
49326
  summary.status = "failed";
49327
+ if (missingDependencyFailure) {
49328
+ summary.failureKind = "missing_dependencies";
49329
+ summary.failureCode = "missing_dependencies";
49330
+ }
49213
49331
  return summary;
49214
49332
  }
49215
49333
  }
@@ -50193,9 +50311,9 @@ ${(0, import_node_path.resolve)(workspace || os17.tmpdir())}`;
50193
50311
  if (validationSummary.status === "failed") {
50194
50312
  return {
50195
50313
  success: false,
50196
- code: "validation_failed",
50314
+ code: validationSummary.failureCode || "validation_failed",
50197
50315
  convergenceStatus: "blocked_review",
50198
- error: "Refinery validation gate failed; merge/refine was not attempted.",
50316
+ error: validationSummary.failureCode === "missing_dependencies" ? "Refinery validation dependencies are missing; merge/refine was not attempted. Configure validation.bootstrapCommands if Refinery should bootstrap dependencies before validation." : validationSummary.failureCode === "dependency_bootstrap_failed" ? "Refinery dependency/bootstrap command failed; merge/refine was not attempted." : "Refinery validation gate failed; merge/refine was not attempted.",
50199
50317
  branch,
50200
50318
  into: baseBranch,
50201
50319
  validationSummary,
@@ -50264,7 +50382,8 @@ ${(0, import_node_path.resolve)(workspace || os17.tmpdir())}`;
50264
50382
  const autoPublishSubmoduleMainCommits = resolveRefineryAutoPublishSubmoduleMainCommits(mesh, node.workspace);
50265
50383
  const submoduleReachability = await runMeshRefineSubmoduleReachabilityGate(repoRoot, patchEquivalence.mergedTree || branchHead, {
50266
50384
  allowAutoPublishSubmoduleMainCommits: autoPublishSubmoduleMainCommits.enabled,
50267
- autoPublishPolicySource: autoPublishSubmoduleMainCommits.source
50385
+ autoPublishPolicySource: autoPublishSubmoduleMainCommits.source,
50386
+ worktreeRoot: node.workspace
50268
50387
  });
50269
50388
  recordMeshRefineStage(refineStages, "submodule_reachability", submoduleReachability.status, submoduleReachabilityStarted, {
50270
50389
  checked: submoduleReachability.checked,
@@ -50282,6 +50401,14 @@ ${(0, import_node_path.resolve)(workspace || os17.tmpdir())}`;
50282
50401
  remoteMainReachable: entry.remoteMainReachable,
50283
50402
  error: entry.error
50284
50403
  })),
50404
+ autoPublishSkipped: submoduleReachability.entries.filter((entry) => entry.autoPublishAllowed === true && entry.autoPublishAttempted !== true).map((entry) => ({
50405
+ path: entry.path,
50406
+ commit: entry.commit,
50407
+ remote: entry.remote,
50408
+ remoteUrl: entry.remoteUrl,
50409
+ remoteMainBranch: entry.remoteMainBranch,
50410
+ reason: entry.autoPublishSkippedReason || entry.error || "auto-publish was allowed but no publish attempt was possible"
50411
+ })),
50285
50412
  unreachable: submoduleReachability.unreachable.map((entry) => ({
50286
50413
  path: entry.path,
50287
50414
  commit: entry.commit,
@@ -50291,6 +50418,7 @@ ${(0, import_node_path.resolve)(workspace || os17.tmpdir())}`;
50291
50418
  autoPublishSucceeded: entry.autoPublishSucceeded,
50292
50419
  autoPublishVerified: entry.autoPublishVerified,
50293
50420
  autoPublishRefspec: entry.autoPublishRefspec,
50421
+ autoPublishSkippedReason: entry.autoPublishSkippedReason,
50294
50422
  remote: entry.remote,
50295
50423
  remoteUrl: entry.remoteUrl,
50296
50424
  remoteReachable: entry.remoteReachable,
@@ -50329,6 +50457,7 @@ ${(0, import_node_path.resolve)(workspace || os17.tmpdir())}`;
50329
50457
  autoPublishSucceeded: entry.autoPublishSucceeded,
50330
50458
  autoPublishVerified: entry.autoPublishVerified,
50331
50459
  autoPublishRefspec: entry.autoPublishRefspec,
50460
+ autoPublishSkippedReason: entry.autoPublishSkippedReason,
50332
50461
  error: entry.error
50333
50462
  })),
50334
50463
  branch,
@@ -52116,8 +52245,9 @@ ${block2}`);
52116
52245
  if (!mesh) return { success: false, error: "Mesh not found" };
52117
52246
  const meshHost = resolveMeshHostStatus(mesh);
52118
52247
  const refreshRequested = args?.refresh === true || args?.forceRefresh === true;
52248
+ const pendingCoordinatorEventCount = getPendingMeshCoordinatorEvents(meshId).length;
52119
52249
  const hadAggregateCache = this.aggregateMeshStatusCache.has(meshId);
52120
- if (!refreshRequested) {
52250
+ if (!refreshRequested && pendingCoordinatorEventCount === 0) {
52121
52251
  const cachedStatus = this.getCachedAggregateMeshStatus(meshId, mesh, { requireDirectPeerTruth: args?.requireDirectPeerTruth === true });
52122
52252
  if (cachedStatus) {
52123
52253
  logRepoMeshStatusDebug("return_cached", {
@@ -52129,7 +52259,7 @@ ${block2}`);
52129
52259
  return cachedStatus;
52130
52260
  }
52131
52261
  }
52132
- const refreshReason = refreshRequested ? "explicit_refresh" : hadAggregateCache ? "stale_pending_cache_refresh" : "cold_cache_miss";
52262
+ const refreshReason = refreshRequested ? "explicit_refresh" : pendingCoordinatorEventCount > 0 ? "pending_coordinator_events" : hadAggregateCache ? "stale_pending_cache_refresh" : "cold_cache_miss";
52133
52263
  const { getMeshQueueStats: getMeshQueueStats2, getQueue: getQueue2 } = await Promise.resolve().then(() => (init_mesh_work_queue(), mesh_work_queue_exports));
52134
52264
  const queue = getQueue2(meshId);
52135
52265
  const queueSummary = getMeshQueueStats2(meshId);
@@ -52155,7 +52285,9 @@ ${block2}`);
52155
52285
  };
52156
52286
  const passivePeerTruthNotAttempted = requireDirectPeerTruth && !refreshRequested && directTruth.directEvidenceCount > 0 && directTruth.peerAttemptedCount === 0;
52157
52287
  const effectiveDirectTruth = passivePeerTruthNotAttempted ? { ...directTruth, unavailableNodeIds: [] } : directTruth;
52158
- const directTruthSatisfied = !requireDirectPeerTruth || effectiveDirectTruth.directEvidenceCount > 0;
52288
+ const unavailableDirectTruthNodeIds = new Set(effectiveDirectTruth.unavailableNodeIds);
52289
+ const unavailableNodesAreOnlyRemovedWorktrees = unavailableDirectTruthNodeIds.size > 0 && Array.isArray(mesh.nodes) && mesh.nodes.filter((node) => unavailableDirectTruthNodeIds.has(String(node.id || node.nodeId || ""))).every((node) => node?.isLocalWorktree === true);
52290
+ const directTruthSatisfied = !requireDirectPeerTruth || effectiveDirectTruth.directEvidenceCount > 0 && (effectiveDirectTruth.unavailableNodeIds.length === 0 || unavailableNodesAreOnlyRemovedWorktrees);
52159
52291
  if (requireDirectPeerTruth && !directTruthSatisfied) {
52160
52292
  const failureResult = {
52161
52293
  success: false,
@@ -52386,6 +52518,7 @@ ${block2}`);
52386
52518
  finalizeMeshNodeStatus({ status, node, daemonId, isSelfNode });
52387
52519
  nodeStatuses.push(status);
52388
52520
  }
52521
+ const pendingCoordinatorEvents = drainPendingMeshCoordinatorEvents(meshId);
52389
52522
  const statusResult = {
52390
52523
  success: true,
52391
52524
  meshId: mesh.id,
@@ -52422,9 +52555,12 @@ ${block2}`);
52422
52555
  branchConvergenceSummary: summarizeInlineMeshBranchConvergence(nodeStatuses),
52423
52556
  nodes: nodeStatuses,
52424
52557
  queue: { tasks: queue, summary: queueSummary },
52425
- ledger: { entries: ledgerEntries, summary: ledgerSummary }
52558
+ ledger: { entries: ledgerEntries, summary: ledgerSummary },
52559
+ ...pendingCoordinatorEvents.length > 0 ? { pendingCoordinatorEvents } : {}
52426
52560
  };
52427
- const rememberedStatus = this.rememberAggregateMeshStatus(meshId, statusResult, refreshReason);
52561
+ const { pendingCoordinatorEvents: _pendingCoordinatorEvents, ...cacheableStatusResult } = statusResult;
52562
+ const rememberedStatus = this.rememberAggregateMeshStatus(meshId, cacheableStatusResult, refreshReason);
52563
+ const returnedStatus = pendingCoordinatorEvents.length > 0 ? { ...rememberedStatus, pendingCoordinatorEvents } : rememberedStatus;
52428
52564
  logRepoMeshStatusDebug("return_live", {
52429
52565
  meshId,
52430
52566
  command: "mesh_status",
@@ -52432,9 +52568,9 @@ ${block2}`);
52432
52568
  refreshReason,
52433
52569
  meshSource: meshRecord.source,
52434
52570
  directTruth,
52435
- summary: summarizeRepoMeshStatusDebug(rememberedStatus)
52571
+ summary: summarizeRepoMeshStatusDebug(returnedStatus)
52436
52572
  });
52437
- return rememberedStatus;
52573
+ return returnedStatus;
52438
52574
  } catch (e) {
52439
52575
  return { success: false, error: e.message };
52440
52576
  }