@adhdev/daemon-core 0.9.82-rc.454 → 0.9.82-rc.455

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.
@@ -3,3 +3,5 @@ export declare const EVENT_TO_LEDGER_KIND: Record<string, MeshLedgerKind>;
3
3
  export declare function isMeshCoordinatorEvent(eventName: unknown): eventName is string;
4
4
  export declare const MESH_FORCE_INJECT_EVENTS: ReadonlySet<string>;
5
5
  export declare function shouldForceInjectMeshEvent(eventName: unknown): boolean;
6
+ export declare const MESH_APPROVAL_EVENTS: ReadonlySet<string>;
7
+ export declare function isMeshApprovalEvent(eventName: unknown): boolean;
@@ -38,6 +38,26 @@ export declare function isWorktreeBootstrapStaleRunning(node: {
38
38
  };
39
39
  workspace?: string;
40
40
  } | undefined, nowMs?: number): boolean;
41
+ /**
42
+ * COMPLETION-PROPAGATION F7 (C2): the single shared consume-ready / bootstrap-pending defer
43
+ * predicate. A task must NOT be injected into a worktree node whose bootstrap is still 'running'
44
+ * — the provider is not yet ready to consume input, so the inject lands in the input buffer and
45
+ * is silently swallowed (empty session). Both the remote dispatch guard (the router agent_command
46
+ * handler) and the local queue-claim gate (tryAssignQueueTask) route through THIS predicate so
47
+ * they agree on exactly when to defer. Returns true = defer. The stale-'running' backstop
48
+ * (isWorktreeBootstrapStaleRunning) is honored here too: a 'running' state far older than any real
49
+ * bootstrap whose worktree is git-clean is treated as silently complete (do NOT defer), so a node
50
+ * whose terminal stamp never reached this daemon is not stranded forever.
51
+ */
52
+ export declare function shouldDeferDispatchForBootstrap(node: {
53
+ worktreeBootstrap?: {
54
+ status?: string;
55
+ startedAt?: string;
56
+ updatedAt?: string;
57
+ completedAt?: string;
58
+ };
59
+ workspace?: string;
60
+ } | undefined, nowMs?: number): boolean;
41
61
  export interface WorktreeBootstrapConfigLoadResult {
42
62
  config?: RepoMeshWorktreeBootstrapConfig;
43
63
  source: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adhdev/daemon-core",
3
- "version": "0.9.82-rc.454",
3
+ "version": "0.9.82-rc.455",
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,8 +46,8 @@
46
46
  "author": "vilmire",
47
47
  "license": "AGPL-3.0-or-later",
48
48
  "dependencies": {
49
- "@adhdev/mesh-shared": "0.9.82-rc.454",
50
- "@adhdev/session-host-core": "0.9.82-rc.454",
49
+ "@adhdev/mesh-shared": "0.9.82-rc.455",
50
+ "@adhdev/session-host-core": "0.9.82-rc.455",
51
51
  "@agentclientprotocol/sdk": "^0.16.1",
52
52
  "ajv": "^8.20.0",
53
53
  "ajv-formats": "^3.0.1",
@@ -114,32 +114,35 @@ export const cliAgentHandlers: Record<string, MedFamilyHandler> = {
114
114
  if (isSendChat && dispatchNodeId && dispatchMeshId) {
115
115
  try {
116
116
  const { getMesh } = await import('../../config/mesh-config.js');
117
- const meshObj = getMesh(dispatchMeshId) ?? ctx.getCachedInlineMesh(dispatchMeshId);
117
+ // COMPLETION-PROPAGATION F6 (C1 SSOT): read the router's synchronous inline mesh
118
+ // cache FIRST, falling back to getMesh only when the inline view has nothing. The
119
+ // inline cache is the authoritative bootstrap-status source — markWorktreeBootstrapTerminalState
120
+ // stamps 'complete'/'failed' into it SYNCHRONOUSLY, then persists to local config
121
+ // (what getMesh reads) via a DETACHED async import chain that lags. Reading getMesh
122
+ // first therefore observed a stale 'running' and deferred a dispatch whose worktree
123
+ // was already bootstrapped — the stale-'running' defer this eliminates. Inline-first
124
+ // makes the freshest single source of truth win for both the running and terminal states.
125
+ const meshObj = ctx.getCachedInlineMesh(dispatchMeshId) ?? getMesh(dispatchMeshId);
118
126
  const nodeObj = Array.isArray(meshObj?.nodes)
119
127
  ? meshObj.nodes.find((n: any) => meshNodeIdMatches(n, dispatchNodeId))
120
128
  : undefined;
121
- const bootstrapStatus = readStringValue(nodeObj?.worktreeBootstrap?.status);
122
- if (bootstrapStatus === 'running') {
123
- // Fix (3) safety net: a 'running' bootstrap far older than any real bootstrap whose
124
- // worktree is git-clean is almost certainly one whose terminal-state stamp never
125
- // reached this daemon — fall through and dispatch instead of deferring forever. The
126
- // conservative threshold + git-clean co-requirement keep a genuinely in-progress
127
- // bootstrap (which must still defer) gated.
128
- const { isWorktreeBootstrapStaleRunning } = await import('../../mesh/worktree-bootstrap-config.js');
129
- if (!isWorktreeBootstrapStaleRunning(nodeObj as any)) {
130
- return {
131
- success: false,
132
- recoverable: true,
133
- dispatched: false,
134
- code: 'mesh_node_bootstrap_pending',
135
- reason: 'bootstrap_still_running',
136
- nodeId: dispatchNodeId,
137
- meshId: dispatchMeshId,
138
- ...(readStringValue(meshCtx?.taskId) ? { taskId: readStringValue(meshCtx?.taskId) } : {}),
139
- error: `Node '${dispatchNodeId}' worktree bootstrap is still running; a task injected now would land in the session input buffer before the provider is ready to consume it and be silently lost. Dispatch deferred.`,
140
- nextAction: 'Wait for the worktree_bootstrap_complete event (or poll mesh_status until the node session is ready), then re-send the task with mesh_send_task. Alternatively use mesh_enqueue_task so the queue auto-assigns it once a ready session is available.',
141
- };
142
- }
129
+ // COMPLETION-PROPAGATION F7 (C2): the single shared consume-ready/bootstrap-pending
130
+ // defer predicate (honors the stale-'running' git-clean backstop internally), reused
131
+ // by the local queue-claim gate too so remote and local dispatch agree on when to defer.
132
+ const { shouldDeferDispatchForBootstrap } = await import('../../mesh/worktree-bootstrap-config.js');
133
+ if (shouldDeferDispatchForBootstrap(nodeObj as any)) {
134
+ return {
135
+ success: false,
136
+ recoverable: true,
137
+ dispatched: false,
138
+ code: 'mesh_node_bootstrap_pending',
139
+ reason: 'bootstrap_still_running',
140
+ nodeId: dispatchNodeId,
141
+ meshId: dispatchMeshId,
142
+ ...(readStringValue(meshCtx?.taskId) ? { taskId: readStringValue(meshCtx?.taskId) } : {}),
143
+ error: `Node '${dispatchNodeId}' worktree bootstrap is still running; a task injected now would land in the session input buffer before the provider is ready to consume it and be silently lost. Dispatch deferred.`,
144
+ nextAction: 'Wait for the worktree_bootstrap_complete event (or poll mesh_status until the node session is ready), then re-send the task with mesh_send_task. Alternatively use mesh_enqueue_task so the queue auto-assigns it once a ready session is available.',
145
+ };
143
146
  }
144
147
  } catch { /* best-effort — if the bootstrap probe fails, fall through and dispatch */ }
145
148
  }