@adhdev/daemon-standalone 1.0.56-rc.8 → 1.0.56-rc.9
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 +292 -109
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/vendor/mcp-server/index.js +110 -0
- package/vendor/mcp-server/index.js.map +1 -1
package/dist/index.js
CHANGED
|
@@ -36620,10 +36620,10 @@ var require_dist3 = __commonJS({
|
|
|
36620
36620
|
}
|
|
36621
36621
|
function getDaemonBuildInfo() {
|
|
36622
36622
|
if (cached2) return cached2;
|
|
36623
|
-
const commit = readInjected(true ? "
|
|
36624
|
-
const commitShort = readInjected(true ? "
|
|
36625
|
-
const version2 = readInjected(true ? "1.0.56-rc.
|
|
36626
|
-
const builtAt = readInjected(true ? "2026-08-
|
|
36623
|
+
const commit = readInjected(true ? "346a82b2748c5a3d6ab32d126bbe7399d24d9a82" : void 0) ?? "unknown";
|
|
36624
|
+
const commitShort = readInjected(true ? "346a82b2" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
|
|
36625
|
+
const version2 = readInjected(true ? "1.0.56-rc.9" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
|
|
36626
|
+
const builtAt = readInjected(true ? "2026-08-19T22:46:34.487Z" : void 0);
|
|
36627
36627
|
cached2 = builtAt ? { commit, commitShort, version: version2, builtAt } : { commit, commitShort, version: version2 };
|
|
36628
36628
|
return cached2;
|
|
36629
36629
|
}
|
|
@@ -42860,6 +42860,7 @@ ${error48.message || ""}`;
|
|
|
42860
42860
|
"mesh_graph_view",
|
|
42861
42861
|
"mesh_graph_gate_claim",
|
|
42862
42862
|
"mesh_graph_gate_release",
|
|
42863
|
+
"mesh_graph_gate_abandon",
|
|
42863
42864
|
"mesh_queue_cancel",
|
|
42864
42865
|
"mesh_queue_requeue",
|
|
42865
42866
|
"mesh_send_task",
|
|
@@ -57196,6 +57197,7 @@ When you compose the task message you dispatch to a node, include this requireme
|
|
|
57196
57197
|
| \`mesh_graph_view\` | Inspect orchestration graphs \u2014 node states, gates awaiting you, workspace sagas, why something is blocked |
|
|
57197
57198
|
| \`mesh_graph_gate_claim\` | Take the lease on a gate awaiting a coordinator; returns the fencing token + generation a release needs |
|
|
57198
57199
|
| \`mesh_graph_gate_release\` | Pass a gate you hold \u2014 the ONLY way through one (no timeout ever passes a gate). **A gate and its dependents are one unit**: a gate earns its keep only when some task names it in \`gated_by\`, because releasing it is what dispatches that task. A gate nothing depends on opens nothing and is pure claim/release overhead \u2014 declare the follower in the same batch, or skip the gate |
|
|
57200
|
+
| \`mesh_graph_gate_abandon\` | Give up on a gate that can never be opened, so its graph can go terminal. **Not a pass**: it CANCELS everything the gate was holding and produces no gate outcome. Use it when you cancelled the work behind a gate \u2014 otherwise that gate stays awaiting forever and the graph reaches no terminal state, not even cancelled |
|
|
57199
57201
|
| \`mesh_queue_cancel\` | Cancel a queue task (audit history kept) |
|
|
57200
57202
|
| \`mesh_queue_requeue\` | Return a task to pending for retry |
|
|
57201
57203
|
| \`mesh_send_task\` | Push a task straight to a specific node/session |
|
|
@@ -57270,6 +57272,7 @@ Before doing any coordinator work, confirm that the actual callable tool list in
|
|
|
57270
57272
|
- **"The only thing I am sure of right now is this one task" is not evidence of a single.** That feeling is about your confidence, not about how many steps are settled; two steps are routinely settled at once while it still feels that way. Count the steps you would actually dispatch. If that count is two or more, it is a batch no matter how the plan feels.
|
|
57271
57273
|
- **"I cannot choose the next step until I see this result" states that the next step EXISTS.** What the result decides is *which branch you take*, not *whether* there is a follow-up \u2014 and a branch that turns on a predecessor's output is what \`run_if\` selects, what \`inputs_from\` feeds, and what a coordinator gate holds until you decide. Needing to look at evidence before choosing is the ordinary case for a graph edge, not an exception to it.
|
|
57272
57274
|
- **A gate or a batch is not overhead when something follows it.** The extra call buys the dispatch of everything behind it, so it costs one call and saves a whole round-trip through you. The only genuinely wasteful gate is one nothing depends on \u2014 a gate no task names in \`gated_by\` opens nothing when released, which the release response tells you about; that case is answered by declaring the follower, not by abandoning the batch.
|
|
57275
|
+
- **If you cancel the tasks behind a gate, close the gate too.** Cancelling a task never touches the gate that was holding it \u2014 gates are a separate control plane on purpose. A gate left over a cancelled branch stays \`awaiting_coordinator\` forever, and while ANY gate is unsettled its graph can reach no terminal state at all, not even \`cancelled\`. Close it with \`mesh_graph_gate_abandon\` and a reason. \`mesh_graph_view\` flags this case for you as a \`gate_abandon\` action. Abandon is not a shortcut through a gate: it cancels whatever the gate was holding and yields no gate outcome, so use \`mesh_graph_gate_release\` whenever you actually want the downstream work to run.
|
|
57273
57276
|
|
|
57274
57277
|
When you do use \`mesh_enqueue_task\`, pass \`orchestration_decision\` recording why a single was right (\`single_reason\`: \`only_one_step_known\` / \`future_step_not_specifiable\` / \`same_session_continuation\` / \`legacy_client\` / \`operator_override\`). Omitting it is recorded as \`decision_missing\`.
|
|
57275
57278
|
|
|
@@ -60972,6 +60975,98 @@ ${rendered}`, "utf-8");
|
|
|
60972
60975
|
store.updateQueueEntry(entry);
|
|
60973
60976
|
}
|
|
60974
60977
|
}
|
|
60978
|
+
function coordinatorGateAbandonedReason(gateId) {
|
|
60979
|
+
return `coordinator_gate_abandoned:${gateId}`;
|
|
60980
|
+
}
|
|
60981
|
+
function abandonMeshGraphGate(input) {
|
|
60982
|
+
const store = MeshRuntimeStore.getInstance();
|
|
60983
|
+
const nowMs = input.nowMs ?? Date.now();
|
|
60984
|
+
const nowIso = new Date(nowMs).toISOString();
|
|
60985
|
+
const result = store.transaction(() => {
|
|
60986
|
+
const graphStore = store.graphStore();
|
|
60987
|
+
const gate = graphStore.getGate(input.gateId);
|
|
60988
|
+
if (!gate || gate.meshId !== input.meshId) {
|
|
60989
|
+
return { abandoned: false, reason: "gate_not_found", cancelledNodeIds: [], cancelledTaskIds: [] };
|
|
60990
|
+
}
|
|
60991
|
+
if (gate.state === "cancelled") {
|
|
60992
|
+
return { abandoned: true, reason: "gate_already_abandoned", gate, cancelledNodeIds: [], cancelledTaskIds: [] };
|
|
60993
|
+
}
|
|
60994
|
+
if (gate.state === "released") {
|
|
60995
|
+
return { abandoned: false, reason: `gate_terminal:${gate.state}`, gate, cancelledNodeIds: [], cancelledTaskIds: [] };
|
|
60996
|
+
}
|
|
60997
|
+
if (!input.force && gate.state === "claimed" && gate.leaseExpiresAt && gate.leaseExpiresAt > nowIso) {
|
|
60998
|
+
return { abandoned: false, reason: "gate_lease_held", gate, cancelledNodeIds: [], cancelledTaskIds: [] };
|
|
60999
|
+
}
|
|
61000
|
+
const abandonReason = `${coordinatorGateAbandonedReason(gate.gateId)}:${input.reason}`;
|
|
61001
|
+
const won = graphStore.patchGate(gate.gateId, {
|
|
61002
|
+
state: "cancelled",
|
|
61003
|
+
// Drop the lease: an abandoned gate has no owner and no live fence.
|
|
61004
|
+
leaseOwnerSessionId: null,
|
|
61005
|
+
fencingToken: null,
|
|
61006
|
+
leaseExpiresAt: null
|
|
61007
|
+
}, nowIso, { leaseGeneration: gate.leaseGeneration });
|
|
61008
|
+
if (!won) {
|
|
61009
|
+
return { abandoned: false, reason: "gate_abandon_race", gate, cancelledNodeIds: [], cancelledTaskIds: [] };
|
|
61010
|
+
}
|
|
61011
|
+
const node = graphStore.getNode(gate.graphId, gate.nodeId);
|
|
61012
|
+
if (node && node.state !== "cancelled") {
|
|
61013
|
+
graphStore.updateNodeState(gate.graphId, gate.nodeId, "cancelled", nowIso, { failureReason: abandonReason });
|
|
61014
|
+
}
|
|
61015
|
+
const cancelledNodeIds = node ? cancelGateDownstreamSubtree(store, node, nowIso, abandonReason) : [];
|
|
61016
|
+
const cancelledTaskIds = [];
|
|
61017
|
+
for (const nodeId of cancelledNodeIds) {
|
|
61018
|
+
const target = graphStore.getNode(gate.graphId, nodeId);
|
|
61019
|
+
if (target?.queueTaskId) cancelledTaskIds.push(target.queueTaskId);
|
|
61020
|
+
}
|
|
61021
|
+
const graph = graphStore.getGraph(gate.graphId);
|
|
61022
|
+
let graphStatus;
|
|
61023
|
+
const rolled = classifyGraphRollup(graphStore.listNodes(gate.graphId));
|
|
61024
|
+
if (graph && rolled && graph.status !== rolled) {
|
|
61025
|
+
graphStore.updateGraphStatus(gate.graphId, rolled, nowIso, true);
|
|
61026
|
+
graphStatus = rolled;
|
|
61027
|
+
insertGateOutbox(
|
|
61028
|
+
graphStore,
|
|
61029
|
+
gate.meshId,
|
|
61030
|
+
gate.graphId,
|
|
61031
|
+
rolled === "completed" ? "graph_completed" : rolled === "failed" ? "graph_failed" : "graph_cancelled",
|
|
61032
|
+
{ graphId: gate.graphId, status: rolled },
|
|
61033
|
+
nowIso
|
|
61034
|
+
);
|
|
61035
|
+
} else if (graph?.status === "waiting_gate") {
|
|
61036
|
+
const stillWaiting = graphStore.listGatesByGraph(gate.graphId).some((g) => g.gateId !== gate.gateId && (g.state === "awaiting_coordinator" || g.state === "claimed"));
|
|
61037
|
+
if (!stillWaiting) {
|
|
61038
|
+
graphStore.updateGraphStatus(gate.graphId, "active", nowIso);
|
|
61039
|
+
graphStatus = "active";
|
|
61040
|
+
}
|
|
61041
|
+
}
|
|
61042
|
+
insertGateOutbox(graphStore, gate.meshId, gate.graphId, "graph_gate_abandoned", {
|
|
61043
|
+
graphId: gate.graphId,
|
|
61044
|
+
gateId: gate.gateId,
|
|
61045
|
+
nodeId: gate.nodeId,
|
|
61046
|
+
ref: gate.ref,
|
|
61047
|
+
action: gate.action,
|
|
61048
|
+
priorState: gate.state,
|
|
61049
|
+
reason: input.reason,
|
|
61050
|
+
...input.coordinatorSessionId ? { coordinatorSessionId: input.coordinatorSessionId } : {},
|
|
61051
|
+
...input.force ? { force: true } : {},
|
|
61052
|
+
...cancelledNodeIds.length > 0 ? { cancelledNodeIds } : {}
|
|
61053
|
+
}, nowIso);
|
|
61054
|
+
return {
|
|
61055
|
+
abandoned: true,
|
|
61056
|
+
gate: graphStore.getGate(gate.gateId),
|
|
61057
|
+
cancelledNodeIds,
|
|
61058
|
+
cancelledTaskIds,
|
|
61059
|
+
...graphStatus ? { graphStatus } : {}
|
|
61060
|
+
};
|
|
61061
|
+
});
|
|
61062
|
+
if (result.abandoned) {
|
|
61063
|
+
try {
|
|
61064
|
+
drainMeshGraphOutbox(input.meshId);
|
|
61065
|
+
} catch {
|
|
61066
|
+
}
|
|
61067
|
+
}
|
|
61068
|
+
return result;
|
|
61069
|
+
}
|
|
60975
61070
|
function sweepMeshGraphGateTimeouts(meshId, nowMs) {
|
|
60976
61071
|
const store = MeshRuntimeStore.getInstance();
|
|
60977
61072
|
const now = nowMs ?? Date.now();
|
|
@@ -61024,7 +61119,7 @@ ${rendered}`, "utf-8");
|
|
|
61024
61119
|
function isCancelExempt(state) {
|
|
61025
61120
|
return state === "completed" || state === "released" || state === "skipped" || state === "cancelled" || state === "failed" || state === "expired";
|
|
61026
61121
|
}
|
|
61027
|
-
function cancelGateDownstreamSubtree(store, gateNode, nowIso) {
|
|
61122
|
+
function cancelGateDownstreamSubtree(store, gateNode, nowIso, reason = `coordinator_gate_timeout:${gateNode.nodeId}`) {
|
|
61028
61123
|
const graphStore = store.graphStore();
|
|
61029
61124
|
const nodes = graphStore.listNodes(gateNode.graphId);
|
|
61030
61125
|
const edges = graphStore.listEdges(gateNode.graphId);
|
|
@@ -61041,13 +61136,13 @@ ${rendered}`, "utf-8");
|
|
|
61041
61136
|
const target = byId.get(edge.toNodeId);
|
|
61042
61137
|
if (!target || isCancelExempt(target.state)) continue;
|
|
61043
61138
|
graphStore.updateNodeState(target.graphId, target.nodeId, "cancelled", nowIso, {
|
|
61044
|
-
failureReason:
|
|
61139
|
+
failureReason: reason
|
|
61045
61140
|
});
|
|
61046
61141
|
if (target.queueTaskId) {
|
|
61047
61142
|
const entry = store.findQueueEntryById(target.meshId, target.queueTaskId);
|
|
61048
61143
|
if (entry && entry.status === "pending") {
|
|
61049
61144
|
entry.status = "cancelled";
|
|
61050
|
-
entry.blockedReason =
|
|
61145
|
+
entry.blockedReason = reason;
|
|
61051
61146
|
store.updateQueueEntry(entry);
|
|
61052
61147
|
}
|
|
61053
61148
|
}
|
|
@@ -61084,6 +61179,7 @@ ${rendered}`, "utf-8");
|
|
|
61084
61179
|
init_logger();
|
|
61085
61180
|
init_mesh_graph_input_binding();
|
|
61086
61181
|
init_mesh_graph_types();
|
|
61182
|
+
init_mesh_graph_derived_failure();
|
|
61087
61183
|
init_mesh_graph_transition_runner();
|
|
61088
61184
|
init_mesh_graph_transition_runner();
|
|
61089
61185
|
MESH_GATE_DEFAULT_LEASE_SECONDS = 900;
|
|
@@ -61216,6 +61312,20 @@ ${rendered}`, "utf-8");
|
|
|
61216
61312
|
...p.cancelledNodeIds?.length ? { cancelledNodeIds: p.cancelledNodeIds } : {}
|
|
61217
61313
|
});
|
|
61218
61314
|
}
|
|
61315
|
+
function recordGraphGateAbandoned(meshId, p) {
|
|
61316
|
+
safeAppend(meshId, "graph_gate_abandoned", {
|
|
61317
|
+
graphId: p.graphId,
|
|
61318
|
+
gateId: p.gateId,
|
|
61319
|
+
...p.ref ? { ref: p.ref } : {},
|
|
61320
|
+
action: p.action,
|
|
61321
|
+
priorState: p.priorState,
|
|
61322
|
+
reason: p.reason.slice(0, 500),
|
|
61323
|
+
...p.coordinatorSessionId ? { coordinatorSessionId: p.coordinatorSessionId } : {},
|
|
61324
|
+
...p.force ? { force: true } : {},
|
|
61325
|
+
...p.cancelledNodeIds?.length ? { cancelledNodeIds: p.cancelledNodeIds } : {},
|
|
61326
|
+
...p.graphStatus ? { graphStatus: p.graphStatus } : {}
|
|
61327
|
+
});
|
|
61328
|
+
}
|
|
61219
61329
|
var MESH_VALID_SINGLE_REASONS;
|
|
61220
61330
|
var MESH_SUPERSEDED_SINGLE_REASONS;
|
|
61221
61331
|
var MESH_DECLARED_ELIGIBLE_SINGLE_HINT;
|
|
@@ -70844,81 +70954,6 @@ ${cleanBody}`;
|
|
|
70844
70954
|
init_mesh_events_utils();
|
|
70845
70955
|
}
|
|
70846
70956
|
});
|
|
70847
|
-
function bootstrapQueueTaskCountsAsHandled(task, bootstrapNodeId, nowMs) {
|
|
70848
|
-
if (!meshNodeIdMatches({ id: task.targetNodeId }, bootstrapNodeId)) return false;
|
|
70849
|
-
if (task.status === "assigned") return true;
|
|
70850
|
-
const al = task.autoLaunch;
|
|
70851
|
-
if (!al) return true;
|
|
70852
|
-
if (al.status === "started" || al.status === "completed") {
|
|
70853
|
-
const launchedAtMs = Date.parse(al.updatedAt);
|
|
70854
|
-
return Number.isFinite(launchedAtMs) && nowMs - launchedAtMs < AUTO_LAUNCH_AWAIT_CLAIM_MS;
|
|
70855
|
-
}
|
|
70856
|
-
return true;
|
|
70857
|
-
}
|
|
70858
|
-
function resolveCoordinatorDrainDaemonIds(components) {
|
|
70859
|
-
const statusInstanceId = readNonEmptyString(components.statusInstanceId);
|
|
70860
|
-
const machineId = readNonEmptyString(loadConfig2().machineId);
|
|
70861
|
-
return expandDaemonIdForms([statusInstanceId, machineId]);
|
|
70862
|
-
}
|
|
70863
|
-
function getCachedMeshByWorkspace(workspace) {
|
|
70864
|
-
const now = Date.now();
|
|
70865
|
-
const cached5 = meshByWorkspaceCache.get(workspace);
|
|
70866
|
-
if (cached5 && now - cached5.cachedAt < MESH_WORKSPACE_CACHE_TTL_MS) return cached5.mesh;
|
|
70867
|
-
const mesh = getMeshByRepo(workspace);
|
|
70868
|
-
meshByWorkspaceCache.set(workspace, { mesh, cachedAt: now });
|
|
70869
|
-
return mesh;
|
|
70870
|
-
}
|
|
70871
|
-
function recoverMeshIdByNodeId(nodeId) {
|
|
70872
|
-
if (!nodeId) return "";
|
|
70873
|
-
for (const mesh of listMeshes()) {
|
|
70874
|
-
if (Array.isArray(mesh.nodes) && mesh.nodes.some((n) => meshNodeIdMatches(n, nodeId))) {
|
|
70875
|
-
return readNonEmptyString(mesh.id);
|
|
70876
|
-
}
|
|
70877
|
-
}
|
|
70878
|
-
return "";
|
|
70879
|
-
}
|
|
70880
|
-
function recoverMeshIdByCoordinatorAndNode(coordinatorDaemonId, nodeId) {
|
|
70881
|
-
if (!coordinatorDaemonId) return "";
|
|
70882
|
-
const hosted = listMeshes().filter((mesh) => {
|
|
70883
|
-
const host = resolveMeshHostStatus(mesh);
|
|
70884
|
-
return host.role === "host" && (!host.hostDaemonId || daemonIdsEquivalent(host.hostDaemonId, coordinatorDaemonId));
|
|
70885
|
-
});
|
|
70886
|
-
if (hosted.length === 0) return "";
|
|
70887
|
-
if (nodeId) {
|
|
70888
|
-
const byNode = hosted.find((mesh) => Array.isArray(mesh.nodes) && mesh.nodes.some((n) => meshNodeIdMatches(n, nodeId)));
|
|
70889
|
-
if (byNode) return readNonEmptyString(byNode.id);
|
|
70890
|
-
return "";
|
|
70891
|
-
}
|
|
70892
|
-
return hosted.length === 1 ? readNonEmptyString(hosted[0].id) : "";
|
|
70893
|
-
}
|
|
70894
|
-
function resolveForwardEventMeshId(components, payload) {
|
|
70895
|
-
const direct = readNonEmptyString(payload.meshId);
|
|
70896
|
-
if (direct) return direct;
|
|
70897
|
-
const workspace = readNonEmptyString(payload.workspace);
|
|
70898
|
-
const byWorkspace = workspace ? readNonEmptyString(getCachedMeshByWorkspace(workspace)?.id) : "";
|
|
70899
|
-
if (byWorkspace) return byWorkspace;
|
|
70900
|
-
const byNode = recoverMeshIdByNodeId(readNonEmptyString(payload.nodeId));
|
|
70901
|
-
if (byNode) return byNode;
|
|
70902
|
-
const sessionId = readNonEmptyString(payload.targetSessionId) || readNonEmptyString(payload.sessionId) || readNonEmptyString(payload.instanceId);
|
|
70903
|
-
if (sessionId) {
|
|
70904
|
-
try {
|
|
70905
|
-
const state = components.instanceManager?.getInstance?.(sessionId)?.getState?.();
|
|
70906
|
-
const settings = state?.settings || {};
|
|
70907
|
-
const meshNodeFor = readNonEmptyString(settings.meshNodeFor);
|
|
70908
|
-
if (meshNodeFor) return meshNodeFor;
|
|
70909
|
-
const byStamp = recoverMeshIdByNodeId(readNonEmptyString(settings.meshNodeId));
|
|
70910
|
-
if (byStamp) return byStamp;
|
|
70911
|
-
const sessionWorkspace = readNonEmptyString(state?.workspace);
|
|
70912
|
-
const bySessionWorkspace = sessionWorkspace ? readNonEmptyString(getCachedMeshByWorkspace(sessionWorkspace)?.id) : "";
|
|
70913
|
-
if (bySessionWorkspace) return bySessionWorkspace;
|
|
70914
|
-
} catch {
|
|
70915
|
-
}
|
|
70916
|
-
}
|
|
70917
|
-
return "";
|
|
70918
|
-
}
|
|
70919
|
-
function __resetMeshWorkspaceCacheForTests() {
|
|
70920
|
-
meshByWorkspaceCache.clear();
|
|
70921
|
-
}
|
|
70922
70957
|
function sweepExpiredRemoteIdleSessions() {
|
|
70923
70958
|
try {
|
|
70924
70959
|
MeshRuntimeStore.getInstance().pruneExpiredRemoteIdleSessions();
|
|
@@ -71046,6 +71081,10 @@ ${cleanBody}`;
|
|
|
71046
71081
|
if (explicit) return explicit;
|
|
71047
71082
|
return extractJsonObjectFromSummary(readNonEmptyString(metadataEvent.finalSummary) || void 0);
|
|
71048
71083
|
}
|
|
71084
|
+
function resolveUnifiedCompletionEvidenceLevel(args) {
|
|
71085
|
+
if (args.computedLevel === "insufficient" || args.priorLevel === "insufficient") return "insufficient";
|
|
71086
|
+
return args.computedLevel || args.priorLevel;
|
|
71087
|
+
}
|
|
71049
71088
|
function supersedesTruncatedTerminalSummary(args) {
|
|
71050
71089
|
if (!args.terminalTaskId || !args.eventTaskId || args.terminalTaskId !== args.eventTaskId) return false;
|
|
71051
71090
|
if (!isGenuineCompletionEvidence(args.metadataEvent)) return false;
|
|
@@ -71086,7 +71125,7 @@ ${cleanBody}`;
|
|
|
71086
71125
|
return false;
|
|
71087
71126
|
}
|
|
71088
71127
|
function evaluateMeshEventSuppression(args, ctx) {
|
|
71089
|
-
const { traceCtx, eventSessionId, eventNodeId, eventTimestamp, workerCoordinatorDaemonId, components } = ctx;
|
|
71128
|
+
const { traceCtx, eventSessionId, eventNodeId, eventTimestamp, workerCoordinatorDaemonId, components, injectMeshSystemMessage: injectMeshSystemMessage2 } = ctx;
|
|
71090
71129
|
const intentionalCleanupStop = shouldSuppressIntentionalCleanupStop({
|
|
71091
71130
|
event: args.event,
|
|
71092
71131
|
meshId: args.meshId,
|
|
@@ -71172,7 +71211,7 @@ ${cleanBody}`;
|
|
|
71172
71211
|
eventSessionId,
|
|
71173
71212
|
attempt
|
|
71174
71213
|
});
|
|
71175
|
-
const heldForRetry = retryEligible && holdCompletionForLiveStateRetry(components, args, eventSessionId, Date.now(),
|
|
71214
|
+
const heldForRetry = retryEligible && holdCompletionForLiveStateRetry(components, args, eventSessionId, Date.now(), injectMeshSystemMessage2);
|
|
71176
71215
|
const authorityDetail = !authority.authoritative && authority.detail ? ` [authorityClass=${authority.detail.authorityClass ?? "none"} evidenceSource=${authority.detail.evidenceSource ?? "none"} timing=${authority.detail.timing ?? "none"}]` : "";
|
|
71177
71216
|
LOG2.info("MeshEvents", `Suppressed agent:generating_completed for session ${eventSessionId} (mesh ${args.meshId}): current live evidence remains pending (${live.kind ?? "unknown"}); transcript authority=${authority.authoritative ? "fresh_but_not_newer" : authority.reason}${authorityDetail}${heldForRetry ? " \u2014 bounded content-free retry armed" : ""}`);
|
|
71178
71217
|
traceMeshEventDrop(
|
|
@@ -71218,7 +71257,7 @@ ${cleanBody}`;
|
|
|
71218
71257
|
args,
|
|
71219
71258
|
eventSessionId,
|
|
71220
71259
|
Date.now(),
|
|
71221
|
-
|
|
71260
|
+
injectMeshSystemMessage2
|
|
71222
71261
|
);
|
|
71223
71262
|
LOG2.info("MeshEvents", `Suppressed agent:generating_completed for session ${eventSessionId} (mesh ${args.meshId}): terminal admission declined (${admission.reason}) \u2014 ${admission.detail}${heldForRetry ? " \u2014 bounded content-free retry armed" : ""}`);
|
|
71224
71263
|
traceMeshEventDrop(
|
|
@@ -71485,6 +71524,119 @@ ${cleanBody}`;
|
|
|
71485
71524
|
}
|
|
71486
71525
|
return false;
|
|
71487
71526
|
}
|
|
71527
|
+
var lastPendingEventsPruneAt;
|
|
71528
|
+
var PENDING_EVENTS_PRUNE_INTERVAL_MS;
|
|
71529
|
+
var INTENTIONAL_CLEANUP_STOP_SUPPRESSION_MS;
|
|
71530
|
+
var RECENT_COMPLETION_FINGERPRINT_TTL_MS;
|
|
71531
|
+
var RECONCILED_COMPLETION_SOURCES;
|
|
71532
|
+
var turnOutboxDrainScheduled;
|
|
71533
|
+
var init_mesh_event_suppression = __esm2({
|
|
71534
|
+
"src/mesh/mesh-event-suppression.ts"() {
|
|
71535
|
+
"use strict";
|
|
71536
|
+
init_logger();
|
|
71537
|
+
init_mesh_ledger();
|
|
71538
|
+
init_mesh_work_queue();
|
|
71539
|
+
init_mesh_runtime_store();
|
|
71540
|
+
init_mesh_events_pending();
|
|
71541
|
+
init_mesh_event_trace();
|
|
71542
|
+
init_dist();
|
|
71543
|
+
init_mesh_events_stale();
|
|
71544
|
+
init_mesh_task_inflight();
|
|
71545
|
+
init_mesh_node_identity();
|
|
71546
|
+
init_mesh_events_utils();
|
|
71547
|
+
init_mesh_turn_ledger();
|
|
71548
|
+
init_mesh_turn_presentation();
|
|
71549
|
+
init_mesh_queue_assignment();
|
|
71550
|
+
init_mesh_completion_live_gate();
|
|
71551
|
+
init_mesh_provider_event_admission();
|
|
71552
|
+
lastPendingEventsPruneAt = 0;
|
|
71553
|
+
PENDING_EVENTS_PRUNE_INTERVAL_MS = 60 * 60 * 1e3;
|
|
71554
|
+
INTENTIONAL_CLEANUP_STOP_SUPPRESSION_MS = 30 * 60 * 1e3;
|
|
71555
|
+
RECENT_COMPLETION_FINGERPRINT_TTL_MS = 10 * 60 * 1e3;
|
|
71556
|
+
RECONCILED_COMPLETION_SOURCES = /* @__PURE__ */ new Set([
|
|
71557
|
+
"direct_task_transcript_reconciliation",
|
|
71558
|
+
"daemon_reconcile_transcript_completion",
|
|
71559
|
+
"mcp_mesh_status_transcript_reconciliation",
|
|
71560
|
+
"no_progress_reconciliation"
|
|
71561
|
+
]);
|
|
71562
|
+
turnOutboxDrainScheduled = false;
|
|
71563
|
+
}
|
|
71564
|
+
});
|
|
71565
|
+
function bootstrapQueueTaskCountsAsHandled(task, bootstrapNodeId, nowMs) {
|
|
71566
|
+
if (!meshNodeIdMatches({ id: task.targetNodeId }, bootstrapNodeId)) return false;
|
|
71567
|
+
if (task.status === "assigned") return true;
|
|
71568
|
+
const al = task.autoLaunch;
|
|
71569
|
+
if (!al) return true;
|
|
71570
|
+
if (al.status === "started" || al.status === "completed") {
|
|
71571
|
+
const launchedAtMs = Date.parse(al.updatedAt);
|
|
71572
|
+
return Number.isFinite(launchedAtMs) && nowMs - launchedAtMs < AUTO_LAUNCH_AWAIT_CLAIM_MS;
|
|
71573
|
+
}
|
|
71574
|
+
return true;
|
|
71575
|
+
}
|
|
71576
|
+
function resolveCoordinatorDrainDaemonIds(components) {
|
|
71577
|
+
const statusInstanceId = readNonEmptyString(components.statusInstanceId);
|
|
71578
|
+
const machineId = readNonEmptyString(loadConfig2().machineId);
|
|
71579
|
+
return expandDaemonIdForms([statusInstanceId, machineId]);
|
|
71580
|
+
}
|
|
71581
|
+
function getCachedMeshByWorkspace(workspace) {
|
|
71582
|
+
const now = Date.now();
|
|
71583
|
+
const cached5 = meshByWorkspaceCache.get(workspace);
|
|
71584
|
+
if (cached5 && now - cached5.cachedAt < MESH_WORKSPACE_CACHE_TTL_MS) return cached5.mesh;
|
|
71585
|
+
const mesh = getMeshByRepo(workspace);
|
|
71586
|
+
meshByWorkspaceCache.set(workspace, { mesh, cachedAt: now });
|
|
71587
|
+
return mesh;
|
|
71588
|
+
}
|
|
71589
|
+
function recoverMeshIdByNodeId(nodeId) {
|
|
71590
|
+
if (!nodeId) return "";
|
|
71591
|
+
for (const mesh of listMeshes()) {
|
|
71592
|
+
if (Array.isArray(mesh.nodes) && mesh.nodes.some((n) => meshNodeIdMatches(n, nodeId))) {
|
|
71593
|
+
return readNonEmptyString(mesh.id);
|
|
71594
|
+
}
|
|
71595
|
+
}
|
|
71596
|
+
return "";
|
|
71597
|
+
}
|
|
71598
|
+
function recoverMeshIdByCoordinatorAndNode(coordinatorDaemonId, nodeId) {
|
|
71599
|
+
if (!coordinatorDaemonId) return "";
|
|
71600
|
+
const hosted = listMeshes().filter((mesh) => {
|
|
71601
|
+
const host = resolveMeshHostStatus(mesh);
|
|
71602
|
+
return host.role === "host" && (!host.hostDaemonId || daemonIdsEquivalent(host.hostDaemonId, coordinatorDaemonId));
|
|
71603
|
+
});
|
|
71604
|
+
if (hosted.length === 0) return "";
|
|
71605
|
+
if (nodeId) {
|
|
71606
|
+
const byNode = hosted.find((mesh) => Array.isArray(mesh.nodes) && mesh.nodes.some((n) => meshNodeIdMatches(n, nodeId)));
|
|
71607
|
+
if (byNode) return readNonEmptyString(byNode.id);
|
|
71608
|
+
return "";
|
|
71609
|
+
}
|
|
71610
|
+
return hosted.length === 1 ? readNonEmptyString(hosted[0].id) : "";
|
|
71611
|
+
}
|
|
71612
|
+
function resolveForwardEventMeshId(components, payload) {
|
|
71613
|
+
const direct = readNonEmptyString(payload.meshId);
|
|
71614
|
+
if (direct) return direct;
|
|
71615
|
+
const workspace = readNonEmptyString(payload.workspace);
|
|
71616
|
+
const byWorkspace = workspace ? readNonEmptyString(getCachedMeshByWorkspace(workspace)?.id) : "";
|
|
71617
|
+
if (byWorkspace) return byWorkspace;
|
|
71618
|
+
const byNode = recoverMeshIdByNodeId(readNonEmptyString(payload.nodeId));
|
|
71619
|
+
if (byNode) return byNode;
|
|
71620
|
+
const sessionId = readNonEmptyString(payload.targetSessionId) || readNonEmptyString(payload.sessionId) || readNonEmptyString(payload.instanceId);
|
|
71621
|
+
if (sessionId) {
|
|
71622
|
+
try {
|
|
71623
|
+
const state = components.instanceManager?.getInstance?.(sessionId)?.getState?.();
|
|
71624
|
+
const settings = state?.settings || {};
|
|
71625
|
+
const meshNodeFor = readNonEmptyString(settings.meshNodeFor);
|
|
71626
|
+
if (meshNodeFor) return meshNodeFor;
|
|
71627
|
+
const byStamp = recoverMeshIdByNodeId(readNonEmptyString(settings.meshNodeId));
|
|
71628
|
+
if (byStamp) return byStamp;
|
|
71629
|
+
const sessionWorkspace = readNonEmptyString(state?.workspace);
|
|
71630
|
+
const bySessionWorkspace = sessionWorkspace ? readNonEmptyString(getCachedMeshByWorkspace(sessionWorkspace)?.id) : "";
|
|
71631
|
+
if (bySessionWorkspace) return bySessionWorkspace;
|
|
71632
|
+
} catch {
|
|
71633
|
+
}
|
|
71634
|
+
}
|
|
71635
|
+
return "";
|
|
71636
|
+
}
|
|
71637
|
+
function __resetMeshWorkspaceCacheForTests() {
|
|
71638
|
+
meshByWorkspaceCache.clear();
|
|
71639
|
+
}
|
|
71488
71640
|
function injectMeshSystemMessage(components, args) {
|
|
71489
71641
|
const eventSessionId = resolveEventSessionId(args.metadataEvent, args.sourceInstanceId);
|
|
71490
71642
|
const eventNodeId = readNonEmptyString(args.nodeId) || readNonEmptyString(args.metadataEvent.meshNodeId);
|
|
@@ -71562,7 +71714,8 @@ ${cleanBody}`;
|
|
|
71562
71714
|
eventNodeId,
|
|
71563
71715
|
eventTimestamp,
|
|
71564
71716
|
workerCoordinatorDaemonId,
|
|
71565
|
-
components
|
|
71717
|
+
components,
|
|
71718
|
+
injectMeshSystemMessage
|
|
71566
71719
|
});
|
|
71567
71720
|
if (suppression) {
|
|
71568
71721
|
if (suppression.kind === "reconcile") {
|
|
@@ -72039,7 +72192,36 @@ ${cleanBody}`;
|
|
|
72039
72192
|
// worker-result-shaped, e.g. a MAGI envelope) is concrete evidence and must
|
|
72040
72193
|
// resolve to 'sufficient' — resolveWorkerResult now upgrades that case so a
|
|
72041
72194
|
// complete, valid answer is no longer mislabelled insufficient/reviewRecommended.
|
|
72042
|
-
|
|
72195
|
+
//
|
|
72196
|
+
// EVIDENCE-LEVEL-UNIFY: the LEDGER value is merged with whatever
|
|
72197
|
+
// applyTaskModeCompletionEvidence already stamped onto
|
|
72198
|
+
// args.metadataEvent.evidenceLevel earlier in markSessionTerminal, so a
|
|
72199
|
+
// 'reported' stamp can never make the ledger forget a locally-computed
|
|
72200
|
+
// 'insufficient' (and vice versa). See resolveUnifiedCompletionEvidenceLevel.
|
|
72201
|
+
//
|
|
72202
|
+
// ONE-WAY ON PURPOSE — do NOT write the resolved level back onto
|
|
72203
|
+
// args.metadataEvent. That mutation looks like the natural way to make the
|
|
72204
|
+
// later buildMeshSystemMessage read agree with the ledger, but
|
|
72205
|
+
// metadataEvent.evidenceLevel is load-bearing for DEDUP, not just wording:
|
|
72206
|
+
// buildPendingEventFingerprint (mesh-events-pending.ts) keys terminal
|
|
72207
|
+
// completions `…::weak` / `…::genuine` off isWeakCompletionMetadata, which
|
|
72208
|
+
// reads this very field. Stamping 'insufficient' back onto an ordinary
|
|
72209
|
+
// completion (workerResult.source === 'default' is the COMMON plain-text
|
|
72210
|
+
// finalSummary case, not an anomaly) moves it into the `::weak` slot, where
|
|
72211
|
+
// it collides with an earlier weak synth for the same taskId and the
|
|
72212
|
+
// genuine completion is dropped as a duplicate — the exact swallow that
|
|
72213
|
+
// EARLYNOTIFY-GATEBYPASS guards against. The ledger records the stricter
|
|
72214
|
+
// verdict; the coordinator-facing weakness signal stays owned by the
|
|
72215
|
+
// producers that set it deliberately.
|
|
72216
|
+
...(() => {
|
|
72217
|
+
const computedLevel = completionEvidence ? completionEvidence.workerResult.source === "default" ? "insufficient" : "sufficient" : void 0;
|
|
72218
|
+
const resolvedLevel = resolveUnifiedCompletionEvidenceLevel({
|
|
72219
|
+
computedLevel,
|
|
72220
|
+
priorLevel: readNonEmptyString(args.metadataEvent.evidenceLevel)
|
|
72221
|
+
});
|
|
72222
|
+
if (!resolvedLevel) return {};
|
|
72223
|
+
return resolvedLevel === "insufficient" ? { evidenceLevel: resolvedLevel, reviewRecommended: true } : { evidenceLevel: resolvedLevel };
|
|
72224
|
+
})(),
|
|
72043
72225
|
// FALSE-COMPLETION-GIT-EVIDENCE: markSessionTerminal's synchronous git-clean
|
|
72044
72226
|
// gate stamps this onto metadataEvent BEFORE this ledger append runs — OR it
|
|
72045
72227
|
// into reviewRecommended (never downgrade the NOTIF Defect-2b verdict above)
|
|
@@ -72537,12 +72719,6 @@ ${cleanBody}`;
|
|
|
72537
72719
|
var REMOTE_IDLE_SESSION_TTL_MS;
|
|
72538
72720
|
var meshByWorkspaceCache;
|
|
72539
72721
|
var MESH_WORKSPACE_CACHE_TTL_MS;
|
|
72540
|
-
var lastPendingEventsPruneAt;
|
|
72541
|
-
var PENDING_EVENTS_PRUNE_INTERVAL_MS;
|
|
72542
|
-
var INTENTIONAL_CLEANUP_STOP_SUPPRESSION_MS;
|
|
72543
|
-
var RECENT_COMPLETION_FINGERPRINT_TTL_MS;
|
|
72544
|
-
var RECONCILED_COMPLETION_SOURCES;
|
|
72545
|
-
var turnOutboxDrainScheduled;
|
|
72546
72722
|
var init_mesh_event_forwarding = __esm2({
|
|
72547
72723
|
"src/mesh/mesh-event-forwarding.ts"() {
|
|
72548
72724
|
"use strict";
|
|
@@ -72569,28 +72745,15 @@ ${cleanBody}`;
|
|
|
72569
72745
|
init_mesh_events_stale();
|
|
72570
72746
|
init_mesh_task_inflight();
|
|
72571
72747
|
init_mesh_graph_transition_runner();
|
|
72572
|
-
init_mesh_node_identity();
|
|
72573
72748
|
init_mesh_events_utils();
|
|
72574
72749
|
init_mesh_event_classify();
|
|
72575
72750
|
init_mesh_turn_ledger();
|
|
72576
|
-
init_mesh_turn_presentation();
|
|
72577
72751
|
init_mesh_queue_assignment();
|
|
72578
|
-
|
|
72579
|
-
|
|
72752
|
+
init_mesh_event_suppression();
|
|
72753
|
+
init_mesh_event_suppression();
|
|
72580
72754
|
REMOTE_IDLE_SESSION_TTL_MS = 5 * 60 * 1e3;
|
|
72581
72755
|
meshByWorkspaceCache = /* @__PURE__ */ new Map();
|
|
72582
72756
|
MESH_WORKSPACE_CACHE_TTL_MS = 5e3;
|
|
72583
|
-
lastPendingEventsPruneAt = 0;
|
|
72584
|
-
PENDING_EVENTS_PRUNE_INTERVAL_MS = 60 * 60 * 1e3;
|
|
72585
|
-
INTENTIONAL_CLEANUP_STOP_SUPPRESSION_MS = 30 * 60 * 1e3;
|
|
72586
|
-
RECENT_COMPLETION_FINGERPRINT_TTL_MS = 10 * 60 * 1e3;
|
|
72587
|
-
RECONCILED_COMPLETION_SOURCES = /* @__PURE__ */ new Set([
|
|
72588
|
-
"direct_task_transcript_reconciliation",
|
|
72589
|
-
"daemon_reconcile_transcript_completion",
|
|
72590
|
-
"mcp_mesh_status_transcript_reconciliation",
|
|
72591
|
-
"no_progress_reconciliation"
|
|
72592
|
-
]);
|
|
72593
|
-
turnOutboxDrainScheduled = false;
|
|
72594
72757
|
}
|
|
72595
72758
|
});
|
|
72596
72759
|
var init_mesh_events_coordinator = __esm2({
|
|
@@ -83162,6 +83325,7 @@ ${e?.stderr || ""}`;
|
|
|
83162
83325
|
WORKSPACE_OWNER_GIT_CONFIG_KEY: () => WORKSPACE_OWNER_GIT_CONFIG_KEY,
|
|
83163
83326
|
WORKSPACE_SAGA_LEASE_MS: () => WORKSPACE_SAGA_LEASE_MS,
|
|
83164
83327
|
WorkspaceSagaPermanentError: () => WorkspaceSagaPermanentError,
|
|
83328
|
+
abandonMeshGraphGate: () => abandonMeshGraphGate,
|
|
83165
83329
|
addNode: () => addNode,
|
|
83166
83330
|
appendLedgerEntry: () => appendLedgerEntry,
|
|
83167
83331
|
appendRecentActivity: () => appendRecentActivity,
|
|
@@ -83235,6 +83399,7 @@ ${e?.stderr || ""}`;
|
|
|
83235
83399
|
configureDebugTraceStore: () => configureDebugTraceStore,
|
|
83236
83400
|
connectCdpManager: () => connectCdpManager,
|
|
83237
83401
|
consoleSymbols: () => consoleSymbols,
|
|
83402
|
+
coordinatorGateAbandonedReason: () => coordinatorGateAbandonedReason,
|
|
83238
83403
|
coordinatorGateBlockReason: () => coordinatorGateBlockReason,
|
|
83239
83404
|
coordinatorIdentityFromEmitFields: () => coordinatorIdentityFromEmitFields,
|
|
83240
83405
|
createDebugTraceStore: () => createDebugTraceStore,
|
|
@@ -83499,6 +83664,7 @@ ${e?.stderr || ""}`;
|
|
|
83499
83664
|
recordGraphEnqueueCommitted: () => recordGraphEnqueueCommitted,
|
|
83500
83665
|
recordGraphEnqueueRolledBack: () => recordGraphEnqueueRolledBack,
|
|
83501
83666
|
recordGraphEnqueueValidationFailed: () => recordGraphEnqueueValidationFailed,
|
|
83667
|
+
recordGraphGateAbandoned: () => recordGraphGateAbandoned,
|
|
83502
83668
|
recordGraphGateClaimed: () => recordGraphGateClaimed,
|
|
83503
83669
|
recordGraphGateExpired: () => recordGraphGateExpired,
|
|
83504
83670
|
recordGraphGateReleased: () => recordGraphGateReleased,
|
|
@@ -86660,8 +86826,25 @@ ${e?.stderr || ""}`;
|
|
|
86660
86826
|
});
|
|
86661
86827
|
const nodeStates = {};
|
|
86662
86828
|
for (const node of nodes) nodeStates[node.state] = (nodeStates[node.state] ?? 0) + 1;
|
|
86829
|
+
const orphanedGateIds = /* @__PURE__ */ new Set();
|
|
86830
|
+
for (const gate of gates) {
|
|
86831
|
+
if (gate.state !== "awaiting_coordinator" && gate.state !== "claimed" && gate.state !== "expired") continue;
|
|
86832
|
+
const downstream = edges.filter((e) => e.fromNodeId === gate.nodeId).map((e) => byId.get(e.toNodeId)).filter((n) => !!n);
|
|
86833
|
+
if (downstream.length === 0) continue;
|
|
86834
|
+
if (downstream.every((n) => n.state === "cancelled" || n.state === "failed" || n.state === "skipped")) {
|
|
86835
|
+
orphanedGateIds.add(gate.gateId);
|
|
86836
|
+
}
|
|
86837
|
+
}
|
|
86663
86838
|
const actions = [];
|
|
86664
86839
|
for (const gate of gateViews) {
|
|
86840
|
+
if (orphanedGateIds.has(gate.gateId)) {
|
|
86841
|
+
actions.push({
|
|
86842
|
+
kind: "gate_abandon",
|
|
86843
|
+
gateId: gate.gateId,
|
|
86844
|
+
detail: `Gate '${gate.ref ?? gate.gateId}' (${gate.action}) is ORPHANED: every task it was gating is already cancelled, failed or skipped, so releasing it would open nothing. While it stays unsettled this graph cannot reach ANY terminal state \u2014 not even cancelled. Close it with mesh_graph_gate_abandon and a reason. Abandon cancels what the gate was holding; it never passes the gate.`
|
|
86845
|
+
});
|
|
86846
|
+
continue;
|
|
86847
|
+
}
|
|
86665
86848
|
if (gate.state === "awaiting_coordinator") {
|
|
86666
86849
|
actions.push({
|
|
86667
86850
|
kind: "gate_awaiting",
|
|
@@ -86684,7 +86867,7 @@ ${e?.stderr || ""}`;
|
|
|
86684
86867
|
actions.push({
|
|
86685
86868
|
kind: "gate_reclaim",
|
|
86686
86869
|
gateId: gate.gateId,
|
|
86687
|
-
detail: `Gate '${gate.ref ?? gate.gateId}' passed its deadline under on_timeout=hold \u2014 downstream is still held. Reclaim it (optionally with extend_deadline_seconds) to resume, or
|
|
86870
|
+
detail: `Gate '${gate.ref ?? gate.gateId}' passed its deadline under on_timeout=hold \u2014 downstream is still held. Reclaim it with mesh_graph_gate_claim (optionally with extend_deadline_seconds) to resume, or give it up with mesh_graph_gate_abandon, which cancels what it was holding instead of opening it. A timeout is never passage: the gate cannot release itself.`
|
|
86688
86871
|
});
|
|
86689
86872
|
}
|
|
86690
86873
|
}
|