@adhdev/daemon-standalone 1.0.28-rc.33 → 1.0.28-rc.35
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 +186 -26
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -33311,10 +33311,10 @@ var require_dist3 = __commonJS({
|
|
|
33311
33311
|
}
|
|
33312
33312
|
function getDaemonBuildInfo() {
|
|
33313
33313
|
if (cached2) return cached2;
|
|
33314
|
-
const commit = readInjected(true ? "
|
|
33315
|
-
const commitShort = readInjected(true ? "
|
|
33316
|
-
const version2 = readInjected(true ? "1.0.28-rc.
|
|
33317
|
-
const builtAt = readInjected(true ? "2026-07-
|
|
33314
|
+
const commit = readInjected(true ? "cea3ab2da10d31dbd18ef98dd0e5db0a65bb2617" : void 0) ?? "unknown";
|
|
33315
|
+
const commitShort = readInjected(true ? "cea3ab2d" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
|
|
33316
|
+
const version2 = readInjected(true ? "1.0.28-rc.35" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
|
|
33317
|
+
const builtAt = readInjected(true ? "2026-07-31T04:26:19.809Z" : void 0);
|
|
33318
33318
|
cached2 = builtAt ? { commit, commitShort, version: version2, builtAt } : { commit, commitShort, version: version2 };
|
|
33319
33319
|
return cached2;
|
|
33320
33320
|
}
|
|
@@ -38307,6 +38307,56 @@ Next step: ${nextStep}`;
|
|
|
38307
38307
|
nowMs: args.nowMs
|
|
38308
38308
|
});
|
|
38309
38309
|
}
|
|
38310
|
+
function rebindAttemptToLiveHolder(args) {
|
|
38311
|
+
const holder = typeof args.holderSessionId === "string" ? args.holderSessionId.trim() : "";
|
|
38312
|
+
if (!holder) return { rebound: false, reason: "no_holder" };
|
|
38313
|
+
const store = MeshRuntimeStore.getInstance();
|
|
38314
|
+
const attempt = store.getCurrentTurnAttempt(args.meshId, args.taskId);
|
|
38315
|
+
if (!attempt) return { rebound: false, reason: "no_attempt" };
|
|
38316
|
+
if (attempt.terminalOutcome) return { rebound: false, reason: "attempt_terminal", attemptId: attempt.attemptId };
|
|
38317
|
+
if (attempt.sessionId && sessionIdsEquivalent(attempt.sessionId, holder)) {
|
|
38318
|
+
return { rebound: false, reason: "same_session", attemptId: attempt.attemptId };
|
|
38319
|
+
}
|
|
38320
|
+
const nowMs = args.nowMs ?? Date.now();
|
|
38321
|
+
const nowIso = new Date(nowMs).toISOString();
|
|
38322
|
+
const ok = store.rebindTurnAttemptSession(attempt.attemptId, holder, nowIso);
|
|
38323
|
+
if (!ok) return { rebound: false, reason: "store_rejected", attemptId: attempt.attemptId };
|
|
38324
|
+
try {
|
|
38325
|
+
store.insertTurnEvent({
|
|
38326
|
+
eventId: (0, import_crypto5.randomUUID)(),
|
|
38327
|
+
meshId: args.meshId,
|
|
38328
|
+
attemptId: attempt.attemptId,
|
|
38329
|
+
taskId: args.taskId,
|
|
38330
|
+
kind: "session_rebound",
|
|
38331
|
+
dedupeKey: holder,
|
|
38332
|
+
payload: safeEvidenceJson({ fromSessionId: attempt.sessionId ?? null, toSessionId: holder, reason: "duplicate_dispatch_refused" }),
|
|
38333
|
+
occurredAtMs: nowMs,
|
|
38334
|
+
recordedAt: nowIso
|
|
38335
|
+
});
|
|
38336
|
+
} catch {
|
|
38337
|
+
}
|
|
38338
|
+
LOG2.info("TurnLedger", `Rebound attempt ${attempt.attemptId} (task ${args.taskId}) from session ${attempt.sessionId ?? "none"} to live holder ${holder} after a duplicate-dispatch refusal`);
|
|
38339
|
+
return { rebound: true, attemptId: attempt.attemptId, fromSessionId: attempt.sessionId ?? void 0, toSessionId: holder };
|
|
38340
|
+
}
|
|
38341
|
+
function resolveTaskEvidenceSessionId(meshId, taskId, rowAssignedSessionId) {
|
|
38342
|
+
const nonEmpty = (v) => {
|
|
38343
|
+
const s2 = typeof v === "string" ? v.trim() : "";
|
|
38344
|
+
return s2 ? s2 : void 0;
|
|
38345
|
+
};
|
|
38346
|
+
const rowSessionId = nonEmpty(rowAssignedSessionId);
|
|
38347
|
+
try {
|
|
38348
|
+
const attempt = MeshRuntimeStore.getInstance().getCurrentTurnAttempt(meshId, taskId);
|
|
38349
|
+
if (!attempt || attempt.terminalOutcome) return rowSessionId;
|
|
38350
|
+
const attemptSessionId = nonEmpty(attempt.sessionId);
|
|
38351
|
+
if (!attemptSessionId) return rowSessionId;
|
|
38352
|
+
if (rowSessionId && !sessionIdsEquivalent(attemptSessionId, rowSessionId)) {
|
|
38353
|
+
LOG2.info("TurnLedger", `Evidence read for task ${taskId} follows the ATTEMPT session ${attemptSessionId} (attempt ${attempt.attemptId}), not the claim-time row stamp ${rowSessionId} \u2014 the attempt was rebound to the live holder`);
|
|
38354
|
+
}
|
|
38355
|
+
return attemptSessionId;
|
|
38356
|
+
} catch {
|
|
38357
|
+
return rowSessionId;
|
|
38358
|
+
}
|
|
38359
|
+
}
|
|
38310
38360
|
function evaluateRedrive(meshId, taskId, nowMs = Date.now()) {
|
|
38311
38361
|
const store = MeshRuntimeStore.getInstance();
|
|
38312
38362
|
const attempt = store.getCurrentTurnAttempt(meshId, taskId);
|
|
@@ -43655,6 +43705,23 @@ Next step: ${nextStep}`;
|
|
|
43655
43705
|
`).run(leaseDeadlineMs, updatedAt, attemptId);
|
|
43656
43706
|
this.maybeCheckpointWal();
|
|
43657
43707
|
}
|
|
43708
|
+
/**
|
|
43709
|
+
* DUP-CLAIM-REBIND: point a still-open attempt at the session that is ACTUALLY
|
|
43710
|
+
* working it. Used when a node refuses a duplicate dispatch and names the live
|
|
43711
|
+
* holder — the attempt was opened against the session we tried to dispatch to,
|
|
43712
|
+
* but the work is running on the holder, so the binding (not the attempt) is what
|
|
43713
|
+
* is wrong. Conditional on `terminal_outcome IS NULL` so a settled attempt is
|
|
43714
|
+
* never rewritten; returns whether the rebind landed.
|
|
43715
|
+
*/
|
|
43716
|
+
rebindTurnAttemptSession(attemptId, sessionId, updatedAt) {
|
|
43717
|
+
const res = this.db.prepare(`
|
|
43718
|
+
UPDATE mesh_turn_attempts
|
|
43719
|
+
SET session_id = ?, updated_at = ?
|
|
43720
|
+
WHERE attempt_id = ? AND terminal_outcome IS NULL
|
|
43721
|
+
`).run(sessionId, updatedAt, attemptId);
|
|
43722
|
+
this.maybeCheckpointWal();
|
|
43723
|
+
return res.changes > 0;
|
|
43724
|
+
}
|
|
43658
43725
|
// ── TURN-LEDGER (Stage 5): idempotency-keyed causal events ───────────────
|
|
43659
43726
|
/**
|
|
43660
43727
|
* Append a causal event. INSERT OR IGNORE on UNIQUE(attempt_id, kind, dedupe_key)
|
|
@@ -44879,7 +44946,8 @@ Valid status values: \`completed\` | \`failed\` | \`blocked\` | \`partial\`.`;
|
|
|
44879
44946
|
"task_reclaimed",
|
|
44880
44947
|
"task_approval_needed",
|
|
44881
44948
|
"task_question_pending",
|
|
44882
|
-
"p2p_dispatch_failed"
|
|
44949
|
+
"p2p_dispatch_failed",
|
|
44950
|
+
"dispatch_duplicate_rebound"
|
|
44883
44951
|
]);
|
|
44884
44952
|
LEDGER_DIR_NAME = "mesh-ledger";
|
|
44885
44953
|
MAX_FILE_SIZE_BYTES = 10 * 1024 * 1024;
|
|
@@ -53979,6 +54047,42 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
|
|
|
53979
54047
|
]);
|
|
53980
54048
|
}
|
|
53981
54049
|
});
|
|
54050
|
+
function encodeDuplicateMeshDispatchCode(holderSessionId) {
|
|
54051
|
+
const holder = typeof holderSessionId === "string" ? holderSessionId.trim() : "";
|
|
54052
|
+
return holder ? `${DUPLICATE_MESH_DISPATCH_CODE}:${holder}` : DUPLICATE_MESH_DISPATCH_CODE;
|
|
54053
|
+
}
|
|
54054
|
+
function classifyDuplicateMeshDispatch(err) {
|
|
54055
|
+
if (!err || typeof err !== "object") return null;
|
|
54056
|
+
const e = err;
|
|
54057
|
+
if (e.code === DUPLICATE_MESH_DISPATCH_CODE) {
|
|
54058
|
+
const holder = typeof e.holderSessionId === "string" ? e.holderSessionId.trim() : "";
|
|
54059
|
+
return holder ? { holderSessionId: holder } : {};
|
|
54060
|
+
}
|
|
54061
|
+
for (const raw of [e.meshCode, e.code]) {
|
|
54062
|
+
if (typeof raw !== "string") continue;
|
|
54063
|
+
if (raw !== DUPLICATE_MESH_DISPATCH_CODE && !raw.startsWith(`${DUPLICATE_MESH_DISPATCH_CODE}:`)) continue;
|
|
54064
|
+
const holder = raw.slice(DUPLICATE_MESH_DISPATCH_CODE.length + 1).trim();
|
|
54065
|
+
return holder ? { holderSessionId: holder } : {};
|
|
54066
|
+
}
|
|
54067
|
+
return null;
|
|
54068
|
+
}
|
|
54069
|
+
var DUPLICATE_MESH_DISPATCH_CODE;
|
|
54070
|
+
var DuplicateMeshDispatchError;
|
|
54071
|
+
var init_mesh_duplicate_dispatch = __esm2({
|
|
54072
|
+
"src/mesh/mesh-duplicate-dispatch.ts"() {
|
|
54073
|
+
"use strict";
|
|
54074
|
+
DUPLICATE_MESH_DISPATCH_CODE = "DUPLICATE_MESH_DISPATCH";
|
|
54075
|
+
DuplicateMeshDispatchError = class extends Error {
|
|
54076
|
+
code = DUPLICATE_MESH_DISPATCH_CODE;
|
|
54077
|
+
holderSessionId;
|
|
54078
|
+
constructor(message, info = {}) {
|
|
54079
|
+
super(message);
|
|
54080
|
+
this.name = "DuplicateMeshDispatchError";
|
|
54081
|
+
this.holderSessionId = info.holderSessionId;
|
|
54082
|
+
}
|
|
54083
|
+
};
|
|
54084
|
+
}
|
|
54085
|
+
});
|
|
53982
54086
|
function localCoordinatorDaemonId() {
|
|
53983
54087
|
return canonicalDaemonId(readNonEmptyString(loadConfig2().machineId));
|
|
53984
54088
|
}
|
|
@@ -54179,6 +54283,37 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
|
|
|
54179
54283
|
}
|
|
54180
54284
|
}).catch((e) => {
|
|
54181
54285
|
if (timer) clearTimeout(timer);
|
|
54286
|
+
const duplicate = classifyDuplicateMeshDispatch(e);
|
|
54287
|
+
if (duplicate?.holderSessionId) {
|
|
54288
|
+
const rebind = rebindAttemptToLiveHolder({
|
|
54289
|
+
meshId: ctx.meshId,
|
|
54290
|
+
taskId: ctx.task.id,
|
|
54291
|
+
holderSessionId: duplicate.holderSessionId
|
|
54292
|
+
});
|
|
54293
|
+
if (rebind.rebound || rebind.reason === "same_session") {
|
|
54294
|
+
LOG2.info("MeshQueue", `Duplicate dispatch of task ${ctx.task.id} refused by node ${ctx.nodeId}: it is already being worked by live session ${duplicate.holderSessionId}. Task stays assigned; turn attempt ${rebind.attemptId ?? "n/a"} ${rebind.rebound ? "rebound to that session" : "was already bound to it"}.`);
|
|
54295
|
+
updateSessionDeliveryStatus(delivery.id, "delivered");
|
|
54296
|
+
try {
|
|
54297
|
+
appendLedgerEntry(ctx.meshId, {
|
|
54298
|
+
kind: "dispatch_duplicate_rebound",
|
|
54299
|
+
nodeId: ctx.nodeId,
|
|
54300
|
+
sessionId: duplicate.holderSessionId,
|
|
54301
|
+
payload: {
|
|
54302
|
+
taskId: ctx.task.id,
|
|
54303
|
+
deliveryId: delivery.id,
|
|
54304
|
+
transport: ctx.transport,
|
|
54305
|
+
attemptedSessionId: ctx.sessionId,
|
|
54306
|
+
holderSessionId: duplicate.holderSessionId,
|
|
54307
|
+
...rebind.attemptId ? { attemptId: rebind.attemptId } : {},
|
|
54308
|
+
rebound: rebind.rebound
|
|
54309
|
+
}
|
|
54310
|
+
});
|
|
54311
|
+
} catch {
|
|
54312
|
+
}
|
|
54313
|
+
return;
|
|
54314
|
+
}
|
|
54315
|
+
LOG2.warn("MeshQueue", `Duplicate dispatch of task ${ctx.task.id} refused by node ${ctx.nodeId} (holder ${duplicate.holderSessionId}), but the turn attempt could not be rebound (${rebind.reason}) \u2014 falling back to the requeue path.`);
|
|
54316
|
+
}
|
|
54182
54317
|
LOG2.error("MeshQueue", `Failed to dispatch task via ${ctx.transport} to node ${ctx.nodeId}: ${e?.message}`);
|
|
54183
54318
|
updateSessionDeliveryStatus(delivery.id, "failed", { lastError: e?.message, incrementAttempt: true });
|
|
54184
54319
|
endTaskDispatchInFlight(ctx.meshId, ctx.task.id);
|
|
@@ -55751,6 +55886,7 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
|
|
|
55751
55886
|
init_mesh_task_inflight();
|
|
55752
55887
|
init_model_provider_compat();
|
|
55753
55888
|
init_mesh_turn_ledger();
|
|
55889
|
+
init_mesh_duplicate_dispatch();
|
|
55754
55890
|
IDLE_AUTO_FAST_FORWARD_THROTTLE_MS = 30 * 60 * 1e3;
|
|
55755
55891
|
idleAutoFastForwardLastAttempt = /* @__PURE__ */ new Map();
|
|
55756
55892
|
CONTINUOUS_AUTO_FAST_FORWARD_SCAN_COOLDOWN_MS = 45 * 1e3;
|
|
@@ -60906,12 +61042,13 @@ ${cleanBody}`;
|
|
|
60906
61042
|
}
|
|
60907
61043
|
async function pollAssignedTaskActivity(components, mesh, row) {
|
|
60908
61044
|
const NONE = { inTurnProgress: false, lastAgentActivityMs: null };
|
|
60909
|
-
const sessionId =
|
|
61045
|
+
const sessionId = resolveTaskEvidenceSessionId(mesh.id, row.id, row.assignedSessionId);
|
|
60910
61046
|
const nodeId = readNonEmptyString(row.assignedNodeId);
|
|
60911
61047
|
if (!sessionId || !nodeId) return NONE;
|
|
61048
|
+
const evidenceRow = sessionId !== row.assignedSessionId ? { ...row, assignedSessionId: sessionId } : row;
|
|
60912
61049
|
const dispatchedAtMs = Date.parse(readNonEmptyString(row.dispatchTimestamp));
|
|
60913
61050
|
if (!Number.isFinite(dispatchedAtMs)) return NONE;
|
|
60914
|
-
const payload = await runSessionEvidenceCollection(sessionId, () => fetchAssignedTaskChatTail(components, mesh,
|
|
61051
|
+
const payload = await runSessionEvidenceCollection(sessionId, () => fetchAssignedTaskChatTail(components, mesh, evidenceRow));
|
|
60915
61052
|
if (!payload) return NONE;
|
|
60916
61053
|
const messages = Array.isArray(payload.messages) ? payload.messages : [];
|
|
60917
61054
|
let lastAgentActivityMs = null;
|
|
@@ -60926,8 +61063,9 @@ ${cleanBody}`;
|
|
|
60926
61063
|
return { inTurnProgress: lastAgentActivityMs !== null, lastAgentActivityMs };
|
|
60927
61064
|
}
|
|
60928
61065
|
async function pollAssignedTaskTerminalEvidence(components, mesh, row, opts) {
|
|
60929
|
-
const sessionId =
|
|
61066
|
+
const sessionId = resolveTaskEvidenceSessionId(mesh.id, row.id, row.assignedSessionId);
|
|
60930
61067
|
const nodeId = readNonEmptyString(row.assignedNodeId);
|
|
61068
|
+
const evidenceRow = sessionId && sessionId !== row.assignedSessionId ? { ...row, assignedSessionId: sessionId } : row;
|
|
60931
61069
|
const traceCtx = {
|
|
60932
61070
|
taskId: row.id,
|
|
60933
61071
|
...sessionId ? { sessionId } : {},
|
|
@@ -60943,7 +61081,7 @@ ${cleanBody}`;
|
|
|
60943
61081
|
return declined("no_assigned_worker", `sessionId=${sessionId ?? "none"} nodeId=${nodeId ?? "none"}`);
|
|
60944
61082
|
}
|
|
60945
61083
|
const providerType = readNonEmptyString(row.assignedProviderType);
|
|
60946
|
-
const payload = await runSessionEvidenceCollection(sessionId, () => fetchAssignedTaskChatTail(components, mesh,
|
|
61084
|
+
const payload = await runSessionEvidenceCollection(sessionId, () => fetchAssignedTaskChatTail(components, mesh, evidenceRow));
|
|
60947
61085
|
if (!payload) return declined("chat_tail_unreadable", "worker transcript read returned no payload (offline/unreachable?)");
|
|
60948
61086
|
const payloadStatus = readChatPayloadStatus(payload);
|
|
60949
61087
|
if (payloadStatus !== "idle") return declined("session_not_idle", `status=${payloadStatus ?? "unknown"} \u2014 mid-turn, not a turn-end`);
|
|
@@ -61554,7 +61692,9 @@ ${cleanBody}`;
|
|
|
61554
61692
|
}
|
|
61555
61693
|
}
|
|
61556
61694
|
const shortStreakKey = `${meshId}::${row.id}`;
|
|
61557
|
-
const
|
|
61695
|
+
const evidenceSessionId = resolveTaskEvidenceSessionId(meshId, row.id, row.assignedSessionId);
|
|
61696
|
+
const evidenceRow = evidenceSessionId && evidenceSessionId !== row.assignedSessionId ? { ...row, assignedSessionId: evidenceSessionId } : row;
|
|
61697
|
+
const verdict = evidenceSessionId ? resolveSessionBusyVerdict(components, evidenceSessionId) : "IDLE_CONFIRMED";
|
|
61558
61698
|
if (verdict === "GENERATING") {
|
|
61559
61699
|
deliveredUnconsumedUnknownStreak.delete(shortStreakKey);
|
|
61560
61700
|
const gate = gateRedriveForHeldSuspension({ meshId, taskId: row.id, sessionLiveness: "alive", nowMs });
|
|
@@ -61568,15 +61708,16 @@ ${cleanBody}`;
|
|
|
61568
61708
|
}, `held suspension recovered \u2192 ${gate.stage} (verdict GENERATING)`);
|
|
61569
61709
|
}
|
|
61570
61710
|
} else {
|
|
61571
|
-
const redriveProfile =
|
|
61572
|
-
if (redriveProfile?.emitsPtyTurnEvents === false && await pollAssignedTaskInTurnProgress(components, { id: meshId, nodes: mesh.nodes },
|
|
61711
|
+
const redriveProfile = evidenceSessionId ? resolveAssignedTranscriptProfile(components, evidenceRow) : void 0;
|
|
61712
|
+
if (redriveProfile?.emitsPtyTurnEvents === false && await pollAssignedTaskInTurnProgress(components, { id: meshId, nodes: mesh.nodes }, evidenceRow)) {
|
|
61573
61713
|
deliveredUnconsumedUnknownStreak.delete(shortStreakKey);
|
|
61574
61714
|
try {
|
|
61575
61715
|
recordTurnAck({
|
|
61576
61716
|
meshId,
|
|
61577
61717
|
taskId: row.id,
|
|
61578
61718
|
kind: "consumed",
|
|
61579
|
-
|
|
61719
|
+
// Attempt-bound session (rc.35): see the long path below.
|
|
61720
|
+
sessionId: evidenceSessionId,
|
|
61580
61721
|
legacy: {
|
|
61581
61722
|
...typeof row.dispatchNonce === "number" ? { dispatchNonce: row.dispatchNonce } : {},
|
|
61582
61723
|
...row.assignedNodeId ? { nodeId: row.assignedNodeId } : {},
|
|
@@ -61602,7 +61743,7 @@ ${cleanBody}`;
|
|
|
61602
61743
|
}
|
|
61603
61744
|
if (verdict === "IDLE_CONFIRMED") {
|
|
61604
61745
|
deliveredUnconsumedUnknownStreak.delete(shortStreakKey);
|
|
61605
|
-
} else if (assignedRowLiveStatusIsAwaitingApproval(mesh, row.assignedNodeId,
|
|
61746
|
+
} else if (assignedRowLiveStatusIsAwaitingApproval(mesh, row.assignedNodeId, evidenceSessionId)) {
|
|
61606
61747
|
traceMeshEventDrop("short_redrive_deferred_awaiting_approval", {
|
|
61607
61748
|
taskId: row.id,
|
|
61608
61749
|
sessionId: row.assignedSessionId,
|
|
@@ -61665,10 +61806,10 @@ ${cleanBody}`;
|
|
|
61665
61806
|
event: "agent:generating_started"
|
|
61666
61807
|
}, !redriveEval || redriveEval.allowed ? "n/a" : redriveEval.reason);
|
|
61667
61808
|
} else {
|
|
61668
|
-
if (redriveProfile?.emitsPtyTurnEvents === false &&
|
|
61809
|
+
if (redriveProfile?.emitsPtyTurnEvents === false && evidenceSessionId) {
|
|
61669
61810
|
stopStaleMeshWorker(components, {
|
|
61670
61811
|
meshId,
|
|
61671
|
-
sessionId:
|
|
61812
|
+
sessionId: evidenceSessionId,
|
|
61672
61813
|
nodeId: row.assignedNodeId,
|
|
61673
61814
|
providerType: row.assignedProviderType
|
|
61674
61815
|
});
|
|
@@ -61719,7 +61860,9 @@ ${cleanBody}`;
|
|
|
61719
61860
|
if (store.taskHasConfirmedDelivery(meshId, row.id)) {
|
|
61720
61861
|
if (nowMs - dispatchedAtMs < DELIVERED_NO_TURN_DEADLINE_MS) continue;
|
|
61721
61862
|
const streakKey = `${meshId}::${row.id}`;
|
|
61722
|
-
const
|
|
61863
|
+
const evidenceSessionId = resolveTaskEvidenceSessionId(meshId, row.id, row.assignedSessionId);
|
|
61864
|
+
const evidenceRow = evidenceSessionId && evidenceSessionId !== row.assignedSessionId ? { ...row, assignedSessionId: evidenceSessionId } : row;
|
|
61865
|
+
const verdict = evidenceSessionId ? resolveSessionBusyVerdict(components, evidenceSessionId) : "IDLE_CONFIRMED";
|
|
61723
61866
|
if (verdict === "GENERATING") {
|
|
61724
61867
|
deliveredNoTurnUnknownStreak.delete(streakKey);
|
|
61725
61868
|
const gate = gateRedriveForHeldSuspension({ meshId, taskId: row.id, sessionLiveness: "alive", nowMs });
|
|
@@ -61738,7 +61881,7 @@ ${cleanBody}`;
|
|
|
61738
61881
|
if (verdict === "IDLE_CONFIRMED") {
|
|
61739
61882
|
deliveredNoTurnUnknownStreak.delete(streakKey);
|
|
61740
61883
|
reclaimReason = "delivered_no_turn_deadline";
|
|
61741
|
-
} else if (assignedRowLiveStatusIsAwaitingApproval(mesh, row.assignedNodeId,
|
|
61884
|
+
} else if (assignedRowLiveStatusIsAwaitingApproval(mesh, row.assignedNodeId, evidenceSessionId)) {
|
|
61742
61885
|
traceMeshEventDrop("reclaim_deferred_awaiting_approval", {
|
|
61743
61886
|
taskId: row.id,
|
|
61744
61887
|
sessionId: row.assignedSessionId,
|
|
@@ -61785,7 +61928,7 @@ ${cleanBody}`;
|
|
|
61785
61928
|
if (suspensionGate.kind === "released" && suspensionGate.dropped > 0) {
|
|
61786
61929
|
LOG2.info("MeshReconcile", `Dropped ${suspensionGate.dropped} held suspension(s) for task ${row.id} on mesh ${meshId}: worker session ${row.assignedSessionId ?? "?"} demonstrably dead \u2014 ${reclaimReason} proceeds to a new attempt`);
|
|
61787
61930
|
}
|
|
61788
|
-
const terminalEvidence = await pollAssignedTaskTerminalEvidence(components, mesh,
|
|
61931
|
+
const terminalEvidence = await pollAssignedTaskTerminalEvidence(components, mesh, evidenceRow);
|
|
61789
61932
|
if (terminalEvidence) {
|
|
61790
61933
|
deliveredNoTurnUnknownStreak.delete(streakKey);
|
|
61791
61934
|
if (!reconcileTerminalViaReducer({
|
|
@@ -61802,7 +61945,7 @@ ${cleanBody}`;
|
|
|
61802
61945
|
const propagation = propagateWatchdogTranscriptCompletion(
|
|
61803
61946
|
components,
|
|
61804
61947
|
meshId,
|
|
61805
|
-
|
|
61948
|
+
evidenceRow,
|
|
61806
61949
|
terminalEvidence,
|
|
61807
61950
|
"redrive_deadline_transcript_evidence",
|
|
61808
61951
|
{ boundedBackstop: true }
|
|
@@ -61854,9 +61997,9 @@ ${cleanBody}`;
|
|
|
61854
61997
|
}, `attempt stage ${attemptStage} \u2014 live turn, ${reclaimReason} suppressed`);
|
|
61855
61998
|
continue;
|
|
61856
61999
|
}
|
|
61857
|
-
const noTurnProfile =
|
|
62000
|
+
const noTurnProfile = evidenceSessionId ? resolveAssignedTranscriptProfile(components, evidenceRow) : void 0;
|
|
61858
62001
|
if (noTurnProfile?.emitsPtyTurnEvents === false) {
|
|
61859
|
-
const activity = await pollAssignedTaskActivity(components, { id: meshId, nodes: mesh.nodes },
|
|
62002
|
+
const activity = await pollAssignedTaskActivity(components, { id: meshId, nodes: mesh.nodes }, evidenceRow);
|
|
61860
62003
|
if (activity.inTurnProgress && activity.lastAgentActivityMs !== null && nowMs - activity.lastAgentActivityMs <= NATIVE_SOURCE_ACTIVITY_STALE_MS) {
|
|
61861
62004
|
deliveredNoTurnUnknownStreak.delete(streakKey);
|
|
61862
62005
|
try {
|
|
@@ -61864,7 +62007,9 @@ ${cleanBody}`;
|
|
|
61864
62007
|
meshId,
|
|
61865
62008
|
taskId: row.id,
|
|
61866
62009
|
kind: "consumed",
|
|
61867
|
-
|
|
62010
|
+
// Attempt-bound session (rc.35): a consumed ACK naming the
|
|
62011
|
+
// rebound-away row session would fail the reducer's causality check.
|
|
62012
|
+
sessionId: evidenceSessionId,
|
|
61868
62013
|
legacy: {
|
|
61869
62014
|
...typeof row.dispatchNonce === "number" ? { dispatchNonce: row.dispatchNonce } : {},
|
|
61870
62015
|
...row.assignedNodeId ? { nodeId: row.assignedNodeId } : {},
|
|
@@ -70921,6 +71066,7 @@ ${lastSnapshot}`;
|
|
|
70921
71066
|
DEFAULT_STATUS_P2P_REPORT_INTERVAL_MS: () => DEFAULT_STATUS_P2P_REPORT_INTERVAL_MS,
|
|
70922
71067
|
DEFAULT_STATUS_SERVER_REPORT_INTERVAL_MS: () => DEFAULT_STATUS_SERVER_REPORT_INTERVAL_MS,
|
|
70923
71068
|
DEV_SERVER_PORT: () => DEV_SERVER_PORT,
|
|
71069
|
+
DUPLICATE_MESH_DISPATCH_CODE: () => DUPLICATE_MESH_DISPATCH_CODE,
|
|
70924
71070
|
DaemonAgentStreamManager: () => DaemonAgentStreamManager,
|
|
70925
71071
|
DaemonCdpInitializer: () => DaemonCdpInitializer,
|
|
70926
71072
|
DaemonCdpManager: () => DaemonCdpManager,
|
|
@@ -70930,6 +71076,7 @@ ${lastSnapshot}`;
|
|
|
70930
71076
|
DaemonCommandRouter: () => DaemonCommandRouter,
|
|
70931
71077
|
DaemonStatusReporter: () => DaemonStatusReporter,
|
|
70932
71078
|
DevServer: () => DevServer,
|
|
71079
|
+
DuplicateMeshDispatchError: () => DuplicateMeshDispatchError,
|
|
70933
71080
|
FsmDriver: () => FsmDriver,
|
|
70934
71081
|
GOAL_PREVIEW_MAX: () => GOAL_PREVIEW_MAX,
|
|
70935
71082
|
GitCommandError: () => GitCommandError,
|
|
@@ -71039,6 +71186,7 @@ ${lastSnapshot}`;
|
|
|
71039
71186
|
canonicalDaemonId: () => canonicalDaemonId,
|
|
71040
71187
|
claimNextTask: () => claimNextTask,
|
|
71041
71188
|
classifyChatMessageVisibility: () => classifyChatMessageVisibility,
|
|
71189
|
+
classifyDuplicateMeshDispatch: () => classifyDuplicateMeshDispatch,
|
|
71042
71190
|
classifyHotChatSessionsForSubscriptionFlush: () => classifyHotChatSessionsForSubscriptionFlush2,
|
|
71043
71191
|
classifyP2pRelayFailure: () => classifyP2pRelayFailure,
|
|
71044
71192
|
classifyShadowDivergence: () => classifyShadowDivergence,
|
|
@@ -71081,6 +71229,7 @@ ${lastSnapshot}`;
|
|
|
71081
71229
|
detectIDEs: () => detectIDEs,
|
|
71082
71230
|
detectNewlySettledCompletedSessions: () => detectNewlySettledCompletedSessions2,
|
|
71083
71231
|
drainPendingMeshCoordinatorEvents: () => drainPendingMeshCoordinatorEvents,
|
|
71232
|
+
encodeDuplicateMeshDispatchCode: () => encodeDuplicateMeshDispatchCode,
|
|
71084
71233
|
enqueueTask: () => enqueueTask,
|
|
71085
71234
|
ensureSessionHostReady: () => ensureSessionHostReady2,
|
|
71086
71235
|
evaluateFsm: () => evaluateFsm,
|
|
@@ -73641,6 +73790,7 @@ ${lastSnapshot}`;
|
|
|
73641
73790
|
this.authEpoch = context.authEpoch;
|
|
73642
73791
|
}
|
|
73643
73792
|
};
|
|
73793
|
+
init_mesh_duplicate_dispatch();
|
|
73644
73794
|
init_state_store();
|
|
73645
73795
|
var import_child_process5 = require("child_process");
|
|
73646
73796
|
var import_util22 = require("util");
|
|
@@ -85333,6 +85483,7 @@ ${body}
|
|
|
85333
85483
|
init_recent_activity();
|
|
85334
85484
|
init_hash();
|
|
85335
85485
|
init_coordinator_registry();
|
|
85486
|
+
init_mesh_duplicate_dispatch();
|
|
85336
85487
|
init_summary_metadata();
|
|
85337
85488
|
var os19 = __toESM2(require("os"));
|
|
85338
85489
|
var crypto5 = __toESM2(require("crypto"));
|
|
@@ -94846,7 +94997,10 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
94846
94997
|
} catch {
|
|
94847
94998
|
}
|
|
94848
94999
|
if (stampResult && stampResult.stamped === false && stampResult.reason === "task_already_stamped_on_live_instance") {
|
|
94849
|
-
throw new
|
|
95000
|
+
throw new DuplicateMeshDispatchError(
|
|
95001
|
+
`Refusing duplicate mesh dispatch: task ${meshContext.taskId} is already being worked by a live session on this daemon`,
|
|
95002
|
+
{ holderSessionId: stampResult.holderSessionId }
|
|
95003
|
+
);
|
|
94850
95004
|
}
|
|
94851
95005
|
if (meshContext.silentIdlePush === true) {
|
|
94852
95006
|
try {
|
|
@@ -110614,7 +110768,13 @@ ${e?.stderr || ""}`;
|
|
|
110614
110768
|
* marker in state.settings). Returns `{ stamped: true }` when the stamp was
|
|
110615
110769
|
* applied, or `{ stamped: false, reason }` when it was refused — the instance
|
|
110616
110770
|
* was missing / has no attach method, or the DOUBLE-DISPATCH idempotence guard
|
|
110617
|
-
* fired (the same task is already running on another live session here).
|
|
110771
|
+
* fired (the same task is already running on another live session here).
|
|
110772
|
+
*
|
|
110773
|
+
* DUP-CLAIM-REBIND: when the guard fires, the id of the live session that already
|
|
110774
|
+
* holds the task is returned as `holderSessionId`. The coordinator needs it to
|
|
110775
|
+
* REBIND its turn-ledger attempt onto the real worker instead of cancelling the
|
|
110776
|
+
* attempt — the guard already resolved that instance, so surfacing it here keeps
|
|
110777
|
+
* the caller from having to parse it back out of an error string. */
|
|
110618
110778
|
attachMeshAssignmentToInstance(instanceId, assignment) {
|
|
110619
110779
|
const inst = this.instances.get(instanceId);
|
|
110620
110780
|
if (!inst || typeof inst.attachMeshAssignment !== "function") {
|
|
@@ -110625,7 +110785,7 @@ ${e?.stderr || ""}`;
|
|
|
110625
110785
|
const conflict = this.findLiveWorkingTaskHolder(assignment.meshId, assignment.taskId, instanceId);
|
|
110626
110786
|
if (conflict) {
|
|
110627
110787
|
LOG2.warn("MeshDispatch", `attachMeshAssignment refused: task ${assignment.taskId} (mesh ${assignment.meshId}) is already being worked by live session ${conflict} \u2014 skipping duplicate stamp on ${instanceId}`);
|
|
110628
|
-
return { stamped: false, reason: "task_already_stamped_on_live_instance" };
|
|
110788
|
+
return { stamped: false, reason: "task_already_stamped_on_live_instance", holderSessionId: conflict };
|
|
110629
110789
|
}
|
|
110630
110790
|
}
|
|
110631
110791
|
inst.attachMeshAssignment(assignment);
|