@adhdev/daemon-core 0.9.82-rc.380 → 0.9.82-rc.381
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.d.ts +4 -2
- package/dist/index.js +222 -59
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +215 -59
- package/dist/index.mjs.map +1 -1
- package/dist/mesh/mesh-runtime-store.d.ts +12 -0
- package/dist/mesh/mesh-scheduling-runtime.d.ts +78 -0
- package/dist/repo-mesh-types.d.ts +81 -0
- package/package.json +2 -2
- package/src/config/mesh-config.ts +6 -58
- package/src/index.ts +13 -0
- package/src/mesh/coordinator-prompt.ts +3 -3
- package/src/mesh/mesh-event-forwarding.ts +17 -1
- package/src/mesh/mesh-runtime-store.ts +23 -0
- package/src/mesh/mesh-scheduling-runtime.ts +199 -0
- package/src/repo-mesh-types.ts +164 -0
package/dist/index.mjs
CHANGED
|
@@ -38,6 +38,56 @@ function resolveNodeSchedulingPriority(nodePolicy) {
|
|
|
38
38
|
function resolveAutoConvergeCodeChange(policy) {
|
|
39
39
|
return policy?.autoConvergeCodeChange === true;
|
|
40
40
|
}
|
|
41
|
+
function resolveMaxParallelTasks(value) {
|
|
42
|
+
const n = Number(value);
|
|
43
|
+
if (!Number.isFinite(n)) return DEFAULT_MESH_POLICY.maxParallelTasks;
|
|
44
|
+
return Math.max(MESH_MAX_PARALLEL_TASKS_MIN, Math.min(MESH_MAX_PARALLEL_TASKS_MAX, Math.floor(n)));
|
|
45
|
+
}
|
|
46
|
+
function normalizeAutoFastForwardPolicy(value) {
|
|
47
|
+
const record = value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
48
|
+
const maxBehind = Number(record.maxBehind);
|
|
49
|
+
return {
|
|
50
|
+
enabled: record.enabled !== false,
|
|
51
|
+
...Number.isFinite(maxBehind) && maxBehind >= 0 ? { maxBehind: Math.floor(maxBehind) } : {},
|
|
52
|
+
requireCleanSubmodules: record.requireCleanSubmodules !== false
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function mergeAndNormalizePolicy(base, patch) {
|
|
56
|
+
const autoFastForward = normalizeAutoFastForwardPolicy({
|
|
57
|
+
...DEFAULT_MESH_POLICY.autoFastForward,
|
|
58
|
+
...base?.autoFastForward && typeof base.autoFastForward === "object" ? base.autoFastForward : {},
|
|
59
|
+
...patch?.autoFastForward && typeof patch.autoFastForward === "object" ? patch.autoFastForward : {}
|
|
60
|
+
});
|
|
61
|
+
const policy = {
|
|
62
|
+
...DEFAULT_MESH_POLICY,
|
|
63
|
+
...base || {},
|
|
64
|
+
...patch || {},
|
|
65
|
+
autoFastForward
|
|
66
|
+
};
|
|
67
|
+
if (!DIRTY_WORKSPACE_BEHAVIORS.has(policy.dirtyWorkspaceBehavior)) {
|
|
68
|
+
policy.dirtyWorkspaceBehavior = "warn";
|
|
69
|
+
}
|
|
70
|
+
policy.maxParallelTasks = resolveMaxParallelTasks(policy.maxParallelTasks);
|
|
71
|
+
policy.allowAutoPublishSubmoduleMainCommits = policy.allowAutoPublishSubmoduleMainCommits === true;
|
|
72
|
+
if (!SESSION_CLEANUP_MODES.has(policy.sessionCleanupOnNodeRemove)) {
|
|
73
|
+
policy.sessionCleanupOnNodeRemove = "preserve";
|
|
74
|
+
}
|
|
75
|
+
if (!SPAWNED_SESSION_VISIBILITY_MODES.has(policy.spawnedSessionVisibility)) {
|
|
76
|
+
policy.spawnedSessionVisibility = DEFAULT_MESH_POLICY.spawnedSessionVisibility;
|
|
77
|
+
}
|
|
78
|
+
const normalizedStrategy = normalizeMeshSchedulingStrategy(policy.schedulingStrategy);
|
|
79
|
+
if (normalizedStrategy === "first_eligible") {
|
|
80
|
+
delete policy.schedulingStrategy;
|
|
81
|
+
} else {
|
|
82
|
+
policy.schedulingStrategy = normalizedStrategy;
|
|
83
|
+
}
|
|
84
|
+
if (policy.autoConvergeCodeChange === true) {
|
|
85
|
+
policy.autoConvergeCodeChange = true;
|
|
86
|
+
} else {
|
|
87
|
+
delete policy.autoConvergeCodeChange;
|
|
88
|
+
}
|
|
89
|
+
return policy;
|
|
90
|
+
}
|
|
41
91
|
function resolveDelegatedWorkerAutoApprove(meshPolicy, nodePolicy) {
|
|
42
92
|
if (typeof nodePolicy?.delegatedWorkerAutoApprove === "boolean") {
|
|
43
93
|
return nodePolicy.delegatedWorkerAutoApprove;
|
|
@@ -62,7 +112,7 @@ function resolveProviderMaxParallel(nodePolicy, providerType) {
|
|
|
62
112
|
}
|
|
63
113
|
return void 0;
|
|
64
114
|
}
|
|
65
|
-
var MESH_SCHEDULING_STRATEGIES, DEFAULT_MESH_SCHEDULING_STRATEGY, MESH_CONVERGE_REFINE_TAG, MESH_CONVERGE_FAST_FORWARD_TAG, DEFAULT_MESH_POLICY;
|
|
115
|
+
var MESH_SCHEDULING_STRATEGIES, DEFAULT_MESH_SCHEDULING_STRATEGY, MESH_CONVERGE_REFINE_TAG, MESH_CONVERGE_FAST_FORWARD_TAG, DEFAULT_MESH_POLICY, SESSION_CLEANUP_MODES, SPAWNED_SESSION_VISIBILITY_MODES, DIRTY_WORKSPACE_BEHAVIORS, MESH_MAX_PARALLEL_TASKS_MIN, MESH_MAX_PARALLEL_TASKS_MAX;
|
|
66
116
|
var init_repo_mesh_types = __esm({
|
|
67
117
|
"src/repo-mesh-types.ts"() {
|
|
68
118
|
"use strict";
|
|
@@ -92,6 +142,23 @@ var init_repo_mesh_types = __esm({
|
|
|
92
142
|
autoFastForward: { enabled: true },
|
|
93
143
|
maxTaskRetries: 1
|
|
94
144
|
};
|
|
145
|
+
SESSION_CLEANUP_MODES = /* @__PURE__ */ new Set([
|
|
146
|
+
"preserve",
|
|
147
|
+
"stop",
|
|
148
|
+
"delete_stopped",
|
|
149
|
+
"stop_and_delete"
|
|
150
|
+
]);
|
|
151
|
+
SPAWNED_SESSION_VISIBILITY_MODES = /* @__PURE__ */ new Set([
|
|
152
|
+
"visible",
|
|
153
|
+
"hidden"
|
|
154
|
+
]);
|
|
155
|
+
DIRTY_WORKSPACE_BEHAVIORS = /* @__PURE__ */ new Set([
|
|
156
|
+
"block",
|
|
157
|
+
"warn",
|
|
158
|
+
"checkpoint_then_continue"
|
|
159
|
+
]);
|
|
160
|
+
MESH_MAX_PARALLEL_TASKS_MIN = 1;
|
|
161
|
+
MESH_MAX_PARALLEL_TASKS_MAX = 8;
|
|
95
162
|
}
|
|
96
163
|
});
|
|
97
164
|
|
|
@@ -311,10 +378,10 @@ function readInjected(value) {
|
|
|
311
378
|
}
|
|
312
379
|
function getDaemonBuildInfo() {
|
|
313
380
|
if (cached) return cached;
|
|
314
|
-
const commit = readInjected(true ? "
|
|
315
|
-
const commitShort = readInjected(true ? "
|
|
316
|
-
const version = readInjected(true ? "0.9.82-rc.
|
|
317
|
-
const builtAt = readInjected(true ? "2026-06-
|
|
381
|
+
const commit = readInjected(true ? "18afac213951f79c502feb6b25b7399fe4d709b3" : void 0) ?? "unknown";
|
|
382
|
+
const commitShort = readInjected(true ? "18afac21" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
|
|
383
|
+
const version = readInjected(true ? "0.9.82-rc.381" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
|
|
384
|
+
const builtAt = readInjected(true ? "2026-06-25T11:44:40.598Z" : void 0);
|
|
318
385
|
cached = builtAt ? { commit, commitShort, version, builtAt } : { commit, commitShort, version };
|
|
319
386
|
return cached;
|
|
320
387
|
}
|
|
@@ -2366,52 +2433,6 @@ function normalizeRepoIdentity(remoteUrl) {
|
|
|
2366
2433
|
if (sshMatch) return `${sshMatch[1]}/${sshMatch[2]}`;
|
|
2367
2434
|
return identity;
|
|
2368
2435
|
}
|
|
2369
|
-
function mergeMeshPolicy(base, patch) {
|
|
2370
|
-
const autoFastForward = normalizeAutoFastForwardPolicy({
|
|
2371
|
-
...DEFAULT_MESH_POLICY.autoFastForward,
|
|
2372
|
-
...base?.autoFastForward && typeof base.autoFastForward === "object" ? base.autoFastForward : {},
|
|
2373
|
-
...patch?.autoFastForward && typeof patch.autoFastForward === "object" ? patch.autoFastForward : {}
|
|
2374
|
-
});
|
|
2375
|
-
const policy = {
|
|
2376
|
-
...DEFAULT_MESH_POLICY,
|
|
2377
|
-
...base || {},
|
|
2378
|
-
...patch || {},
|
|
2379
|
-
autoFastForward
|
|
2380
|
-
};
|
|
2381
|
-
if (!["block", "warn", "checkpoint_then_continue"].includes(policy.dirtyWorkspaceBehavior)) {
|
|
2382
|
-
policy.dirtyWorkspaceBehavior = "warn";
|
|
2383
|
-
}
|
|
2384
|
-
const maxParallelTasks = Number(policy.maxParallelTasks);
|
|
2385
|
-
policy.maxParallelTasks = Number.isFinite(maxParallelTasks) ? Math.max(1, Math.min(8, Math.floor(maxParallelTasks))) : 2;
|
|
2386
|
-
policy.allowAutoPublishSubmoduleMainCommits = policy.allowAutoPublishSubmoduleMainCommits === true;
|
|
2387
|
-
if (!SESSION_CLEANUP_MODES.has(String(policy.sessionCleanupOnNodeRemove))) {
|
|
2388
|
-
policy.sessionCleanupOnNodeRemove = "preserve";
|
|
2389
|
-
}
|
|
2390
|
-
if (!SPAWNED_SESSION_VISIBILITY_MODES.has(String(policy.spawnedSessionVisibility))) {
|
|
2391
|
-
policy.spawnedSessionVisibility = DEFAULT_MESH_POLICY.spawnedSessionVisibility;
|
|
2392
|
-
}
|
|
2393
|
-
const normalizedStrategy = normalizeMeshSchedulingStrategy(policy.schedulingStrategy);
|
|
2394
|
-
if (normalizedStrategy === "first_eligible") {
|
|
2395
|
-
delete policy.schedulingStrategy;
|
|
2396
|
-
} else {
|
|
2397
|
-
policy.schedulingStrategy = normalizedStrategy;
|
|
2398
|
-
}
|
|
2399
|
-
if (policy.autoConvergeCodeChange === true) {
|
|
2400
|
-
policy.autoConvergeCodeChange = true;
|
|
2401
|
-
} else {
|
|
2402
|
-
delete policy.autoConvergeCodeChange;
|
|
2403
|
-
}
|
|
2404
|
-
return policy;
|
|
2405
|
-
}
|
|
2406
|
-
function normalizeAutoFastForwardPolicy(value) {
|
|
2407
|
-
const record = value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
2408
|
-
const maxBehind = Number(record.maxBehind);
|
|
2409
|
-
return {
|
|
2410
|
-
enabled: record.enabled !== false,
|
|
2411
|
-
...Number.isFinite(maxBehind) && maxBehind >= 0 ? { maxBehind: Math.floor(maxBehind) } : {},
|
|
2412
|
-
requireCleanSubmodules: record.requireCleanSubmodules !== false
|
|
2413
|
-
};
|
|
2414
|
-
}
|
|
2415
2436
|
function listMeshes() {
|
|
2416
2437
|
return loadMeshConfig().meshes;
|
|
2417
2438
|
}
|
|
@@ -2710,7 +2731,7 @@ function updateNode(meshId, nodeId, opts) {
|
|
|
2710
2731
|
saveMeshConfig(config);
|
|
2711
2732
|
return node;
|
|
2712
2733
|
}
|
|
2713
|
-
var
|
|
2734
|
+
var mergeMeshPolicy;
|
|
2714
2735
|
var init_mesh_config = __esm({
|
|
2715
2736
|
"src/config/mesh-config.ts"() {
|
|
2716
2737
|
"use strict";
|
|
@@ -2718,8 +2739,7 @@ var init_mesh_config = __esm({
|
|
|
2718
2739
|
init_config();
|
|
2719
2740
|
init_repo_mesh_types();
|
|
2720
2741
|
init_mesh_host_ownership();
|
|
2721
|
-
|
|
2722
|
-
SPAWNED_SESSION_VISIBILITY_MODES = /* @__PURE__ */ new Set(["visible", "hidden"]);
|
|
2742
|
+
mergeMeshPolicy = mergeAndNormalizePolicy;
|
|
2723
2743
|
}
|
|
2724
2744
|
});
|
|
2725
2745
|
|
|
@@ -3043,7 +3063,7 @@ Default branch: \`${mesh.defaultBranch}\`` : ""}`);
|
|
|
3043
3063
|
if (recentActivity) sections.push(recentActivity);
|
|
3044
3064
|
const operatingNotes = buildOperatingNotesSection(ctx.operatingNotes);
|
|
3045
3065
|
if (operatingNotes) sections.push(operatingNotes);
|
|
3046
|
-
sections.push(buildPolicySection(
|
|
3066
|
+
sections.push(buildPolicySection(mergeAndNormalizePolicy(void 0, mesh.policy)));
|
|
3047
3067
|
sections.push(TOOLS_SECTION);
|
|
3048
3068
|
sections.push(TOOL_EXPOSURE_PREFLIGHT_SECTION);
|
|
3049
3069
|
sections.push(WORKFLOW_SECTION);
|
|
@@ -3076,7 +3096,7 @@ function expandPromptPlaceholders(template, ctx) {
|
|
|
3076
3096
|
mission: ctx.missionSection?.trim() || "",
|
|
3077
3097
|
recentActivity: buildRecentActivitySection(ctx.recentActivity) || "",
|
|
3078
3098
|
operatingNotes: buildOperatingNotesSection(ctx.operatingNotes) || "",
|
|
3079
|
-
policy: buildPolicySection(
|
|
3099
|
+
policy: buildPolicySection(mergeAndNormalizePolicy(void 0, mesh.policy)),
|
|
3080
3100
|
tools: TOOLS_SECTION,
|
|
3081
3101
|
workflow: WORKFLOW_SECTION,
|
|
3082
3102
|
rules: buildRulesSection(coordinatorCliType),
|
|
@@ -5741,6 +5761,28 @@ var init_mesh_runtime_store = __esm({
|
|
|
5741
5761
|
AND status NOT IN ('completed', 'failed')
|
|
5742
5762
|
`).run({ status, meshId, sessionId, updatedAt: now });
|
|
5743
5763
|
}
|
|
5764
|
+
/**
|
|
5765
|
+
* MESH-DISPATCH-MISROUTE (fix 3, consumer residual): resolve the task_id of the SINGLE
|
|
5766
|
+
* non-terminal direct dispatch a session owns. Returns the task_id only when the session
|
|
5767
|
+
* holds exactly ONE active ('dispatched'/'acked') row — the case where a taskId-less
|
|
5768
|
+
* lifecycle event (a legacy/relayed worker whose producer never stamped meshActiveTaskId)
|
|
5769
|
+
* unambiguously belongs to that one dispatch. With zero rows there is nothing to ack; with
|
|
5770
|
+
* two or more (a re-dispatch/nudge sibling) the firing event's owner is ambiguous, so we
|
|
5771
|
+
* return null and the caller MUST NOT fall back to the session_id sweep that would flip a
|
|
5772
|
+
* sibling row ("may flip a sibling dispatch row"). This narrows the legacy fallback to the
|
|
5773
|
+
* only safe case instead of removing the producer-side TASKIDLESS stamp's safety net.
|
|
5774
|
+
*/
|
|
5775
|
+
getSoleActiveDirectDispatchTaskId(meshId, sessionId) {
|
|
5776
|
+
if (!sessionId) return null;
|
|
5777
|
+
const rows = this.db.prepare(`
|
|
5778
|
+
SELECT task_id FROM mesh_direct_dispatches
|
|
5779
|
+
WHERE mesh_id = ? AND session_id = ?
|
|
5780
|
+
AND status NOT IN ('completed', 'failed', 'stale')
|
|
5781
|
+
`).all(meshId, sessionId);
|
|
5782
|
+
if (rows.length !== 1) return null;
|
|
5783
|
+
const taskId = typeof rows[0]?.task_id === "string" ? rows[0].task_id.trim() : "";
|
|
5784
|
+
return taskId || null;
|
|
5785
|
+
}
|
|
5744
5786
|
cleanupTerminalDirectDispatches(olderThanMs) {
|
|
5745
5787
|
const cutoff = new Date(Date.now() - olderThanMs).toISOString();
|
|
5746
5788
|
this.db.prepare(`
|
|
@@ -10815,8 +10857,8 @@ async function maybeAutoLaunchOneQueueSession(components, meshId, mesh) {
|
|
|
10815
10857
|
const maxParallelTasks = Math.max(1, Math.floor(Number(mesh?.policy?.maxParallelTasks) || 2));
|
|
10816
10858
|
const maxReadonlyParallelTasks = Math.max(2, maxParallelTasks * 2);
|
|
10817
10859
|
for (const task of pending) {
|
|
10818
|
-
const
|
|
10819
|
-
if (
|
|
10860
|
+
const isReadonly2 = task.taskMode === "live_debug_readonly";
|
|
10861
|
+
if (isReadonly2) {
|
|
10820
10862
|
if (activeReadonlyAssignedCount(meshId) >= maxReadonlyParallelTasks) {
|
|
10821
10863
|
markAutoLaunch(meshId, task.id, { status: "skipped", reason: "max_readonly_parallel_tasks_reached" });
|
|
10822
10864
|
continue;
|
|
@@ -14244,8 +14286,19 @@ function injectMeshSystemMessage(components, args) {
|
|
|
14244
14286
|
}
|
|
14245
14287
|
if (sessionId) {
|
|
14246
14288
|
const startedTaskId = readNonEmptyString2(args.metadataEvent.taskId) || void 0;
|
|
14247
|
-
if (startedTaskId
|
|
14289
|
+
if (startedTaskId) {
|
|
14248
14290
|
updateDirectDispatchStatus(args.meshId, sessionId, "acked", startedTaskId);
|
|
14291
|
+
} else if (sessionHasActiveAssignment(args.meshId, sessionId)) {
|
|
14292
|
+
const soleTaskId = (() => {
|
|
14293
|
+
try {
|
|
14294
|
+
return MeshRuntimeStore.getInstance().getSoleActiveDirectDispatchTaskId(args.meshId, sessionId);
|
|
14295
|
+
} catch {
|
|
14296
|
+
return null;
|
|
14297
|
+
}
|
|
14298
|
+
})();
|
|
14299
|
+
if (soleTaskId) {
|
|
14300
|
+
updateDirectDispatchStatus(args.meshId, sessionId, "acked", soleTaskId);
|
|
14301
|
+
}
|
|
14249
14302
|
}
|
|
14250
14303
|
const activeDeliveries = (() => {
|
|
14251
14304
|
try {
|
|
@@ -22921,6 +22974,102 @@ function buildMeshLedgerReconciliationEvidence(meshId, replicas) {
|
|
|
22921
22974
|
init_mesh_work_queue();
|
|
22922
22975
|
init_mesh_active_work();
|
|
22923
22976
|
init_mesh_refine_status();
|
|
22977
|
+
|
|
22978
|
+
// src/mesh/mesh-scheduling-runtime.ts
|
|
22979
|
+
init_repo_mesh_types();
|
|
22980
|
+
init_dist();
|
|
22981
|
+
function isReadonly(task) {
|
|
22982
|
+
return task.taskMode === "live_debug_readonly";
|
|
22983
|
+
}
|
|
22984
|
+
function isAssigned(task) {
|
|
22985
|
+
return task.status === "assigned";
|
|
22986
|
+
}
|
|
22987
|
+
function buildMeshSchedulingRuntime(mesh, queue) {
|
|
22988
|
+
const strategy = normalizeMeshSchedulingStrategy(mesh?.policy?.schedulingStrategy);
|
|
22989
|
+
const maxParallelTasks = resolveMaxParallelTasks(mesh?.policy?.maxParallelTasks);
|
|
22990
|
+
const maxReadonlyParallelTasks = Math.max(2, maxParallelTasks * 2);
|
|
22991
|
+
const assignedTasks = (Array.isArray(queue) ? queue : []).filter(isAssigned);
|
|
22992
|
+
const activeWriteAssigned = assignedTasks.filter((t) => !isReadonly(t)).length;
|
|
22993
|
+
const activeReadonlyAssigned = assignedTasks.filter(isReadonly).length;
|
|
22994
|
+
const globalWriteCapReached = activeWriteAssigned >= maxParallelTasks;
|
|
22995
|
+
const globalReadonlyCapReached = activeReadonlyAssigned >= maxReadonlyParallelTasks;
|
|
22996
|
+
const writeAssignedByNode = /* @__PURE__ */ new Map();
|
|
22997
|
+
const assignedByNode = /* @__PURE__ */ new Map();
|
|
22998
|
+
const providerCountByNode = /* @__PURE__ */ new Map();
|
|
22999
|
+
for (const task of assignedTasks) {
|
|
23000
|
+
const nodeId = typeof task.assignedNodeId === "string" ? task.assignedNodeId.trim() : "";
|
|
23001
|
+
if (!nodeId) continue;
|
|
23002
|
+
assignedByNode.set(nodeId, (assignedByNode.get(nodeId) ?? 0) + 1);
|
|
23003
|
+
if (!isReadonly(task)) {
|
|
23004
|
+
writeAssignedByNode.set(nodeId, (writeAssignedByNode.get(nodeId) ?? 0) + 1);
|
|
23005
|
+
}
|
|
23006
|
+
const provider = typeof task.assignedProviderType === "string" ? task.assignedProviderType : "";
|
|
23007
|
+
if (provider) {
|
|
23008
|
+
let byProvider = providerCountByNode.get(nodeId);
|
|
23009
|
+
if (!byProvider) {
|
|
23010
|
+
byProvider = /* @__PURE__ */ new Map();
|
|
23011
|
+
providerCountByNode.set(nodeId, byProvider);
|
|
23012
|
+
}
|
|
23013
|
+
byProvider.set(provider, (byProvider.get(provider) ?? 0) + 1);
|
|
23014
|
+
}
|
|
23015
|
+
}
|
|
23016
|
+
const nodes = [];
|
|
23017
|
+
for (const rawNode of Array.isArray(mesh?.nodes) ? mesh.nodes : []) {
|
|
23018
|
+
const nodeId = normalizeMeshNodeId(rawNode);
|
|
23019
|
+
if (!nodeId) continue;
|
|
23020
|
+
const policy = rawNode?.policy || void 0;
|
|
23021
|
+
const load4 = assignedByNode.get(nodeId) ?? 0;
|
|
23022
|
+
const schedulingPriority = resolveNodeSchedulingPriority(policy);
|
|
23023
|
+
const capReasons = [];
|
|
23024
|
+
if (globalWriteCapReached) capReasons.push("global_max_parallel_tasks_reached");
|
|
23025
|
+
if ((writeAssignedByNode.get(nodeId) ?? 0) > 0) capReasons.push("node_has_active_assignment");
|
|
23026
|
+
let providerRoles;
|
|
23027
|
+
const declaredRoles = Array.isArray(policy?.providerRoles) ? policy.providerRoles : [];
|
|
23028
|
+
if (declaredRoles.length) {
|
|
23029
|
+
const byProvider = providerCountByNode.get(nodeId);
|
|
23030
|
+
providerRoles = [];
|
|
23031
|
+
for (const role of declaredRoles) {
|
|
23032
|
+
if (!role || typeof role !== "object") continue;
|
|
23033
|
+
const providerType = typeof role.providerType === "string" ? role.providerType.trim() : "";
|
|
23034
|
+
if (!providerType) continue;
|
|
23035
|
+
const maxParallel = resolveProviderMaxParallel(policy, providerType);
|
|
23036
|
+
const activeAssigned = byProvider?.get(providerType) ?? 0;
|
|
23037
|
+
const capReached = maxParallel !== void 0 && activeAssigned >= maxParallel;
|
|
23038
|
+
providerRoles.push({
|
|
23039
|
+
providerType,
|
|
23040
|
+
...maxParallel !== void 0 ? { maxParallel } : {},
|
|
23041
|
+
activeAssigned,
|
|
23042
|
+
capReached
|
|
23043
|
+
});
|
|
23044
|
+
if (capReached) capReasons.push(`max_provider_parallel_reached:${providerType}`);
|
|
23045
|
+
}
|
|
23046
|
+
if (!providerRoles.length) providerRoles = void 0;
|
|
23047
|
+
}
|
|
23048
|
+
const maxConcurrentSessions = Number(policy?.maxConcurrentSessions);
|
|
23049
|
+
const hasSessionCap = Number.isFinite(maxConcurrentSessions) && maxConcurrentSessions >= 0;
|
|
23050
|
+
nodes.push({
|
|
23051
|
+
nodeId,
|
|
23052
|
+
load: load4,
|
|
23053
|
+
schedulingPriority,
|
|
23054
|
+
...hasSessionCap ? { maxConcurrentSessions: Math.floor(maxConcurrentSessions) } : {},
|
|
23055
|
+
...providerRoles ? { providerRoles } : {},
|
|
23056
|
+
capReached: capReasons.length > 0,
|
|
23057
|
+
capReasons
|
|
23058
|
+
});
|
|
23059
|
+
}
|
|
23060
|
+
return {
|
|
23061
|
+
strategy,
|
|
23062
|
+
maxParallelTasks,
|
|
23063
|
+
maxReadonlyParallelTasks,
|
|
23064
|
+
activeWriteAssigned,
|
|
23065
|
+
activeReadonlyAssigned,
|
|
23066
|
+
globalWriteCapReached,
|
|
23067
|
+
globalReadonlyCapReached,
|
|
23068
|
+
nodes
|
|
23069
|
+
};
|
|
23070
|
+
}
|
|
23071
|
+
|
|
23072
|
+
// src/index.ts
|
|
22924
23073
|
init_mesh_host_ownership();
|
|
22925
23074
|
init_mesh_events();
|
|
22926
23075
|
init_mesh_events_utils();
|
|
@@ -62209,6 +62358,8 @@ export {
|
|
|
62209
62358
|
MAX_LEDGER_SLICE_LIMIT,
|
|
62210
62359
|
MESH_CONVERGE_FAST_FORWARD_TAG,
|
|
62211
62360
|
MESH_CONVERGE_REFINE_TAG,
|
|
62361
|
+
MESH_MAX_PARALLEL_TASKS_MAX,
|
|
62362
|
+
MESH_MAX_PARALLEL_TASKS_MIN,
|
|
62212
62363
|
MESH_MISSION_STATUSES,
|
|
62213
62364
|
MESH_NODE_LIVE_TRUTH_MARKER,
|
|
62214
62365
|
MESH_REFINE_CONFIG_LOCATIONS,
|
|
@@ -62259,6 +62410,7 @@ export {
|
|
|
62259
62410
|
buildMeshNodeCapabilityTags,
|
|
62260
62411
|
buildMeshNodeDataFreshness,
|
|
62261
62412
|
buildMeshNodeProbeFreshness,
|
|
62413
|
+
buildMeshSchedulingRuntime,
|
|
62262
62414
|
buildMissionPromptSection,
|
|
62263
62415
|
buildP2pRelayFailurePayload,
|
|
62264
62416
|
buildPinnedGlobalInstallCommand,
|
|
@@ -62407,11 +62559,13 @@ export {
|
|
|
62407
62559
|
markSetupComplete,
|
|
62408
62560
|
markStaleDirectDispatches,
|
|
62409
62561
|
maybeRunDaemonUpgradeHelperFromEnv,
|
|
62562
|
+
mergeAndNormalizePolicy,
|
|
62410
62563
|
meshNodeIdMatches,
|
|
62411
62564
|
namedKeyToAnsi,
|
|
62412
62565
|
namedKeysToAnsi,
|
|
62413
62566
|
nodeSatisfiesRequiredTags,
|
|
62414
62567
|
normalizeActiveChatData,
|
|
62568
|
+
normalizeAutoFastForwardPolicy,
|
|
62415
62569
|
normalizeChatMessage,
|
|
62416
62570
|
normalizeChatMessageKind,
|
|
62417
62571
|
normalizeChatMessages,
|
|
@@ -62473,11 +62627,13 @@ export {
|
|
|
62473
62627
|
resolveDelegatedWorkerAutoApprove,
|
|
62474
62628
|
resolveDeliveryDecision,
|
|
62475
62629
|
resolveGitRepository,
|
|
62630
|
+
resolveMaxParallelTasks,
|
|
62476
62631
|
resolveMeshHostStatus,
|
|
62477
62632
|
resolveMeshNodeAttribution,
|
|
62478
62633
|
resolveMeshRefineValidationPlan,
|
|
62479
62634
|
resolveMeshSurfacedSessionPreview,
|
|
62480
62635
|
resolveNodeSchedulingPriority,
|
|
62636
|
+
resolveProviderMaxParallel,
|
|
62481
62637
|
resolveSessionHostAppName,
|
|
62482
62638
|
resolveSessionHostAppNameResolution,
|
|
62483
62639
|
resolveWorktreePath,
|