@adhdev/daemon-core 0.9.82-rc.297 → 0.9.82-rc.298
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 +12 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +12 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/mesh/mesh-events-coordinator.ts +5 -2
- package/src/mesh/mesh-events-stale.ts +8 -1
- package/src/mesh/mesh-routing.ts +23 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adhdev/daemon-core",
|
|
3
|
-
"version": "0.9.82-rc.
|
|
3
|
+
"version": "0.9.82-rc.298",
|
|
4
4
|
"description": "ADHDev daemon core — CDP, IDE detection, providers, command execution",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"author": "vilmire",
|
|
47
47
|
"license": "AGPL-3.0-or-later",
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@adhdev/mesh-shared": "0.9.82-rc.
|
|
49
|
+
"@adhdev/mesh-shared": "0.9.82-rc.298",
|
|
50
50
|
"@adhdev/session-host-core": "*",
|
|
51
51
|
"@agentclientprotocol/sdk": "^0.16.1",
|
|
52
52
|
"ajv": "^8.20.0",
|
|
@@ -15,7 +15,7 @@ import type { PendingMeshCoordinatorEvent } from './mesh-events-pending.js';
|
|
|
15
15
|
import { resolveWorkerDelegateRouting, recordUnroutableDelegateEvent, isUnroutableDelegateRejection } from './mesh-routing.js';
|
|
16
16
|
import { enqueueUnresolvedDelegateForward, peekUnresolvedDelegateForwards, ackUnresolvedDelegateForward } from './mesh-unresolved-forward-outbox.js';
|
|
17
17
|
import { resolveDelegatedWorkerAutoApprove } from '../repo-mesh-types.js';
|
|
18
|
-
import { normalizeMeshNodeId, meshNodeIdMatches } from '@adhdev/mesh-shared';
|
|
18
|
+
import { normalizeMeshNodeId, meshNodeIdMatches, type MeshNodeIdentified } from '@adhdev/mesh-shared';
|
|
19
19
|
import {
|
|
20
20
|
findRecentTerminalLedgerEvidence,
|
|
21
21
|
hasDispatchAfterTerminal,
|
|
@@ -109,7 +109,10 @@ function hasRecentIntentionalCleanupStop(meshId: string, sessionId?: string, nod
|
|
|
109
109
|
if (!Number.isNaN(timestamp) && timestamp < cutoff) break;
|
|
110
110
|
if (!isIntentionalCleanupStopEntry(entry)) continue;
|
|
111
111
|
if (sessionId && entry.sessionId === sessionId) return true;
|
|
112
|
-
|
|
112
|
+
// Normalized node-id match (P4): the cleanup-stop entry's node id may be stored as
|
|
113
|
+
// `nodeId` or `node_id` and the `nodeId` arg can be in either form — a raw `===`
|
|
114
|
+
// would miss a genuine intentional-cleanup entry and fail to suppress the stop event.
|
|
115
|
+
if (!sessionId && nodeId && meshNodeIdMatches(entry as unknown as MeshNodeIdentified, nodeId)) return true;
|
|
113
116
|
}
|
|
114
117
|
return false;
|
|
115
118
|
}
|
|
@@ -4,6 +4,7 @@ import { updateDirectDispatchStatus, cleanupTerminalDirectDispatches } from './m
|
|
|
4
4
|
import { markSessionDeliveriesTerminal } from './mesh-delivery-policy.js';
|
|
5
5
|
import { queuePendingMeshCoordinatorEvent } from './mesh-events-pending.js';
|
|
6
6
|
import { readNonEmptyString, readRecord, resolveEventSessionId, readWorkerResultMetadata } from './mesh-events-utils.js';
|
|
7
|
+
import { meshNodeIdMatches, type MeshNodeIdentified } from '@adhdev/mesh-shared';
|
|
7
8
|
|
|
8
9
|
// ---------------------------------------------------------------------------
|
|
9
10
|
// Stale direct-dispatch detection & transcript reconciliation
|
|
@@ -25,7 +26,13 @@ export function findRecentTerminalLedgerEvidence(args: {
|
|
|
25
26
|
if (args.sessionId && entry.sessionId === args.sessionId) {
|
|
26
27
|
return { id: entry.id, kind: entry.kind, payload: entry.payload || {}, timestamp: entry.timestamp };
|
|
27
28
|
}
|
|
28
|
-
|
|
29
|
+
// Normalized node-id match (P4): a ledger entry may store its node id as `nodeId`
|
|
30
|
+
// (runtime form) or `node_id` (DB column form leaked onto the object). A raw `===`
|
|
31
|
+
// against args.nodeId drops the entry when the entry's stored form differs from the
|
|
32
|
+
// form the caller passes, so a valid terminal completion goes unfound. meshNodeIdMatches
|
|
33
|
+
// normalizes the entry across all 3 forms before comparing. (The entry's typed shape
|
|
34
|
+
// omits the open index signature MeshNodeIdentified declares, hence the cast.)
|
|
35
|
+
if (!args.sessionId && args.nodeId && meshNodeIdMatches(entry as unknown as MeshNodeIdentified, args.nodeId)) {
|
|
29
36
|
return { id: entry.id, kind: entry.kind, payload: entry.payload || {}, timestamp: entry.timestamp };
|
|
30
37
|
}
|
|
31
38
|
}
|
package/src/mesh/mesh-routing.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { hasUnterminalDirectDispatchLedgerEntry } from './mesh-events-stale.js';
|
|
|
4
4
|
import { appendLedgerEntry, readLedgerEntries } from './mesh-ledger.js';
|
|
5
5
|
import { LOG } from '../logging/logger.js';
|
|
6
6
|
import { readNonEmptyString } from './mesh-events-utils.js';
|
|
7
|
+
import { meshNodeIdMatches } from '@adhdev/mesh-shared';
|
|
7
8
|
|
|
8
9
|
// ---------------------------------------------------------------------------
|
|
9
10
|
// R1: single-source coordinator routing resolution
|
|
@@ -141,13 +142,28 @@ export function resolveWorkerDelegateRouting(
|
|
|
141
142
|
const meshId = meshIdFromRuntime || readNonEmptyString(mesh?.id);
|
|
142
143
|
if (!meshId) return reject('mesh_unresolved');
|
|
143
144
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
145
|
+
// Node resolution authority: the runtime stamp (meshNodeId) is the worker's
|
|
146
|
+
// own identity, set when the coordinator dispatched/launched it. Trust it FIRST,
|
|
147
|
+
// matched against mesh.nodes with the 3-form normalizer (id / nodeId / node_id).
|
|
148
|
+
// Workspace lookup is only a fallback for workers that never carried a node stamp.
|
|
149
|
+
//
|
|
150
|
+
// This is the P1 fix: a worktree clone and its base node can share the same
|
|
151
|
+
// `workspace`, or a freshly-cloned node may not yet be in mesh.nodes — in either
|
|
152
|
+
// case `.find(n => n.workspace === workspace)` would match the BASE node (or
|
|
153
|
+
// undefined) and stamp the completion event with the wrong/absent nodeId, so the
|
|
154
|
+
// event fails post-hoc node matching and the coordinator never sees the completion.
|
|
155
|
+
// The stamped meshNodeId splits base vs worktree correctly even on shared workspace.
|
|
156
|
+
const stampedNode = runtimeNodeId
|
|
157
|
+
? mesh?.nodes?.find((n: any) => meshNodeIdMatches(n, runtimeNodeId))
|
|
158
|
+
: undefined;
|
|
159
|
+
const targetNode = stampedNode || mesh?.nodes?.find((n: any) => n.workspace === workspace);
|
|
160
|
+
const nodeId = runtimeNodeId || readNonEmptyString(targetNode?.id);
|
|
161
|
+
// Label off the resolved nodeId (which now prefers the stamp) so a node matched
|
|
162
|
+
// by its `nodeId`/`node_id` form — where `targetNode.id` may be absent — never
|
|
163
|
+
// renders as `Node 'undefined'`.
|
|
164
|
+
const nodeLabel = nodeId
|
|
165
|
+
? `Node '${nodeId}'`
|
|
166
|
+
: `Agent at ${workspace}`;
|
|
151
167
|
|
|
152
168
|
return {
|
|
153
169
|
isDelegate: true,
|